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


Python IRCMessage.channel方法代码示例

本文整理汇总了Python中ircmessage.IRCMessage.channel方法的典型用法代码示例。如果您正苦于以下问题:Python IRCMessage.channel方法的具体用法?Python IRCMessage.channel怎么用?Python IRCMessage.channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ircmessage.IRCMessage的用法示例。


在下文中一共展示了IRCMessage.channel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testIsInitialized

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
 def testIsInitialized(self):
   self.assertTrue(self.m.is_initialized())
   q = IRCMessage()
   self.assertFalse(q.is_initialized())
   ## Message with no channel should be false.
   q.channel = "#"
   q.msg = "notempty"
   self.assertFalse(q.is_initialized())
   ## Adding directed testing.
   q.channel = self.channel
   q.directed = True
   self.assertFalse(q.is_initialized())
   q.user = self.user
   self.assertTrue(q.is_initialized())
开发者ID:killman,项目名称:bot,代码行数:16,代码来源:ircmessage_test.py

示例2: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def execute(self, ircMsg, userRole, *args, **kwargs):
      user = ircMsg.user
      m = IRCMessage()
      term = ' '.join(ircMsg.arguments)

      try:
        temblo = self.get_quake(term)
      except Exception as e:
        ircMsg.msg = e.args[0]
        return ircMsg

      ## Converting UNIX timestamp to human readable time.
      date_t = datetime.fromtimestamp(temblo['properties']['time'] / 1000)
      date = date_t.isoformat()

      response_string = "Quake in: {0} | Magnitude: {1} | Time: {2} | URI: {3}".format(
          temblo[ 'properties' ][ 'place' ],
          temblo[ 'properties' ][ 'mag' ],
          date,
          temblo[ 'properties' ][ 'url' ]
        )
      m.msg = response_string
      m.channel = ircMsg.channel
      m.user = user
      m.directed = True
      return m
开发者ID:latopas,项目名称:tio_chema,代码行数:28,代码来源:temblor.py

示例3: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
 def execute(self, ircMsg, userRole, *args, **kwargs):
     user = ircMsg.user
     m = IRCMessage()
     definiciones = []
     message = ' '.join(ircMsg.msg.split())
     
     cal = subprocess.Popen( [ 'calendar' ], stdout=subprocess.PIPE )
     wc = subprocess.Popen( [ 'wc', '-l' ], stdin=cal.stdout, stdout=subprocess.PIPE )
     num = wc.communicate()
     numero = int( num[0] )
     numero = randint( 0, numero )
     cal = subprocess.Popen( [ 'calendar'], stdout=subprocess.PIPE )
     head = subprocess.Popen( [ 'head', '-' + str( numero ) ], stdin=cal.stdout, stdout=subprocess.PIPE )
     tail = subprocess.Popen( [ 'tail', '-1' ], stdin=head.stdout, stdout=subprocess.PIPE )
     resp = tail.communicate();
     if len( resp ) > 0 :
       respuesta = resp[ 0 ]
     else:
       respuesta = ''
     #calendar | wc -l ; calendar | head -rand | tail -1
     m.msg = '' + respuesta
     m.channel = ircMsg.channel
     m.user = user
     m.directed = True
     return m
开发者ID:latopas,项目名称:tio_chema,代码行数:27,代码来源:calendar.py

示例4: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
    def execute(self, ircMsg, userRole, *args, **kwargs):
        
        command = ircMsg.msg.split(' ')
        command_type = command[1]
        
        irc_msg = IRCMessage()
        irc_msg.channel = ircMsg.channel
        irc_msg.user = ircMsg.user
        irc_msg.directed = True
        
        try:
            args = command[2]
        
            func = self.function_dict[command_type]

            if args != '' or args is not None:
                print args;
                irc_msg.msg = func(args)

            else:
                irc_msg.msg = func('help')
                
        except:
            irc_msg.msg =  self.help(None)
            logging.error('Error processing commands')
            
        return irc_msg
开发者ID:latopas,项目名称:tio_chema,代码行数:29,代码来源:chaturbate.py

示例5: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def execute(self, ircMsg, userRole, *args, **kwargs):
      user = ircMsg.user
      m = IRCMessage()
      definiciones = []
      message = ' '.join(ircMsg.msg.split())
      term = re.sub('^!urbano ', '', message)

      payload = {'term': term  }
      url = "http://www.urbandictionary.com/define.php?"    

      f = requests.get( url, params=payload)
      data = f.text

      soup = BeautifulSoup( data )
      tag = soup.find_all('div', attrs={'class' : 'definition' } )

      for tagita in tag:
        if type(tagita.string) != types.NoneType :
          definiciones.append( tagita.string.strip() )

      respuesta = definiciones[ randint( 0, len( definiciones ) - 1 ) ]

      m.msg = respuesta
      m.channel = ircMsg.channel
      m.user = user
      m.directed = True
      return m
开发者ID:miguelchuga,项目名称:tio_chema,代码行数:29,代码来源:urbano.py

示例6: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def execute(self, ircMsg, userRole, *args, **kwargs):
      user = ircMsg.user
      m = IRCMessage()
      definiciones = []
      message = ' '.join(ircMsg.msg.split())
      term = re.sub('^!temblor ', '', message)
      url = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson"
      f = requests.get( url )
      data = json.loads(f.text)

      for feature in data['features']:
        cadena = feature['properties']['place']
        
        if cadena.upper().find( term.upper() ) != -1 :
          definiciones.append( feature )

      size = len( definiciones )
      temblo = definiciones[ randint( 0, size ) ]
      fecha_t = datetime.fromtimestamp( temblo[ 'properties' ][ 'time' ] / 1000 )
      fecha = fecha_t.strftime( '%d/%M/%Y %H:%m:%s')
      
      respuesta = '' + str( temblo[ 'properties' ][ 'mag' ] ) + ' | ' + temblo[ 'properties' ][ 'place' ] +  ' | ' + fecha + ' | '+ temblo[ 'properties' ][ 'url' ] 
      m.msg = respuesta
      m.channel = ircMsg.channel
      m.user = user
      m.directed = True
      return m
开发者ID:miguelchuga,项目名称:tio_chema,代码行数:29,代码来源:temblor.py

示例7: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
    def execute(self, ircMsg, userRole, regex_groups):
        try:
            url = regex_groups[0][0]
            msg = IRCMessage()
            msg.channel = ircMsg.channel
            msg.msg = WebTitle.get_title(url)
        except:
            logging.error(":(")

        return msg
开发者ID:tian2992,项目名称:tio_chema,代码行数:12,代码来源:webtitle.py

示例8: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
 def execute(self, ircMsg, userRole, *args, **kwargs):
   user = ircMsg.user
   m = IRCMessage()
   message = ' '.join(ircMsg.msg.split())
   lista_articulos = self.devolver_lista_de(self.baseurl)
   hp=randint(0,len(lista_articulos)-1)
   m.msg=''+lista_articulos[hp][2][:228] + '...... publicado el: ' + lista_articulos[hp][3] + ' en la seccion ' + lista_articulos[hp][9]
   m.channel = ircMsg.channel
   m.user = user
   m.directed = True
   return m
开发者ID:latopas,项目名称:tio_chema,代码行数:13,代码来源:diagonalpunto.py

示例9: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
    def execute(self, ircMsg, userRole, regex_group):
        m = IRCMessage()
        m.channel = ircMsg.channel
        r_group = regex_group[0]

        status = self.api.show_status(id = r_group[-1])
        author = r_group[-2]

        m.msg = u"@{0}: {1}".format(author, status.get("text"))
        m.user = ircMsg.user

        return m
开发者ID:tian2992,项目名称:tio_chema,代码行数:14,代码来源:tuiterText.py

示例10: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def execute(self, ircMsg, userRole, regex_group):
    m = IRCMessage()
    m.channel = ircMsg.channel
    r_group = regex_group[0]

    status = self.api.get_status(r_group[-1])
    if r_group[-2]:
      author = r_group[-2]
    else:
      author = status.author.screen_name
    m.msg = u"@{0}: {1}".format(author, status.text)
    m.user = ircMsg.user
    return m
开发者ID:tian2992,项目名称:tio_chema,代码行数:15,代码来源:twittertext.py

示例11: fetchAndFormatStatus

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def fetchAndFormatStatus(self, ircMsg, api, regex_group):
    m = IRCMessage()
    m.channel = ircMsg.channel

    status = api.get_status(regex_group[-1])
    if regex_group[-2]:
      author = regex_group[-2]
    else:
      author = status.author.screen_name

    m.msg = u"@{0}: {1}".format(author, status.text)
    m.user = ircMsg.user
    return m
开发者ID:killman,项目名称:bot,代码行数:15,代码来源:twittertext.py

示例12: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def execute(self, ircMsg, userRole, *args, **kwargs):
      user = ircMsg.user
      m = IRCMessage()
      definiciones = []
      message = ' '.join(ircMsg.msg.split())
      topic = re.sub('^!preguntar ', '', message)

      respuesta = self.get_question( topic  )

      m.msg = respuesta
      m.channel = ircMsg.channel
      m.user = user
      m.directed = True
      return m
开发者ID:miguelchuga,项目名称:tio_chema,代码行数:16,代码来源:preguntar.py

示例13: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
 def execute(self, ircMsg, userRole, *args, **kwargs):
     user = ircMsg.user
     m = IRCMessage()
     definiciones = []
     message = ' '.join(ircMsg.msg.split())
     
     p = subprocess.Popen(["fortune", "-a", "-n", "160", "-s"], stdout=subprocess.PIPE)
     output, err = p.communicate()
     #TODO manejar err
     m.msg = output
     m.channel = ircMsg.channel
     m.user = user
     m.directed = True
     return m
开发者ID:latopas,项目名称:tio_chema,代码行数:16,代码来源:fortune.py

示例14: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def execute(self, ircMsg, userRole, *args, **kwargs):
    user = ircMsg.user
    m = IRCMessage()
    conn = kwargs["connection"]
    m.msg = unicode()
    all_rows = conn.execute("select * from users").fetchall()
    choice = random.choice(all_rows)
    m.msg = "The selected user is {0}".format(choice[0])

    m.channel = ircMsg.channel
    m.user = user
    m.directed = True
    logging.debug("User: {0} hit the DB".format(user))
    return m
开发者ID:latopas,项目名称:tio_chema,代码行数:16,代码来源:db_test.py

示例15: execute

# 需要导入模块: from ircmessage import IRCMessage [as 别名]
# 或者: from ircmessage.IRCMessage import channel [as 别名]
  def execute(self, ircMsg, userRole, *args, **kwargs):
      user = ircMsg.user
      m = IRCMessage()
      message = ' '.join(ircMsg.msg.split())
      numero = re.sub('^!xkcd ', '', message)

      if numero.isdigit():
        respuesta = self.get_comic( numero )
      else:
        respuesta = self.get_current()

      m.msg = respuesta
      m.channel = ircMsg.channel
      m.user = user
      m.directed = True
      return m
开发者ID:latopas,项目名称:tio_chema,代码行数:18,代码来源:xkcd.py


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