import hashlib from datetime import datetime import config import jsonAndRequest as jsreq from EchoBot import EchoBot import logging from getpass import getpass from argparse import ArgumentParser import asyncio botname = "open_basic_bot" operating_status = 0 JID = botname + "@" + config.JSERVER PORT = config.PORT PASSWORD = hashlib.md5((botname + config.PASSWORD).encode('utf-8')).hexdigest() if __name__ == '__main__': # Setup the command line arguments. parser = ArgumentParser(description=EchoBot.__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.jid is None: # args.jid = input("Username: ") # if args.password is None: # args.password = getpass("Password: ") # Setup the EchoBot and register plugins. Note that while plugins may # have interdependencies, the order in which you register them does # not matter. print(JID, PASSWORD) xmpp = EchoBot(JID, PASSWORD) xmpp.register_plugin('xep_0030') # Service Discovery xmpp.register_plugin('xep_0004') # Data Forms xmpp.register_plugin('xep_0060') # PubSub xmpp.register_plugin('xep_0199') # XMPP Ping # Connect to the XMPP server and start processing XMPP stanzas. xmpp.connect() xmpp.send_message(JID, "message1") xmpp.send_message(JID, "message2") xmpp.send_message(JID, "message3") asyncio.get_event_loop().run_forever()