【发布时间】:2020-10-11 22:22:28
【问题描述】:
如果用户发送了一条推文,我怎样才能得到它,以便机器人自动回复它?例如,如果我有这个发送回复的函数
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
我怎样才能知道当用户发推文时,上述函数会运行并回复他们?谢谢
【问题讨论】:
标签: python twitter bots tweepy tweets