main.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import hashlib
  2. from datetime import datetime
  3. import config
  4. import jsonAndRequest as jsreq
  5. from EchoBot import JabberBot
  6. import logging
  7. from getpass import getpass
  8. from argparse import ArgumentParser
  9. import asyncio
  10. botname = "open_basic_bot"
  11. operating_status = 0
  12. JID = botname + "@" + config.JSERVER
  13. PASSWORD = hashlib.md5((botname + config.PASSWORD).encode('utf-8')).hexdigest()
  14. if __name__ == '__main__':
  15. # Setup the command line arguments.
  16. parser = ArgumentParser(description=JabberBot.__doc__)
  17. # Output verbosity options.
  18. parser.add_argument("-q", "--quiet", help="set logging to ERROR",
  19. action="store_const", dest="loglevel",
  20. const=logging.ERROR, default=logging.INFO)
  21. parser.add_argument("-d", "--debug", help="set logging to DEBUG",
  22. action="store_const", dest="loglevel",
  23. const=logging.DEBUG, default=logging.INFO)
  24. # JID and password options.
  25. # parser.add_argument("-b", "--bot", dest="bot",
  26. # help="Bot name")
  27. args = parser.parse_args()
  28. # Setup logging.
  29. logging.basicConfig(level=args.loglevel,
  30. format='%(levelname)-8s %(message)s')
  31. # if args.jid is None:
  32. # args.jid = input("Username: ")
  33. # if args.password is None:
  34. # args.password = getpass("Password: ")
  35. # Setup the EchoBot and register plugins. Note that while plugins may
  36. # have interdependencies, the order in which you register them does
  37. # not matter.
  38. xmpp = JabberBot(JID, PASSWORD)
  39. xmpp.send_message(JID, f"message send: {datetime.now()}")
  40. asyncio.get_event_loop().run_forever()