def __init__(self, jid, password, obj): if not jid.resource: jid = JID(jid.node, jid.domain, "JabberRTC") tls = TLSSettings(require = True, verify_peer = False) auth = ['sasl:PLAIN'] JabberClient.__init__(self, jid, password, tls_settings = tls, auth_methods = auth) self._rtobj = obj
def __init__(self, jid, password, server, port=5222, channel=None, tls_cacerts=None, listener=None): self._jid = jid self._server = server self._port = port self._channel = channel self._listener = listener # if bare JID is provided add a resource -- it is required if not self._jid.resource: self._jid=JID(self._jid.node, self._jid.domain, "Echobot") if tls_cacerts: if tls_cacerts == 'tls_noverify': tls_settings = TLSSettings(require = True, verify_peer = False) else: tls_settings = TLSSettings(require = True, cacert_file = tls_cacerts) else: tls_settings = None # setup client with provided connection information # and identity data JabberClient.__init__(self, jid=self._jid, password=password, disco_name="Datenverarbeitungseinheit Z45", disco_type="z45", tls_settings=tls_settings) ''' JabberClient.__init__(self, jid, password, disco_name="Datenverarbeitungseinheit Z45", disco_type="z45", tls_settings = tls_settings) ''' # add the separate components self.interface_providers = [ VersionHandler(self), EchoHandler(self), ]
def __init__(self, *args, **kwargs): IRCInterface.__init__(self, *args, **kwargs) self.jid = JID(self.get_config('jid')) password = self.get_config('pw') #: If bare JID is provided add a resource -- it is required if not self.jid.resource: self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") if self.get_config('tls'): tls_settings = streamtls.TLSSettings(require=True, verify_peer=False) auth = ("sasl:PLAIN", "sasl:DIGEST-MD5") else: tls_settings = None auth = ("sasl:DIGEST-MD5", "digest") #: Setup client with provided connection information #: And identity data JabberClient.__init__(self, self.jid, password, disco_name="pyLoad XMPP Client", disco_type="bot", tls_settings=tls_settings, auth_methods=auth) self.interface_providers = [ VersionHandler(self), self, ]
def __init__(self, jid, password, resource='Bot', tls_cacerts=None, server=None, port=5222): # if bare JID is provided add a resource -- it is required if isinstance(jid, basestring): jid = JID(jid) if not jid.resource: jid=JID(jid.node, jid.domain, resource) self.jid = jid server = server or jid.domain if tls_cacerts: if tls_cacerts == 'tls_noverify': tls_settings = TLSSettings(require = True, verify_peer = False) else: tls_settings = TLSSettings(require = True, cacert_file = tls_cacerts) else: tls_settings = None # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, password, disco_name="PyXMPP example: echo bot", disco_type="bot", server=None, port=None, tls_settings=tls_settings) # add the separate components self.interface_providers = self.get_plugins() self.loop_tasks = self.get_loop_tasks()
def __init__(self, jid, password): if not jid.resource: jid=JID(jid.node, jid.domain, "WeiboNotifyRobot") tls_settings = TLSSettings(require = True, verify_peer = False) JabberClient.__init__(self, jid, password, disco_name="Weibo Notify Robot", disco_type="bot", tls_settings = tls_settings, auth_methods=("sasl:PLAIN",))
def __init__(self, server_jid): jid = JID("dummy", server_jid.domain, "GetCert") tls_settings = TLSSettings(require = True, verify_peer = False) # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, "", disco_name="PyXMPP example: getcert.py", disco_type="bot", tls_settings = tls_settings)
def __init__(self, jid, password): if not jid.resource: jid=JID(jid.node, jid.domain, "Bot") tls_settings = TLSSettings(require = True, verify_peer = False) JabberClient.__init__(self, jid, password, auth_methods=['sasl:PLAIN'], disco_name="Pythoner Club", disco_type="bot", tls_settings = tls_settings) self.interface_providers = [ DaemonHandler(self), ]
def __init__(self,jid,password,ini): if not jid.resource: jid=JID(jid.node,jid.domain,"rbot") if ini: self.ini=ini tls=TLSSettings(require=True,verify_peer=False) auth=['sasl:PLAIN'] JabberClient.__init__(self,jid,password,disco_name='rbot',disco_type='bot',tls_settings=tls,auth_methods=auth) self.interface_providers=[VersionHandler(self),EchoHandler(self,ini),]
def __init__(self, jid, password): # if bare JID is provided add a resource -- it is required if not jid.resource: jid=JID(jid.node, jid.domain, "Logger") # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, password, disco_name="PyXMPP Archiver bot", disco_type="bot") # register features to be announced via Service Discovery self.disco_info.add_feature("jabber:iq:version")
def __init__(self, config): self.config = config self.connection = CONNECTION.idle self.running = True self.jid = JID("%s@%s/%s" % (config.register, config.domain, config.register)) log("register: jid:%s" % (self.jid.as_utf8(),)) tls = streamtls.TLSSettings(require=True, verify_peer=False) auth = [ 'digest' ] JabberClient.__init__(self, self.jid, self.config.secret, disco_name="Vipadia Skype Gateway Register", disco_type="bot", tls_settings=tls, auth_methods=auth)
def __init__(self, jid, passwd,to_jid, message_list): """message_list is a list of tuples of strings, each tuple is a sentence and it's expected reply """ self.messages = message_list self.to_jid = JID(to_jid) jid_ = JID(jid) self.fail_count = 0 if not jid_.resource: jid_ = JID(jid_.node, jid_.domain, "Mibot") JabberClient.__init__(self, jid_, passwd) self.send_next = True self.failed_messages = []
def __init__(self, jid, password): if not jid.resource: jid=JID(jid.node, jid.domain, "WeiboNotifyRobot") tls_settings = TLSSettings(require = True, verify_peer = False) JabberClient.__init__(self, jid, password, disco_name="Weibo Notify Robot", disco_type="bot", tls_settings = tls_settings, auth_methods=("sasl:PLAIN",)) # add the separate components self.interface_providers = [ CommandHandler(self), ]
def __init__(self, jid = None, password = None): super(Client, self).__init__() if None != jid and None != password: # if bare JID is provided add a resource if not jid.resource: jid = JID(jid.node, jid.domain, "XMPPMote") JabberClient.__init__(self, jid, password, disco_name = "XMPPMote", disco_type = "bot", tls_settings = None) self.interface_providers = [ VersionHandler(), configuration.commands.get_command_handler(), ]
def __init__(self, jid, password): if not jid.resource: jid = JID(jid.node, jid.domain, "Bot") tls_settings = TLSSettings(require=True, verify_peer=False) JabberClient.__init__( self, jid, password, auth_methods=["sasl:PLAIN"], disco_name="Pythoner Club", disco_type="bot", tls_settings=tls_settings, ) # add the separate components self.interface_providers = [VersionHandler(self), BotHandler(self)]
def __init__(self, jid, password): # if bare JID is provided add a resource -- it is required if not jid.resource: print(jid.resource) jid = JID(jid.node, jid.domain, "Echobot") # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, password, disco_name="PyXMPP example: echo bot", disco_type="bot", keepalive=10) # register features to be announced via Service Discovery self.disco_info.add_feature("jabber:iq:version") self.muc = []
def __init__(self, jid, password): # if bare JID is provided add a resource -- it is required if not jid.resource: jid = JID(jid.node, jid.domain, "Echobot") tlssettings = streamtls.TLSSettings(require=True, verify_peer=False ) auth = ['sasl:PLAIN'] # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, password, disco_name="PyXMPP example: echo bot", disco_type="bot", tls_settings=tlssettings, auth_methods=auth ) # add the separate components self.interface_providers = [ VersionHandler(self), EchoHandler(self), ]
def __init__(self, **args): self.isconnected = False # Create a unique jabber resource resource = args.get('resource') or 'python_client' resource += '_' + gethostname() + ':' + str(os.getpid()) + '_' + \ threading.currentThread().getName().lower() self.jid = JID(args['username'], args['host'], resource) osrf.log.log_debug("initializing network with JID %s and host=%s, " "port=%s, username=%s" % (self.jid.as_utf8(), args['host'], \ args['port'], args['username'])) #initialize the superclass JabberClient.__init__(self, self.jid, args['password'], args['host']) self.queue = [] self.receive_callback = None self.transport_error_msg = None
def __init__(self, config): self.config = config self.connection = CONNECTION.idle self.running = True self.jid = JID("%s@%s/%s" % (config.register, config.domain, config.register)) log("register: jid:%s" % (self.jid.as_utf8(), )) tls = streamtls.TLSSettings(require=True, verify_peer=False) auth = ['digest'] JabberClient.__init__(self, self.jid, self.config.secret, disco_name="Vipadia Skype Gateway Register", disco_type="bot", tls_settings=tls, auth_methods=auth)
def test__init__(self): """ Ensure that the proper superclass methods are called and that the interface providers are set. """ jid = JID(self.__usr) jid = JID(jid.node, jid.domain, "XMPPMote") self.mox.StubOutWithMock(JabberClient, "__init__") self.mox.StubOutWithMock(commands, "get_command_handler") self.mox.StubOutWithMock(VersionHandler, "__init__") JabberClient.__init__(mox.IgnoreArg(), jid, self.__pwd, disco_name = "XMPPMote", disco_type = "bot", tls_settings = None) VersionHandler.__init__() commands.get_command_handler().AndReturn("foobar") self.mox.ReplayAll() cli = Client(JID(self.__usr), self.__pwd) self.assertTrue(isinstance(cli.interface_providers[0], VersionHandler)) self.assertEquals("foobar", cli.interface_providers[1])
def __init__(self, jid, password, tls_cacerts = None): if tls_cacerts is None: tls_cacerts = 'tls_noverify' # if bare JID is provided add a resource -- it is required if not jid.resource: jid=JID(jid.node, jid.domain, "Echobot") if tls_cacerts: if tls_cacerts == 'tls_noverify': tls_settings = TLSSettings(require = True, verify_peer = False) else: tls_settings = TLSSettings(require = True, cacert_file = tls_cacerts) else: tls_settings = None # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, password, disco_name="PyXMPP example: echo bot", disco_type="bot", tls_settings = tls_settings)
def __init__(self, jid, password): # if bare JID is provided add a resource -- it is required if not jid.resource: jid=JID(jid.node, jid.domain, 'w3erbot') #tls验证设置 tls = streamtls.TLSSettings(require=True, verify_peer=False) auth = ['sasl:PLAIN'] # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, password, disco_name='W3er Bot', disco_type='bot', tls_settings=tls, auth_methods=auth) # 添加自己实现的组件 self.interface_providers = [ VersionHandler(self), EchoHandler(self), ]
def __init__(self, config_path): """Initializes the bot with data from a configuration file jid (node@domain) and it's password. starter and starter_params are the class of the first controller to be used and it's params. If none is provided a default controller will be used. user_control is a function to determine if a user should be accepted if he requests so with a suscribe presence stanza. Must return True/False """ self.initialize_logger() self.config = configparser.Config(config_path) self.conversations = {} self.user_control = self.config.user_control self.jid = self.create_jid(self.config.jid) self.nick = self.config.nick self.__starter = self.config.starter self.__starter_params = self.config.starter_params self.rooms_to_join = self.config.rooms_to_join self.start_on_user_connect = self.config.start_on_user_connect JabberClient.__init__(self, self.jid, self.config.password)
def __init__(self, jid, secret, skypeuser, skypesecret, xmppujid): dbg("creating bundle: jid:%s secret:%s skypeuser:%s skypesecret:%s xmppujid:%s" % ( jid.as_utf8(), secret, skypeuser, skypesecret, xmppujid.as_utf8()), 3) self.running = True self.attached = False # skype self.connection = CONNECTION.idle # xmppp self.jid = jid self.secret = secret self.skypeuser = skypeuser self.skypesecret = CryptoAPI().decrypt(skypesecret) self.skype_ps = None self.xmppujid = xmppujid tls = streamtls.TLSSettings(require=False, verify_peer=False) auth = [ 'digest' ] JabberClient.__init__(self, jid, secret, disco_name="Vipadia Skype Gateway Bundle", disco_type="bot", tls_settings=tls, auth_methods=auth) self.disco_info.add_feature("jabber:iq:version")
def run(self): """ Connect and run the application main loop. """ try: self.load_plugins() self.logger.debug ("creating stream...") tls = streamtls.TLSSettings(require=True, verify_peer=False) auth = ['sasl:PLAIN'] JabberClient.__init__(self, jid = self.jid, password = self.password, disco_name="xmppbot", disco_type="bot", tls_settings=tls, auth_methods = auth) self.disco_info.add_feature("jabber:iq:version") self.logger.debug("connecting...") try: self.connect() except dns.exception.Timeout: self.logger.info("Timeout..., Quit now") self.exit() return self.logger.debug("processing...") self.stream.process_stream_error = self.my_stream_error try: self.loop(1) finally: if self.stream: self.disconnect() except KeyboardInterrupt: self.logger.info("Quit request") self.exit() except StreamError: self.exit()
def __init__(self, parent): wx.EvtHandler.__init__(self) self.data_in_handler=DataInHandler(self) self.data_out_handler=DataOutHandler(self) logger = logging.getLogger("pyxmpp.Stream.in"); logger.setLevel(logging.DEBUG) logger.addHandler(self.data_in_handler) logger = logging.getLogger("pyxmpp.Stream.out") logger.setLevel(logging.DEBUG) logger.addHandler(self.data_out_handler) self.keepalive = 30 tls = pyxmpp.TLSSettings(require=True, verify_peer=False) JabberClient.__init__(self, None, None, keepalive = self.keepalive, disco_name=u'Jubatu', disco_category=u'client', disco_type=u'gaming', tls_settings=tls, auth_methods=['sasl:PLAIN']) self.isDetached = False self.disco_mgr = discomgr.DiscoManager(self) self.file_transfer_mgr = filemgr.FileTransferManager(self, glob.config['Chat']['save_folder']) self.storage_mgr = storage.StorageManager(self) self.vard_mgr = vcardmgr.VcardManager(self) self.interface_providers = [ self, VersionHandler(self), self.disco_mgr, self.file_transfer_mgr, self.file_transfer_mgr.ibb, ] self.parent = parent self.evtHandler = self.parent.GetEventHandler()
def __init__(self, jid, password, tls_cacerts): # if bare JID is provided add a resource -- it is required if not jid.resource: jid=JID(jid.node, jid.domain, "attacktest") if tls_cacerts: if tls_cacerts == 'tls_noverify': tls_settings = TLSSettings(require = True, verify_peer = False) else: tls_settings = TLSSettings(require = True, cacert_file = tls_cacerts) else: tls_settings = None # setup client with provided connection information # and identity data JabberClient.__init__(self, jid, password, disco_name="PyXMPP example: echo bot", disco_type="bot", tls_settings = tls_settings) # add the separate components self.interface_providers = [ VersionHandler(self), EchoHandler(self), ]
def __init__(self, conf): # Various config file bits we'll need jid_node = conf.get('login', 'nick') jid_domain = conf.get('jabber', 'domain') jabber_server = conf.get('jabber', 'server') jabber_port = conf.getint('jabber', 'port') # Game config game_product = conf.getint('game', 'productid') game_instance = conf.getint('game', 'instanceid') game_maplist = conf.get('game', 'maplist') game_maprotation = conf.get('game', 'maprotation') game_port = conf.getint('game', 'port') game_mode = conf.get('game', 'mode') game_timelimit = conf.getint('game', 'timelimit') game_scorelimit = conf.getint('game', 'scorelimit') game_autostart = conf.getboolean('game', 'autostart') game_tournament = conf.getboolean('game', 'tournament') game_lt = conf.getboolean('game', 'lt') game_grenades = conf.getboolean('game', 'grenades') # Listener options listen_pid = conf.getint('listener', 'pid') listen_tcpip = conf.getboolean('listener', 'tcpip') listen_ip = conf.get('listener', 'ip') listen_port = conf.getint('listener', 'port') # Stats config stats_enabled = conf.getboolean('stats', 'enabled') stats_urls = conf.get('stats', 'urls') stats_retry = conf.getint('stats', 'retry') stats_db = conf.get('stats', 'db') # Login config username = conf.get('login', 'username') password = conf.get('login', 'password') nickname = conf.get('login', 'nick') login_cache = conf.get('login', 'cache') browser_agent = conf.get('browser', 'agent') homepage_url = conf.get('browser', 'homepage') login_url = conf.get('browser', 'login') # Party config self.party_allowinvites = conf.getboolean('party', 'allowinvites') self.party_maxusers = conf.getint('party', 'maxusers') self.party_membersonly = conf.getboolean('party', 'membersonly') self.party_autoload = conf.getboolean('party', 'autoload') self.party_domain = conf.get('jabber', 'parties') self.party_gamesdomain = conf.get('jabber', 'games') self.party_gamename = conf.get('jabber', 'gamename') party_admins_conf = conf.get('party', 'admins') self.party_admins = party_admins_conf.lower().split(' ') # Generate us some randomish things we'll be needing self.ia_clientresource = u'%s_%d' % ( ''.join([random.choice('0123456789abcdef') for x in range(32)]), time.time()) self.ia_partyresource = u'%s%s%d' % ( nickname, ''.join([random.choice('0123456789abcdef') for x in range(32)]), time.time()) # Need a ticket with our login details ia_login = IALogin(browser_agent, homepage_url, login_url, login_cache) ticket = ia_login.login(username, password) # Setup the client jid = JID(jid_node, jid_domain, self.ia_clientresource) JabberClient.__init__( self, jid, ticket, server=jabber_server, port=jabber_port, auth_methods=('sasl:PLAIN',), keepalive=10) self.stream_class = ClientStreamAsyncore # games JID self.game_jid = JID(u'%s/game' % unicode(self.jid)) self.gamelist_jid = JID( u'%s@%s/%s' % (jid_node, self.party_gamesdomain, self.party_gamename)) # add the separate components self.interface_providers = [ GameHandler(self), MessageHandler(self), ] # Game handler deals with the game messages and game status self.game_handler = IAGameHandler(self.message_from_shazbot) # Register maps and map rotation with the handler maps = csv.reader(open(game_maplist)) for i in maps: self.game_handler.register_map(i[0], i[1], int(i[2])) map_rotation = csv.reader(open(game_maprotation)) for i in map_rotation: self.game_handler.add_rotation(i[0], int(i[1]), int(i[2])) # Start up the stats thread if enabled, register with the game handler if stats_enabled: stats_urllist = stats_urls.split(' ') self.stats_thread = StatsThread(stats_db, stats_urllist, stats_retry) self.stats_thread.start() else: self.stats_thread = None self.game_handler.stats_thread = self.stats_thread # Other game settings self.game_handler.port = game_port self.game_handler.login = nickname self.game_handler.mode_name = game_mode self.game_handler.timelimit = game_timelimit self.game_handler.scorelimit = game_scorelimit self.game_handler.autostart = game_autostart self.game_handler.tournament = game_tournament self.game_handler.lt = game_lt self.game_handler.grenades = game_grenades # Game listener accepts connections for the game handler self.game_listener = IAGameListener( game_handler=self.game_handler, product=game_product, instance=game_instance) if listen_tcpip: self.game_listener.setup_tcpip((listen_ip, listen_port)) else: # Auto detect pid if -1 is given, only useful to specify if game runs under another uid if listen_pid == -1: self.game_listener.setup_unix() else: self.game_listener.setup_unix(listen_pid)
def __init__(self, jid, password): if not jid.resource: jid = JID(jid.node, jid.domain, app.name) JabberClient.__init__(self, jid, password) self.disco_info.add_feature("jabber:iq:version")
def __init__(self, jid, password): jid=JID(jid.node, jid.domain, "Basicbot") tls = streamtls.TLSSettings(require=True, verify_peer=False) auth = ['sasl:PLAIN'] JabberClient.__init__(self, jid, password, tls_settings=tls,auth_methods=auth) self.interface_providers = [BasicHandler(self)]
def __init__(self, jid, password, nick): self.nick = nick self.jid = jid if jid.resource else JID(jid.node, jid.domain, "Robot-"+self.nick) tls = TLSSettings(require=True, verify_peer=False) JabberClient.__init__(self, self.jid, password, disco_name="chatbot", disco_type="user", tls_settings=tls, auth_methods=['sasl:PLAIN']) self.disco_info.add_feature("jabber:iq:version")