当前位置: 首页>>代码示例>>Python>>正文


Python Channel.join方法代码示例

本文整理汇总了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
开发者ID:droptable,项目名称:pxmppbot,代码行数:40,代码来源:admin.py

示例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
开发者ID:ivucica,项目名称:jjigw,代码行数:26,代码来源:ircsession.py

示例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'])
开发者ID:droptable,项目名称:pxmppbot,代码行数:8,代码来源:bot.py


注:本文中的channel.Channel.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。