A powerful, interactive Telegram bot that leverages Google's Gemini API to provide:
- Text-based AI responses
- Image generation
- Voice message transcription and replies
- User access control (admin-restricted)
- 🧠 Chat with Gemini 1.5 Pro
- 🎨 Generate images using Gemini 2.0 Flash
- 🎤 Voice-to-text transcription and AI responses
- 🔒 Access control (admin-only and authorized users)
- 🔧 Command handlers for management
- 📂 Logs all activity to
telegram_bot.log
- Python 3.9+
- Telegram Bot Token
- Google Gemini API Key
- Admin Telegram User ID
- Clone the repository:
git clone https://github.com/yourusername/gemini-telegram-bot.git
cd gemini-telegram-bot
- Install dependencies:
pip install -r requirements.txt
- Set environment variables:
export TELEGRAM_TOKEN="your-telegram-bot-token"
export GEMINI_API_KEY="your-google-gemini-api-key"
export ADMIN_USER_ID="your-telegram-user-id"
Optionally, use a .env
file with python-dotenv for easier config.
python bot.py
The bot will start in long-polling mode.
Command | Description |
---|---|
/start |
Welcome message and usage instructions |
/help |
Help message with tips |
/image |
Generate an image from a description |
/whoami |
Display your user ID and authorization status |
/auth <id> |
(Admin only) Authorize a user ID |
/revoke <id> |
(Admin only) Revoke access from a user ID |
/users |
(Admin only) List authorized users |
- Only users listed in
authorized_users.json
can interact with the bot. - The admin can add or revoke users using
/auth
and/revoke
.
Text Response:
User: "What's the capital of France?" Bot: "💬 You asked: 'What's the capital of France?' 🤖 Response: Paris is the capital of France 🇫🇷"
Image Generation:
/image a futuristic city skyline at sunset in cyberpunk style
Voice Message:
Send a voice clip — Bot will transcribe and respond intelligently.
- All logs are stored in
telegram_bot.log
for auditing and debugging.
MIT License. Feel free to modify and share.
Built by @alwalid54321
Feel free to contribute, fork, or give feedback!