Python 有没有办法让推特机器人在推特时回复特定用户名
如果用户发送tweet,我如何获取它,以便bot自动回复它?例如,如果我有一个发送回复的函数Python 有没有办法让推特机器人在推特时回复特定用户名,python,twitter,bots,tweepy,tweets,Python,Twitter,Bots,Tweepy,Tweets,如果用户发送tweet,我如何获取它,以便bot自动回复它?例如,如果我有一个发送回复的函数 username = "someones_username" count = 1 # I'm just doing this so that the practice code will only send to the newest tweet. In the final program, I want it so that evertime the user tweets, th
username = "someones_username"
count = 1 # I'm just doing this so that the practice code will only send to the newest tweet. In the final program, I want it so that evertime the user tweets, they get a reply
def send_reply():
for tweet in api.user_timeline(id=username, count=count):
try:
tweetID = tweet.id
api.update_status("@" + username + "hello", in_reply_to_status_id=tweetID)
except tweepy.TweepError as e:
print(e.reason)
except StopIteration:
break
我怎样才能知道当用户发tweet时,上面的函数会运行并回复他们?谢谢我建议您阅读此文档 特别是关于API.user_时间线的部分。它回答了你的问题。您可以在收到初始请求后使用sinceId来查看是否有新的帖子,如果有,请更新sinceId并回复它们