Skip to content
bhaizyPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

📓 Legend AI - Telegram Study & Doubt Solving Bot

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!


📂 Repository Structure

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

🖥️ VPS Hosting Guide (Ubuntu / Debian)

Step 1: VPS Packages & Python 3 Update

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).


Step 2: Code Upload / Clone Karein

Apna repo clone karein:

git clone <your-repo-link> LegendAI
cd LegendAI

Step 3: Environment Setup (.env)

cp .env.example .env
nano .env

File me apni values daalein:

  • BOT_TOKEN: @BotFather ka token
  • ADMIN_IDS: Aapka numeric Telegram User ID
  • FSUB_CHANNEL: Channel username (e.g., @LegendStudyChannel)
  • FSUB_LINK: Channel link
  • OWNER_USERNAME: Aapka username bina @ ke
  • GEMINI_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.


Step 4: Virtual Environment & Dependencies Install

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

Step 5: Bot Run Karna (3 Options)

Option A: 24/7 Background Service with Systemd (RECOMMENDED 🏆)

Yeh bot ko 24/7 chalata hai aur VPS reboot hone par auto-restart karta hai:

  1. legendai.service file check karein (agar repo path /root/LegendAI ke alawa hai toh path edit kar lein):
    sudo cp legendai.service /etc/systemd/system/legendai.service
  2. Service start aur enable karein:
    sudo systemctl daemon-reload
    sudo systemctl enable legendai
    sudo systemctl start legendai
  3. Status check karein:
    sudo systemctl status legendai
  4. Live logs dekhne ke liye:
    journalctl -u legendai -f

Option B: Screen ke zariye (Simple & Fast)

screen -S legendai
source venv/bin/activate
python3 main.py

Screen se bahar aane ke liye: Ctrl + A fir D.
Wapas screen kholne ke liye: screen -r legendai.


Option C: start.sh Script

chmod +x start.sh
./start.sh

📋 Commands List

👨‍🎓 For Students / Members:

  • /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.

🛡️ For Admins (Private Chat):

  • /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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages