From 49feb66d8d3274439c665a4fa40763f9d6d016f4 Mon Sep 17 00:00:00 2001 From: Mallory Hancock Date: Mon, 8 Jan 2018 12:51:38 -0800 Subject: [PATCH] simplify plugin loading --- pinhook/bot.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pinhook/bot.py b/pinhook/bot.py index 0bda256..8b81a0e 100644 --- a/pinhook/bot.py +++ b/pinhook/bot.py @@ -61,25 +61,21 @@ class Bot(irc.bot.SingleServerIRCBot): if not os.path.exists(self.plugin_dir): os.makedirs(self.plugin_dir) # load all plugins - plugins = [] for m in os.listdir(self.plugin_dir): if m.endswith('.py'): try: name = m[:-3] fp, pathname, description = imp.find_module(name, [self.plugin_dir]) - p = imp.load_module(name, fp, pathname, description) - p.pinhook - plugins.append(p) + imp.load_module(name, fp, pathname, description) except Exception as e: print(e) # gather all commands and listeners self.cmds = {} self.lstnrs = {} - for plugin in plugins: - for cmd in plugin.pinhook.plugin.cmds: - self.cmds[cmd['cmd']] = cmd['func'] - for lstnr in plugin.pinhook.plugin.lstnrs: - self.lstnrs[lstnr['lstn']] = lstnr['func'] + for cmd in pinhook.plugin.cmds: + self.cmds[cmd['cmd']] = cmd['func'] + for lstnr in pinhook.plugin.lstnrs: + self.lstnrs[lstnr['lstn']] = lstnr['func'] def on_welcome(self, c, e): if self.ns_pass: