Quiz bot for Telegram and Vkontakte
See for yourself:
Python should already be installed. This project is tested on Python 3.11. You may use other versions as you will, but YMMV.
Clone the repo / download code
Using virtual environment virtualenv/venv is recommended for project isolation.
Install requirements:
pip install -r requirements.txt
This project uses redis database. Create and connect your instance at redis website
To configure those settings, create a .env
file in the root folder of the project and put in there the following:
TELEGRAM_BOT_TOKEN
- Access token of your bot. You get one from BotFather Telegram bot when you create a bot.TELEGRAM_LOGGING_BOT_TOKEN
- same as above, but used for sending logs. Can be the same bot or separate as the main one.TELEGRAM_USER_ID
- Your numeric Telegram ID. Can be checked by writing to special user info bot. Used to recieve logs.LOGGING_LEVEL
- Desired logging levelREDIS_HOST
- Host of your redis databaseREDIS_PORT
- Port of your redis databaseREDIS_PASSWORD
- Password for your redis databaseREDIS_DB_NUMBER
- The ID of your redis databaseQUIZ_FILE_PATH
- Filepath to your quiz file inKOI8-R
encoding (seequiz_questions/example.txt
)
Telegram and VK bots are separate and should be launched by executing tg_bot.py
and vk_bot.py
python tg_bot.py # launches Telegram bot
python vk_bot.py # launches VK bot
For Telegram bot to be able to send messages, send it a /start
command
The code is written for educational purposes on online-course for web-developers dvmn.org.