A telegram bot to forward messages automatically when they arrived.

Overview

Telegram Message Forwarder Bot

A telegram bot, which can forward messages from channel, group or chat to another channel, group or chat automatically.

Deploy

Configuration

To configure this bot add the environment variables stated below. Or add them in config.env.template and change the name to config.env.

  • API_ID - Get it by creating an app on https://my.telegram.org
  • API_HASH - Get it by creating an app on https://my.telegram.org
  • BOT_TOKEN - Get it by creating a bot on https://t.me/BotFather
  • FROM_CHATS - Chat ID of the chats from where to forward messages. Seperated by space.
  • TO_CHATS - Chat ID of the chats where to forward messages. Seperated by space.
  • TELEGRAM_SESSION - (Optional) If you want to use this bot as user add the telegram session name in environment variables. Get it by running GenString and select the option 1 and follow the instructions.
  • SUDO_USERS - (Optional) Chat identifier of the sudo user. For multiple users use ; as seperator.
  • ADVANCE_CONFIG - (Optional) If you want forward message from chat A to chat B and from chat C to chat D add this value in the format given below.
CHAT_ID_A CHAT_ID_B; CHAT_ID_C CHAT_ID_D

Or if you want to forward message from chat A to chat B, C and D. And from Chat E to Chat F

CHAT_ID_A CHAT_ID_B CHAT_ID_C CHAT_ID_D; CHAT_ID_E CHAT_ID_F
     ↑       ^---------------------^         ↑         ↑ to another chat
From channel       To channel        from another channel
  • REMOVE_STRINGS - (Optional) Keywords to remove from message before forwarding. For multiple string use ; as a seperator. For example -
@username;https://t.me/username;Hey! My channel is XXxxXX
  • REPLACE_STRING - (Optional) Keyword to add in the place of REMOVE_STRING

Note

  • Supported identifier for a chat should be the chat id, username or message link.
  • Use /forward command to forward older messages. For message older than 2 days you have to login as a user and set the TELEGRAM_SESSION variable. Command usage - /forward <Chat ID/Username/Message Link> <Limit, No. of Messages to forward> <ID of the last message of from chat to avoid repetition>

Installing Requirements

Install the required Python Modules in your machine.

pip3 install -r requirements.txt

Deployment

With python3.7 or later.

python3 -m bot

Copyright & License

Comments
  • Error when forwarding poll/quiz

    Error when forwarding poll/quiz

    2021-04-11T04:01:03.790280+00:00 heroku[worker.1]: Starting process with command python3 -m bot 2021-04-11T04:01:04.649398+00:00 heroku[worker.1]: State changed from starting to up 2021-04-11T04:01:09.151090+00:00 app[worker.1]: [2021-04-11 04:01:09,150 - /app/bot/init.py - INFO] [-1001278299702] 2021-04-11T04:01:09.157193+00:00 app[worker.1]: [2021-04-11 04:01:09,151 - /app/bot/init.py - INFO] [-1001321563599] 2021-04-11T04:01:10.336203+00:00 app[worker.1]: Pyrogram v1.2.8, Copyright (C) 2017-2021 Dan https://github.com/delivrance 2021-04-11T04:01:10.336228+00:00 app[worker.1]: Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+) 2021-04-11T04:01:10.336229+00:00 app[worker.1]: 2021-04-11T04:04:44.883063+00:00 app[worker.1]: [2021-04-11 04:04:44,881 - /app/.heroku/python/lib/python3.7/site-packages/pyrogram/dispatcher.py - ERROR] 'NoneType' object has no attribute 'html' 2021-04-11T04:04:44.883089+00:00 app[worker.1]: Traceback (most recent call last): 2021-04-11T04:04:44.883090+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/pyrogram/dispatcher.py", line 223, in handler_worker 2021-04-11T04:04:44.883091+00:00 app[worker.1]: *args 2021-04-11T04:04:44.883093+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/concurrent/futures/thread.py", line 57, in run 2021-04-11T04:04:44.883093+00:00 app[worker.1]: result = self.fn(*self.args, **self.kwargs) 2021-04-11T04:04:44.883094+00:00 app[worker.1]: File "/app/bot/main.py", line 11, in work 2021-04-11T04:04:44.883094+00:00 app[worker.1]: caption = message.caption.html.replace(remove_string, replace_string) 2021-04-11T04:04:44.883095+00:00 app[worker.1]: AttributeError: 'NoneType' object has no attribute 'html' 2021-04-11T04:04:45.518226+00:00 app[worker.1]: [2021-04-11 04:04:45,517 - /app/.heroku/python/lib/python3.7/site-packages/pyrogram/dispatcher.py - ERROR] 'NoneType' object has no attribute 'html' 2021-04-11T04:04:45.518237+00:00 app[worker.1]: Traceback (most recent call last): 2021-04-11T04:04:45.518238+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/site-packages/pyrogram/dispatcher.py", line 223, in handler_worker 2021-04-11T04:04:45.518239+00:00 app[worker.1]: *args 2021-04-11T04:04:45.518240+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.7/concurrent/futures/thread.py", line 57, in run 2021-04-11T04:04:45.518240+00:00 app[worker.1]: result = self.fn(*self.args, **self.kwargs) 2021-04-11T04:04:45.518241+00:00 app[worker.1]: File "/app/bot/main.py", line 11, in work 2021-04-11T04:04:45.518241+00:00 app[worker.1]: caption = message.caption.html.replace(remove_string, replace_string) 2021-04-11T04:04:45.518242+00:00 app[worker.1]: AttributeError: 'NoneType' object has no attribute 'html'

    Please fix this.

    opened by ankit-sinha-18 7
  • Enhance logging

    Enhance logging

    In order to configure the bot, it is useful to have clear log messages.

    With this PR the logging on startup is a bit extended in order to help finding configuration issues.

    opened by tompluess 2
  • Messages not getting forwarded

    Messages not getting forwarded

    Hi,

    I was trying to set this up on Heroku.. there were no errors.. but it just sits here and the messages do not get forwarded.. is there something else that we need to do?

    Below is the extract from the logs.. let me know if you need any other details.

    2021-05-04T16:11:40.983172+00:00 heroku[worker.1]: Stopping all processes with SIGTERM 2021-05-04T16:11:41.116429+00:00 heroku[worker.1]: Process exited with status 143 2021-05-04T16:11:45.661667+00:00 heroku[worker.1]: Starting process with command python3 -m bot 2021-05-04T16:11:46.302173+00:00 heroku[worker.1]: State changed from starting to up 2021-05-04T16:11:56.164946+00:00 app[worker.1]: Pyrogram v1.2.9, Copyright (C) 2017-2021 Dan https://github.com/delivrance 2021-05-04T16:11:56.165014+00:00 app[worker.1]: Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+) 2021-05-04T16:11:56.165021+00:00 app[worker.1]: 2021-05-04T16:12:02.731343+00:00 app[worker.1]: [2021-05-04 16:12:02,731 - /app/bot/init.py - INFO] Sudo users - [11922955] 2021-05-04T16:12:02.731534+00:00 app[worker.1]: [2021-05-04 16:12:02,731 - /app/bot/init.py - INFO] [14270915] 2021-05-04T16:12:02.731671+00:00 app[worker.1]: [2021-05-04 16:12:02,731 - /app/bot/init.py - INFO] {14270915: [12629845, 13922525]}

    opened by mujahidazamcsm 2
  • [

    ["400 PEER_ID_INVALID"]

    2021-04-12T04:34:21.469747+00:00 app[worker.1]: Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+) 2021-04-12T04:34:21.469749+00:00 app[worker.1]: 2021-04-12T04:34:32.222167+00:00 app[worker.1]: [2021-04-12 04:34:32,221 - /app/bot/main.py - ERROR] [400 PEER_ID_INVALID]: The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it

    I have logged in as a user I got this error when the FROM_CHATS Id is of CHANNEL_ID, and TO_CHATS id is of my another Telegram account ID After getting this issue in logs,I send a message to my another account,and when file received in FROM_CHATS Channel id,it send to my another Telegram account.

    Is this step necessary (sending a random message to my another Telegram account) Everytime, whenever bot restarts??

    opened by ankit-sinha-18 1
  • İnstalL not found?

    İnstalL not found?

    Hi. İm noob :) İ can speak english a little :)

    python3 install -r requirements.txt

    python3: can't open file '/data/data/com.termux/files/home/telegram-message-forwarder-bot/install': [Errno 2] No such file or directory

    opened by InglorNenha 0
  • Forward media of a message

    Forward media of a message

    New Telegram privacy option in channels doesn't allow to resend media. You need to download the media and upload them to telegram back, so you will be able to forward message with media from channel with protected content.

    opened by nkuznetsow 0
  • sqlite3.OperationalError: unable to open database file

    sqlite3.OperationalError: unable to open database file

    On my computer, I can't work.

    [...]
      File "C:\Users\---\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyrogram\storage\file_storage.py", line 58, in open
        self.conn = sqlite3.connect(str(path), timeout=1, check_same_thread=False)
    sqlite3.OperationalError: unable to open database file
    
    opened by lithoykai 0
  • Why does he say there is no bot file

    Why does he say there is no bot file

    Traceback (most recent call last): File "C:\Users\ll\Desktop\telegram-message-forwarder-bot-main\bot_init_.py", line 7, in from bot.helper.utils import get_formatted_chats ModuleNotFoundError: No module named 'bot'

    opened by yundaji 0
  • Unable to deploy on my local machine

    Unable to deploy on my local machine

    I'm trying to deploy it on my pc but I couldn't pip 22.2.2 from c:\python\python37\lib\site-packages\pip (python 3.7) I've got this:

    C:\Users\xxxx\Documents\GitHub\Telegram-signal-forwarder\telegram-message-forwarder-bot>python -m bot [2022-08-12 13:10:00,202 - C:\Users\xxxx\Documents\GitHub\Telegram-signal-forwarder\telegram-message-forwarder-bot\bot_init_.py - INFO] Welcome, this is the telegram-message-forwarder-bot. initializing... [2022-08-12 13:10:00,202 - C:\Users\xxxx\Documents\GitHub\Telegram-signal-forwarder\telegram-message-forwarder-bot\bot_init_.py - INFO] Bot Mode Traceback (most recent call last): File "C:\Python\Python37\lib\runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "C:\Python\Python37\lib\runpy.py", line 142, in _get_module_details return _get_module_details(pkg_main_name, error) File "C:\Python\Python37\lib\runpy.py", line 109, in get_module_details import(pkg_name) File "C:\Users\xxxx\Documents\GitHub\Telegram-signal-forwarder\telegram-message-forwarder-bot\bot_init.py", line 63, in with app: File "C:\Python\Python37\lib\site-packages\pyrogram\client.py", line 280, in enter return self.start() File "C:\Python\Python37\lib\site-packages\pyrogram\sync.py", line 66, in async_to_sync_wrap return loop.run_until_complete(coroutine) File "C:\Python\Python37\lib\asyncio\base_events.py", line 587, in run_until_complete return future.result() File "C:\Python\Python37\lib\site-packages\pyrogram\methods\utilities\start.py", line 58, in start is_authorized = await self.connect() File "C:\Python\Python37\lib\site-packages\pyrogram\methods\auth\connect.py", line 40, in connect await self.load_session() File "C:\Python\Python37\lib\site-packages\pyrogram\client.py", line 563, in load_session await self.storage.open() File "C:\Python\Python37\lib\site-packages\pyrogram\storage\file_storage.py", line 56, in open file_exists = path.is_file() File "C:\Python\Python37\lib\pathlib.py", line 1387, in is_file return S_ISREG(self.stat().st_mode) File "C:\Python\Python37\lib\pathlib.py", line 1183, in stat return self._accessor.stat(self)

    opened by omidta 0
  • delay option

    delay option

    hello,

    can we have a delay option? so for example if multiple message are posted in "from chat" it should not flood "to chat" and should send with few seconds delay between messages

    thanks

    opened by somedevreally 0
Releases(v0.1.0)
Owner
Adnan Ahmad
Currently learning Python, Bash, HTML, CSS, BootStrap and JavaScript. Remember ! Everyone starts with Zero.
Adnan Ahmad
Python function to construct an ODS spreadsheet on the fly - without having to store the entire file in memory or disk

stream-write-ods Python function to construct an ODS (OpenDocument Spreadsheet) on the fly - without having to store the entire file in memory or disk

Department for International Trade 1 Oct 09, 2022
A Python script for rendering glTF files with V-Ray App SDK

V-Ray glTF viewer Overview The V-Ray glTF viewer is a set of Python scripts for the V-Ray App SDK that allow the parsing and rendering of glTF (.gltf

Chaos 24 Dec 05, 2022
Jupyter notebooks and AWS CloudFormation template to show how Hudi, Iceberg, and Delta Lake work

Modern Data Lake Storage Layers This repository contains supporting assets for my research in modern Data Lake storage layers like Apache Hudi, Apache

Damon P. Cortesi 25 Oct 31, 2022
A Python API wrapper for the Twitter API!

PyTweet PyTweet is an api wrapper made for twitter using twitter's api version 2! Installation Windows py3 -m pip install PyTweet Linux python -m pip

TheFarGG 1 Nov 19, 2022
An API wrapper around the pythonanywhere's API.

pyaww An API wrapper around the pythonanywhere's API. The name stands for pythonanywherewrapper. 100% api coverage most of the codebase is documented

7 Dec 11, 2022
szrose is an all in one group management bot made for managing your group effectively with some advance security tools & Suit For All Your Needs ❤️

szrose is an all in one group management bot made for managing your group effectively with some advance security tools & Suit For All Your Needs ❤️

szsupunma 93 Jan 07, 2023
An API wrapper for Discord written in Python.

disnake A modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python. About disnake All the contributors and develop

557 Jan 05, 2023
A simple API wrapper for the Tenor API

Gifpy A simple API wrapper for the Tenor API Installation Python 3.9 or higher is recommended python3 -m pip install gifpy Clone repository: $ git cl

Juan Ignacio Battiston 4 Dec 22, 2021
This will create new discord accounts and add them to your server

Discord-Botter This tool will create new discord accounts add them to your server, this tool needs a captcha api like capmonster.cloud or anti-captcha

Shahzain 27 Nov 30, 2022
Python script to replace BTC adresses in the clipboard with similar looking ones, whose private key can be retrieved by a netcat listener or similar.

BTCStealer Python script to replace BTC adresses in the clipboard with similar looking ones, whose private key can be retrieved by a netcat listener o

Some Person 6 Jun 07, 2022
This is a telegram bot built using the Oxford Dictionary API

Oxford Dictionaries Telegram Bot This is a telegram bot built using the Oxford Dictionary API Source: Oxford Dictionaries API Documentation Install En

Abhijith N T 2 Mar 18, 2022
Clash of Clans v6.253 private server written in python

cocps Clash of Clans v6.253 private server written in python how2play download server files download Patched APK run Main.py and play Authors Patched

5 Aug 28, 2022
Aws-cidr-finder - A Python CLI tool for finding unused CIDR blocks in AWS VPCs

aws-cidr-finder Overview An Example Installation Configuration Contributing Over

Cooper Walbrun 18 Jul 31, 2022
Scrapes an instagram user's photos and videos

Instagram Scraper instagram-scraper is a command-line application written in Python that scrapes and downloads an instagram user's photos and videos.

7.3k Nov 18, 2022
SMAM2 is a package manager built specifically for SourceMod.

SourceMod Addon Manager 2 (SMAM2) SMAM2 is a package manager built specifically for SourceMod. This was heavily inspired by Phil25's SMAM. I thought t

John Mascagni 6 Sep 16, 2022
A smart tool to backup members 📈 So you even after a raid/ ban you can easily restore them in seconds 🎲

🤑 Discord-backer 🤑 A open-source Discord member backup and restore tool for your server. This can help you get all your members in 5 Seconds back af

John 29 Dec 21, 2022
TypeRig is a Python library aimed at simplifying the current FontLab API

TypeRig TypeRig is a Python library aimed at simplifying the current FontLab API while offering some additional functionality that is heavily biased t

Vassil Kateliev 41 Nov 02, 2022
An EmbedBuilder for Discord bots in Python.

An EmbedBuilder for Discord bots in Python. You need discord.py to use this module.

6 Jan 13, 2022
Telegram bot to provide Telegram user/group/channel information

Whois-TeLeTiPs Telegram bot to provide Telegram user/group/channel information Deployment Methods Heroku Config Vars API_ID : Telegram API_ID, get it

11 Oct 21, 2022
Data and a Twitter bot for the EPA's DOCUMERICA (1972-1977) program.

documerica This repository holds JSON(L) artifacts and a few scripts related to managing archival data from the EPA's DOCUMERICA program. Contents: Ma

William Woodruff 2 Oct 27, 2021