def handle(self, client, msg): token = msg['body'].split(' ') try: if token[0] == '+': Channel.channels[token[1]].plugins.append(token[2]) msg.reply("Plugin {0} in {1} has beend activated".format(token[2], token[1])).send() elif token[0] == '-': Channel.channels[token[1]].plugins.remove(token[2]) msg.reply("Plugin {0} in {1} has beend deactivated".format(token[2], token[1])).send() elif token[0] == 'reload': Plugin.plugins = [] Plugin.load_all() msg.reply("Plugins reloaded!").send() elif token[0] == 'list': plugins = [] for p in Plugin.plugins: plugins.append(p.name) msg.reply("Plugins loaded: {0}".format(', '.join(plugins))).send() elif token[0] == 'active': msg.reply("Plugins active in {0}: {1}".format(Channel.channels[token[1]].jid, ', '.join(Channel.channels[token[1]].plugins))).send() except: pass
self.register_plugin('xep_0199') def run(self): if self.connect((Config.get('auth.server'), 5222)): self.process(block=True) def start(self, event): self.send_presence() self.get_roster() for channel in Config.get('channels'): Channel.join(self, channel['jid'], channel['plugins']) def message_private(self, msg): Plugin().handle(self, msg) def message_muc(self, msg): pass if __name__ == '__main__': config_fn = "default.conf" # Later: Pass as Argument to script Config.load(config_fn) Plugin.load_all() bot = Bot() try: bot.run() except KeyboardInterrupt: quit()