]> kaliko git repositories - sid.git/blobdiff - sid/sid.py
traceback sent in MUC for levels < logging.DEBUG
[sid.git] / sid / sid.py
index 24f543f6e60d6ed3cdd7efbd86f24b3e3d03bb3c..1d3383c9b3c7f87d131f0939bf37ed44f1655b2d 100644 (file)
@@ -89,27 +89,26 @@ class MUCBot(sleekxmpp.ClientXMPP):
 
     def muc_message(self, msg):
         # ignore message from self
-        body = msg['body']
+        body = msg['body'].strip()
         mucfrom = msg['mucnic']
         if msg['mucnick'] == self.nick:
-            self.log.debug('ignoring message from me')
             return
         if not body.startswith(MUCBot.prefix):
             return
         args = body[1:].split()
-        cmd= args.pop(0)
+        cmd = args.pop(0)
         if cmd not in self.commands:
             return
         self.log.debug('cmd: {0}'.format(cmd))
         if args:
             self.log.debug('arg: {0}'.format(args))
         try:
-            reply = self.commands[cmd](msg, args)
+            self.commands[cmd](msg, args)
         except Exception as err:
-            reply = traceback.format_exc(err)
+            reply = ''.join(traceback.format_exc())
             self.log.exception('An error occurred processing: {0}: {1}'.format(body, reply))
-        self.log.debug(reply)
-        self.send_message(mto=msg['from'].bare, mbody=reply, mtype='groupchat')
+            if self.log.level < 10 and reply:
+                self.send_message(mto=msg['from'].bare, mbody=reply, mtype='groupchat')
 
     def start(self, event):
         """
@@ -158,7 +157,6 @@ class MUCBot(sleekxmpp.ClientXMPP):
         """Returns a help string listing available options.
 
         Automatically assigned to the "help" command."""
-        self.log.info(args)
         help_cmd = ('Type {}help <command name>'.format(self.prefix) +
                     ' to get more info about that specific command.')
         if not args:
@@ -178,10 +176,8 @@ class MUCBot(sleekxmpp.ClientXMPP):
             usage = usage + '\n\n' + help_cmd
             text = '{}\n\n{}'.format(description, usage)
         else:
-            self.log.debug(args[0])
-            self.log.debug(args[0] in self.commands.keys())
             if args[0] in self.commands.keys():
                 text = self.commands[args[0]].__doc__.strip() or 'undocumented'
             else:
                 text = 'That command is not defined.'
-        return text
+        self.send_message(mto=message['from'].bare, mbody=text, mtype='groupchat')