quiz-bot is a Telegram bot designed to create, manage, and take interactive quizzes. It allows users to start a quiz and review existing questions. The bot supports multiple languages and allows questions to be categorized by topics.
- Start Quiz: Users can initiate a quiz and answer a series of questions.
- Review Question: Users can review and explore existing quiz questions.
- Automated Testing: Ensures that updates do not break functionality by testing the bot automatically.
- Module Update Automation: Automatically manages and updates the bot’s dependencies.
- Python Version: 3.7 or higher.
- Required Libraries: All required libraries are listed in the
requirements.txtfile.python-telegram-botfor Telegram API integration.python-dotenvfor managing environment variables.
- Optional: Docker for containerized deployment.
-
Fork and Clone the Repository:
git clone https://github.com/your-username/quiz-bot.git cd quiz-bot -
Create a Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Required Dependencies:
pip install -r requirements.txt
-
Fork and Clone the Repository:
git clone https://github.com/stefanopaolonii/quizbot.git cd quiz-bot -
Build the Docker Image:
docker build -t quiz-bot . -
Run the Docker Container:
docker run -d --name quiz-bot -v $(pwd)/config.py:/app/config.py -v $(pwd)/questions.json:/app/questions.json quiz-bot
-
Set up Environment Variables: Create a
.envfile in the root of your project. This file will store your bot's token securely.TOKEN="YOUR_BOT_TOKEN_HERE"Important: Add the
.envfile to your.gitignoreto prevent your token from being committed to version control. -
Configure Paths (
config.py): Ensure theconfig.pyfile points to your questions data file.QUESTIONS_JSON_PATH = "data/questions.json"
-
Setup Questions File (
questions.json):
Ensure you have adata/questions.jsonfile containing an array of questions in the specified format:[ { "id": -1, "language": "en", "text": "What is the capital of France?", "options": [ "Berlin", "Madrid", "Paris", "Rome" ], "correct_index": 2, "verified": true, "explanation": "Paris is the capital city of France.", "topic": "Geography" } ]
Once you've completed the installation and configuration steps, you can start the bot with the following command:
python main.py