changeset 2118:805d56ccbea7

Don't import each command by hand, rather used a shortened module name.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Tue, 12 Jun 2007 13:45:00 +0200
parents 38c8f31be12e
children 9d497d976218
files jabberbot/xmlrpcbot.py jabberbot/xmppbot.py
diffstat 2 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/jabberbot/xmlrpcbot.py	Tue Jun 12 13:39:27 2007 +0200
+++ b/jabberbot/xmlrpcbot.py	Tue Jun 12 13:45:00 2007 +0200
@@ -10,9 +10,7 @@
 from threading import Thread
 from SimpleXMLRPCServer import SimpleXMLRPCServer
 
-from jabberbot.commands import NotificationCommand, AddJIDToRosterCommand
-from jabberbot.commands import RemoveJIDFromRosterCommand
-
+import jabberbot.commands as cmd
 
 class XMLRPCClient(Thread):
     """XMLRPC Client
@@ -95,7 +93,7 @@
         @type text: unicode
         
         """
-        c = NotificationCommand(jid, text)
+        c = cmd.NotificationCommand(jid, text)
         self.commands.put_nowait(c)
         return True
     send_notification.export = True
@@ -107,7 +105,7 @@
         @type jid: str or unicode, 
         
         """  
-        c = AddJIDToRosterCommand(jid)
+        c = cmd.AddJIDToRosterCommand(jid)
         self.commands.put_nowait(c)
         return True
     addJIDToRoster.export = True
@@ -119,7 +117,7 @@
         @type jid: str or unicode
         
         """
-        c = RemoveJIDFromRosterCommand(jid)
+        c = cmd.RemoveJIDFromRosterCommand(jid)
         self.commands.put_nowait(c)
         return True
     removeJIDFromRoster.export = True
--- a/jabberbot/xmppbot.py	Tue Jun 12 13:39:27 2007 +0200
+++ b/jabberbot/xmppbot.py	Tue Jun 12 13:45:00 2007 +0200
@@ -17,9 +17,6 @@
 from pyxmpp.presence import Presence
 
 import jabberbot.commands as cmd
-from jabberbot.commands import NotificationCommand, AddJIDToRosterCommand
-from jabberbot.commands import RemoveJIDFromRosterCommand
-
 
 class Contact:
     """Abstraction of a roster item / contact
@@ -177,7 +174,7 @@
         
         """
         # Handle normal notifications
-        if isinstance(command, NotificationCommand):
+        if isinstance(command, cmd.NotificationCommand):
             jid = JID(node_or_jid=command.jid)
             jid_text = jid.bare().as_utf8()
             text = command.text
@@ -195,11 +192,11 @@
             self.send_message(jid, text)
             
         # Handle subscribtion management commands
-        if isinstance(command, AddJIDToRosterCommand):
+        if isinstance(command, cmd.AddJIDToRosterCommand):
             jid = JID(node_or_jid=command.jid)
             self.ask_for_subscription(jid)
             
-        if isinstance(command, RemoveJIDFromRosterCommand):
+        if isinstance(command, cmd.RemoveJIDFromRosterCommand):
             jid = JID(node_or_jid=command.jid)
             self.remove_subscription(jid)
             
@@ -300,15 +297,15 @@
         # Here we have to deal with help messages of external (xmlrpc) commands
         else:
             classobj = self.xmlrpc_commands[command]
-            help_str = u"%s - %s\n\nUsage: %s"
-            return help_str % (command, classobj.description, classobj.parameter_list)
+            help_str = u"%s - %s\n\nUsage: %s %s"
+            return help_str % (command, classobj.description, command, classobj.parameter_list)
         
         
     def handle_xmlrpc_command(self, command):
         """Creates a command object, and puts it the command queuq
         
         @param command: a valid name of available xmlrpc command
-        @type command: str
+        @type command: list representing a command, name and parameters
         
         """
         command_class = self.xmlrpc_commands[command[0]]