当前位置: 首页>>代码示例>>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;未经允许,请勿转载。