1

I am trying to program a Twitter bot using Tweepy that will respond to new mentions. Currently, I am using the code:

class StreamListener(tweepy.Stream):
    def on_status(self, status):
        print("recieved tweet!")
        main(status)

    def on_error(self, status_code):
        if status_code == 420:
            return False

stream = StreamListener(consumer_key,
                        consumer_secret,
                        access_token,
                        access_secret)

stream.filter(follow=[user.id_str]) # the bot's user id

However, in my testing, the bot only responds to mentions that are in a single tweet. When I reply to a thread with a mention, the bot is silent. Is there a way for my bot to respond to mentions in a thread?

karepan
  • 25
  • 6
  • Does this answer your question? [How to stream twitter mentions with tweepy?](https://stackoverflow.com/questions/27115442/how-to-stream-twitter-mentions-with-tweepy) – Luigi Mar 29 '22 at 18:06

1 Answers1

0

Instead of using follow use track. It will be:

stream.filter(track=["@username"])

AKMalkadi
  • 782
  • 1
  • 5
  • 18