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


Python ircmessage.IRCMessage类代码示例

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


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

示例1: get_user_track

  def get_user_track(self, ircMsg):
    """Gets the selected user track, returns an IRCMessage."""
    m = IRCMessage(user=ircMsg.user, channel=ircMsg.channel)
    user_s = ircMsg.msg.split(' ')[2]
    user = self.last.get_user(user_s)
    logging.info("Getting last.fm user {0}".format(user_s))
    try:
      recent_tracks = user.get_recent_tracks()
    except:
      m.msg = "No user with that name."
      return m

    try:
      last_track = user.get_now_playing()
      if not last_track:
        last_track = recent_tracks[0].track
    except:
      m.msg = "No tracks avaliable for that username."
      return m

    tags_string =  u" , ".join([tag[0].name for tag in last_track.get_top_tags(4)])

    m.msg = u'User {0} is listening to: {1} - {2}: tags [ {3} ]'.format(user_s, last_track.title,
      last_track.artist.name, tags_string)
    return m
开发者ID:miguelchuga,项目名称:tio_chema,代码行数:25,代码来源:lastfm.py

示例2: execute

 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,代码行数:25,代码来源:calendar.py

示例3: execute

  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,代码行数:26,代码来源:temblor.py

示例4: execute

  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,代码行数:27,代码来源:temblor.py

示例5: pull

  def pull(self, ircMsg):
    user = ircMsg.user
    message = ircMsg.msg
    args = message.split() #self.split_args(ircMsg)
    userid = args[2]
    if len(args) > 3:
      index = int(args[3])
    else:
      index = 0

    m = IRCMessage()

    #m.msg = _("msgIdentiPost").format(user, post)

    try:
      self.oauth()
      self.api = tweepy.API(self.auth, host = self.host, api_root = self.api_root)
      timeline = self.api.user_timeline(userid)
      #TODO: add support to pull an specific index
      m.msg = u"@{0}: {1}".format(userid, timeline[index].text)
    except:
      import traceback
      traceback.print_exc()
      m.msg("msgIdentiFail")

    return m
开发者ID:killman,项目名称:bot,代码行数:26,代码来源:identica.py

示例6: execute

  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,代码行数:27,代码来源:urbano.py

示例7: join

    def join(self, channel):
        ircmsg = IRCMessage("")

        ircmsg.msg_type = "JOIN"
        ircmsg.cmd = "join"
        ircmsg.args = channel

        self._join(ircmsg)
开发者ID:typoon,项目名称:boteco,代码行数:8,代码来源:botcommands.py

示例8: execute

    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,代码行数:10,代码来源:webtitle.py

示例9: execute

 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,代码行数:11,代码来源:diagonalpunto.py

示例10: execute

    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,代码行数:12,代码来源:tuiterText.py

示例11: execute

  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,代码行数:13,代码来源:twittertext.py

示例12: fetchAndFormatStatus

  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,代码行数:13,代码来源:twittertext.py

示例13: testIsInitialized

 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,代码行数:14,代码来源:ircmessage_test.py

示例14: execute

  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,代码行数:14,代码来源:preguntar.py

示例15: execute

 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,代码行数:14,代码来源:fortune.py


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