Apr-20-2019, 11:45 AM
I have a problem and I want my bot to respond to a specified twitter account, but what happens is that it responds but in a loop, please help me.
And besides that, answer all the people in that tweet, how can I solve this?
messages.txt = Love a cloud, love a woman, but love.
------------------------------------------------------------
And besides that, answer all the people in that tweet, how can I solve this?
messages.txt = Love a cloud, love a woman, but love.
------------------------------------------------------------
import tweepy class MyStreamListener(tweepy.StreamListener): def on_status(self, status): file = open("messages.txt", "r") content = file.readlines() line = content[0] # just a total guess of an index print("answering @" + status.user.screen_name + " tweetID " + status.id_str + " with : " + line.rstrip()) api.update_status(status="@" + status.user.screen_name + " " + line, in_reply_to_status_id=status.id) consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) myStream = tweepy.Stream(auth, MyStreamListener()) myStream.filter(follow=[''])