This bot sends images to specific topics (threads) in a Telegram group using the Bot API.
-
Step 1: Add your bot to your desired Telegram group.
-
Step 2: Promote the bot to Administrator with permission to:
- Send messages
- Read all messages
Edit the config.toml
file with the following required settings:
bot_token = "YOUR_BOT_TOKEN"
chat_id = "@your_group_username_or_chat_id"
folder_path = "path_to_image_folder"
max_retries = 3
timeout = 20
time_between_retries = 3
resize_max_dimension = 4096
resize_min_dimension = 320
allowed_extensions = [".jpg", ".jpeg", ".png", ".gif", ".bmp"]
[topics]
# This section will be filled automatically after running `get_topics.py`
📁 In the folder_path
directory:
- Create one folder per topic
- Place relevant images inside each corresponding folder
Example structure:
images/
📄 topic1/
image1.jpg
image2.jpg
📄 topic2/
image3.jpg
image4.jpg
Run the following script after sending an initial message in each group topic:
python3 get_topics.py
This script:
- Calls Telegram's
getUpdates
endpoint - Finds topic names and thread IDs
- Updates the
[topics]
section in yourconfig.toml
Once the config is ready and topics are mapped:
python3 main.py
The bot will:
- Resize images if needed
- Send each image as both photo and document to its corresponding topic
- Retry failed messages (based on config)
Install dependencies using pip
:
pip install -r requirements.txt
- Only
.jpg
,.png
,.gif
,.bmp
, and.jpeg
are supported. - Images are resized based on
resize_max_dimension
andresize_min_dimension
before sending..
MIT License
A Telegram automation enthusiast — powered by Python 🐍