|
@@ -3,6 +3,8 @@ from EchoBot import JabberBot
|
|
|
import sys
|
|
|
import logging
|
|
|
from argparse import ArgumentParser
|
|
|
+import importlib
|
|
|
+import asyncio
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
# Setup the command line arguments.
|
|
@@ -28,22 +30,21 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
if args.bot and args.bot in config.BOTLIST:
|
|
|
- module = __import__("handlers." + args.bot)
|
|
|
-
|
|
|
- print(module.JID)
|
|
|
+ module = importlib.import_module("handlers." + args.bot)
|
|
|
|
|
|
JID = module.JID
|
|
|
PASSWORD = module.PASSWORD
|
|
|
|
|
|
- fn_start_handler = module.start_handler
|
|
|
- fn_message = module.message
|
|
|
+ start_handler = module.start_handler
|
|
|
+ message_handler = module.message_handler
|
|
|
|
|
|
|
|
|
bot = JabberBot(JID, PASSWORD)
|
|
|
- bot.add_event_handler("message", fn_message)
|
|
|
+ bot.add_event_handler("message", message_handler)
|
|
|
bot.run()
|
|
|
- fn_start_handler(bot)
|
|
|
- bot.stop()
|
|
|
+ start_handler(bot)
|
|
|
+ # bot.stop()
|
|
|
+ asyncio.get_event_loop().run_forever()
|
|
|
else:
|
|
|
print("Select using -n flag for select availible bot from botlist:\n")
|
|
|
for botname in config.BOTLIST:
|