leekeifuture / telegram-mirror

Telegram client for forwarding incoming messages to Saved Messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Telegram channel mirroring app

App helps make telegram channel mirror. We will use Telegram client API because Bot API have limited functionality.

Functionality

  1. Catching NewMessage and MessageEdited event and sending them forward
  2. Flexible source and target channels mapping

Prepare

  1. Create Telegram App
  2. Obtain API App ID and hash Telegram API Credentials
  3. Setup Postgres database
  4. Fill .env-example with your data and rename it to .env
    1. 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
# Mapping between source and target channels
# Channel id can be fetched by using @messageinformationsbot telegram bot
# and it always starts with -100 prefix
# [id1, id2, id3:id4] means send messages from id1, id2, id3 to id4
# id5:id6 means send messages from id5 to id6
# [id1, id2, id3:id4];[id5:id6] semicolon means AND
CHAT_MAPPING=[-100999999,-100999999,-100999999:-1009999999];
TIMEOUT_MIRRORING=0.1 # Delay in sec between sending or editing messages
REMOVE_URLS=false   # Apply removing URLs on messages
# Remove URLs whitelist
REMOVE_URLS_WL=youtube.com,youtu.be,vk.com,twitch.tv,instagram.com
# Postgres credentials
DATABASE_URL=postgres://user:pass@host/dbname
# or
DB_NAME=test
DB_USER=test
DB_HOST=test
DB_PASS=test

Deploy

Locally

  1. Create and activate python virtual environment
python -m venv myvenv
source myvenv/Scripts/activate # linux
myvenv/Scripts/activate # windows
  1. Install depencies
pip install -r requirements.txt
  1. Run
python app/telemirror.py

Heroku

Deploy

or

  1. Clone project
    git clone https://github.com/khoben/telemirror.git
  1. Create new heroku app within Heroku CLI
    heroku create {your app name}
  1. Add heroku remote
    heroku git:remote -a {your app name}
  1. Set environment variables to your heroku app from .env by running .bash script
    ./.bash
  1. Upload on heroku host
    git push heroku master
  1. Start heroku app
    heroku ps:scale run=1

About

Telegram client for forwarding incoming messages to Saved Messages

License:GNU General Public License v3.0


Languages

Language:Python 98.1%Language:Dockerfile 1.2%Language:Shell 0.6%Language:Procfile 0.2%