Telegram channel mirroring app
App helps mirroring newly created post from Telegram channels. We will use Telegram client API because Bot API have limited functionality.
Prepare
- Create Telegram App
- Obtain API App ID and hash
- Setup Postgres database
- Fill .env-example with your data and rename it to .env
- SESSION_STRING can be obtained by running login.py with putted API_ID and API_HASH before.
API_ID=test # Telegram app ID
API_HASH=test # Telegram app hash
SESSION_STRING=test # Telegram session string
TARGET_CHAT=test # Target chat to post
# Postgres credentials
DB_NAME=test
DB_USER=test
DB_HOST=test
DB_PASS=test
- Setup channel sources in settings.py
# use channel id more stable
# it can be fetched by using @messageinformationsbot telegram bot
# channels id always starts with -100 prefix
CHATS = (
-1001104714255,
-1001458049012,
-1001253406503,
)
# but also names usable too
CHATS = (
'@test1',
'@test2',
'@test3',
)
Deploy
Locally
- Create and activate python virtual environment
python -m venv myvenv
source myvenv/Scripts/activate # linux
myvenv/Scripts/activate # windows
- Install depencies
pip install -r requirements.txt
- Run
python telemirror.py