Skip to main content

Algebra Bot

I run the GNU Social bot @algebra, and this is a brief post laying out the details of how it works, in case anyone else is interested in setting up their own version of this. First I just want to point out that all below is mostly stolen from "Autopost RSS feed content to GNUsocial".

The bot simply takes tweets from the John D. Cook's interesting twitter account @AlgebraFact and relays the tweets to a GNU Social account;, on a daily basis for all of the fediverse to enjoy. The simple process is a follows.

Step 1: Twitter to RSS

First we need to transform the twitter feed into a RSS feed. Once upon a time twitter provided this as an inherent feature, e.g. you could simply go to:{username}.rss

and that's that but since twitter hates everything free and open they removed this feature so we have to find another solution.

I simply searched for twitter to rss on duckduckgo and found where you input some twitter account and get the desired RSS feed, in my case:

There are probably better more self-hostable alternatives for this but since this is just for fun I haven't really made the effort of investigating this further.

Step 2: RSS to GNU social

Next up we need a way to post entries from the RSS feed to a GNU Social instance, it turns out there exists the perfect tool for the job; feed2omb.

feed2omb is a simple tool that takes input from Atom or RSS feeds and posts updates to the open microblogging service of your choice.

My my.config looks like this:

#The URL of the feed you want to post. Can be Atom or RSS, any version
#feedurl =
feedurl =

#The base API URL for the microblogging service you want to post to. Examples:
#This can be blank if you don't want to send to an OMB API, which would only
#make sense if you were using XMPP instead - see below.
#apibaseurl =

apibaseurl =

#Replace the following credentials with those for the microblogging service you want to post to
user = algebra
password = myVerySecurePassword

#The XMPP server to use for sending. Leave out, or blank, for no XMPP, which is the default.
#xmpp_server =

#The JID for the source of the messages.
#xmpp_jid =

#The password of the source user
#xmpp_password = 1234

#Where to send the XMPP messages
#xmpp_to =

#Room where to send the XMPP messages
#xmpp_room =

#Nick for room access
#xmpp_nick = feedbot

#The maximum length of message. Defaults to 140.
maxlen = 999

#The notice source that is reported when a notice is posted
source = feed2omb

#URL shortening mode. Possible values are:
#  lilurl - use a lilURL-based shortening service - specify the host
#           below (default)
#  yourls - use a YOURLS-based shortening service - specify the host
#           below
# - shorten the url using the service at
#           You need a API account and API Key, and you need
#           to specify the details under urlshortenlogin and
#           urlshortenkey below.
#   - shorten the url using the service at (same as
# , but a shorter url.
#  laconica - assume that Laconica will shorten the url automatically
#  none - do not shorten (drastically reducing available message space)

#urlshortener = lilurl

#If using the 'lilurl' or 'yourls' shortening mode, specify the host
#here. Otherwise this is ignored.
#urlshortenhost =

#If using '' shortening mode, you need to specify your login and
#API key here.
#urlshortenlogin =
#urlshortenkey =

#By default, URL shortening is only used if there isn't room in the message
#for the full URL. You can set this to 'yes' to force shortening to always
shortenalways = no

#Specify the 'sent mode'. This determines how we decide if we have already
#sent an entry from the feed to the OMB service. There are two possible
#  sentlinks - uses the links attached to each entry, and stores a list of
#              all those that have been sent previously (default)
#  timestamp - keeps track of the timestamp of the most recent entry and
#              only sends newer ones
sentmode = timestamp

#Specify the message mode, i.e. how the OMB message is formed from the
#available information in the feed entries:
#  title       - just the title of the entry (default)
#  authtitle   - the author followed by the title
#  summary     - use the entry's summary (description in RSS), falling back
#                on the title if there is no summary
#  authsummary - like authtitle, but using the summary instead of the title
msgmode = title

#Should links be appended to the message? Default is 'yes' - to get rid
#of them, set it to 'no'...
includelinks = yes

#The following, if enabled, allow a regular expression search and replace on
#the message before it is sent. This can be used, for example, to prepend
#boilerplate text to the message (which might be used if you are directing
#multiple feeds to the same account) or to remove the same (which might be
#useful when reposting twitter content to an open account elsewhere)
#Much more creative things are possible with this, but the following example
#would remove the text "MarsPhoenix:" from the start of all messages:
#messageregex = 'MarsPhoenix:(.*)'
#messagereplace = '\1'
#On the other hand, this one ADDS 'Example:' to the start of all messages:
#messageregex = '(.*)'
#messagereplace = 'Example:\1'
#You can also have multiple regular expressions and replacements by giving
#a comma-separated list of each. The number of expressions and replacements
#must be the same.
#messageregex = 'red','blue'
#messagereplace = 'green','yellow'

#Specify the maximum number of items that will be posted in one go. This
#prevents flooding. Any additional items will be picked up on the next run.
#You can set this to 0 to always post all available new items.
#This value can be overridden by the --max command-line option.
maxpost = 25

#Specify the hashtags mode. If this is set to 'category', then any categories
#specified in the feed's entries will be appended to the message as hashtags,
#so long as there is space.
hashtags = none
lastsent = 2017-11-17 16:55:22

#Links that have already been posted will be added to this section if
#the sentmode option is set to sentlinks.

Some remarks on my configuration:

  • The username and password is just the ordinary credentials you use to login to the instance. It's maybe not such a great idea to have this information hardcoded in a configuration file but hey, living on the edge!

  • The apibaseurl for GNU social instances is often just

  • maxpost = 25 (0 or higher than 25) might not be a very good idea for a high volume feed. Use your own judgement.

When we are done configuring we should probably do a dry run to see that everything is working properly before we start spamming the fediverse with algebra facts:

python ~/feed2omb/ --update --test ~/feed2omb/config/my.config

If everything is working as expected we can start posting by running:

python ~/feed2omb/ --update ~/feed2omb/config/my.config

Step 3: Automate!

It's of course tedious to run this manually so let's add a crontab entry as follows:

22 19 * * 1-5 python ~/feed2omb/ --update ~/feed2omb/config/my.config

Which means that the script runs at 19:22 Monday through Friday. We can just kick back, wait and let the script work its magick.