How can I make a twitter Bot in python using tweepy which tweets on a specific user tweet?


How can I make a twitter Bot in python using tweepy which tweets on a specific user tweet?


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)





please, indent your code correctly. It is actually unreadable.
– JeffProd
Jun 30 at 11:58





I'm sorry for my code but I'm a newbie can you tell me how to create a Twitter bot that replies a specific username when they tweet
– Pranilesh Royal
Jul 1 at 17:01





Make sure that any bot you build follows the automation rules help.twitter.com/en/rules-and-policies/twitter-automation - just autoreplying to random users is not compliant.
– Andy Piper
2 days ago




1 Answer
1



To reply to a tweet, you must use in_reply_to_status_id as you did, and you have also to mention the user at the beginning of the text :


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)






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to input without newline? (Python)

C++ thread error: no type named ‘type’ MINGW

Analog for TagView in flutter