如何使用tweepy在特定用户tweet上发布推文,从而在python中创建一个Twitter Bot?

时间:2018-06-30 11:51:35

标签: python twitter

message = " Truly agreed with you "

for tweet in tweepy.Cursor(api.search, q='seo_regio', lang = 'en').items(1):
    try:
     print("Found tweet by:@" + tweet.user.screen_name)
     api.update_status(status = "Truly agreed with you #IndianPolitics", in_reply_to _status_id = tweet.id_str)
     print("responded to @" + tweet.user.screen_name)

    if tweet.user.following == False:
        tweet.user.follow()
        print("following @" + tweet.user.screen_name)

1 个答案:

答案 0 :(得分:1)

要回复推文,您必须像以前一样使用in_reply_to_status_id,并且还必须在文本开头提及用户:

api.update_status(status = "@" + tweet.user.screen_name + " Truly agreed with you #IndianPolitics", in_reply_to_status_id = tweet.id_str)