π¬ | AI Chat Natural conversations powered by GPT-4o and other models |
π¨ | Image Generation Create stunning images from text descriptions, with /img and inline mode |
π | Voice Processing Two-way voice message and text conversion (speech-to-text, text-to-speech) |
π | Text Extraction (img2text) Extract text, solve MCQs, and answer questions from images and documents |
π | Multi-language Support Communicate in your preferred language, with translation and language settings |
π₯ | Group Integration Full AI functionality in group chats, with group-specific settings |
π± | Inline Mode Generate AI responses and images in any chat, with advanced inline query handling |
β‘ | Fast, Reliable Delivery Optimized for quick, robust interactions, including large code/image snippets |
ποΈ | File-to-Text (img2text) Upload images or documents and interact with their content via AI |
β³ | Image Context Expiry Uploaded images for vision/AI analysis are auto-deleted after 2 minutes (configurable) |
π | Premium Model Handling Premium AI/image models are shown only to eligible users |
π‘οΈ | Admin Tools Broadcast images (/share), code snippets (/snippet), ban/unban, premium management, logs, and more |
π§© | Multi-Bot Support Run multiple bots with isolated sessions and MongoDB fork safety |
π§ | Advanced Prompting Smart prompt logic for images, MCQs, and document Q&A |
π± Try it now: t.me/AdvChatGptBot
# Clone repository
git clone https://github.com/TechyCSR/AdvAITelegramBot.git
# Navigate to directory
cd AdvAITelegramBot
# Set up virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure your bot
cp config.example.py config.py
# Edit config.py with your API credentials
# Launch!
python run.py
Command | Description |
---|---|
/start |
π Start a conversation with the bot |
/help |
β Get help and see available commands |
/settings |
βοΈ Adjust preferences, language, and models |
/img [prompt] or /generate [prompt] |
π¨ Generate an image from text |
/newchat , /reset , /new , /clear_chat |
π Start a new conversation |
Upload image/document | π Extract text, solve MCQs, or ask questions about content |
How to use:
- Upload an image or document in private chat to extract text, solve MCQs, or ask questions about its content. Only one image context is active per user; uploading a new image replaces the previous one. Images are auto-deleted after 2 minutes (user is notified).
- For image generation, the bot always replies with a
/img
command snippet and clear copy-paste instructions. - All code/image snippets are delivered unbroken, using HTML formatting for reliability.
Edit config.py
with the following fields:
BOT_TOKEN = "your_telegram_bot_token" # From BotFather
API_KEY = "your_telegram_api_key" # From my.telegram.org
API_HASH = "your_telegram_api_hash" # From my.telegram.org
DATABASE_URL = "mongodb://localhost:27017/" # MongoDB connection string
ADMINS = [123456789] # List of Telegram user IDs with admin rights
# Optional advanced settings:
IMAGE_CONTEXT_EXPIRY_MINUTES = 2 # Minutes before uploaded images are auto-deleted
PREMIUM_MODELS = ["gpt-4o", "dalle3", ...] # List of premium models (shown only to premium users)
MULTI_BOT = True # Enable multi-bot support (one process per bot)
- For multi-bot, provide multiple
BOT_TOKEN
s and setMULTI_BOT = True
. - For MongoDB fork safety, each process creates its own MongoClient.
- All settings are documented in
config.py
.
-
Image/Document Upload:
- Upload an image or document, then ask questions, solve MCQs, or request a description.
- If a caption is present, it is used as the prompt; otherwise, the bot will prompt the AI to answer questions, solve MCQs, or describe the image.
- Only one image context is active per user; uploading a new image replaces the previous one.
- Images are auto-deleted after expiry, and the user is notified.
-
AI Prompting:
- The bot is aware of all its capabilities (text, image, vision, MCQ, document, multi-model).
- For any image generation request, the bot always replies with a
/img
command snippet and clear copy-paste instructions.
-
Code/Prompt Snippets:
- Code and image generation snippets are always delivered unbroken, using HTML formatting for reliability.
A simple, user-friendly architecture that powers all the bot's amazing features.
graph TD
%% Users
USER[π€ Users]
%% User Interfaces - Simplified
subgraph "π± How Users Interact"
TELEGRAM[π¬ Telegram Chat]
WEBAPP[π Web App]
INLINE[β‘ Inline Mode]
end
%% Main System
subgraph "π€ Main Bot System"
BOT[π§ AI Bot Brain]
QUEUE[π Request Handler]
end
%% AI Services - Main Categories Only
subgraph "π― AI Services"
TEXTAI[π Text AI<br/>Chat & Responses]
IMAGEAI[π¨ Image AI<br/>Generate & Analyze]
VOICEAI[π Voice AI<br/>Speech Processing]
VIDEOAI[π¬ Video AI<br/>Video Creation]
end
%% Core Features
subgraph "βοΈ Core Features"
USERS[π₯ User Management]
GROUPS[π’ Group Features]
ADMIN[π Admin Tools]
end
%% External AI Providers
subgraph "π AI Providers"
GPT[π§ OpenAI GPT-4o]
POLLINATIONS[π¨ Pollinations AI]
DEEPINFRA[β‘ DeepInfra]
end
%% Database
subgraph "πΎ Data Storage"
MONGODB[(ποΈ MongoDB Database)]
FILES[π Generated Files]
end
%% Simple Connections
USER --> TELEGRAM
USER --> WEBAPP
USER --> INLINE
TELEGRAM --> BOT
WEBAPP --> BOT
INLINE --> BOT
BOT --> QUEUE
QUEUE --> TEXTAI
QUEUE --> IMAGEAI
QUEUE --> VOICEAI
QUEUE --> VIDEOAI
BOT --> USERS
BOT --> GROUPS
BOT --> ADMIN
TEXTAI --> GPT
TEXTAI --> DEEPINFRA
IMAGEAI --> POLLINATIONS
IMAGEAI --> GPT
VOICEAI --> GPT
VIDEOAI --> POLLINATIONS
BOT --> MONGODB
IMAGEAI --> FILES
VOICEAI --> FILES
VIDEOAI --> FILES
%% Clean Styling with High Contrast
classDef user fill:#2E3440,stroke:#88C0D0,stroke-width:3px,color:#ECEFF4
classDef interface fill:#5E81AC,stroke:#81A1C1,stroke-width:3px,color:#ECEFF4
classDef system fill:#8FBCBB,stroke:#88C0D0,stroke-width:3px,color:#2E3440
classDef ai fill:#EBCB8B,stroke:#D08770,stroke-width:3px,color:#2E3440
classDef features fill:#A3BE8C,stroke:#B48EAD,stroke-width:3px,color:#2E3440
classDef external fill:#BF616A,stroke:#D08770,stroke-width:3px,color:#ECEFF4
classDef data fill:#B48EAD,stroke:#5E81AC,stroke-width:3px,color:#ECEFF4
class USER user
class TELEGRAM,WEBAPP,INLINE interface
class BOT,QUEUE system
class TEXTAI,IMAGEAI,VOICEAI,VIDEOAI ai
class USERS,GROUPS,ADMIN features
class GPT,POLLINATIONS,DEEPINFRA external
class MONGODB,FILES data
Component | What It Does | Example |
---|---|---|
π Text AI | Smart conversations and responses | "Tell me about space" β Detailed explanation |
π¨ Image AI | Creates and analyzes images | "/img sunset beach" β Beautiful beach sunset image |
π Voice AI | Speech-to-text and text-to-speech | Voice message β Text transcription |
π¬ Video AI | AI-powered video generation | Text prompt β Generated video |
π₯ User Management | Handles accounts, settings, premium | User preferences, premium features |
π’ Group Features | Group chat functionality | Group settings, permissions |
π Admin Tools | Bot management and monitoring | Statistics, user management |
- β‘ Fast: Smart request handling prevents delays
- π§ Intelligent: Multiple AI models for best results
- π± Accessible: Works on Telegram, web, and inline mode
- π Secure: User data protected in MongoDB database
- π― Reliable: Queue system handles high traffic
- π Global: Multi-language support for everyone
- Python 3.8 or higher
- MongoDB (local or cloud instance)
- Telegram Bot Token from BotFather
- 1GB+ RAM recommended for image generation
1. Environment Setup
# Make sure you have Python 3.8+ installed
python --version
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
2. Install Dependencies
# Install required packages
pip install -r requirements.txt
# Verify installations
pip list
3. Configuration
Create a config.py
file with your credentials:
BOT_TOKEN = "your_telegram_bot_token" # From BotFather
API_KEY = "your_telegram_api_key" # From my.telegram.org
API_HASH = "your_telegram_api_hash" # From my.telegram.org
DATABASE_URL = "mongodb://localhost:27017/"
ADMINS = [123456789] # Your Telegram user ID
# Optional advanced settings:
IMAGE_CONTEXT_EXPIRY_MINUTES = 2 # Minutes before uploaded images are auto-deleted
PREMIUM_MODELS = ["gpt-4o", "dalle3", ...] # List of premium models (shown only to premium users)
MULTI_BOT = True # Enable multi-bot support (one process per bot)
4. Database Setup
# Start MongoDB (if using local instance)
mongod --dbpath /path/to/data/db
# The bot will automatically create required collections
5. Running the Bot
# Start the bot
python run.py
# For production deployment
# Consider using systemd, Docker, or PM2
Docker Deployment
# Build the Docker image
docker build -t advai-telegram-bot .
# Run the container
docker run -d --name advai-bot advai-telegram-bot
Environment Variables
You can use environment variables instead of config.py:
export BOT_TOKEN="your_telegram_bot_token"
export API_KEY="your_telegram_api_key"
export API_HASH="your_telegram_api_hash"
export DATABASE_URL="mongodb://localhost:27017/"
- Pyrogram: Modern, fast, and elegant Telegram client library for Python.
- MongoDB: Scalable NoSQL database for user data and bot state.
- OpenAI GPT-4o & Vision: Advanced language and vision models for text, image, and document understanding.
- Docker: Containerization for easy deployment and scaling.
- Python 3.8+: The core language powering all features and async operations.
Contributions are welcome! Check out our Contributing Guide to get started.
Development Workflow
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.