# 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
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"""
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)