forked from varia/bots
Take a pass on the README
This commit is contained in:
parent
56a6af156b
commit
75059ab7f8
89
README.md
89
README.md
@ -1,4 +1,3 @@
|
||||
|
||||
```
|
||||
_ _ _____ __ _____ ___ ____ ___ _____
|
||||
| | | |/ _ \ \ / / |_ _/ _ \ | __ ) / _ \_ _|
|
||||
@ -8,50 +7,52 @@
|
||||
|
||||
```
|
||||
|
||||
# how to play around with a local bot
|
||||
# How to play around with a local bot
|
||||
|
||||
See existing ones:
|
||||
Take a look at the existing bots:
|
||||
|
||||
<https://git.vvvvvvaria.org/varia/xmpp.streambot>
|
||||
- [streambot](./streambot)
|
||||
- [logbot](./logbot)
|
||||
|
||||
<https://git.vvvvvvaria.org/varia/logbot>
|
||||
They're implemented using [slixmpp](https://slixmpp.readthedocs.io/).
|
||||
|
||||
You might want to see <https://slixmpp.readthedocs.io/> also.
|
||||
Install the dependencies (only slixmpp for now).
|
||||
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 (bot.py) and using the `slixmpp` library, you write a single Python class which knows how to speak XMPP, join rooms, respond to commands etc. 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. See below.
|
||||
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, run the following and answer the questions:
|
||||
```
|
||||
$ pip install -r requirements.txt
|
||||
$ python streambot/streambot.py
|
||||
```
|
||||
|
||||
`$ python3 streambot.py`
|
||||
# How to run a bot on the varia systers server
|
||||
|
||||
# how to run a bot on the varia systers server
|
||||
## Make a bot
|
||||
|
||||
## make a bot
|
||||
Firstly, clone the bots repository.
|
||||
|
||||
Clone the bots repository, either over https or ssh:
|
||||
```
|
||||
$ 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 https://git.vvvvvvaria.org/varia/bots`
|
||||
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).
|
||||
|
||||
or with ssh:
|
||||
|
||||
`$ git clone ssh://gitea@vvvvvvaria.org:12345/varia/bots.git`
|
||||
|
||||
Add your bot python script to the folder.
|
||||
|
||||
If your bot uses any dependencies, add them to the `requirements.txt` file in the repository.
|
||||
|
||||
## push
|
||||
## Push your changes
|
||||
|
||||
Push the changes you made to the server.
|
||||
|
||||
`$ git add yourfiles.py`
|
||||
`$ git add mynewcoolbot/bot.py`
|
||||
|
||||
or
|
||||
|
||||
`$ git add -A` (but be sure you want to add all the files you added to the repo)
|
||||
`$ git add -A`
|
||||
|
||||
`$ git commit -m "your commit message"` (something actually informative is best)
|
||||
But be sure you want to add all the files you added to the repo.
|
||||
|
||||
`$ git commit -m "your commit message"`
|
||||
|
||||
Something informative is best.
|
||||
|
||||
`$ git push`
|
||||
|
||||
@ -63,41 +64,57 @@ After your push, a git hook is pulling the changes: the `bots` folder on the ser
|
||||
|
||||
After that, `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.
|
||||
|
||||
There is a "bots" config file, where you can add your new bot to.
|
||||
|
||||
To do this, log into the server hehe:
|
||||
To do this, log into the server:
|
||||
|
||||
`$ ssh username@vvvvvvaria.org -p 12345`
|
||||
|
||||
Open the config file, either with your own user, or as the systers user (has sudo rights!):
|
||||
Open the config file using your Sudo rights:
|
||||
|
||||
`$ sudo su systers`
|
||||
|
||||
`$ 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:
|
||||
|
||||
```
|
||||
[program:logbot-pub.club]
|
||||
directory = /srv/gitea/clones/bots
|
||||
user = bot
|
||||
environment=PATH="/srv/gitea/clones/bots/.venv/lib/python3.7/site-packages:%(ENV_PATH)s"
|
||||
directory = /srv/gitea/clones/bots
|
||||
command = /srv/gitea/clones/bots/.venv/bin/python /srv/gitea/clones/bots/logbot/logbot.py -j bot@vvvvvvaria.org -p streaming -r afijeno@muc.vvvvvvaria.org -o /var/www/logs/pub.club
|
||||
priority = 999
|
||||
command =
|
||||
.venv/bin/python
|
||||
logbot/logbot.py
|
||||
-j bot@vvvvvvaria.org
|
||||
-p streaming
|
||||
-r afijeno@muc.vvvvvvaria.org
|
||||
-n logbot
|
||||
-o /var/www/logs/pub.club
|
||||
```
|
||||
|
||||
Save and exit!
|
||||
|
||||
`CTRL+X Y [enter]`
|
||||
|
||||
Now, we need to restart supervisor itself, in order to activate these changes to the config:
|
||||
Now, we need to restart `supervisor` itself, in order to activate these changes to the config:
|
||||
|
||||
`$ sudo service supervisor restart`
|
||||
|
||||
It will activate all the bots! And hopefully they work!!
|
||||
|
||||
You can check with:
|
||||
|
||||
```
|
||||
$ sudo supervisorctl status bots:
|
||||
```
|
||||
|
||||
If there are errors, have a look in:
|
||||
|
||||
```
|
||||
$ ls /var/log/supervisor
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user