Python Forum

Full Version: Because this is repeated in a loop, what is going on?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
------------------------------------------------------------

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=[''])
I want you to respond to the owner of the tweet simply, please help me.

messages.txt = Everything seems impossible until it is done.

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)
        return False

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=[''])