This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
fedibot [2025/02/02 18:17] – créée Yuki | fedibot [2025/02/13 16:37] (current) – Yuki | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | # Write your own simple Fediverse bot | + | ====== |
- | ## 1. Acquire the ingredients | + | ===== 1. Acquire the ingredients |
- | - [toot](https:// | + | * [[https:// |
- | - systemd | + | |
+ | * fortune-mod | ||
- | ## 2. Write the shell script | + | ===== 2. Write the shell script |
- | Create an account to the desired instance, then login to that account with toot. | + | Create an account to the desired instance, then login to that account with toot. Make sure you do this with the user account the cron job is going to run as. |
- | ~/ | + | <code bash ~/ |
- | ```sh | + | |
#!/bin/sh | #!/bin/sh | ||
- | toot post -l fr -u " | + | toot post -l fr -u " |
- | ``` | + | </ |
- | 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. | + | You will want to make sure the output of the command you give out to '' |
- | ## 3. Run cron job | + | ===== 3. Run cron job ===== |
- | / | + | <code ini / |
- | ```ini | + | |
[Unit] | [Unit] | ||
Description=Post a random DUG quote to Mastodon | Description=Post a random DUG quote to Mastodon | ||
Line 27: | Line 26: | ||
[Service] | [Service] | ||
Type=oneshot | Type=oneshot | ||
- | ExecStart=/ | + | ExecStart=/ |
- | User=juju | + | User=yuki |
- | ``` | + | </ |
- | / | + | Make sure to point '' |
- | ```ini | + | |
+ | <code ini / | ||
[Unit] | [Unit] | ||
Description=Run dugbot every 30 minutes | Description=Run dugbot every 30 minutes | ||
Line 41: | Line 41: | ||
[Install] | [Install] | ||
WantedBy=timers.target | WantedBy=timers.target | ||
- | ``` | + | </ |
- | Run it: | + | The .timer file should have the same file name as the corresponding .service. |
- | ```sh | + | Enable the timer: |
+ | |||
+ | <code bash> | ||
sudo systemctl enable dugbot.timer | sudo systemctl enable dugbot.timer | ||
- | ``` | + | sudo systemctl start dugbot.timer |
+ | </ | ||
+ | |||
+ | Or run it once: | ||
+ | |||
+ | <code bash> | ||
+ | sudo systemctl start dugbot.service | ||
+ | </ | ||
+ | |||
+ | ===== Current list of bots ===== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// |