123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import config
- from core.JabberBot import JabberBot
- import logging
- from argparse import ArgumentParser
- import importlib
- if __name__ == '__main__':
-
- parser = ArgumentParser(description=JabberBot.__doc__)
-
- 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)
-
- parser.add_argument("-b", "--bot", dest="bot",
- help="Bot name")
- args = parser.parse_args()
-
- 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)
- start_handler = module.start_handler
- message_handler = module.message_handler
- bot = module.bot
-
-
-
- bot.send_presence()
-
- logging.info(f"Bot {bot.jid} started!")
- bot.add_event_handler("message", message_handler)
-
- bot.connect()
-
- start_handler()
-
-
-
- bot.stop()
- else:
- print("Select using -n flag for select availible bot from botlist:\n")
- for botname in config.BOTLIST:
- print(f"- {botname}")
|