Telegram bot for an educational center — card-based subscription management with admin & student roles.
Built with aiogram 3, PostgreSQL (asyncpg), and modular architecture.
- ➕ Add students — by phone number + password (default
123on/skip) - 👤 View all users — click to see phone, subscription status, card details
- 🔑 Reset password — admin can reset any student's password
- 📊 Statistics — weekly / monthly sales and subscription stats
- 📢 Broadcast — send announcements to all users
- 📋 Plan management — view, add, edit, delete subscription plans
- 🔐 Login — phone + password authentication
- 📋 View plans — browse available subscription plans
- 💳 Purchase — select plan, make payment, send proof (screenshot)
- 🎴 Digital card — visually rich card displayed after payment approval
- 📜 Payment history — track past and pending payments
- ℹ️ Profile — view personal info and subscription status
| Card | Duration | Visual |
|---|---|---|
| 🥉 Bronze | 1 month | Brown theme |
| 🥈 Silver | 3 months | Silver theme |
| 🥇 Gold | 6 months | Gold theme |
| 💎 Platinum | 12 months | Blue diamond theme |
- ⭐ Rating
- ❓ Q&A
- 📚 Course Info
- 🧠 Daily Quiz
card-bot/
├── .env # Environment variables
├── .env.example # Template
├── requirements.txt # Dependencies
├── run.py # Entry point
├── bot/
│ ├── __init__.py
│ ├── config.py # Configuration loader
│ ├── main.py # Bot & dispatcher setup
│ ├── db/
│ │ ├── database.py # Connection pool & table init
│ │ └── models.py # All database queries
│ ├── handlers/
│ │ ├── common.py # /start, shared handlers
│ │ ├── admin.py # Full admin panel
│ │ └── student.py # Student features
│ ├── keyboards/
│ │ ├── admin_kb.py # Admin keyboards
│ │ └── student_kb.py # Student keyboards
│ ├── states/
│ │ ├── admin_states.py
│ │ └── student_states.py
│ └── utils/
│ ├── card_generator.py # Card visual generator
│ └── helpers.py # Utility functions
- Python 3.11+
- PostgreSQL running locally or remotely
CREATE DATABASE card_bot;cp .env.example .envEdit .env with your values:
BOT_TOKEN— from @BotFatherADMIN_IDS— comma-separated Telegram user IDsDATABASE_URL— PostgreSQL connection stringPAYMENT_CARD_NUMBER— payment card for studentsPAYMENT_CARD_HOLDER— cardholder name
pip install -r requirements.txtpython run.pyTables are auto-created on startup. Default plans (Bronze, Silver, Gold, Platinum) are seeded if the plans table is empty.
- Admin adds a student via phone number
- Student sends
/start, logs in with phone + password - Student browses plans and selects one to purchase
- Payment details are shown; student sends proof (screenshot)
- Admin receives the proof and approves/rejects
- On approval, a digital subscription card is generated and sent to the student
- Student can view their card, expiry, and payment history anytime
MIT