Skip to content

Ownermood/Miss-Quiz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

47 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—      โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—    โ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•—
โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ•šโ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•    โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘       โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•‘     โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘       โ•šโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘
โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘  โ–ˆโ–ˆโ•‘   โ–ˆโ–ˆโ•‘        โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•‘
 โ•šโ•โ•โ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•  โ•šโ•โ•   โ•šโ•โ•         โ•šโ•โ•โ•โ•  โ•šโ•โ•โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•  โ•šโ•โ•โ•โ•

๐ŸŒท Miss Quiz โ€” CLAT Vision Quiz Bot ๐ŸŽ“

Premium Telegram Quiz Bot ยท MongoDB ยท Python 3.11 ยท python-telegram-bot v22

Python Telegram MongoDB License Docker


สœษชษชษชษช แด…แด€ส€สŸษชษดษข! ๐Ÿ’• แดกแด‡สŸแด„แดแดแด‡ แด›แด แด›สœแด‡ แดแด๊œฑแด› แด€แด…แดส€แด€ส™สŸแด‡ แด„สŸแด€แด› แด˜ส€แด‡แด˜ แด„แดแดแด˜แด€ษดษชแดษด แดษด แด›แด‡สŸแด‡ษขส€แด€แด!


โœจ What is Miss Quiz?

Miss Quiz is a production-ready, feature-rich Telegram quiz bot built for CLAT aspirants. It delivers interactive multiple-choice questions, tracks progress across groups, runs a live global leaderboard, and auto-broadcasts quizzes every 30 minutes โ€” all backed by MongoDB Atlas.

๐Ÿ‘ค Users          โ†’   /quiz /score /stats /achievements /leaderboard
๐Ÿ›ก๏ธ Admins         โ†’   /addquiz /delquiz /editquiz /importquiz /broadcast
๐Ÿ“Š Analytics      โ†’   /botstats + Web Admin Panel at /admin
โฐ Auto Quiz      โ†’   Every 30 min to all registered groups

๐Ÿš€ Features

๐ŸŽฏ Quiz Engine

  • Telegram native Quiz Polls (not messages)
  • 8 categories โ€” Legal, English, GK, Polity, Math, Reasoning, History, Current Affairs
  • Anti-repeat per chat โ€” never sees the same question twice in a row
  • Poll answer persistence across bot restarts (MongoDB + pickle backup)

๐Ÿ† Leaderboard & Stats

  • Global / Weekly / Monthly leaderboards (paginated, top 50)
  • Per-user stats โ€” accuracy, streak, XP level, rank badge
  • Group-wise leaderboard
  • Achievement system with milestone badges

โš™๏ธ Admin Tools

  • /addquiz โ€” Add single question inline
  • /importquiz โ€” Bulk import from .txt file (auto-detects format)
  • /delquiz โ€” Delete by reply-to-poll or interactive paginated menu
  • /editquiz โ€” Paginated question browser
  • /broadcast + /delbroadcast โ€” Mass messaging with recall
  • /reload โ€” Hot-reload questions from DB without restart

๐Ÿ“ก Web Admin Panel

  • Dark-mode SPA at http://localhost:5000/admin
  • Question CRUD, user leaderboard, broadcast composer
  • REST API for all operations (/api/questions, /api/metrics, ...)

๐Ÿ“ Project Structure

Miss-Quiz/
โ”‚
โ”œโ”€โ”€ main.py                     โ† Entry point (polling + webhook modes)
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ bot/
โ”‚   โ”‚   โ”œโ”€โ”€ handlers_main.py    โ† TelegramQuizBot (assembles all mixins)
โ”‚   โ”‚   โ”œโ”€โ”€ handlers.py         โ† Compat shim โ†’ handlers_main
โ”‚   โ”‚   โ”œโ”€โ”€ ui.py               โ† Design tokens, UI class, constants
โ”‚   โ”‚   โ”œโ”€โ”€ tracking.py         โ† Group & user registration pipeline
โ”‚   โ”‚   โ”œโ”€โ”€ poll_manager.py     โ† Poll persistence & answer handler
โ”‚   โ”‚   โ”œโ”€โ”€ quiz_parser.py      โ† Bulk .txt import parser
โ”‚   โ”‚   โ”œโ”€โ”€ dev_commands.py     โ† Developer-only extended commands
โ”‚   โ”‚   โ””โ”€โ”€ commands/
โ”‚   โ”‚       โ”œโ”€โ”€ user_cmds.py    โ† /start /help /ping /info /categories
โ”‚   โ”‚       โ”œโ”€โ”€ quiz_cmds.py    โ† /quiz /score /stats /achievements /botstats
โ”‚   โ”‚       โ”œโ”€โ”€ leaderboard_cmds.py  โ† /leaderboard + pagination
โ”‚   โ”‚       โ””โ”€โ”€ admin_cmds.py   โ† /addquiz /delquiz /editquiz + more
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ config.py           โ† Environment config (Config dataclass)
โ”‚   โ”‚   โ”œโ”€โ”€ database.py         โ† MongoDB data access layer (1090 lines)
โ”‚   โ”‚   โ”œโ”€โ”€ quiz.py             โ† QuizManager โ€” in-memory cache + logic
โ”‚   โ”‚   โ””โ”€โ”€ exceptions.py       โ† Custom exception hierarchy
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ rate_limiter.py     โ† Sliding-window per-user rate limiting
โ”‚   โ”‚   โ””โ”€โ”€ scheduler.py        โ† Auto-quiz scheduler (APScheduler)
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ web/
โ”‚       โ”œโ”€โ”€ app.py              โ† Flask REST API + webhook endpoint
โ”‚       โ””โ”€โ”€ wsgi.py             โ† Gunicorn / Waitress entry point
โ”‚
โ”œโ”€โ”€ templates/
โ”‚   โ””โ”€โ”€ admin.html              โ† Admin panel SPA (dark-mode)
โ”œโ”€โ”€ static/js/
โ”‚   โ””โ”€โ”€ admin.js                โ† Admin panel JavaScript
โ”œโ”€โ”€ tests/                      โ† 54 unit tests (pytest)
โ”œโ”€โ”€ data/                       โ† Poll cache, restart flag
โ”œโ”€โ”€ Dockerfile                  โ† Multi-stage production build
โ”œโ”€โ”€ docker-compose.yml          โ† Local dev stack
โ”œโ”€โ”€ render.yaml                 โ† One-click Render deployment
โ””โ”€โ”€ requirements.txt

โšก Quick Start

1. Clone & Configure

git clone https://github.com/Ownermood/Miss-Quiz.git
cd Miss-Quiz
cp .env.example .env

Edit .env:

TELEGRAM_TOKEN=your_bot_token_here
OWNER_ID=your_telegram_user_id
MONGODB_URL=mongodb+srv://user:pass@cluster.mongodb.net/
MONGODB_DB=quiz_bot
SESSION_SECRET=any_random_secret

2. Install & Run

pip install -r requirements.txt
python main.py

Bot starts in polling mode by default. Admin panel โ†’ http://localhost:5000/admin

3. Docker (Recommended)

# Copy and fill .env first
docker build -t miss-quiz .
docker run --env-file .env -p 5000:5000 miss-quiz

๐ŸŒ Deploy to Render (Free)

  1. Fork this repo
  2. Go to render.com โ†’ New Web Service โ†’ connect your fork
  3. Set environment variables:
Variable Value
TELEGRAM_TOKEN Your bot token from @BotFather
OWNER_ID Your Telegram user ID
MONGODB_URL MongoDB Atlas connection string
SESSION_SECRET Any random string
MODE webhook
RENDER_URL Your render app URL
  1. Deploy โ€” render.yaml handles everything automatically โœ…

๐ŸŽฎ Bot Commands

User Commands

Command Description
/quiz Get a random quiz question
/quiz Legal Reasoning Quiz from a specific category
/score Your personal score card
/stats Detailed performance stats
/achievements Badges & milestones
/leaderboard Global top 50 leaderboard
/botstats Bot-wide analytics
/categories Browse all quiz categories
/help Command reference
/ping Bot health check

Admin Commands (Owner / Developer only)

Command Description
/addquiz Add a question (inline format)
/importquiz Bulk import from .txt file
/delquiz Delete a question
/editquiz Browse & edit question bank
/broadcast Send message to all users & groups
/delbroadcast Recall last broadcast
/reload Sync questions from MongoDB
/restart Graceful bot restart
/dev Developer control panel

๐Ÿ“Š Architecture

Telegram API
     โ”‚
     โ–ผ
TelegramQuizBot  โ†โ”€โ”€ inherits โ”€โ”€โ†’  PollMixin
     โ”‚                             TrackingMixin
     โ”‚                             UserCommandsMixin
     โ”‚                             QuizCommandsMixin
     โ”‚                             LeaderboardMixin
     โ”‚                             AdminCommandsMixin
     โ”‚
     โ”œโ”€โ”€ QuizManager  โ†โ”€โ”€ caches โ”€โ”€โ†’  MongoDB (questions)
     โ”‚
     โ”œโ”€โ”€ DatabaseManager  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’  MongoDB Atlas
     โ”‚       โ”œโ”€โ”€ users_col
     โ”‚       โ”œโ”€โ”€ groups_col
     โ”‚       โ”œโ”€โ”€ activities_col
     โ”‚       โ”œโ”€โ”€ poll_map_col
     โ”‚       โ””โ”€โ”€ broadcasts_col
     โ”‚
     โ”œโ”€โ”€ AutoQuizScheduler  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’  every 30 min โ†’ all groups
     โ”‚
     โ””โ”€โ”€ Flask (Waitress)  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’  /admin  /api/*  /webhook

๐Ÿงช Testing

pip install pytest pytest-asyncio pytest-cov
pytest tests/ -v
tests/test_config.py         โ€” Config loading & validation
tests/test_quiz_manager.py   โ€” QuizManager business logic
tests/test_ui.py             โ€” UI helpers & design system
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
54 passed in 1.5s โœ…

๐Ÿ“ฆ Bulk Import Format (.txt)

Send a .txt file to the bot after /importquiz. The parser auto-detects:

1. Which Article of the Constitution abolishes untouchability?
A) Article 14
B) Article 17
C) Article 19
D) Article 21
Answer: B
Category: Legal Reasoning

2. ...

Supports numbered questions, lettered options (A) / a.), answer lines (Answer: / Ans: / asterisk marking), and automatic category tagging.


๐Ÿ… Rank System

Rank Score Grade
๐Ÿ‘‘ LEGEND 500+ S
๐Ÿ”ฑ MASTER 200+ A+
โš”๏ธ EXPERT 100+ A
๐ŸŽฏ ADVANCED 50+ B
๐Ÿ“ˆ RISING 20+ C
๐ŸŒฑ BEGINNER 5+ D
๐ŸŽฒ ROOKIE 0โ€“4 E

XP Level: Bronze โ†’ Silver โ†’ Gold โ†’ Platinum โ†’ Diamond โ†’ ๐Ÿ’  Legendary


๐Ÿค Contributing

  1. Fork the repo
  2. Create a branch: git checkout -b feature/amazing-feature
  3. Commit: git commit -m "Add amazing feature"
  4. Push: git push origin feature/amazing-feature
  5. Open a Pull Request

๐Ÿ“œ License

MIT ยฉ CLAT Vision


Made with ๐Ÿ’• for CLAT aspirants

สแดแดœส€ สŸแดแด ษชษดษข Qแดœษชแดข ส™แดœแด…แด…ส ษช๊œฑ แด€สŸสŸ สแดแดœส€๊œฑ ~ ๐Ÿฅฐ

Telegram

About

๐ŸŽ“ Premium Telegram Quiz Bot for CLAT aspirants โ€” leaderboards, auto-quiz, bulk import, MongoDB, admin panel

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors