π¬ | 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.
The bot employs a modern, modular architecture with several key design patterns:
- π Service Container: Centralized dependency injection for clean, testable code
- π Singleton Database Service: Efficient MongoDB connection pooling
- π Model-View Pattern: Separation of data and presentation layers
- π Async Processing: Non-blocking operations for inline queries and image generation
- 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.