English | 简体中文
Forward messages between Telegram chats using a simple, file‑configured bot. Users can register themselves, add forwarding rules, list or delete their own rules, while admins can inspect users and their forwards.
- Forward channel posts or group messages from one chat to another
- High concurrency
- YAML configuration with log level and admin controls
- Python
>= 3.12 - Dependencies installed from
requirements.txtorpyproject.toml
The bot reads config.yaml at startup. On first run, if config.yaml does not exist, a default file is created and the program exits. Edit the file and restart.
Example config.yaml:
log:
level: INFO
telegram:
token: "YOUR_BOT_TOKEN"
only_admin_add_forward: false
admins: [123456789]log.level: Logging verbosity (DEBUG,INFO,WARNING,ERROR,CRITICAL).telegram.token: Bot token from BotFather.telegram.only_admin_add_forward: Iftrue, regular users cannot add forwards.telegram.admins: Telegram user IDs who are considered admins.
Needs Python 3.12 or newer.
# If uv is available
uv sync && uv run main.py
# If uv is not available
pip install -r requirements.txt
# Start the bot
python main.pyNotes:
- Invite the bot to the source and destination chats.
- For channels, ensure the bot has permission to read posts; for groups, it must be present and able to read messages.
- The first successful run initializes
data.dband creates tables.
/start— Register yourself with the bot./add <from_chat> <to_chat>— Add a forwarding rule. Example:/add -1001234567890 -1009876543210from_chatandto_chatare numeric chat IDs. Use/chat_idin a group/channel to get its ID./list— List your forwarding rules. Chat names are shown when known./del <forward_id>— Delete one of your rules by its ID./chat_id— In a group/channel, returns the chat’s numeric ID.
/list_users— Show all registered users./list_forwards <user_id>— Show all forwards for a specific user.
- Channel posts are handled and forwarded when a matching rule exists.
- Group messages are handled and forwarded when a matching rule exists.
- Private chats are ignored (aside from registration via
/start).
- SQLite database file:
data.db - Tables:
forwards(id, user_id, from_chat, to_chat)users(id, user_id, name)chats(id, chat_id, name)
- Telegram supergroup and channel IDs are typically negative numbers (e.g.,
-100...). - If forwarding does not occur, verify the bot’s permissions and the chat IDs.