當前位置: 首頁>>代碼示例>>Python>>正文


Python client.JabberClient類代碼示例

本文整理匯總了Python中pyxmpp.jabber.client.JabberClient的典型用法代碼示例。如果您正苦於以下問題:Python JabberClient類的具體用法?Python JabberClient怎麽用?Python JabberClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了JabberClient類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    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()
開發者ID:Apkawa,項目名稱:nyasha,代碼行數:27,代碼來源:core.py

示例2: session_started

	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: #['[email protected]','[email protected]']:
			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)
開發者ID:ManiacTwister,項目名稱:dionaea,代碼行數:34,代碼來源:pg_backend.py

示例3: __init__

    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),
            ]
開發者ID:s0x,項目名稱:Z45,代碼行數:32,代碼來源:xmpp_connection.py

示例4: __init__

 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
開發者ID:yosuke,項目名稱:OpenHRIWeb,代碼行數:7,代碼來源:JabberRTC.py

示例5: connect

 def connect(self):
     JabberClient.connect(self)
     while not self.isconnected:
         stream = self.get_stream()
         act = stream.loop_iter(10)
         if not act:
             self.idle()
開發者ID:StephenGWills,項目名稱:OpenSRF,代碼行數:7,代碼來源:net.py

示例6: session_started

    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")
開發者ID:yetist,項目名稱:xmppdog,代碼行數:31,代碼來源:main.py

示例7: __init__

    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,
        ]
開發者ID:OpenMediaVault-Plugin-Developers,項目名稱:openmediavault-pyload,代碼行數:27,代碼來源:XMPPInterface.py

示例8: authorized

    def authorized(self) :
        JabberClient.authorized(self)
        # ########################
	self.sendPresence(None)	
	self.request_roster()
        # ########################
	evt = IMEvent(self, IM_AUTHORIZED_EVENT)
        self.evtHandler.AddPendingEvent(evt)
開發者ID:walker8088,項目名稱:easyworld,代碼行數:8,代碼來源:imclient.py

示例9: session_started

 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)
開發者ID:davux,項目名稱:Tavu,代碼行數:9,代碼來源:jabberbot.py

示例10: session_started

 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)
開發者ID:yosuke,項目名稱:OpenHRIWeb,代碼行數:9,代碼來源:JabberRTC.py

示例11: __init__

     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",))
開發者ID:squarezhou,項目名稱:weibo-notify,代碼行數:9,代碼來源:notify.py

示例12: _session_started_helper

    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()
開發者ID:iferguson90,項目名稱:Walrus,代碼行數:9,代碼來源:mucroombot.py

示例13: __init__

    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)
開發者ID:AdamPrzybyla,項目名稱:pyxmpp,代碼行數:10,代碼來源:getcert.py

示例14: session_started

    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()
開發者ID:Ranushka,項目名稱:karaka,代碼行數:11,代碼來源:slave.py

示例15: __init__

    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),]
開發者ID:blueicesir,項目名稱:utils,代碼行數:12,代碼來源:gtalk.py


注:本文中的pyxmpp.jabber.client.JabberClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。