Skip to content

Code underlying WUEST's online representations. Includes Telegram chatbot.

License

Notifications You must be signed in to change notification settings

wuest-halle/wuestbot

Repository files navigation

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:

  • Events:
    • eName: string
    • date: string, Format DD.MM.YYYY
    • time: string, Format HH:MM
    • description: string, must not exceed 150 characters
    • admission: string
    • ePicID: string, 6 ciphers long, begins with a 0. followed by file ending - e.g. 002378.jpg
  • Artist:
    • aName: string
    • website: string
    • soundcloud: string
    • bandcamp: string
    • bio: string, must not exceed 150 characters
    • aPicID: string, 6 ciphers long, begins with a 1. followed by file ending - e.g. 100356.jpg
  • PlaysAt:
    • aName: str, same as Artist.aName
    • eName: str, same as Event.eName
    • date: str, same as Event.date

The EMR of the database is as follows:

Database EMR

License

GPLv3