tockbot.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:nanobot 作者: bgporter 项目源码 文件源码
def HandleOneMention(self, mention):
      ''' Like the tweet that mentions us. If the word 'tick' appears
         in that tweet, also reply with the current time.
      '''
      who = mention['user']['screen_name']
      text = mention['text']
      theId = mention['id_str']
      eventType = "Mention"

      # we favorite every mention that we see
      if self.debug:
         print "Faving tweet {0} by {1}:\n {2}".format(theId, who, text.encode("utf-8"))
      else:
         self.twitter.create_favorite(id=theId)

      if 'tick' in text.lower():
         # reply to them with the current time.
         replyMsg = "@{0} {1}".format(who, NowString(datetime.now()))
         if self.debug:
            print "REPLY: {}".format(replyMsg)
         else:
            self.tweets.append({'status': replyMsg, 'in_reply_to_status_id': theId})
         eventType = "Reply"

      self.Log(eventType, [who])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号