Telegram bot which will forward a message from a channel/chat to another chat.
Requires Telethon
# Install Telethon
$ pip3 install -U telethon --user
# Verify Telethon's version:
$ python3 -c "import telethon; print(telethon.__version__)"
The script requires your Telegram API keys.
- Proceed to https://my.telegram.org
- Enter your phone number and confirmation code.
- Click on API development tools -> App configuration
- Copy App api_id and App api_hash
# Telegram 'api_id' Key
API_ID = environ['API_ID']
# Telegram 'api_hash' Key
API_HASH = environ['API_HASH']
# Channel/Chat's name for incoming messages
GROUP = environ['GROUP']
# The recipient of the message. @username or me
RECIPIENT = environ['RECIPIENT']
# [OPTIONAL] Embed your login credentials.
SESSION = environ['SESSION']
with TelegramClient(StringSession(), API_ID, API_HASH) as client:
print(client.session.save())