Legend AI ek high-speed Telegram AI Study Bot hai jo aiogram 3.x par bana hai. Ye students ke text aur screenshot doubts ko Double-Verify karke ek realistic handwritten-style notebook page (PNG) bana kar deta hai!
LegendAI/
├── LegendAI/
│ ├── __init__.py
│ ├── config.py # Bot Token, Admin IDs, FSUB Channel loader
│ ├── database.py # Built-in SQLite database (async threaded)
│ ├── handlers/
│ │ ├── __init__.py
│ │ ├── user_handlers.py # /start, /help, fsub verification
│ │ ├── doubt_handlers.py # /ai doubt solver + student mention/reply
│ │ └── admin_handlers.py # /addgroup, /delgroup, /grouplist, /stats
│ ├── middlewares/
│ │ ├── __init__.py
│ │ ├── force_sub.py # DM me Channel Force-Subscribe check
│ │ └── group_auth.py # Group Paid check (unpaid groups me 0 token waste)
│ └── services/
│ ├── __init__.py
│ ├── ai_engine.py # 2-Pass AI Solver + Verifier (with demo fallback)
│ └── notebook_renderer.py # Pillow-based ruled notebook PNG generator
├── main.py # Main Bot Runner
├── requirements.txt # Ultra-lightweight dependencies
├── .env.example # Environment template
├── .gitignore # Ignored files
├── start.sh # Quick start script for VPS
├── legendai.service # Systemd service unit file (24/7 background)
└── README.md # Documentation
Apne VPS terminal me run karein:
sudo apt update && sudo apt upgrade -y
sudo apt install -y python3 python3-pip python3-venv git fonts-dejavu-core fonts-freefont-ttf(Fonts package zaroori hai taaki notebook paper pe text ekdum clean aur sundar render ho).
Apna repo clone karein:
git clone <your-repo-link> LegendAI
cd LegendAIcp .env.example .env
nano .envFile me apni values daalein:
BOT_TOKEN:@BotFatherka tokenADMIN_IDS: Aapka numeric Telegram User IDFSUB_CHANNEL: Channel username (e.g.,@LegendStudyChannel)FSUB_LINK: Channel linkOWNER_USERNAME: Aapka username bina@keGEMINI_API_KEY: Google AI Studio ki free key (Optional: demo mode bina key ke bhi run hota hai)
Save karne ke liye: Ctrl + O fir Enter, aur exit ke liye Ctrl + X.
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txtYeh bot ko 24/7 chalata hai aur VPS reboot hone par auto-restart karta hai:
legendai.servicefile check karein (agar repo path/root/LegendAIke alawa hai toh path edit kar lein):sudo cp legendai.service /etc/systemd/system/legendai.service
- Service start aur enable karein:
sudo systemctl daemon-reload sudo systemctl enable legendai sudo systemctl start legendai - Status check karein:
sudo systemctl status legendai
- Live logs dekhne ke liye:
journalctl -u legendai -f
screen -S legendai
source venv/bin/activate
python3 main.pyScreen se bahar aane ke liye: Ctrl + A fir D.
Wapas screen kholne ke liye: screen -r legendai.
chmod +x start.sh
./start.sh/start: Bot introduction & channel verification./help: Help and commands guide./ai <question>: Doubt solve karne ke liye (Text).- Photo ke sath caption me
/ai: Screenshot doubt solve karne ke liye. - Reply to message with
/ai: Kisi ke message ko reply karke solve karne ke liye.
/addgroup <group_id> <days>: Group ka paid license activate karein (e.g./addgroup -1001234567890 30)./delgroup <group_id>: Group subscription cancel karein./grouplist: Saare active paid groups ki list aur expiry dates dekhein./stats: Total users, active groups, aur solved doubts ke stats dekhein.