]> kaliko git repositories - sid.git/commitdiff
Some minor code formatting
authorkaliko <kaliko@azylum.org>
Wed, 6 May 2020 10:26:04 +0000 (12:26 +0200)
committerkaliko <kaliko@azylum.org>
Wed, 6 May 2020 10:26:04 +0000 (12:26 +0200)
sid/sid.py

index b9c7df71c55373cfaa989f8ef5582a576ab9fa4d..729f7b65784e5c9828c8782dc0ec8a9ac3bc741b 100644 (file)
@@ -92,7 +92,8 @@ class MUCBot(slixmpp.ClientXMPP):
 
         # Discover bot internal command (ie. help)
         for name, value in inspect.getmembers(self):
-            if inspect.ismethod(value) and getattr(value, '_bot_command', False):
+            if inspect.ismethod(value) and \
+               getattr(value, '_bot_command', False):
                 name = getattr(value, '_bot_command_name')
                 self.log.debug('Registered command: %s', name)
                 self.commands[name] = value
@@ -138,7 +139,8 @@ class MUCBot(slixmpp.ClientXMPP):
             reply = ''.join(traceback.format_exc())
             self.log.exception('An error occurred processing: %s: %s', body, reply)
             if self.log.level < 10 and reply:
-                self.send_message(mto=msg['from'].bare, mbody=reply, mtype='groupchat')
+                self.send_message(mto=msg['from'].bare, mbody=reply,
+                                  mtype='groupchat')
 
     def _view(self, pres):
         """Track known nick"""
@@ -160,28 +162,31 @@ class MUCBot(slixmpp.ClientXMPP):
         self.get_roster()
         self.send_presence()
         self.plugin['xep_0045'].join_muc(self.room,
-                                        self.nick,
-                                        # If a room password is needed, use:
-                                        # password=the_room_password,
-                                        wait=True)
+                                         self.nick,
+                                         # If a room password is needed, use:
+                                         # password=the_room_password,
+                                         wait=True)
+
+    def register_bot_plugin(self, plugin_cls):
+        """Registers plugin, takes a class, the method instanciates the plugin
 
         :param `sid.plugin.Plugin` plugin_cls: A :py:obj:`sid.plugin.Plugin` class
         """
         self.plugins.append(plugin_cls(self))
         for name, value in inspect.getmembers(self.plugins[-1]):
-            if inspect.ismethod(value) and getattr(value, '_bot_command',
-                                                   False):
+            if inspect.ismethod(value) and \
+               getattr(value, '_bot_command', False):
                 name = getattr(value, '_bot_command_name')
                 self.log.debug('Registered command: %s', name)
                 self.commands[name] = value
 
     def foreach_plugin(self, method, *args, **kwds):
         for plugin in self.plugins:
-            self.log.debug('shuting down %s', plugin.__str__)
+            self.log.debug('calling %s for %s', method, plugin)
             getattr(plugin, method)(*args, **kwds)
 
     def shutdown_plugins(self):
-        # TODO: why can't use event session_end|disconnected?
+        # TODO: also use event session_end|disconnected?
         self.log.info('shuting down')
         for plugin in self.plugins:
             self.log.debug('shuting down %s', plugin)