neige d'aoust

knowledge, art, and other stuff

User Tools

Site Tools


fedibot

This is an old revision of the document!


# Write your own simple Fediverse bot

## 1. Acquire the ingredients

- [toot](https://github.com/ihabunek/toot) - systemd

## 2. Write the shell script

Create an account to the desired instance, then login to that account with toot.

~/bin/dugbot: ```sh #!/bin/sh toot post -l fr -u “[email protected]” “$(fortune -sn500 dansunegalaxie)” ```

You will want to make sure the output of the command you give out to `toot post` isn't longer than the character limit allowed by your instance, or else it won't post.

## 3. Run cron job

/etc/systemd/system/dugbot.service: ```ini [Unit] Description=Post a random DUG quote to Mastodon

[Service] Type=oneshot ExecStart=/home/juju/bin/dugbot User=juju ```

/etc/systemd/system/dugbot.timer: ```ini [Unit] Description=Run dugbot every 30 minutes

[Timer] OnCalendar=*:00,30

[Install] WantedBy=timers.target ```

Run it:

```sh sudo systemctl enable dugbot.timer ```

fedibot.1738538263.txt.gz · Last modified: 2025/02/02 18:17 by Yuki