Move module loading into bot function and add clearing of cache
This commit is contained in:
parent
fd668a6124
commit
e588ffbb5d
10
bot.py
10
bot.py
|
@ -4,6 +4,13 @@ BOTOP = "~minerobber@127.0.0.1"
|
|||
PREFIX = "!"
|
||||
|
||||
class MinerbotPhoenix(teambot.Handler):
|
||||
def on_connection_established(self,*args):
|
||||
self.load_modules()
|
||||
def load_modules(self):
|
||||
plugin.clear()
|
||||
for name in os.listdir("plugins"):
|
||||
if name.endswith(".py"):
|
||||
bot.handler.load_module(name[:-3])
|
||||
def load_module(self,modname):
|
||||
try:
|
||||
fp, pathname, desc = imp.find_module(modname,["plugins"])
|
||||
|
@ -33,7 +40,4 @@ class MinerbotPhoenix(teambot.Handler):
|
|||
if __name__=="__main__":
|
||||
channels = "#bots".split()
|
||||
bot = teambot.TeamBot(channels,"minerbot","localhost",chandler=MinerbotPhoenix)
|
||||
for name in os.listdir("plugins"):
|
||||
if name.endswith(".py"):
|
||||
bot.handler.load_module(name[:-3])
|
||||
bot.start()
|
||||
|
|
Loading…
Reference in New Issue