Relaygram is a multilingual Telegram relay bot that forwards messages from one channel to another and saves attached files locally.
This project automatically monitors a Telegram channel to:
- Download any attached files
- Forward all new messages (whether they contain files or not) to another channel
It is built with Python using the Telethon library and supports Docker deployment.
The interface messages (CLI outputs) are multilingual and controlled via the LANG variable in your .env file.
LANG=frfor FrenchLANG=enfor English
The default language is French if not specified.
Before using the bot, you need to generate a persistent Telegram session.
- Go to https://my.telegram.org
- Create an app to get your
API_IDandAPI_HASH - On the first launch, the script will guide you to generate a
StringSession:- Enter your phone number
- Enter the code you receive by SMS or Telegram
- Copy the generated session string
- Paste it into the
.envfile underSESSION_STRING
This session will be reused automatically on each launch.
You can choose between two modes using the MODE variable in .env:
- Displays a terminal menu with a list of your channels
- You manually select the source channel to monitor
- The destination channel is defined in
.env
- Both source and destination channels are set in
.env - No user interaction is needed
- Ideal for automated server deployment
generate_session.py: generates the StringSessionmain.py: main bot scriptstart.py: entrypoint that checks for session and launches the right scriptlang.py: contains multilingual CLI messagesdownloads/: where received files are saved.env: environment configuration (not versioned).env.example: configuration templateDockerfile: defines the Docker imagedocker-compose.yml: simplifies containerized executionREADME.md: this documentation
Required variables:
API_ID: your Telegram app IDAPI_HASH: your Telegram app hashSESSION_STRING: persistent session stringMODE: eitherdevorprodSOURCE_CHANNEL_ID: source channel ID (used only in prod)TARGET_CHANNEL_ID: destination channel ID (used in both modes)LANG:froren(optional)
Run this only once, or after modifying the Dockerfile:
docker compose buildRun the bot in development mode. You'll be able to choose the source channel manually:
docker compose run --rm relaygramRun the bot in production mode using .env configuration, with no user interaction:
docker compose up -d- Authentication happens only once: the Telegram session is saved.
- You must be a member of both source and destination channels.
- Only new messages are forwarded – history is not retrieved.