Mastodon and the Vintage BASIC Bot#

Mastodon has gained popularity as an alternative to commercial social media, especially within the #retrocomputing community. Even 8bitworkshop is on Mastodon, so feel free to follow! Just post @8bitworkshop@oldbytes.space into your search bar.

One feature of the “other” social media network (affectionally known as “Birdsite” on Mastodon) is the presence of bots.

Some of the more complex bots can actually run programs! For example, the BBC Micro Bot accepts a “toot” that includes a program in the BBC BASIC dialect created by Sophie Wilson. It then runs the program on a BBC Micro emulator, and returns the output.

Why not write our own Matsodon bot? To make it simpler, let’s start with a bot that only deals with text. 8bitworkshop already has a vintage BASIC intepreter that pretends to be hooked up to a teletype, so let’s use that.

To use the bot, just post a “toot” with some BASIC code. For example:

@basicbot@botsin.space 
OPTION DIALECT DARTMOUTH
10 INPUT "HI! WHAT'S YOUR FAVORITE NUMBER?",A
20 PRINT "ISN'T IT BETTER CUBED?",A^3
30 END

When you publish this post, the bot will reply:

HI! WHAT'S YOUR FAVORITE NUMBER
?

You can reply with a number, for example “42”. The bot will then continue the program:

ISN'T IT BETTER CUBED?       74088

Due to limitations of the instance that hosts the bot, programs are limited to 500 characters. The bot’s replies are also limited to 500 characters per status update.

One useful feature of Mastodon is the ability to hide the contents of a status under a “content warning”. The bot will happily interpret programs sent under a CW. It’ll also add its own CW if the output is longer than five lines of text. This can help keep followers’ timelines tidy.

You can try the bot from your own Mastodon account! Just post a program to @basicbot@botsin.space and wait. Depending on instance traffic, it can take up to a minute or more for a response.

If you’re interested in Mastodon bot development, the code is available on GitHub.