bots/README.md

43 lines
1.5 KiB
Markdown
Raw Normal View History

2020-02-06 18:32:36 +01:00
```
2020-02-07 11:28:57 +01:00
_ _ _____ __ _____ ___ ____ ___ _____
2020-02-06 18:32:36 +01:00
| | | |/ _ \ \ / / |_ _/ _ \ | __ ) / _ \_ _|
2020-02-07 11:28:57 +01:00
| |_| | | | \ \ /\ / / | || | | | | _ \| | | || |
| _ | |_| |\ V V / | || |_| | | |_) | |_| || |
|_| |_|\___/ \_/\_/ |_| \___/ |____/ \___/ |_|
2020-02-06 18:32:36 +01:00
2020-02-07 11:28:57 +01:00
```
2020-02-06 18:32:36 +01:00
2021-02-03 10:38:07 +01:00
> status: experimental
2021-02-03 10:47:54 +01:00
# Bots
2020-02-06 18:32:36 +01:00
2021-02-03 10:47:54 +01:00
The Varia XMPP botspace. These bots are written using
2021-02-03 10:55:42 +01:00
[`slixmpp`](https://slixmpp.readthedocs.io/) and sometimes also
[`xbotlib`](https://git.vvvvvvaria.org/decentral1se/xbotlib).
2020-02-06 18:32:36 +01:00
2021-02-03 10:47:54 +01:00
# Write your own
2020-02-06 18:32:36 +01:00
2021-02-03 10:47:54 +01:00
The idea is that you create a single python file and then using one of the
above libraries, you write a single Python class which knows how to speak XMPP,
join rooms, respond to commands etc. Probably the simplest place to start is by
reading the [`xbotlib` getting started guide](https://git.vvvvvvaria.org/decentral1se/xbotlib#user-content-getting-started).
2020-02-06 18:32:36 +01:00
2021-02-03 10:47:54 +01:00
# Deploy it on the Varia server
2020-02-06 18:32:36 +01:00
2021-02-03 10:47:54 +01:00
Add a configuration entry to `/etc/supervisor/conf.d/bots.conf` like the following.
2020-02-06 18:32:36 +01:00
2021-02-03 10:47:54 +01:00
```conf
[program:whisperbot]
directory=/srv/gitea/clones/bots/whisperbot.xbotlib
user=bot
autostart=true
autorestart=true
2020-02-06 18:32:36 +01:00
environment=PATH="/srv/gitea/clones/bots/.venv/lib/python3.7/site-packages:%(ENV_PATH)s"
2021-02-03 10:47:54 +01:00
command=/srv/gitea/clones/bots/.venv/bin/python3 whisperbot.py --password <YOUR-PASSWORD>
2020-02-06 18:32:36 +01:00
```
2021-02-03 10:47:54 +01:00
Then `systemctl restart supervisorctl` and then check if it comes up with
`supervisorctl status bots:`. Logs for all bots can be found in
`/var/log/supervisor/`. Finally, when you git push your bot changes, a git hook
will restart your bot.