Python Forum
Because this is repeated in a loop, what is going on?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Because this is repeated in a loop, what is going on?
#1
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=[''])
Reply
#2
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=[''])
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020