Python 如何通过提及过滤流

Python 如何通过提及过滤流,python,tweepy,twitter-streaming-api,Python,Tweepy,Twitter Streaming Api,我正在创建一个Twitter机器人,它将响应指向其相关Twitter句柄的tweet。我看过关于如何通过hashtags过滤流的文档,但我不知道如何通过提及过滤流。例如,如果与bot关联的Twitter句柄是Twitter\u bot,我想做如下操作: listener = CustomListener() stream = tweepy.Stream(OAuth, listener) # Is there a parameter here that accomplishes this?? s

我正在创建一个Twitter机器人,它将响应指向其相关Twitter句柄的tweet。我看过关于如何通过hashtags过滤流的文档,但我不知道如何通过提及过滤流。例如,如果与bot关联的Twitter句柄是Twitter\u bot,我想做如下操作:

listener = CustomListener()
stream = tweepy.Stream(OAuth, listener)

# Is there a parameter here that accomplishes this??
stream.filter(mentions=["twitter_bot"])
我只想处理有人在推特机器人手柄上推特的情况

例如:“@twitter\u bot进展如何?”

谢谢

提到的内容还有一个休息时间,你可以将它与tweepy一起使用,该方法已过时,该方法已重命名为提及时间线。这里是tweepy中的方法:

使用以下代码并更改密钥/机密,您将获得认证用户的信息:

import tweepy

auth = tweepy.OAuthHandler(consumer_key='AAA', consumer_secret='BBB')
auth.set_access_token('CCC', 'DDD')
api = tweepy.API(auth_handler=auth, secure=True, retry_count=5)

mentions = api.mentions_timeline()
for mention in mentions:
    print mention.id, mention.author.screen_name, mention.text

我找不到任何东西,但您可能会找到,这是源代码