Skip to content

Latest commit

Β 

History

History
130 lines (100 loc) Β· 3.74 KB

File metadata and controls

130 lines (100 loc) Β· 3.74 KB

πŸŽ“ Edu Center Card Bot

Telegram bot for an educational center β€” card-based subscription management with admin & student roles.

Built with aiogram 3, PostgreSQL (asyncpg), and modular architecture.


✨ Features

Admin Panel

  • βž• Add students β€” by phone number + password (default 123 on /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

Student Features

  • πŸ” 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 Types

Card Duration Visual
πŸ₯‰ Bronze 1 month Brown theme
πŸ₯ˆ Silver 3 months Silver theme
πŸ₯‡ Gold 6 months Gold theme
πŸ’Ž Platinum 12 months Blue diamond theme

Coming Soon (placeholder buttons)

  • ⭐ Rating
  • ❓ Q&A
  • πŸ“š Course Info
  • 🧠 Daily Quiz

πŸ“ Project Structure

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

πŸš€ Setup & Run

1. Prerequisites

  • Python 3.11+
  • PostgreSQL running locally or remotely

2. Create the database

CREATE DATABASE card_bot;

3. Configure environment

cp .env.example .env

Edit .env with your values:

  • BOT_TOKEN β€” from @BotFather
  • ADMIN_IDS β€” comma-separated Telegram user IDs
  • DATABASE_URL β€” PostgreSQL connection string
  • PAYMENT_CARD_NUMBER β€” payment card for students
  • PAYMENT_CARD_HOLDER β€” cardholder name

4. Install dependencies

pip install -r requirements.txt

5. Run the bot

python run.py

Tables are auto-created on startup. Default plans (Bronze, Silver, Gold, Platinum) are seeded if the plans table is empty.


πŸ”„ Workflow

  1. Admin adds a student via phone number
  2. Student sends /start, logs in with phone + password
  3. Student browses plans and selects one to purchase
  4. Payment details are shown; student sends proof (screenshot)
  5. Admin receives the proof and approves/rejects
  6. On approval, a digital subscription card is generated and sent to the student
  7. Student can view their card, expiry, and payment history anytime

πŸ“ License

MIT