0
Using the library Tweepy
, I’m trying to make a bot
that reply in all tweets of only one specific user, the problem is that the bot is giving reply not only in the tweet but in everyone that retweet or responds the tweet.
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
id = "1234"
user = api.get_user(id)
def randomize(status):
tweet = status.split()
shuffle(tweet)
tweet_string = " ".join(tweet)
return tweet_string
class Reply(tweepy.StreamListener):
def on_status(self, status):
print(status.text)
api.update_status("@" + status.user.screen_name + " " + randomize(status.text), in_reply_to_status_id=status.id)
listener = Reply()
stream = tweepy.Stream(auth=api.auth, listener=listener)
stream.filter(follow=[id])
Library documentation Tweepy
:
https://docs.tweepy.org/en/stable/