π¬ | AI Chat Natural conversations powered by GPT-4o |
π¨ | Image Generation Create stunning images from text descriptions |
π | Voice Processing Two-way voice message and text conversion |
π | Text Extraction Extract text from any image with OCR |
π | Multi-language Support Communicate in your preferred language |
π₯ | Group Integration Full AI functionality in group chats |
π± | Inline Mode Generate AI responses and images in any chat |
β‘ | Fast Response Optimized for quick, efficient interactions |
π± 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 |
/generate [prompt] |
π¨ Generate an image from text |
/newchat |
π Clear conversation history |
/settings |
βοΈ Adjust bot preferences |
/rate |
β Rate your experience |
/clear_cache |
π§Ή Clear your stored images |
The bot offers powerful inline mode capabilities:
Type @YourBot your question?
in any chat to quickly get AI responses without leaving the conversation.
Type @YourBot image your description.
to generate and share images instantly in any chat.
Pro Tip: End your AI queries with .
or ?
and your image prompts with .
to trigger generation. If the response takes time, simply add a space every 5-7 seconds to refresh the query without losing your prompt.
How to use inline mode effectively
- AI Responses: Type
@YourBot What is quantum computing?
in any chat - Image Generation: Type
@YourBot image beautiful sunset over mountains.
- Select the result when it appears to send it to the chat
- For complex queries, wait a few seconds and you'll see "Still generating..." which will update with your response
- If no response appears: Add a space after your prompt every 5-7 seconds to refresh the query while maintaining your place in the generation queue
- You can use this in private chats, group conversations, or channels
Click to expand folder structure
AdvAITelegramBot/
βββ modules/ # Core application modules
β βββ core/ # Core infrastructure components
β β βββ database.py # DatabaseService with connection pooling
β β βββ service_container.py # Dependency injection container
β βββ models/ # Data models and services
β β βββ ai_res.py # AI conversation functionality
β β βββ user_db.py # User data operations
β β βββ inline_ai_response.py # Inline mode AI responses
β β βββ image_service.py # Image generation and management
β βββ user/ # User interaction modules
β β βββ start.py # Bot start and onboarding
β β βββ settings.py # User settings management
β β βββ help.py # Help and documentation
β β βββ commands.py # Command handling
β β βββ assistant.py # Assistant mode settings
β β βββ lang_settings.py # Language preferences
β β βββ user_support.py # User support functionality
β βββ group/ # Group chat functionality
β β βββ group_info.py # Group information
β β βββ group_settings.py # Group configuration
β β βββ new_group.py # New group handling
β βββ image/ # Image processing components
β β βββ img_to_text.py # OCR and text extraction
β β βββ image_generation.py # Image generation from prompts
β β βββ inline_image_generation.py # Inline mode image generation
β βββ speech/ # Voice processing components
β β βββ voice_to_text.py # Speech recognition
β β βββ text_to_voice.py # Text-to-speech conversion
β βββ chatlogs.py # Logging user interactions
β βββ feedback_nd_rating.py # User feedback system
β βββ lang.py # Language translation
β βββ maintenance.py # Maintenance utilities
βββ database/ # Database configuration
βββ generated_images/ # Local storage for generated images
βββ sessions/ # Pyrogram session files
βββ logs/ # Application logs
βββ assets/ # Static assets
βββ ImgGenModel/ # Image generation models
βββ run.py # Main application entry point
βββ config.py # Configuration settings
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container configuration
βββ LICENSE # MIT License
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
OCR_KEY = "your_ocr_space_api_key" # From ocr.space
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 Telegram client library
- MongoDB: NoSQL database for user data
- GPT-4o: Advanced language model
- OCR.space: Text extraction API
- Various Image Generators: High-quality AI image creation
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.