From 6e89cc3085b8a21dd62b9f605176a4e56b33fc9c Mon Sep 17 00:00:00 2001 From: mb Date: Thu, 6 Feb 2020 18:32:36 +0100 Subject: [PATCH] adding the documentation! --- README.md | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7ba79da..952e06a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,100 @@ -# bots -All our bots. +``` + _ _ _____ __ _____ ___ ____ ___ _____ +| | | |/ _ \ \ / / |_ _/ _ \ | __ ) / _ \_ _| +| |_| | | | \ \ /\ / / | || | | | | _ \| | | || | +| _ | |_| |\ V V / | || |_| | | |_) | |_| || | +|_| |_|\___/ \_/\_/ |_| \___/ |____/ \___/ |_| + +``` -Testing moment! +# how to play around with a local bot + +See existing ones: + + + + + +You might want to see also. +Install the dependencies (only slixmpp for now). + +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, run the following and answer the questions: + + $ python3 streambot.py + +# how to run a bot on the varia systers server + +## make a bot + +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 + +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 the changes you made to the server. + + $ git add yourfiles.py + +or + + $ git add -A (but be sure you want to add all the files you added to the repo) + + $ git commit -m "your commit message" (something actually informative is best) + + $ git push + +You can also check the status of your repository by typing + $ 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 that, `supervisor` restarts all the bots. + +## 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: + + $ ssh username@vvvvvvaria.org -p 12345 + +Open the config file, either with your own user, or as the systers user (has sudo rights!): + + $ sudo su systers + + $ 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] +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 +``` + +Save and exit! + + CTRL+X Y [enter] + +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!! -It is just a little test :D -It works!!!!!