コード例 #1
0
    def __init__(self, core, manager):
        IRCInterface.__init__(self, core, manager)

        self.jid = JID(self.getConfig('jid'))
        password = self.getConfig('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.getConfig('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,
        ]
コード例 #2
0
ファイル: net.py プロジェクト: StephenGWills/OpenSRF
 def connect(self):
     JabberClient.connect(self)
     while not self.isconnected:
         stream = self.get_stream()
         act = stream.loop_iter(10)
         if not act:
             self.idle()
コード例 #3
0
    def session_started(self):
        """This is called when the IM session is successfully started
		(after all the neccessery negotiations, authentication and
		authorizasion).
		That is the best place to setup various handlers for the stream.
		Do not forget about calling the session_started() method of the base
		class!"""
        JabberClient.session_started(self)

        # set up handlers for supported <iq/> queries
        self.stream.set_iq_get_handler("query", "jabber:iq:version",
                                       self.get_version)

        # set up handlers for <presence/> stanzas
        self.stream.set_presence_handler("available", self.presence)
        self.stream.set_presence_handler("subscribe", self.presence_control)
        self.stream.set_presence_handler("subscribed", self.presence_control)
        self.stream.set_presence_handler("unsubscribe", self.presence_control)
        self.stream.set_presence_handler("unsubscribed", self.presence_control)

        # set up handler for <message stanza>
        self.stream.set_message_handler("normal", self.message)
        print(self.stream)

        print u"joining..."
        self.roommgr = MucRoomManager(self.stream)
        self.roommgr.set_handlers()
        nick = self.jid.node + '-' + self.jid.resource
        for loc in options.channels:  #['*****@*****.**','*****@*****.**']:
            roomjid = JID(loc, options.muc)
            print("\t %s" % roomjid.as_unicode())
            h = RoomHandler()
            self.muc.append(h)
            mucstate = self.roommgr.join(roomjid, nick, h)
            h.assign_state(mucstate)
コード例 #4
0
    def __init__(self, username, password, server, resource="Digsby"):

        host, port = server

        alphanum = string.letters + string.digits
        resource = resource + "." + "".join(random.choice(alphanum) for _x in xrange(6))
        jid = JID(username, "digsby.org", resource)

        if isinstance(username, unicode):
            username = username.encode('utf8')
        if isinstance(password, unicode):
            password = sha256(password.encode('utf-8')).digest()

        jkwargs = dict(jid          = jid,
                       password     = password,
                       keepalive    = 45)

        if host:
            jkwargs.update(server = host)
        if port:
            jkwargs.update(port = port)

        jkwargs.update(auth_methods = ("sasl:DIGSBY-SHA256-RSA-CERT-AES",))
        JabberClient.__init__(self, **jkwargs)
        StateMixin.__init__(self)
        self.stream_class = ThreadStream
コード例 #5
0
ファイル: xmpp_connection.py プロジェクト: s0x/Z45
    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),
            ]
コード例 #6
0
    def connect(self):
        """Connect to the server and set up the stream.

        Set `self.stream` and notify `self.state_changed` when connection
        succeeds. Additionally, initialize Disco items and info of the client.
        """
        JabberClient.connect(self, register=False)
コード例 #7
0
    def __init__(self, jid, password, password_verifier, outbox_directory):
        # If a bare JID is provided add a resource
        if not jid.resource:
            jid = JID(jid.node, jid.domain, "gtalkbot")

        # Setup client with provided connection information and identity data,
        # this block also handles the SSL encryption using with Google Talk
        tls = streamtls.TLSSettings(require=True, verify_peer=False)
        auth = ['sasl:PLAIN']
        print u'Logging into talk network as %s' % jid
        JabberClient.__init__(self,
                              jid,
                              password,
                              disco_name="gtalkbot",
                              disco_type="bot",
                              tls_settings=tls,
                              auth_methods=auth)

        # Register features to be announced via Service Discovery
        self.disco_info.add_feature("jabber:iq:version")

        # Initialize the client
        print u'Initialize client'
        self.jid = jid
        self.passwd = password_verifier
        self.outbox_directory = outbox_directory
コード例 #8
0
ファイル: pg_backend.py プロジェクト: ManiacTwister/dionaea
	def session_started(self):
		"""This is called when the IM session is successfully started
		(after all the neccessery negotiations, authentication and
		authorizasion).
		That is the best place to setup various handlers for the stream.
		Do not forget about calling the session_started() method of the base
		class!"""
		JabberClient.session_started(self)

		# set up handlers for supported <iq/> queries
		self.stream.set_iq_get_handler("query","jabber:iq:version",self.get_version)

		# set up handlers for <presence/> stanzas
		self.stream.set_presence_handler("available",self.presence)
		self.stream.set_presence_handler("subscribe",self.presence_control)
		self.stream.set_presence_handler("subscribed",self.presence_control)
		self.stream.set_presence_handler("unsubscribe",self.presence_control)
		self.stream.set_presence_handler("unsubscribed",self.presence_control)

		# set up handler for <message stanza>
		self.stream.set_message_handler("normal",self.message)
		print(self.stream)

		print u"joining..."
		self.roommgr = MucRoomManager(self.stream)
		self.roommgr.set_handlers()
		nick = self.jid.node + '-' + self.jid.resource
		for loc in options.channels: #['*****@*****.**','*****@*****.**']:
			roomjid = JID(loc, options.muc)
			print("\t %s" % roomjid.as_unicode())
			h = RoomHandler()
			self.muc.append(h)
			mucstate = self.roommgr.join(roomjid, nick, h)
			h.assign_state(mucstate)
コード例 #9
0
ファイル: net.py プロジェクト: jobdiogenes/OpenSRF
 def connect(self):
     JabberClient.connect(self)
     while not self.isconnected:
         stream = self.get_stream()
         act = stream.loop_iter(10)
         if not act:
             self.idle()
コード例 #10
0
ファイル: core.py プロジェクト: Apkawa/nyasha
    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, *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,
        ]
コード例 #12
0
ファイル: bundle.py プロジェクト: optixx/karaka
    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")
コード例 #13
0
    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, "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)

        # add the separate components
        self.interface_providers = [
            VersionHandler(self),
            EchoHandler(self),
        ]
コード例 #14
0
ファイル: main.py プロジェクト: yetist/xmppdog
    def session_started(self):
        """
        Stream-related plugin setup (stanza handler registration, etc).
        Send bot presence, set message handler for chat message
        and call session_started for all loaded plugins.
        """ 
        JabberClient.session_started(self)

        presence = Presence();
        presence.set_priority(20);
        self.stream.send(presence)

        # Set up handlers for supported <iq/> queries
        self.stream.set_iq_get_handler('query', 'jabber:iq:version',
                                       self.get_version)

        # Set up handlers for <presence/> stanzas
        self.stream.set_presence_handler('subscribe', self.presence_control)
        self.stream.set_presence_handler('subscribed', self.presence_control)
        self.stream.set_presence_handler('unsubscribe', self.presence_control)
        self.stream.set_presence_handler('unsubscribed', self.presence_control)

        self.stream.set_message_handler("chat", self.message_chat)
        self.stream.set_message_handler("normal", self.plugins_message_normal)
        
        for plugin in self.plugins.values():
            try:
                plugin.session_started(self.stream)
            except StandardError:
                self.print_exception()
                self.logger.info("Plugin call failed")
コード例 #15
0
ファイル: JabberRTC.py プロジェクト: yosuke/OpenHRIWeb
 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
コード例 #16
0
ファイル: XMPP.py プロジェクト: vuolter/pyload-plugins
    def __init__(self, *args, **kwargs):
        IRC.__init__(self, *args, **kwargs)

        self.jid = pyxmpp.all.JID(self.config.get('jid'))
        password = self.config.get('pw')

        #: If bare JID is provided add a resource -- it is required
        if not self.jid.resource:
            self.jid = pyxmpp.all.JID(self.jid.node, self.jid.domain, "pyLoad")

        if self.config.get('tls'):
            tls_settings = pyxmpp.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,
                              keepalive=self.config.get('keepalive'))

        self.interface_providers = [
            VersionHandler(self),
            self,
        ]
コード例 #17
0
ファイル: imclient.py プロジェクト: walker8088/easyworld
    def authorized(self) :
        JabberClient.authorized(self)
        # ########################
	self.sendPresence(None)	
	self.request_roster()
        # ########################
	evt = IMEvent(self, IM_AUTHORIZED_EVENT)
        self.evtHandler.AddPendingEvent(evt)
コード例 #18
0
 def authorized(self):
     JabberClient.authorized(self)
     # ########################
     self.sendPresence(None)
     self.request_roster()
     # ########################
     evt = IMEvent(self, IM_AUTHORIZED_EVENT)
     self.evtHandler.AddPendingEvent(evt)
コード例 #19
0
    def disconnected(self, want_try_again = False):
        log.debug('disconnected 1')
        with self.lock:
            log.debug('disconnected 2')
            if not want_try_again and not self.want_try_again:
                log.debug('disconnected 3')
#                assert False
                self.change_state(self.Statuses.OFFLINE)
            JabberClient.disconnected(self)
コード例 #20
0
 def idle(self):
     try:
         JabberClient.idle(self)
         if not self.stream.socket or self.stream.eof:
             raise AssertionError, "if the stream is dead or gone, we can't really send a keep-alive"
     except Exception:
         self.stop_timer_loops()
     else:
         self.cache.tick()
コード例 #21
0
ファイル: notify.py プロジェクト: squarezhou/weibo-notify
     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",))
コード例 #22
0
    def _session_started_helper(self,bot,muc_jid):
        '''Pass this an instance of your bot (that subclasses MucRoomHandler) and a MUC room JID'''
        JabberClient.session_started(self)
        self.stream.set_iq_get_handler("query","jabber:iq:version",self.get_version)
        self.stream.set_message_handler("normal",self.message)

        self.muc_manager = MucRoomManager(self.stream)
        self.muc_state = self.muc_manager.join(muc_jid,self.nick,bot,history_maxchars=0)
        self.muc_manager.set_handlers()
コード例 #23
0
 def stream_error(self, err):
     if err.get_condition().name == "pwchanged":
         self.change_reason(self.Reasons.BAD_PASSWORD)
         self.profile.signoff(kicked=True)
     elif err.get_condition().name == "conflict":
         self.change_reason(self.Reasons.OTHER_USER)
     else:
         self.change_reason(self.Reasons.CONN_LOST)
         JabberClient.stream_error(self, err)
コード例 #24
0
ファイル: jabberbot.py プロジェクト: davux/Tavu
 def session_started(self):
     """This is called when the IM session is successfully started
     (after all the neccessery negotiations, authentication and
     authorizasion).
     That is the best place to setup various handlers for the stream.
     Do not forget about calling the session_started() method of the base
     class!"""
     self.request_roster()
     JabberClient.session_started(self)
コード例 #25
0
ファイル: JabberRTC.py プロジェクト: yosuke/OpenHRIWeb
 def session_started(self):
     JabberClient.session_started(self)
     self.stream.set_presence_handler(None, self.presence)
     self.stream.set_presence_handler("unavailable", self.presence)
     self.stream.set_presence_handler("subscribe", self.presence_control)
     self.stream.set_presence_handler("subscribed", self.presence_control)
     self.stream.set_presence_handler("unsubscribe", self.presence_control)
     self.stream.set_presence_handler("unsubscribed", self.presence_control)
     self.stream.set_message_handler("normal",self.message)
コード例 #26
0
ファイル: getcert.py プロジェクト: AdamPrzybyla/pyxmpp
    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)
コード例 #27
0
ファイル: slave.py プロジェクト: optixx/karaka
    def session_started(self):
        log("session_started: jid:%s" % (self.jid.as_utf8(), ))

        self.connection = CONNECTION.connected
        JabberClient.session_started(self)

        self.stream.set_presence_handler("subscribe", self.subscribe)
        self.stream.set_iq_set_handler("query", "http://vipadia.com/skype",
                                       self.vipadia_iq)

        self.slave_online()
コード例 #28
0
ファイル: slave.py プロジェクト: Ranushka/karaka
    def session_started(self):
        log("session_started: jid:%s" % (self.jid.as_utf8(),))

        self.connection = CONNECTION.connected
        JabberClient.session_started(self)
        
        self.stream.set_presence_handler("subscribe", self.subscribe)
        self.stream.set_iq_set_handler(
            "query", "http://vipadia.com/skype", self.vipadia_iq)

        self.slave_online()
コード例 #29
0
ファイル: run.py プロジェクト: cuimuxi/gtalkbot
    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),
        ]
コード例 #30
0
ファイル: gtalk.py プロジェクト: blueicesir/utils
    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),]
コード例 #31
0
ファイル: getcert.py プロジェクト: udaycyberitus/pyxmpp
    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)
コード例 #32
0
    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")

        # setup client with provided connection information
        # and identity data
        JabberClient.__init__(self, jid, password,
                disco_name="PyXMPP example: echo bot", disco_type="bot")

        # register features to be announced via Service Discovery
        self.disco_info.add_feature("jabber:iq:version")
コード例 #33
0
ファイル: jabber-logger.py プロジェクト: pontus/jabber-logger
    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")
コード例 #34
0
ファイル: robot.py プロジェクト: squarezhou/weibo-notify
    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),
            ]
コード例 #35
0
ファイル: register.py プロジェクト: mor1/karaka
    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)
コード例 #36
0
ファイル: clienttester.py プロジェクト: dgsuarez/jabbs
    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 = []
コード例 #37
0
ファイル: register.py プロジェクト: mor1/karaka
    def session_started(self):
        log("session_started: jid:%s" % (self.jid.as_utf8(),))

        self.connection = CONNECTION.connected
        JabberClient.session_started(self)

        self.stream.set_message_handler("normal", self.message)
        self.stream.set_presence_handler("subscribe", self.subscription)
        self.stream.set_iq_set_handler(
            "command", "http://vipadia.com/skype", self.vipadia_command)

        global Connected
        Connected = True

        self.safe_send(Presence(to_jid=self.config.master, stanza_type="subscribe"))
コード例 #38
0
    def session_started(self):
        log("session_started: jid:%s" % (self.jid.as_utf8(), ))

        self.connection = CONNECTION.connected
        JabberClient.session_started(self)

        self.stream.set_message_handler("normal", self.message)
        self.stream.set_presence_handler("subscribe", self.subscription)
        self.stream.set_iq_set_handler("command", "http://vipadia.com/skype",
                                       self.vipadia_command)

        global Connected
        Connected = True

        self.safe_send(
            Presence(to_jid=self.config.master, stanza_type="subscribe"))
コード例 #39
0
ファイル: client.py プロジェクト: nthorne/xmppmote
    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(),
            ]
コード例 #40
0
ファイル: bot.py プロジェクト: tomkins/instantactionbot
    def session_started(self):
        JabberClient.session_started(self)

        self.room_manager = MucRoomManager(self.stream)
        self.room_manager.set_handlers()

        self.ia_party = ShazbotParty(
            bot=self, game_handler=self.game_handler, game_jid=self.game_jid,
            gamelist_jid=self.gamelist_jid, bot_nick=self.jid.node, autoload=self.party_autoload,
            allow_invites=self.party_allowinvites, size_limit=self.party_maxusers)
        self.ia_party.commands.admins = self.party_admins
        room_id = JID(self.ia_partyresource, self.party_domain)
        self.ia_shazbotjid = room_id

        new_party = self.room_manager.join(room_id, self.jid.node, self.ia_party)
        new_party.request_configuration_form()
コード例 #41
0
    def __init__(self, jid, password, **options):
        if not isinstance(jid, JID):
            jid = JID(jid)

        self.jid = jid
        self.rooms = {}

        kwargs = {
            'tls_settings': streamtls.TLSSettings(require=True, verify_peer=False),
            'auth_methods': ('sasl:PLAIN',),
            'disco_name': "pyjirc",
            'disco_type': "bot"
        }
        kwargs.update(options)
        JabberClient.__init__(self, jid, password, **kwargs)

        self.disco_info.add_feature("jabber:iq:version")
コード例 #42
0
ファイル: xmpp_connection.py プロジェクト: s0x/Z45
    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),
        ]
コード例 #43
0
    def session_started(self):
        JabberClient.session_started(self)
        self.room_manager = MucRoomManager(self.stream)

        handle_presence = getattr(self, 'handle_presence', None)
        if callable(handle_presence):
            self.stream.set_presence_handler(None, handle_presence)
            #self.stream.set_presence_handler('subscribed', handle_presence)
            #self.stream.set_presence_handler('unsubscribe', handle_presence)
            #self.stream.set_presence_handler('unsubscribed', handle_presence)

        handle_message = getattr(self, 'handle_message', None)
        if callable(handle_message):
            self.stream.set_message_handler('normal', handle_message)

        handle_connect = getattr(self, 'handle_connect', None)
        if callable(handle_connect):
            handle_connect()
コード例 #44
0
ファイル: bot.py プロジェクト: cuimuxi/gtalkbot
    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)]
コード例 #45
0
    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()
コード例 #46
0
ファイル: net.py プロジェクト: StephenGWills/OpenSRF
    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
コード例 #47
0
ファイル: echobot.py プロジェクト: adaptee/bin
    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),
            ]
コード例 #48
0
    def session_started(self):
        """This is called when the IM session is successfully started
    (after all the neccessery negotiations, authentication and
    authorization)."""
        JabberClient.session_started(self)
        print 'Session started'

        # Set up handlers for supported <iq/> queries
        self.stream.set_iq_get_handler('query', 'jabber:iq:version',
                                       self.get_version)

        # Set up handlers for <presence/> stanzas
        self.stream.set_presence_handler('subscribe', self.presence_control)
        self.stream.set_presence_handler('subscribed', self.presence_control)
        self.stream.set_presence_handler('unsubscribe', self.presence_control)
        self.stream.set_presence_handler('unsubscribed', self.presence_control)

        # Set up handler for <message stanza>
        self.stream.set_message_handler('normal', self.message)
コード例 #49
0
ファイル: core.py プロジェクト: dgsuarez/jabbs
 def session_started(self):
     """Triggered when the session starts. Sets some event handlers and
     connects to indicated rooms
     
     """
     JabberClient.session_started(self)
     self.stream.set_message_handler("chat", self.chat_received)
     self.stream.set_message_handler("error", self.error_received)
     self.stream.set_presence_handler(None,self.presence_received)
     self.stream.set_presence_handler("unavailable",self.unavailable_received)
     self.stream.set_presence_handler("subscribe",self.subscription_received)
     self.stream.set_presence_handler("unsubscribe",self.subscription_received)
     self.stream.set_presence_handler("subscribed",self.subscription_received)
     self.stream.set_presence_handler("unsubscribed",self.subscription_received)
     self.logger.info("Session started")
     self.mucman = MucRoomManager(self.stream)
     self.mucman.set_handlers()
     for room in self.rooms_to_join:
         self.join_room(JID(room))
コード例 #50
0
    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)
コード例 #51
0
ファイル: net.py プロジェクト: jobdiogenes/OpenSRF
    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
コード例 #52
0
ファイル: test_client.py プロジェクト: nthorne/xmppmote
    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])
コード例 #53
0
ファイル: echobot2.py プロジェクト: adaptee/bin
    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),
        ]
コード例 #54
0
ファイル: irc.py プロジェクト: mycard/discourse_milkman
    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)
コード例 #55
0
    def session_started(self):
        """This is called when the IM session is successfully started
        (after all the neccessery negotiations, authentication and
        authorizasion).
        That is the best place to setup various handlers for the stream.
        Do not forget about calling the session_started() method of the base
        class!"""
        JabberClient.session_started(self)

        # set up handlers for supported <iq/> queries
        self.stream.set_iq_get_handler("query","jabber:iq:version",self.get_version)

        # set up handlers for <presence/> stanzas
        self.stream.set_presence_handler(None, self.presence)
        self.stream.set_presence_handler("unavailable", self.presence)
        self.stream.set_presence_handler("subscribe", self.presence_control)
        self.stream.set_presence_handler("subscribed", self.presence_control)
        self.stream.set_presence_handler("unsubscribe", self.presence_control)
        self.stream.set_presence_handler("unsubscribed", self.presence_control)

        # set up handler for <message stanza>
        self.stream.set_message_handler("normal",self.message)
コード例 #56
0
ファイル: core.py プロジェクト: dgsuarez/jabbs
    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)
コード例 #57
0
ファイル: core.py プロジェクト: dgsuarez/jabbs
 def session_started(self):
     """Triggered when the session starts. Sets some event handlers and
     connects to indicated rooms
     
     """
     JabberClient.session_started(self)
     self.stream.set_message_handler("chat", self.chat_received)
     self.stream.set_message_handler("error", self.error_received)
     self.stream.set_presence_handler(None, self.presence_received)
     self.stream.set_presence_handler("unavailable",
                                      self.unavailable_received)
     self.stream.set_presence_handler("subscribe",
                                      self.subscription_received)
     self.stream.set_presence_handler("unsubscribe",
                                      self.subscription_received)
     self.stream.set_presence_handler("subscribed",
                                      self.subscription_received)
     self.stream.set_presence_handler("unsubscribed",
                                      self.subscription_received)
     self.logger.info("Session started")
     self.mucman = MucRoomManager(self.stream)
     self.mucman.set_handlers()
     for room in self.rooms_to_join:
         self.join_room(JID(room))
コード例 #58
0
 def registration_form_received(self, stanza):
     print "registration_form_received :", stanza.serialise()
     JabberClient.registration_form_received(self, stanza)
     print "registration_form_received_end"