wuest-halle / wuestbot

Code underlying WUEST's online representations. Includes Telegram chatbot.
GNU General Public License v3.0
1 stars 1 forks source link

WUESTbot

Telegram Newsletter Bot for WUEST in the making.

Installation on your local machine:

Note, that this was written in Python 3.7. If you are still on 2.7, upgrade!

  1. Clone this folder and change to your new local directory (aka the clone)
git clone git@github.com:wuest-halle/wuestbot.git
cd wuestbot
  1. Create a new Python venv:
python3 -m venv venv
source venv/bin/activate
  1. Install the dependencies:
pip install -r requirements.txt

Startup

First configure your environment:

cat > .env <<EOF
# The API token to authenticate against Telegram
API_TOKEN=abcd123
# The Telegam user / chat IDs that are allowed to push messages
# to all users in the database
ADMINS=1235123,67342347,89945234
EOF

Use start.sh to setup the database and create a gunicorn server in front of the bot:

./start.sh

Alternatively you can set up the DB manually:

cd bot/app/database
./db_create.py

Populating the DB

You can enter data by running app/database/db_update.py:

# Needs to be run from the wuestbot/bot directory.
$ ./app/database/db_update.py

        What should be entered in the DB?
        E - Event
        A - Artist
        P - Artist-Event Relation
        C - Cancel

Database

The database schema can be recreated at any time via bot/app/database/db_create.py. Database population is twofold: users are automatically added via the \start command upon first conversation initilization. Events, artists and their relations are added via db_update.py also residing in the app/database subdirectory. It provides a very small CLI to insert new data, using the classes provided in db_objects.py. Manual inputs to the db have to look like this:

The EMR of the database is as follows:

Database EMR

License

GPLv3