Take another pass on the README

This commit is contained in:
Luke Murphy 2021-02-03 10:35:10 +01:00
parent 7a739b613e
commit 0282b7ed1e
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -11,13 +11,14 @@
These bots are written using [slixmpp](https://slixmpp.readthedocs.io/) or [xbotlib](https://git.vvvvvvaria.org/decentral1se/xbotlib). These bots are written using [slixmpp](https://slixmpp.readthedocs.io/) or [xbotlib](https://git.vvvvvvaria.org/decentral1se/xbotlib).
The idea is that you create a single python file (`mybot.py` for example) and using the `slixmpp` library, you write a single Python class which knows how to speak XMPP, join rooms, respond to commands etc (see [ClientXMPP](https://slixmpp.readthedocs.io/api/clientxmpp.html#slixmpp.clientxmpp.ClientXMPP) for more). Following the logbot/streambot example, you can create a command line interface using `argparse` and then start to run it on your own computer first for testing and fun (and not spamming everyone else until your bot is ready!). The idea is that you create a single python file (`mybot.py` for example) 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. Following the examples in this repository, you can create a command line interface using `argparse` and then start to run it on your own computer first for testing and fun (and not spamming everyone else until your bot is ready!).
If you want to play around with the streambot/logbot, do the following and answer the questions (you might want to create your own testing room to join beforehand): If you want to play around with the streambot/logbot, do the following and answer the questions (you might want to create your own testing room to join beforehand):
``` ```
$ pip3 install -r requirements.txt $ python -m venv .venv && source .venv/bin/activate
$ python3 streambot/streambot.py $ pip install -r requirements.txt
$ python streambot/streambot.py
``` ```
# How to run a bot on the varia systers server # How to run a bot on the varia systers server
@ -31,7 +32,10 @@ $ git clone https://git.vvvvvvaria.org/varia/bots
$ git clone ssh://gitea@vvvvvvaria.org:12345/varia/bots.git # or ssh if you prefer (no passwords to type later!) $ git clone ssh://gitea@vvvvvvaria.org:12345/varia/bots.git # or ssh if you prefer (no passwords to type later!)
``` ```
Create a new folder, say, `mynewcoolbot` and add your Python script to the folder. If your bot uses any Python dependencies, add them to the `requirements.txt` file in the repository (please use a == with the version so we can avoid things breaking later). Create a new folder, say, `mynewcoolbot` and add your Python script to the
folder. If your bot uses any Python dependencies, add them to the
`requirements.txt` file in the repository (please use a == with the version so
we can avoid things breaking later).
## Push your changes ## Push your changes
@ -55,13 +59,16 @@ You can also check the status of your repository by typing
`$ git status` `$ git status`
After your push, a git hook is pulling the changes: the `bots` folder on the server (which sits at `/srv/gitea/clones/varia/bots`) is updated. After your push, a git hook is pulling the changes: the `bots` folder on the
server (which sits at `/srv/gitea/clones/varia/bots`) is updated. After that,
After that, `supervisor` restarts all the bots. `supervisor` restarts all the bots.
## Let the bot run continuously ## Let the bot run continuously
To let the bot run all day all night, you can use a "service" and use the software "supervisor". It will take care of starting and stopping your bot when there are changes made to the code or at midnight when the backups are being made. To let the bot run all day all night, you can use a "service" and use the
software "supervisor". It will take care of starting and stopping your bot when
there are changes made to the code or at midnight when the backups are being
made.
There is a "bots" config file, where you can add your new bot to. There is a "bots" config file, where you can add your new bot to.
@ -75,7 +82,8 @@ Open the config file using your Sudo rights:
$ sudo nano /etc/supervisor/conf.d/bots.conf $ sudo nano /etc/supervisor/conf.d/bots.conf
``` ```
Copy/paste one of the other bot's details and add a new one to this file. This is how the details of the pub.club bot look like: Copy/paste one of the other bot's details and add a new one to this file. This
is how the details of the pub.club bot look like:
``` ```
[program:logbot-pub.club] [program:logbot-pub.club]