Skip to content

TechyCSR/AdvAITelegramBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Advanced AI Telegram Bot

Python Telegram MongoDB License





A powerful AI-driven Telegram bot that brings cutting-edge artificial intelligence features to your fingertips.

✨ Features

πŸ’¬ 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

πŸš€ Quick Start

# 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

πŸ“‹ Commands

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

πŸ’‘ Inline Features

The bot offers powerful inline mode capabilities:

Inline AI Responses

Type @YourBot your question? in any chat to quickly get AI responses without leaving the conversation.

Inline Image Generation

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
  1. AI Responses: Type @YourBot What is quantum computing? in any chat
  2. Image Generation: Type @YourBot image beautiful sunset over mountains.
  3. Select the result when it appears to send it to the chat
  4. For complex queries, wait a few seconds and you'll see "Still generating..." which will update with your response
  5. 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
  6. You can use this in private chats, group conversations, or channels

πŸ—οΈ Project Structure

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

🧠 Architecture

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

πŸ› οΈ Setup Guide

System Requirements

  • Python 3.8 or higher
  • MongoDB (local or cloud instance)
  • Telegram Bot Token from BotFather
  • 1GB+ RAM recommended for image generation

Detailed Installation

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

πŸ”§ Advanced Configuration

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/"

πŸ’» Technologies

🀝 Contributing

Contributions are welcome! Check out our Contributing Guide to get started.

Development Workflow
  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘₯ Maintainers

Made with ❀️ by TechyCSR
Website β€’ Twitter β€’ LinkedIn

About

Telegram Advanced AI ChatBot: GPT-4o and Gpt-4o-mini, Dall-E Model, OCR and Google Voice2Text.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •