Only retweet if a specific hashtag is in a tweet with the Retweet Bot

You need to retweet tweets with a specific hashtag from another Twitter account to your own account? Just use the Retweet bot!


Configuration to retweet all tweets with a specific hashtag

Here is a complete example of a Retweet configuration to retweet all tweets with a specific hashtag. In this example every tweets with the hashtag #rt from the carl_chenet Twitter account will be retweeted to the Twitter account with the credentials above:




The [twitter] section uses the screen_name_of_the_user_to_retweet parameter to define which Twitter account should be listened to. The other parameters of this section are the Twitter credentials you need to automatically tweet (see the Configure chapter of the official Retweet bot documentation).

The [retweet] section does use here only one parameter only_if_hashtags. You just need a comma-separated string of your hashtags (without the hash).

The [sqlite] section only needs the sqlitepath parameter with a path to the Sqlite database storing the ids of the already-retweeted tweets.

Install and set up the Retweet bot

Ok now we have a complete Retweet configuration to retweet only if the hashtag #rt appears in the tweets. Now lets install Retweet:

# pip3 install retweet

Then lets create a retweet user with the home /var/lib/retweet:

# adduser --home /var/lib/retweet --gecos "" retweet

The proper way to store our configuration file is to put it in the /etc/retweet directory:

# mkdir -p /etc/retweet /var/lib/retweet
# chown -R retweet:root /etc/retweet /var/lib/retweet

Now lets write our configuration file with the sections and the parameters defined above. You also have a full example available in the Configure section of the official Retweet documentation.

# vi /etc/retweet/retweet.ini

Almost ready! Last step: write a line in the crontab in order to launch Retweet on a regular basis:

*/10 * * * retweet retweet /etc/retweet/retweet.ini

And voila! Your Retweet bot is ready.

More information about the Retweet bot

… and finally

You can help the Retweet Bot by donating anything through Liberaypay (also possible with cryptocurrencies). That’s a big factor motivation 😉

7 thoughts on “Only retweet if a specific hashtag is in a tweet with the Retweet Bot

    • In the configuration file :

      means you’re going to retweet everything from the @carl_chenet Twitter account.

      Just use the complete article and you’ll be able to retweet everything from the Twitter account you use as above.
      To create the app to get the Twitter credentials:

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *