Files
bots/README.md
Camille Frantz 9914f530b7
All checks were successful
ReleaseBot / deploy (push) Successful in 45s
QuipBot / deploy (push) Successful in 18s
DogFacts / deploy (push) Successful in 15s
PuppyBot / deploy (push) Successful in 21s
QuotesBot / deploy (push) Successful in 14s
prettier
2025-07-08 10:35:39 -05:00

5.1 KiB

fyrfli's ActivityPub bots project

A collection of simple bots that post to an ActivityPub-compatible account that implements the Mastodon API. (Tested with Gotosocial and Mastodon Glitch Edition)

To run any of these bots for yourself, you will need:

  • a git repository on a forge that supports github actions* (Gitea, Forgejo, Codeberg, and, of course, Github)
  • the ability to add secrets to the repository
  • an ActivityPub enabled account that supports the Mastodon API (only tested with Mastodon-glitch and Gotosocial at the moment)
  • optionally a Pushover account.

Current bot list:

  • Dog facts (dogs_facts.py) is a little bit of code I wrote in one my lazy, brain-foggy days.
  • Quips (quip.py) I adopted the code I use for the white nonsense bot to use any provided text file that contains a basic list of sayings.
  • Quotes, my first bot. It reads a simple csv-formatted file of quotes.
  • Repository Release watch, this one reads a list of feed urls and checks for a new entry in the last 8 hours. I have it running every 8 hours. This one does not post to an ActivityPub compatible account/feed... yet.
  • The PuppyBot finally made it over. Initially, I was using the Mastodon.py library to post because I couldn't figure out how to make requests upload files. But (a) I didn't want to depend on an external library that may or may not suffer from update lag later on and (b) I wanted to get my hands dirty. So after many months of trial and error and brain fog and forgetfulness and fatigue, I finally figured it out.

Requirements

All the bots here expect the following secrets:

- BOTS_ENDPOINT        # The URL of your ActivityPub instances (e.g. mastodon.social)
- PUSHOVER_USER_TOKEN  # Optional
- PUSHOVER_APP_TOKEN   # Optional

Additionally, each have specific requirement outlined below.

Dog Facts bot

For this bot, you only need an access token that can wrtite posts to your instance. It grabs a random fact from a (up until now) free /facts API endpoint

The Quips Bot

This bot reads a text file containing one line of text per statement. The secrets expected are aa follows:

- QUIP_FILE            # URL to your text file; it expects an https endpoint
- QUIP_TOKEN           # Access token to your ActivityPub account
- QUIP_TAGS            # Additional tags you want posted; the code posts with a "#Bot" tag regardless of this value

Currently, I use this code to post to the White Nonsense Bot account

The Random Quotes bot

A comma-separated formatted text file of quotes and authors like so:

quote,author
"Amet lorem voluptatem tempore sint quod? Nam porro aliquid aspernatur assumenda fugiat A odit excepturi facere vero nihil Nulla voluptate accusantium vero recusandae nulla Obcaecati nemo dolor non reprehenderit excepturi23", "Example Author"
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla","Author Exemplaris",
...

This bot requires only an additional secret with the path to your quotes file.

Release tracker

A secret containing a comma-separated string of feed urls:

https://github.com/blah/blah/releases.atom,https://codeberg.org/blah/blah/releases.rss

As of now, it only posts to Pushover and it requires a Pushover user and app.

PuppyBot

This bot requires two extra secrets:

- BOTS_PUPPYBOT_TOKEN     # Access token to your ActivityPub account
- UNSPLASH_API_KEY        # API Token from Unsplash.com issued via the developer panel 
                            - https://unsplash.com/developers.

Still to come:

  • My newsfeed bot that reads from a list of rss or atom feeds and posts latest entries.
  • Release tracker bot that watches a provided list of got repositories and posts releases to a selected endpoint
  • Make the release tracker post to discord again
  • The puppybot code needs to be able to upload media via the requests library before I am willing to include it here.

Maybe someday

  • Provide several options for output - e.g. Discord, Telegram, etc.