import config from EchoBot import JabberBot import sys import logging from argparse import ArgumentParser import importlib import asyncio if __name__ == '__main__': # Setup the command line arguments. parser = ArgumentParser(description=JabberBot.__doc__) # Output verbosity options. parser.add_argument("-q", "--quiet", help="set logging to ERROR", action="store_const", dest="loglevel", const=logging.ERROR, default=logging.INFO) parser.add_argument("-d", "--debug", help="set logging to DEBUG", action="store_const", dest="loglevel", const=logging.DEBUG, default=logging.INFO) # JID and password options. parser.add_argument("-b", "--bot", dest="bot", help="Bot name") args = parser.parse_args() # Setup logging. logging.basicConfig(level=args.loglevel, format='%(levelname)-8s %(message)s') if args.bot and args.bot in config.BOTLIST: module = importlib.import_module("handlers." + args.bot) JID = module.JID PASSWORD = module.PASSWORD start_handler = module.start_handler message_handler = module.message_handler bot = JabberBot(JID, PASSWORD) bot.add_event_handler("message", message_handler) bot.run() 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: print(f"- {botname}")