本文整理匯總了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()
示例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)
示例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),
]
示例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
示例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()
示例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")
示例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,
]
示例8: authorized
def authorized(self) :
JabberClient.authorized(self)
# ########################
self.sendPresence(None)
self.request_roster()
# ########################
evt = IMEvent(self, IM_AUTHORIZED_EVENT)
self.evtHandler.AddPendingEvent(evt)
示例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)
示例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)
示例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",))
示例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()
示例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)
示例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()
示例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),]