本文整理匯總了Python中pyxmpp.jabber.client.JabberClient.session_started方法的典型用法代碼示例。如果您正苦於以下問題:Python JabberClient.session_started方法的具體用法?Python JabberClient.session_started怎麽用?Python JabberClient.session_started使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyxmpp.jabber.client.JabberClient
的用法示例。
在下文中一共展示了JabberClient.session_started方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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)
示例2: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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")
示例3: _session_started_helper
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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()
示例4: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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)
示例5: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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)
示例6: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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()
示例7: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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"))
示例8: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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()
示例9: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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))
示例10: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
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)
示例11: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
def session_started(self):
JabberClient.session_started(self)
示例12: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
def session_started(self):
JabberClient.session_started(self)
self.stream.set_message_handler("normal", self.received)
示例13: session_started
# 需要導入模塊: from pyxmpp.jabber.client import JabberClient [as 別名]
# 或者: from pyxmpp.jabber.client.JabberClient import session_started [as 別名]
def session_started(self):
log("session_started: jid:%s" % (self.jid.as_utf8(),))
self.connection = CONNECTION.connected
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.stream.set_presence_handler("available", self.available)
self.stream.set_presence_handler("unavailable", self.unavailable)
self.stream.set_presence_handler("subscribe", self.subscription)
self.stream.set_presence_handler("subscribed", self.subscription)
self.stream.set_presence_handler("unsubscribe", self.subscription)
self.stream.set_presence_handler("unsubscribed", self.subscription)
self.stream.set_iq_set_handler(
"command", "http://vipadia.com/skype", self.vipadia_command)
## start skype
echo_ps = subprocess.Popen(
["echo", self.skypeuser, self.skypesecret], stdout=subprocess.PIPE)
if not os.path.exists('/tmp/skype/%s-db' % (self.skypeuser,)):
cmd = "mkdir -p /tmp/skype/%s-db/%s" % (self.skypeuser, self.skypeuser)
dbg(" cmd:%s " % (cmd,))
os.system(cmd)
now_long = long(time.time())
now_str = "%0.1f" % (time.time(),)
f = open("/tmp/skype/%s-db/shared.xml" % (self.skypeuser,), "w")
f.write(SHARED_XML % (now_str,))
f.close()
f = open("/tmp/skype/%s-db/%s/config.xml" % (self.skypeuser,self.skypeuser), "w")
config_str = CONFIG_XML % (now_str, now_long)
dbg(" cfg:%s" % (config_str,))
f.write(config_str)
f.close()
self.skype_ps = subprocess.Popen(
["skype","--pipelogin", '--dbpath=/tmp/skype/%s-db' % (self.skypeuser,)],
stdin=echo_ps.stdout, stdout=subprocess.PIPE,
)
# We need to give skype time to appear before looking for it...
## time.sleep(5)
self.skype = Skype4Py.Skype()
self.skype.OnAttachmentStatus = skype_OnAttachmentStatus
self.skype.OnMessageStatus = skype_OnMessageStatus
self.skype.OnOnlineStatus = skype_OnOnlineStatus
self.skype.OnUserMood = skype_OnUserMood
self.skype.OnCommand = skype_OnCommand
self.skype.OnNotify = skype_OnNotify
self.skype.OnChatMembersChanged = skype_OnChatMembersChanged
self.skype.OnUserAuthorizationRequestReceived = skype_OnUserAuthorizationRequestReceived
dbg("connected")