Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MrMissx/Telegram_Forwarder
Simple telegram bot to forward message from channel/group
https://github.com/MrMissx/Telegram_Forwarder
bot forwarder telegram telegram-bot telegram-forwarder
Last synced: about 1 month ago
JSON representation
Simple telegram bot to forward message from channel/group
- Host: GitHub
- URL: https://github.com/MrMissx/Telegram_Forwarder
- Owner: MrMissx
- License: gpl-3.0
- Created: 2020-05-11T05:07:44.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-18T06:36:31.000Z (7 months ago)
- Last Synced: 2024-08-01T15:10:37.081Z (4 months ago)
- Topics: bot, forwarder, telegram, telegram-bot, telegram-forwarder
- Language: Python
- Homepage:
- Size: 61.5 KB
- Stars: 455
- Watchers: 10
- Forks: 447
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - MrMissx/Telegram_Forwarder - Simple telegram bot to forward message from channel/group (Python)
README
# Telegram Forwarder
A simple Telegram Python bot running on Python3 to automatically forward messages from one chat to another.
## Migration from V1
v2 uses a different configuration file format. Please refer to the [Configuration](#configuration) section for more information. The bot will not start if the configuration file is not in the correct format.
## Starting The Bot
Once you've setup your your configuration (see below) is complete, simply run:
```shell
python -m forwarder
```or with poetry (recommended)
```shell
poetry run forwarder
```## Setting Up The Bot (Read the instruction bellow before starting the bot!):
Telegram Forwarder only supports Python 3.9 and higher.
### Configuration
There are two files mandatory for the bot to work `.env` and `chat_list.json`.
#### `.env`
Template env may be found in `sample.env`. Rename it to `.env` and fill in the values:
- `BOT_TOKEN` - Telegram bot token. You can get it from [@BotFather](https://t.me/BotFather)
- `OWNER_ID` - An integer of consisting of your owner ID.
- `REMOVE_TAG` - set to `True` if you want to remove the tag ("Forwarded from xxxxx") from the forwarded message.
#### `chat_list.json`
Template chat_list may be found in `chat_list.sample.json`. Rename it to `chat_list.json`.
This file contains the list of chats to forward messages from and to. The bot expect it to be an Array of objects with the following structure:
```json
[
{
"source": -10012345678,
"destination": [-10011111111, "-10022222222#123456"]
},
{
"source": "-10087654321#000000", // Topic/Forum group
"destination": ["-10033333333#654321"],
"filters": ["word1", "word2"] // message that contain this word will be forwarded
},
{
"source": -10087654321,
"destination": [-10033333333],
"blacklist": ["word3", "word4"] // message that contain this word will not be forwarded
},
{
"source": -10087654321,
"destination": [-10033333333],
"filters": ["word5"],
"blacklist": ["word6"]
// message must contain word5 and must not contain word6 to be forwarded
}
]
```- `source` - The chat ID of the chat to forward messages from. It can be a group or a channel.
> If the source chat is a Topic groups, you **MUST** explicitly specify the topic ID. The bot will ignore incoming message from topic group if the topic ID is not specified.
- `destination` - An array of chat IDs to forward messages to. It can be a group or a channel.
> Destenation supports Topics chat. You can use `#topicID` string to forward to specific topic. Example: `[-10011111111, "-10022222222#123456"]`. With this config it will forward to chat `-10022222222` with topic `123456` and to chat `-10011111111` .
- `filters` (Optional) - An array of strings to filter words. If the message containes any of the strings in the array, it **WILL BE** forwarded.
- `blacklist` (Optional) - An array of strings to blacklist words. If the message containes any of the string in the array, it will **NOT BE** forwarded.
You may add as many objects as you want. The bot will forward messages from all the chats in the `source` field to all the chats in the `destination` field. Duplicates are allowed as it already handled by the bot.
### Python dependencies
Install the necessary python dependencies by moving to the project directory and running:
```shell
poetry install --only main
```or with pip
```shell
pip3 install -r requirements.txt
```This will install all necessary python packages.
### Launch in Docker container
#### Requrements
- Docker
- docker composeBefore launch make sure all configuration are completed (`.env` and `chat_list.json`)!
Then, simply run the command:
```shell
docker compose up -d
```You can view the logs by the command:
```shell
docker compose logs -f
```### Credits
- [AutoForwarder-TelegramBot](https://github.com/saksham2410/AutoForwarder-TelegramBot)