Forward messages that match a specific pattern from multiple Telegram chats to one or more chats.
- Docker
-
Pull the Docker image from the DockerHub:
docker pull aleg94/telegram-forwarder
-
Create a Telegram session by getting developer's api id and api hash from here and running the command:
docker run -it --rm aleg94/telegram-forwarder python ./scripts/create_session.py --api-id <api-id> --api-hash <api-hash>
Follow the on-screen instructions and enter your confirmation code and password (if two-factor authentication is enabled).
-
Run the image in a container providing the following environment variables:
API_ID
: the api id associated with your Telegram accountAPI_HASH
: the api hash associated with your Telegram accountSESSION
: the session obtained in step 2INPUT_CHATS
: comma separated list of chat's ids or usernames that you'd like to forward messages from (must be present on dialogs)OUTPUT_CHATS
: comma separated list of chat's ids or usernames that you'd like to forward messages to (must be present on dialogs)MESSAGE_PATTERN
: a regular expression that messages must match to be forwarded
docker run --name telegram_forwarder -d -e API_ID=<api-id> -e API_HASH=<api-hash> -e SESSION=<session> -e INPUT_CHATS=<id1>,<username2> -e OUTPUT_CHATS=<username3>,<id4> -e MESSAGE_PATTERN=<regex> aleg94/telegram-forwarder