QuizBot is a feature-rich Telegram bot designed to provide engaging quiz experiences for your Telegram groups. Powered by the OpenTDB and The Open Trivia API, this bot automates quiz deliveries, tracks scores, and provides insightful statistics with a beautiful and modular codebase.
- Quiz Integration: Connects to The OpenTDB and The Open Trivia API to fetch quiz categories and questions.
- Automated Quiz Delivery: Sends quizzes to subscribed groups at configurable intervals: 15m, 30m, 45m, 1H, 1.5H, or 2H.
- Admin Settings: Group admins have access to intuitive settings via Inline Buttons for easy quiz management.
- Score Tracking and Graphs: Displays ranks, scores, weekly scores, and generates stunning score graphs.
- Bot Statistics:
- Total number of chats the bot has joined.
- Total number of users who have interacted with the bot.
- Number of chats with answered quizzes in the last 24H.
- Number of users who answered a quiz in the last 24H.
- Modular Architecture: Designed for easy extensibility, allowing new features to be added seamlessly.
- Docker Support: Out-of-the-box support for Docker and Docker Compose for quick setup and deployment.
Follow the instructions below to get your instance of QuizBot up and running.
-
Option A: Copy the
.env.sample
file to.env
and replace the placeholder values with your secure values for username, password, and DB name:cp .env.sample .env
Update the values in the
.env
file. -
Option B: Directly modify the
docker-compose.yml
file and hardcode the database credentials:POSTGRES_USER: yourusername POSTGRES_PASSWORD: yourpassword POSTGRES_DB: yourdbname
-
Copy
sample_config.yml
toconfig.yml
:cp sample_config.yml config.yml
-
Update the
config.yml
file:- Set the
telegram.bot_token
and other necessary settings. - Ensure the
database.schema
matches the credentials from Step 1.
- Set the
-
Copy
sample_alembic.ini
toalembic.ini
:cp sample_alembic.ini alembic.ini
-
Edit the
sqlalchemy.url
inalembic.ini
to match thedatabase.schema
from Step 2.
-
Pull the necessary database image, build the bot image, and start the bot:
docker compose up --build --detach
-
To stop the bot, run:
docker compose down
Here are two valid SQLAlchemy schemas for easy setup:
-
PostgreSQL:
postgresql://dbbotuser:EU39RVEE7hFkh5Dr85Hsq6YYzaQ2AQxf@postgres:5432/quizbotdb
-
SQLite:
sqlite:///quizbot.db
The QuizBot project relies on the following key libraries:
python-telegram-bot = {extras = ["all"], version = "==21.5"}
matplotlib = "==3.9.2"
pyyaml = "==6.0.2"
sqlalchemy = "==2.0.34"
pytz = "==2024.2"
alembic = "==1.13.2"
psycopg2-binary = "*"
Make sure to refer to the official documentation of python-telegram-bot
for more detailed information about the library's capabilities.
With its built-in analytics, QuizBot can track:
- Number of chats the bot has been added to.
- Total users who have interacted with the bot.
- Chats where quizzes have been answered in the past 24 hours.
- Users who answered a quiz in the past 24 hours.
The bot's ability to generate beautiful graphs enhances the quiz experience by providing visual representations of score progressions.
Thanks to its modular design, adding new features to QuizBot is straightforward. Developers can easily integrate new functionality without disrupting the core bot.
If you're interested in contributing to this project, feel free to submit a pull request or open an issue on the GitHub repository.
QuizBot is fully compatible with Docker, making deployment and management effortless. You can easily start the bot using Docker Compose, and it supports both PostgreSQL and SQLite databases out of the box.
We welcome contributions! Please check out our contribution guidelines for more information on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the Atlas Projects Team