You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AdvancedChannelBot is a versatile Telegram bot designed to interact with users through text and image messages, leveraging the power of Google's Generative AI.
## 🌟 Intelligent Telegram Bot powered by Google Gemini AI 🌟
8
8
9
-
This bot is built to be easily extensible, providing a solid foundation for more advanced features. It's structured to handle different types of content and can be customized to fit various needs. The core of the bot uses the `pyTelegramBotAPI` library for interacting with the Telegram API and `google-generativeai` for intelligent responses.
9
+
AdvancedChannelBot is a versatile and intelligent Telegram bot designed to interact with users through a rich set of features, leveraging the cutting-edge capabilities of **Google's Gemini AI**. This bot brings multimodal communication (text, voice, images) and real-time information directly into your Telegram chats, all while being easily customizable and deployable.
10
10
11
-
### Features
11
+
##✨ About The Project
12
12
13
-
***Command Handling**: Responds to predefined commands (e.g., `/example`).
14
-
***Text Message Processing**: Handles plain text messages for interactive chat.
15
-
***Image Processing**: Can receive and process photo messages.
16
-
***AI Integration**: Utilizes Google Gemini for advanced AI capabilities.
17
-
***Asynchronous**: Built with `asyncio` for efficient, non-blocking operation.
13
+
This project provides a robust and extensible foundation for building a highly interactive Telegram bot. It's structured for clear separation of concerns, making it easy to understand, maintain, and expand with new functionalities. The core communication is handled by `pyTelegramBotAPI`, while `google-generativeai` powers the advanced AI features.
18
14
19
-
Customization:
15
+
### Key Features
20
16
21
-
You have full control over how your bot behaves and responds!
17
+
***Intelligent Conversations**: Engage in natural, context-aware dialogues thanks to the powerful **Google Gemini AI**.
18
+
***Multimodal Interaction**: Processes and responds to both **text messages** and **voice messages**. It can also **analyze and describe uploaded images**.
19
+
***Image Generation**: Request the bot to **generate creative images** based on your text prompts (functionality depends on the specific Gemini model's capabilities and API access).
20
+
***Real-time Market Data**: Get instant updates on **stock prices** and **cryptocurrency values**.
21
+
***Hourly News Briefs**: Stay informed with periodic news summaries delivered directly to your chat.
22
+
***Customizable Persona & Responses**: Tailor the bot's personality, tone, and specific response styles.
23
+
***Dynamic Model Switching**: Flexibly switch between different Gemini models (e.g., `gemini-2.0-flash-exp` and `gemini-1.5-pro`) for varied performance.
24
+
***User-Specific Logging & Summaries**: All user interactions are logged individually, summarized daily, and retained for a configurable period, providing insights into bot usage.
25
+
***Asynchronous Operations**: Built with `asyncio` for efficient, non-blocking performance, ensuring a smooth user experience.
22
26
23
-
Edit Bot's Role & Personality: In the config folder, open bot_role_settings.json. Here, you can easily define the bot's name, its core role, and even adjust its "kindness" (which can influence its tone, e.g., "criminal" for a more mischievous or bold persona).
27
+
### 🛠️ Customization
24
28
25
-
JSON
29
+
You have full control over how your bot behaves, its personality, and how it fine-tunes AI responses!
26
30
27
-
{
28
-
"name": "AZAMAT",
29
-
"role": "Generiere die Antwort wie folgt: Du bist ein Bot, der drauf programmiert worden ist.",
30
-
"kindness": "criminal"
31
-
}
32
-
Adjust AI Generation Settings: Also in the config folder, you'll find generation_config.json. This file lets you fine-tune the Gemini AI's output. For example, temperature controls randomness (lower for more focused, higher for more creative), top_p and top_k influence the diversity of generated tokens, and max_output_tokens limits the response length.
31
+
***Bot's Role & Personality:**
32
+
In the `config` folder, open `bot_role_settings.json`. Here, you can define the bot's name, its core role, and even adjust its "kindness" to influence its tone (e.g., "criminal" for a more mischievous or bold persona).
33
33
34
-
JSON
34
+
```json
35
+
{
36
+
"name": "AZAMAT",
37
+
"role": "Generiere die Antwort wie folgt: Du bist ein Bot, der drauf programmiert worden ist.",
38
+
"kindness": "criminal"
39
+
}
40
+
```
35
41
36
-
{
37
-
"temperature": 0,
38
-
"top_p": 1,
39
-
"top_k": 1,
40
-
"max_output_tokens": 50
41
-
}
42
+
* **AI Generation Settings:**
43
+
Also in the `config` folder, you'll find `generation_config.json`. This file lets you fine-tune the Gemini AI's output. Parameters like `temperature` control randomness (lower for more focused, higher for more creative), `top_p` and `top_k` influence the diversity of generated tokens, and `max_output_tokens` limits the response length.
42
44
43
-
## Getting Started
45
+
```json
46
+
{
47
+
"temperature": 0,
48
+
"top_p": 1,
49
+
"top_k": 1,
50
+
"max_output_tokens": 50
51
+
}
52
+
```
44
53
45
-
To get a local copy up and running, follow these simple steps.
54
+
## 🚀 Getting Started
46
55
47
-
### Prerequisites
48
-
49
-
You need to have Python installed on your system. This project relies on several Python libraries. You can install them using pip:
The bot requires API keys forboth Telegram and Google Gemini. These are managedin a secrets_user.py file. Create this file in the root directory and add your keys as follows:
66
-
67
-
Python
56
+
Follow these simple steps to get a local copy of the bot up and running.
68
57
69
-
# secrets_user.py
70
-
access_secrets = {
71
-
"telegram_bot_token": "YOUR_TELEGRAM_BOT_TOKEN",
72
-
"GOOGLE_GEMINI_KEY": "YOUR_GOOGLE_GEMINI_API_KEY"
73
-
}
74
-
You can get a Telegram Bot Token by talking to the BotFather.
75
-
You can obtain a Google Gemini API Key from the Google AI Studio.
76
-
Usage
77
-
Once the bot is configured, you can start it by running the main.py script:
78
-
79
-
Bash
58
+
### Prerequisites
80
59
60
+
Ensure you have the following installed on your system:
61
+
62
+
* **Python 3.9+**: The project is developed with recent Python versions.
63
+
* **pip**: Python's package installer.
64
+
* **ffmpeg**: Required for processing voice messages.
65
+
* **Windows:** Download from [ffmpeg.org](https://ffmpeg.org/download.html) and add to PATH.
3. **Set up Python Virtual Environment (Recommended):**
85
+
86
+
```bash
87
+
python -m venv .venv
88
+
# On Windows:
89
+
.\.venv\Scripts\activate
90
+
# On Linux/macOS:
91
+
source ./.venv/bin/activate
92
+
```
93
+
94
+
4. **Install Python Libraries:**
95
+
96
+
```bash
97
+
pip install -r requirements.txt
98
+
```
99
+
*A `requirements.txt` file (to be created by you based on your `pyproject.toml` dependencies, or using `pip freeze > requirements.txt` after installing) should include:*
100
+
`pyTelegramBotAPI`
101
+
`google-generativeai`
102
+
`yfinance`
103
+
`requests`
104
+
`beautifulsoup4`
105
+
`md2tgmd`
106
+
`vosk`
107
+
`Pillow`
108
+
109
+
5. **Configure Vosk Speech Recognition Model (within Dockerfile or manually if not using Docker):**
110
+
The bot uses the Vosk German model for voice message processing. This is typically handled during the Docker build process if using the provided Docker setup. If running locally without Docker, ensure this model is downloaded and correctly placed:
111
+
112
+
```bash
113
+
# (Inside your project root, e.g., in a 'data' directory)
The bot requires API keys for both Telegram and Google Gemini. These are managed in a `secrets_user.py` file. Create this file in the **root directory** of your project and add your keys as follows:
125
+
126
+
```python
127
+
# secrets_user.py
128
+
access_secrets = {
129
+
"telegram_bot_token": "YOUR_TELEGRAM_BOT_TOKEN",
130
+
"GOOGLE_GEMINI_KEY": "YOUR_GOOGLE_GEMINI_API_KEY"
131
+
}
132
+
```
133
+
* You can get a **Telegram Bot Token** by talking to the official `@BotFather` on Telegram.
134
+
* You can obtain a **Google Gemini API Key** from the [Google AI Studio](https://aistudio.google.com/app/apikey).
135
+
136
+
### ▶️ Usage
137
+
138
+
Once the bot is configured, you can start it by running the `main.py` script:
139
+
140
+
```bash
81
141
python main.py
82
-
The bot will start polling for new messages. You can interact with it on Telegram:
83
-
84
-
Send /example: The bot will reply with a simple help message.
85
-
Send any text: The bot will process the text using the text_handler.
86
-
Send a photo: The bot will process the image using the image_handler.
87
-
Project Structure
142
+
The bot will start polling for new messages. You can interact with it on Telegram using the following types of messages and commands:
143
+
144
+
/start: Initiates a conversation and gets a welcome message from Azamat.
145
+
/switch: Toggles between the primary and alternative Gemini models.
146
+
Text Messages: Send any text for intelligent replies.
147
+
Voice Messages: Send a voice note, and the bot will transcribe and respond.
148
+
Photos: Send a photo for the bot to analyze and describe.
149
+
Stock/Crypto Queries: Type a stock ticker (e.g., AAPL) or cryptocurrency keyword (e.g., Bitcoin price) to get current market data.
150
+
Image Generation Requests: Use prompts like "Gen Pic [your description]" (e.g., Gen Pic a cute cat playing with yarn) to generate images.
151
+
📁 Project Structure
88
152
AdvancedChannelBot/
89
-
│
90
153
├── core/
91
154
│ ├── handlers/
92
155
│ │ ├── __init__.py
93
-
│ │ ├── text_handler.py
94
-
│ │ └── image_handler.py
95
-
│ └── bot.py
156
+
│ │ ├── command_handler.py # Handles specific bot commands like /start, /switch
157
+
│ │ ├── image_handler.py # Logic for processing image messages
158
+
│ │ ├── query_handler.py # Logic for handling stock/crypto and general queries
159
+
│ │ ├── text_handler.py # Logic for handling general text messages
160
+
│ │ └── voice_handler.py # Logic for handling voice messages
161
+
│ ├── services/
162
+
│ │ ├── __init__.py
163
+
│ │ ├── gemini_service.py # Interfaces with Google Gemini API for text, multimodal, and image generation
│ └── bot.py # Main bot initialization and handler registration (might be merged into main.py)
170
+
│
171
+
├── config/
172
+
│ ├── __init__.py # Package initializer, can hold global config
173
+
│ ├── bot_role_settings.json # JSON file for bot's persona customization
174
+
│ ├── config.py # Main configuration dictionary (e.g., `conf`)
175
+
│ └── generation_config.py # AI generation parameters (e.g., temperature, top_k)
96
176
│
97
-
├── main.py
98
-
└── secrets_user.py
99
-
main.py: The entry point for starting the bot.
100
-
core/: Contains the core logic of the bot.
101
-
handlers/: Modules for handling different message types.
102
-
text_handler.py: Logic for handling text messages.
103
-
image_handler.py: Logic for handling image messages.
104
-
secrets_user.py: (You must create this) Stores your secret API keys.
105
-
Contributing
177
+
├── data/ # Directory for storing data (e.g., Vosk models)
178
+
│ └── vosk-model-de-0.21/ # Vosk German speech recognition model files
179
+
│
180
+
├── logs/ # Directory for user-specific interaction logs
181
+
├── summaries/ # Directory for daily log summaries
182
+
├── .dockerignore # Specifies files/folders to ignore when building Docker images
183
+
├── Dockerfile # Dockerfile for building the bot's Docker image
184
+
├── docker-compose.yml # Docker Compose file for easy multi-service deployment
185
+
├── main.py # The primary entry point for starting the bot
186
+
├── requirements.txt # Python dependencies
187
+
├── secrets_user.py # (You must create this) Stores your sensitive API keys
188
+
└── README.md # This README file
189
+
🙏 Contributing
106
190
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
107
191
192
+
If you have a suggestion that would make this better, please fork the repo and create a pull request. Don't forget to give the project a star! Thanks again!
193
+
108
194
Fork the Project
109
195
Create your Feature Branch (git checkout -b feature/AmazingFeature)
110
196
Commit your Changes (git commit -m 'Add some AmazingFeature')
111
197
Push to the Branch (git push origin feature/AmazingFeature)
112
198
Open a Pull Request
113
-
License
199
+
📄 License
114
200
Distributed under the MIT License. See LICENSE for more information.
0 commit comments