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
This is a script to forward forward large number of documents to another telegram channel.

ChannelForward ?? This is a Script to Forward Large Number of Documents to Another Telegram Channel. If You Try to Forward Very Large Number of Files

Anjana Madushanka 10 Jun 8, 2021
A simple telegram bot to help you to remove forward tag from post from any messages . Maded in python3 using @Pyrogram . Developed by @Kunal-Diwan

Frwd-Tag-Remover Telegram Bot to Remove forward tag from any Post . If you need any more modes in repo or If you find out any bugs, mention in @Develo

Kunal Diwan 2 Oct 14, 2022
Andrei 1.4k Dec 24, 2022
A Telegram Bot for adding Footer caption beside main caption of Telegram Channel Messages.

Footer-Bot A Telegram Bot for adding Footer caption beside main caption of Telegram Channel Messages. Best for Telegram Movie Channels. Made by @AbirH

Abir Hasan 35 Jan 2, 2023
A Telegram bot to send messages in Telegram groups or Channels using bots anonymously.

Group-chatting-bot A bot to send messeges to group using bot telegram bot ❤️ Support Made with Python3

Pyrogramers 16 Nov 6, 2022
A telegram bot does not allow channels to send messages to the telegram supergroup

Channel Message Handler Getting started Installation $ git clone https://github.com/AbhijithNT/GroupChannelHandler.git Change directory $ cd ChannelMe

Abhijith N T 0 Dec 26, 2021
(@Tablada32BOT is my bot in twitter) This is a simple bot, its main and only function is to reply to tweets where they mention their bot with their @

Remember If you are going to host your twitter bot on a page where they can read your code, I recommend that you create an .env file and put your twit

null 3 Jun 4, 2021
A simple telegram bot to forward files from one channel to other.

Forward_2.0 Bot to forward messages from one channel to other without admin permission in source channel. Can be used for both private and Public chan

SUBIN 56 Dec 29, 2022
A simple Telegram bot that can broadcast messages and media to the bot subscribers. with mongo DB support

?????????????????? ?????? A simple Telegram bot that can broadcast messages and media to the bot subscribers using MongoDB. Features Support mongodb.c

N A C BOTS 70 Jan 2, 2023
Force-Subscribe-Bot - A Telegram Bot to force users to join a specific channel before sending messages in a group

Introduction A Telegram Bot to force users to join a specific channel before sen

LG Bot Updates 0 Jan 16, 2022
null 1 Feb 18, 2022
A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

A discord Server Bot made with Python, This bot helps people feel better by inspiring them with motivational quotes or by responding with a great message, also the users of the server can create custom messages by telling the bot with Commands.

Aran 1 Oct 13, 2021
A telegram bot that messages you available vaccine appointments in the Veneto region

Serenissimo, domande frequenti Chi sei? Sono Alberto Granzotto, libero professionista a Berlino. Mi occupo di servizi software, privacy, decentralizza

vrde 31 Sep 30, 2022
This bot will delete messages containing blacklisted words in your telegram groups.

Profanity Detector Bot This bot will delete messages containing blacklisted words in your telegram groups. Made using ProfanityDetector.

Aditya 17 Oct 8, 2022
A simple Python script using Telethon to log all (or some) messages a user or bot account can see on Telegram.

telegram-logger A simple Python script using Telethon to log all (or some) messages a user or bot account can see on Telegram. Requirements Python 3.6

Richard 13 Oct 6, 2022
A Bot To Get Info Of Telegram messages , Media , Channel id Group ID etc.

Info-Bot A Bot To Get Info Of Telegram messages , Media , Channel id Group ID etc. Get Info Of Your And Messages , Channels , Groups ETC... How to mak

Vɪᴠᴇᴋ 23 Nov 12, 2022
A Telegram Bot for searching any channel messages from Inline by @AbirHasan2005

Message-Search-Bot A Telegram Bot for searching any channel messages from Inline by @AbirHasan2005. I made this for @AHListBot. You can use this for s

Abir Hasan 44 Dec 27, 2022
This is a simple Telegram bot to Delete User Messages based on Groupmembers Votes. Heroku deployable

ibCleaner Bot This is a simple Telegram bot to Delete User Messages based on Groupmembers Votes. Deploy to Heroku Deploy locally Edit config.py and ad

null 8 Oct 21, 2022
A simple Telegram bot, written in Python, that you can use to shill (i.e. send messages) your token, or whatever, to channels.

Telegram Shill Bot Ever wanted a Shill Bot but wankers keep scamming for one OR wanted to charge you an arm and a leg? This is a simple bot written in

null 53 Nov 25, 2022