You can inspect a live version of the code in the telegram bot @dleraebot.
$ git clone https://github.com/studentenherz/dleraebot.git
$ pip install -r requirements.txt
Make a copy of the file:
credentials.py.sample
And name it:
credentials.py
Edit your bot token in the file. If you don't have one, you can get it using @BotFather in Telegram.
Here the bot is set to use webhooks, with an aiohttp
server through gunicorn
$ gunicorn app:app -k aiohttp.worker.GunicornWebWorker -b <host>:<port>
See this to learn how to set up the webserver with nginx
+ gunicorn
.
Then, for database update and daily boradcast of the Word Of The Day, schedule the cronjob.py
in the crontab
:
$ crontab -e
should have two lines like these:
* * * * * path/to/your/env/python /path/to/the/code/cronjob.py # update database every minute
0 12 * * * path/to/your/env/python /path/to/the/code/cronjob.py --broadcast # broadcast every day at 12:00