commit
5cd540f732
|
@ -61,25 +61,21 @@ class Bot(irc.bot.SingleServerIRCBot):
|
||||||
if not os.path.exists(self.plugin_dir):
|
if not os.path.exists(self.plugin_dir):
|
||||||
os.makedirs(self.plugin_dir)
|
os.makedirs(self.plugin_dir)
|
||||||
# load all plugins
|
# load all plugins
|
||||||
plugins = []
|
|
||||||
for m in os.listdir(self.plugin_dir):
|
for m in os.listdir(self.plugin_dir):
|
||||||
if m.endswith('.py'):
|
if m.endswith('.py'):
|
||||||
try:
|
try:
|
||||||
name = m[:-3]
|
name = m[:-3]
|
||||||
fp, pathname, description = imp.find_module(name, [self.plugin_dir])
|
fp, pathname, description = imp.find_module(name, [self.plugin_dir])
|
||||||
p = imp.load_module(name, fp, pathname, description)
|
imp.load_module(name, fp, pathname, description)
|
||||||
p.pinhook
|
|
||||||
plugins.append(p)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
# gather all commands and listeners
|
# gather all commands and listeners
|
||||||
self.cmds = {}
|
self.cmds = {}
|
||||||
self.lstnrs = {}
|
self.lstnrs = {}
|
||||||
for plugin in plugins:
|
for cmd in pinhook.plugin.cmds:
|
||||||
for cmd in plugin.pinhook.plugin.cmds:
|
self.cmds[cmd['cmd']] = cmd['func']
|
||||||
self.cmds[cmd['cmd']] = cmd['func']
|
for lstnr in pinhook.plugin.lstnrs:
|
||||||
for lstnr in plugin.pinhook.plugin.lstnrs:
|
self.lstnrs[lstnr['lstn']] = lstnr['func']
|
||||||
self.lstnrs[lstnr['lstn']] = lstnr['func']
|
|
||||||
|
|
||||||
def on_welcome(self, c, e):
|
def on_welcome(self, c, e):
|
||||||
if self.ns_pass:
|
if self.ns_pass:
|
||||||
|
|
Loading…
Reference in New Issue