Telegram Quiz Bot is a quiz bot based on Spring JDBC and Telegram Bot API. This bot allows users to participate in random quizzes and tracks their scores.
/help
- Displays help message./add
- Adds a new quiz./finish
- Finishes adding a new quiz./random
- Starts a random quiz./random <tag>
- Starts a random quiz with a specified tag./score
- Queries your current score./score <tag>
- Queries the scores accumulated from questions with a specified tag./clear
- Resets your current score to 0.
This project supports deployment using docker-compose
or just Dockerfile if you have your own MySQL server.
-
Deploy using Docker Compose:
docker-compose up -d
-
Deploy using Dockerfile (Requires configuring MySQL server):
docker build -t quiz-bot . docker run -d quiz-bot -v <your config file path>:/app/target/classes/config.properties
You will need to modify your config file before booting up Docker container, detail listed below.
Before deploying, ensure the config.properties
file is correctly configured:
database.driver = com.mysql.cj.jdbc.Driver
database.url = jdbc:mysql://localhost:3306/quizbot
database.username = root
database.password = toor
telegram.bot.name = telegram-quizbot
telegram.bot.token = 12345:ABCDE
If you need to deploy from source, use Maven:
mvn clean install
Note that before compiling, you need to edit the ./src/main/resources/development.properties
file according to the actual environment.
The project includes unit tests for the Model, DAO, and Service layers to ensure the correctness of functionalities.
The project uses an MVC architecture, divided into the following layers:
- Model layer - Defines data models.
- DAO layer - Data Access Object layer, used for database interactions.
- Service layer - Business logic layer, processes business requests.
- Controller layer - Control layer, receives user commands and calls the corresponding services.
- Spring JDBC - Used for database operations.
- Telegram Bot API - Used to interact with Telegram.
- Spring Task - Used for managing scheduled tasks.
- Spring IoC - Manages Beans using Java configuration files.
Here are links to this repository and related resources:
- Telegram Bot: @PolytechQuizbot
- GitHub Repository: guiqiqi/PolytechQuizbot
- Docker Hub: dogegui/polytech-quizbot
Here are some examples: