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


Python sleekxmpp.ClientXMPP方法代碼示例

本文整理匯總了Python中sleekxmpp.ClientXMPP方法的典型用法代碼示例。如果您正苦於以下問題:Python sleekxmpp.ClientXMPP方法的具體用法?Python sleekxmpp.ClientXMPP怎麽用?Python sleekxmpp.ClientXMPP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sleekxmpp的用法示例。


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

示例1: __init__

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def __init__(self, server, port, jid, password, rooms, nick):
        sleekxmpp.ClientXMPP.__init__(self, jid, password)

        self.rooms = rooms
        self.nick = nick

        self.add_event_handler("session_start", self.on_start)
        self.add_event_handler("groupchat_message", self.on_muc_message)

        self.register_plugin('xep_0045')  # Multi-User Chat
        self.register_plugin('xep_0199')  # XMPP Ping

        self.srvaddress = (server, port)

        # if not self.connect((server, port)):
        #     raise Exception("Unable to connect to XMPP server") 
開發者ID:tuna,項目名稱:fishroom,代碼行數:18,代碼來源:xmpp.py

示例2: __init__

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def __init__(self, jid, password, xor_var):  # , room, nick):
    sleekxmpp.ClientXMPP.__init__(self, jid, password)
    #self.room = room
    #self.nick = nick
    self.xor_var = bytearray(self.hexToByte(xor_var))

    # The session_start event will be triggered when the bot connects to the server
    self.add_event_handler("session_start", self.start)

    #The message event is triggered whenever you are sent a message
    self.add_event_handler("message", self.message)

    # The groupchat_message event
    #self.add_event_handler("groupchat_message", self.muc_message)

    # The groupchat_presence event is triggered whenever someone joins a room
    #self.add_event_handler("muc::%s::got_online" % self.room, self.muc_online)

  # session_start event 
開發者ID:ahhh,項目名稱:XMPP_Shell_Bot,代碼行數:21,代碼來源:gchat_shell_bot.py

示例3: __init__

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def __init__(self, jid, password):
        sleekxmpp.ClientXMPP.__init__(self, jid, password)

        # The session_start event will be triggered when
        # the bot establishes its connection with the server
        # and the XML streams are ready for use. We want to
        # listen for this event so that we we can initialize
        # our roster.
        self.add_event_handler('session_start', self.start)

        # The message event is triggered whenever a message
        # stanza is received. Be aware that that includes
        # MUC messages and error messages.
        self.add_event_handler('message', self.message)

        # Register plugins. Note that while plugins may have
        # interdependencies, the order you register them in doesn't matter.
        self.register_plugin('xep_0030')  # Service Discovery
        self.register_plugin('xep_0004')  # Data Forms
        self.register_plugin('xep_0060')  # PubSub
        self.register_plugin('xep_0199')  # XMPP Ping 
開發者ID:GoogleCloudPlatform,項目名稱:python-docs-samples,代碼行數:23,代碼來源:wikibot.py

示例4: new_session

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def new_session(cls, jid, password, callback=None):
        '''
        Opens a new session and instantiates a new XMPP client.

        Arguments:
            jid -- The XMPP JID for logging in.
            password -- The password for logging in.
            callback -- An optional callback which can be used to track
                the starting state of the session.
        '''
        client = sleekxmpp.ClientXMPP(jid, password)
        #? Register plug-ins.
        client.registerPlugin('xep_0004') # Data Forms
        client.registerPlugin('xep_0009') # Jabber-RPC
        client.registerPlugin('xep_0030') # Service Discovery
        client.registerPlugin('xep_0060') # PubSub
        client.registerPlugin('xep_0199') # XMPP Ping
        return cls.new_session_with_client(client, callback) 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:20,代碼來源:remote.py

示例5: __init__

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def __init__(self, jid, password, recipient, message):
        sleekxmpp.ClientXMPP.__init__(self, jid, password)

        self.reconnect_max_attempts = 5
        self.auto_reconnect = False
        # The message we wish to send, and the JID that
        # will receive it.
        self.recipient = recipient
        self.msg = message

        # Success checking
        self.message_sent = False

        # The session_start event will be triggered when
        # the bot establishes its connection with the server
        # and the XML streams are ready for use. We want to
        # listen for this event so that we we can initialize
        # our roster.
        self.add_event_handler("session_start", self.start)
        if getattr(settings, 'BROADCAST_IGNORE_INVALID_CERT', False):
            self.add_event_handler("ssl_invalid_cert", self.discard) 
開發者ID:allianceauth,項目名稱:allianceauth,代碼行數:23,代碼來源:manager.py

示例6: __init__

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def __init__(self, jid, password):
        sleekxmpp.ClientXMPP.__init__(self, jid, password)
        if opts.ipv4 is False:
            self.use_ipv6 = True
        else:
            self.use_ipv6 = False
        self.add_event_handler("session_start", self.start)
        self.add_event_handler("message", self.message)
        self.add_event_handler("ssl_invalid_cert", self.ssl_invalid_cert) 
開發者ID:flipkart-incubator,項目名稱:watchdog,代碼行數:11,代碼來源:search_xmpp.py

示例7: _start_xmpp_client

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def _start_xmpp_client(self):
        if self._xmpp_client is not None:
            return

        if self.jid is None or self.password is None:
            raise RuntimeError('%s - jid or password not set', self.name)

        if self.server is None or self.port is None:
            raise RuntimeError('%s - server or port not set', self.name)

        if self.node is None or self.pubsub_service is None:
            raise RuntimeError(
                '%s - node or pubsub_service not set',
                self.name
            )

        self._xmpp_client = sleekxmpp.ClientXMPP(
            jid=self.jid,
            password=self.password
        )
        self._xmpp_client.register_plugin('xep_0030')
        self._xmpp_client.register_plugin('xep_0059')
        self._xmpp_client.register_plugin('xep_0060')
        self._xmpp_client.add_event_handler(
            'session_start',
            self._xmpp_session_start
        )
        self._xmpp_client.add_event_handler(
            'disconnected',
            self._xmpp_disconnected
        )

        if not self._xmpp_client.connect((self.server, self.port)):
            raise RuntimeError(
                '%s - error connecting to XMPP server',
                self.name
            )

        self._xmpp_client.process(block=True) 
開發者ID:PaloAltoNetworks,項目名稱:minemeld-core,代碼行數:41,代碼來源:xmpp.py

示例8: __init__

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def __init__(self, jid, password, sasl_mech):
        sleekxmpp.ClientXMPP.__init__(self, jid, password, sasl_mech=sasl_mech)
        self._overlay_id = None
        # self.overlay_descr = None
        self._sig = None
        self._node_id = None
        self._presence_publisher = None
        self._jid_cache = None
        self._outgoing_rem_acts = None
        self._cbt_to_action_tag = {}  # maps remote action tags to cbt tags
        self._host = None
        self._port = None 
開發者ID:ipop-project,項目名稱:Controllers,代碼行數:14,代碼來源:Signal.py

示例9: load

# 需要導入模塊: import sleekxmpp [as 別名]
# 或者: from sleekxmpp import ClientXMPP [as 別名]
def load(self):

        # Prepare our object
        self.xmpp = sleekxmpp.ClientXMPP(self.jid, self.password)

        # Register our session
        self.xmpp.add_event_handler("session_start", self.session_start)

        for xep in self.xep:
            # Load xep entries
            try:
                self.xmpp.register_plugin('xep_{0:04d}'.format(xep))

            except sleekxmpp.plugins.base.PluginNotFound:
                self.logger.warning(
                    'Could not register plugin {}'.format(
                        'xep_{0:04d}'.format(xep)))
                return False

        if self.secure:
            # Don't even try to use the outdated ssl.PROTOCOL_SSLx
            self.xmpp.ssl_version = ssl.PROTOCOL_TLSv1

            # If the python version supports it, use highest TLS version
            # automatically
            if hasattr(ssl, "PROTOCOL_TLS"):
                # Use the best version of TLS available to us
                self.xmpp.ssl_version = ssl.PROTOCOL_TLS

            self.xmpp.ca_certs = None
            if self.verify_certificate:
                # Set the ca_certs variable for certificate verification
                self.xmpp.ca_certs = next(
                    (cert for cert in self.CA_CERTIFICATE_FILE_LOCATIONS
                     if isfile(cert)), None)

                if self.xmpp.ca_certs is None:
                    self.logger.warning(
                        'XMPP Secure comunication can not be verified; '
                        'no local CA certificate file')
                    return False

        # We're good
        return True 
開發者ID:caronc,項目名稱:apprise,代碼行數:46,代碼來源:SleekXmppAdapter.py


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