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:
[twitter] screen_name_of_the_user_to_retweet=carl_chenet consumer_key=ml9jaiBnf3pmU9uIrKNIxAr3v consumer_secret=8Cmljklzerkhfer4hlj3ljl2hfvc123rezrfsdctpokaelzerp access_token=213416590-jgJnrJG5gz132nzerl5zerwi0ahmnwkfJFN9nr3j access_token_secret=3janlPMqDKlunJ4Hnr90k2bnfk3jfnwkFjeriFZERj32Z [retweet] only_if_hashtags=rt, [sqlite] sqlitepath=/var/lib/retweet/retweet.db
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
# 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
- The Retweet bot on Github.com (would be awesome starring it if you like/use it)
- The official documentation on Readthedocs.io
… and finally
You can help the Retweet Bot by donating anything through Liberaypay (also possible with cryptocurrencies). That’s a big factor motivation 😉