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

82 lines
5.1 KiB
Markdown

# fyrfli's ActivityPub bots project
![](https://fyrfli.dev/fyrfli/bots/actions/workflows/dog_facts.yaml/badge.svg) ![](https://fyrfli.dev/fyrfli/bots/actions/workflows/quip.yaml/badge.svg) ![](https://fyrfli.dev/fyrfli/bots/actions/workflows/quotes.yaml/badge.svg) ![](https://fyrfli.dev/fyrfli/bots/actions/workflows/releases.yaml/badge.svg) ![](https://fyrfli.dev/fyrfli/bots/actions/workflows/puppies.yaml/badge.svg)
A collection of simple bots that post to an ActivityPub-compatible account that implements the [Mastodon API](https://docs.joinmastodon.org/client/intro/). (Tested with [Gotosocial](https://gotosocial.org) and Mastodon [Glitch Edition](https://glitch-soc.github.io/docs/))
To run any of these bots for yourself, you will need:
- a git repository on a forge that supports [github actions](https://github.com/resources/whitepapers/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](https://pushover.net) account.
Current bot list:
- [Dog facts](https://bots.fyrfli.social/@dogfacts) (dogs_facts.py) is a little bit of code I wrote in one my lazy, brain-foggy days.
- [Quips](https://bots.fyrfli.social/@dayswithoutwhitenonsense) (quip.py) I adopted the code I use for the [white nonsense bot](https://bots.fyrfli.social/@dayswithoutwhitenonsense) to use any provided text file that contains a basic list of sayings.
- [Quotes](https://bots.fyrfli.social/@quotesbot), 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](https://bots.fyrfli.social/@puppybot) finally made it over. Initially, I was using the [Mastodon.py](https://github.com/halcy/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](https://dogapi.dog/docs/api-v2)
## 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](https://bots.fyrfli.social/@dayswithoutwhitenonsense) 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](https://bots.fyrfli.social/@puppybot) [code](https://fyrfli.dev/fyrfli/puppybot) 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.