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 Script to download hundreds of images from 'Google Images'. It is a ready-to-run code!

Google Images Download Python Script for 'searching' and 'downloading' hundreds of Google images to the local hard disk! Documentation Documentation H

Hardik Vasa 8.2k Jan 05, 2023
Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the pointless 3200 tweet limit imposed by Twitter.

Twitter Nuke Quickly and efficiently delete your entire tweet history with the help of your Twitter archive without worrying about the puny and pointl

Mayur Bhoi 73 Dec 12, 2022
A discord bot that will help you browse/download nhentai sources.

Risa Introduction Risa is an nHentai discord bot that will help you browse and download your favorite doujin inside your own discord server. Hosting M

markee7 14 Oct 25, 2021
Demo of using Telegram to send alert message

MIAI_Telegram Demo of using Telegram to send alert message Video link: https://youtu.be/oZ9CsIrlMgg #MìAI Fanpage: http://facebook.com/miaiblog Group

4 Jun 20, 2021
Upbit(업비트) Cryptocurrency Exchange OPEN API Client for Python

Base Repository Python Upbit Client Repository Upbit OPEN API Client @Author: uJhin @GitHub: https://github.com/uJhin/upbit-client/ @Officia

Yu Jhin 37 Nov 06, 2022
An interactive App to play with Spotify data, both from the Spotify Web API and from CSV datasets.

An interactive App to play with Spotify data, both from the Spotify Web API and from CSV datasets.

Caio Lang 3 Jan 24, 2022
A fast, easy to set up telegram userbot running Python 3 which uses fork of the Telethon Library.

forked from friendly-telegram/friendly-telegram Friendly Telegram Userbot A fast, easy to set up telegram userbot running Python 3 which uses fork of

GeekTG 75 Jan 04, 2023
A Discord.py bot which can adjust a voice channel's bitrate depending on the number of users connected.

discord_bitrate_bot A Discord.py bot which can adjust a voice channel's bitrate depending on the number of users connected. Programmed to be run on a

1 Feb 10, 2022
CryptoApp - Python code to pull wallet balances from a variety of different chains through nothing other than your public key.

CryptoApp - Python code to pull wallet balances from a variety of different chains through nothing other than your public key.

Zach Frank 4 Dec 13, 2022
A Python interface to AFL, allowing for easy injection of testcases and other functionality.

Fuzzer This module provides a Python wrapper for interacting with AFL (American Fuzzy Lop: http://lcamtuf.coredump.cx/afl/). It supports starting an A

Shellphish 614 Dec 26, 2022
Download nitro generator that generates free nitro code that you can use for Discord

Download nitro generator that generates free nitro code that you can use for Discord, run it and wait for free nitro to come

Umut Bayraktar 154 Jan 05, 2023
Yes, it's true :heartbeat: This repository has 337 stars.

Yes, it's true! Inspired by a similar repository from @RealPeha, but implemented using a webhook on AWS Lambda and API Gateway, so it's serverless! If

512 Jan 01, 2023
Discord Token Nuker With Python

Discord token nuker a.k.a A$$Fvcker Setup For installing the requirements do this: pip install -r requirements.txt To start the Token nuker run this

PR3C14D0 8 Sep 22, 2022
The Fastest multi spambot of Telegram 🤞 🤞

Revil Spam Bot The Fastest multi spambot of Telegram 🤞 🤞 𝚂𝚄𝙿𝙿𝙾𝚁𝚃 🖤 ᴄʀᴇᴀᴛᴏʀ 🖤 ⚡ 𝓡𝓮𝓿𝓲𝓵 𝓗𝓾𝓷𝓽𝓮𝓻 𝔐𝔲𝔩𝔱𝔦 ẞø✞︎ ⚡ 𝓐 𝕾мοοτн 𝓐и∂ 𝕱

REVIL HUNTER 4 Dec 08, 2021
Api REST para gerenciamento de cashback.

Documentação API para gerenciamento de cashback - MaisTODOS Features Em construção... Tecnologias utilizadas Back end Python 3.8.10 Django REST Framew

Alinne Grazielle 2 Jan 22, 2022
A bot to share Facebook posts.

bot_share_facebook a bot to share Facebook posts. install & clone untuk menjalankan anda bisa melalui terminal contohnya termux, cmd, dan terminal lai

Muhammad Latif Harkat 7 Dec 07, 2022
Space Bot, a Discord bot built for HackerSpace Club of PES University

Space Bot Space Bot, a Discord bot built for HackerSpace Club of PES University What can Space Bot do? Space Bot allows you to lookup any mentor or to

HackerSpace @PESU 7 Oct 23, 2022
API RestFull web de pontos turisticos de certa região

##RESTful Web API para exposição de pontos turísticos de uma região## Propor um novo ponto turístico Moderação dos pontos turísticos cadastrados Lista

Lucas Silva 2 Jan 28, 2022
Spacecrypto-bombcrypto-bot - SpaceCrypto And Bombcrypto Bot - MultiScreen

SpaceCrypto And Bombcrypto Bot - MultiScreen This is a open source project inspi

Paulo Bramante 5 Nov 03, 2022
Anchor Protocol Script that can save you from being liquidated!

Why My day job requires a fairly good amount of automation from time to time. Besides, I do like computers to work on what I cannot while I'm sleeping

126 Oct 16, 2022