I created a simple bot on twitter so that every time someone mentions my @ the bot will reply with a random phrase.
But it is not behaving as expected. It answers the first mention and then answers again the answer it provided.
I tried putting the parameter "exclude_reply_user_ids=bot_id" but it still keeps replying to itself.
Please could someone help me?
client = tweepy.Client(
bearer_token=bearer_token,
consumer_key=consumer_key,
consumer_secret=consumer_secret,
access_token=access_token,
access_token_secret=access_token_secret
)
class Tweetmentions(tweepy.StreamingClient):
def on_tweet(self, tweet):
print(tweet.text)
client.create_tweet(text=random_phrase(),
in_reply_to_tweet_id=tweet.id,
exclude_reply_user_ids="bot_id"
)
print('Successfully tweeted!')
stream_mentions = Tweetmentions(bearer_token=bearer_token)
stream_mentions.add_rules(tweepy.StreamRule("my_rule"))
stream_mentions.filter()