album_genre_bot.py 文件源码

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

项目:wiki-album-genre 作者: aliostad 项目源码 文件源码
def respond(consumer_key, consumer_secret, token_key, token_secret):
  if consumer_key is None:
    print 'usage: python album_genre_bot.py <consumer_key> <consumer_secret> <token_key> <token_secret>'
    return

  api = twitter.Api(consumer_key=consumer_key,
                      consumer_secret=consumer_secret,
                      access_token_key=token_key,
                      access_token_secret=token_secret)

  original_timestamp = get_time_stamp()
  new_timestamp = original_timestamp
  for m in api.GetMentions():
    dt = parse_twitter_date(m.created_at)
    new_timestamp = max(dt, new_timestamp)
    if dt > original_timestamp and m.text.startswith(twitterId):
      genre = predict(clean_text(m.text).lower())
      try:
        status = api.PostUpdate(
          in_reply_to_status_id=m.id,
          status='@{} {}'.format(m.user.screen_name, genre))
        print m.text,
        print ' ==> ' + genre
      except Exception as e:
        print e

  save_time_stamp(new_timestamp)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号