本文整理匯總了Python中channel.Channel.join方法的典型用法代碼示例。如果您正苦於以下問題:Python Channel.join方法的具體用法?Python Channel.join怎麽用?Python Channel.join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類channel.Channel
的用法示例。
在下文中一共展示了Channel.join方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: from channel import Channel [as 別名]
# 或者: from channel.Channel import join [as 別名]
def handle(self, client, msg):
token = msg['body'].split(' ')
try:
if token[0] == 'list':
msg.reply("Channels I'm in: {0}".format(', '.join(Channel.channels.keys()))).send()
elif token[0] == 'roster':
channel_jid = "{0}@{1}".format(token[1], Config.get('auth.muc', 'conference.jabber.de'))
for nick in client.plugin['xep_0045'].rooms[channel_jid]:
entry = client.plugin['xep_0045'].rooms[channel_jid][nick]
client.send_message(mto=msg['from'].bare, mbody=str(entry), mtype=msg['type'])
elif token[0] == 'rejoin':
self.handle(client, client.make_message(msg['to'], "leave {0}".format(token[1]), None, msg['type'], None, msg['from'], None))
self.handle(client, client.make_message(msg['to'], "join {0}".format(token[1]), None, msg['type'], None, msg['from'], None))
elif token[0] == 'join':
if token[1] not in Channel.channels.keys():
channel_jid = "{0}@{1}".format(token[1], Config.get('auth.muc', 'conference.jabber.de'))
Channel.join(client, channel_jid)
if len(token) > 2:
client.send_message(mto=channel_jid, mbody=' '.join(token[2:]), mtype='groupchat')
elif token[0] == 'leave':
if token[1] in Channel.channels.keys():
channel_jid = "{0}@{1}".format(token[1], Config.get('auth.muc', 'conference.jabber.de'))
if len(token) > 2:
client.send_message(mto=channel_jid, mbody=' '.join(token[2:]), mtype='groupchat')
Channel.channels[token[1]].leave()
except:
pass
示例2: join
# 需要導入模塊: from channel import Channel [as 別名]
# 或者: from channel.Channel import join [as 別名]
def join(self,stanza):
to=stanza.get_to()
if to.node=='#':
return self.join_raw_channel(stanza)
self.cond.acquire()
try:
if not self.ready:
self.join_requests.append(stanza.copy())
return
finally:
self.cond.release()
try:
channel=node_to_channel(to.node,self.default_encoding)
except ValueError:
e=stanza.make_error_response("not-acceptable")
self.component.send(e)
return
if self.channels.has_key(normalize(channel)):
return
if to not in self.used_for:
self.used_for.append(to)
channel=Channel(self,channel)
channel.join(stanza)
self.channels[normalize(channel.name)]=channel
示例3: start
# 需要導入模塊: from channel import Channel [as 別名]
# 或者: from channel.Channel import join [as 別名]
def start(self, event):
self.send_presence()
self.get_roster()
for channel in Config.get('channels'):
Channel.join(self, channel['jid'], channel['plugins'])