Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Simple bot to post a random line from a text file to a Mastodon instance.

(c) 2018 Kelson Vibber.

Give it an access token and a text file with items to post, and it will pick a random line from the file and post that line to your Mastodon account. (I recommend which is intended to be used by bots. Be sure to check your instance's policy toward bots before you use this!)

Optionally you can specify a second text file as a queue of new items. It will post from the queue until it runs out, adding each item to the main list as it goes. If the second file is missing or empty, it will return to picking random items from the main list.

For now, configuration is done in the script itself. Add the hostname of your instance (ex. and the access token, which you can get by creating an app in your Mastodon preferences at Preferences/Development/Your Applications For example:

Call the script to post one random line from the text file: quotes.txt

Or to post the first line from newquotes.txt, then move that line to quotes.txt, making it available for future randomly-selected posts: quotes.txt newquotes.txt

To run it regularly, you can schedule it as a cron job.

Why Perl and not something more modern? Why text files and not a database?

To keep it simple. This way I can put the script and text files on any *nix system without worrying about which languages or databases are available, or having to install a runtime, and I can just run it from cron. No sense building a scheduler when one already exists, right?


I'm deliberately not making this complicated, but I will probably add:

  • multiline posts.
  • external config file so it can be used to power more than one bot. (I don't want to put the API key in the command-line parameters.)


Simple bot to post a random line from a text file to Mastodon.



No releases published


No packages published