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
Spore Api

SporeApi Spore Api Simple example: import asyncio from spore_api.client import SporeClient async def main() - None: async with SporeClient() a

LEv145 16 Aug 02, 2022
:snake: Python SDK to query Scaleway APIs.

Scaleway SDK Python SDK to query Scaleway's APIs. Stable release: Development: Installation The package is available on pip. To install it in a virtua

Scaleway 114 Dec 11, 2022
A Git Alert Bot - Github Integration for Pyrogram & Telethon

Yet Another GitAlertBot Inspired From @Pokurt's GitGram Run Bot: Local Host Git Clone Repo : For Telethon Version : git clone https://github.com/DevsE

DevsExpo 23 Oct 21, 2022
Based on nonebot, a common bot framework for maimai.

mai bot 使用指南 此 README 提供了最低程度的 mai bot 教程与支持。 Step 1. 安装 Python 请自行前往 https://www.python.org/ 下载 Python 3 版本( 3.7)并将其添加到环境变量(在安装过程中勾选 Add to system P

Diving-Fish 150 Jan 01, 2023
Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of Scratch2py

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of Scratch2py Installation Run this command i

2 Jan 13, 2022
A melhor maneira de atender seus clientes no Telegram!

Clientes.Chat Sobre o serviço Configuração Banco de Dados Variáveis de Ambiente Docker Python Heroku Contribuição Sobre o serviço A maneira mais organ

Gabriel R F 10 Oct 12, 2022
Um bot simples para seguir as pessoas

Um bot simples para seguir pessoas no instagram, criado apeanas para testes. Utilizando o framework "Selenium", criei um bot para entrar em uma conta

Mobben 1 Nov 05, 2021
Change your discord avatar every x h/d based on a list of images

Discord-Avatar-Autochange Introduction A simple script that automatically keeps changing your discord avatar after a given amount of time based on the

Armin Amiri 5 Apr 30, 2022
Petpy is an easy-to-use and convenient Python wrapper for the Petfinder API.

Petpy is an easy-to-use and convenient Python wrapper for the Petfinder API. Includes methods for parsing output JSON into pandas DataFrames for easier data analysis

Aaron Schlegel 27 Nov 19, 2022
Seth Userbot with python

SETH-USERBOT DEPLOY TO HEROKU Group Support: String Session : Stay Support 🚀 ❁ LonamiWebs and Telethon © Credits ⚡ THANK YOU VERY MUCH FOR zeinzo Zei

seth 4 Jan 10, 2022
Just a python library to make reddit post caching easier

Reddist Just a python library to make reddit post caching easier. Caching Options In Memory Caching Redis Caching Pickle Caching Usage Installation: D

Samrid Pandit 3 Jan 16, 2022
Bot per controllare la disponibilità di appuntamenti per la vaccinazione Covid-19 in Veneto

VaxBot9000 Prerequisites Python 3.9 Poetry latest version of geckodriver Firefox Setup poetry install Copy config.sample.toml to config.toml and edit

Augusto Zanellato 5 Jun 13, 2021
Discord-Wrapper - Discord Websocket Wrapper in python

This does not currently work and is in development Discord Websocket Wrapper in

3 Oct 25, 2022
Anti Spam/NSFW Telegram Bot Written In Python With Pyrogram.

✨ SpamProtectionRobot ✨ Anti Spam/NSFW Telegram Bot Written In Python With Pyrogram. Requirements Python = 3.7 Install Locally Or On A VPS $ git clon

Akshay Rajput 46 Dec 13, 2022
Os-Remoter with Python (Telegram Bot)

Remote-Os Os-Remoter with Python (Telegram Bot) [1] First install "python -m pip install --upgrade pip" [2] Second install the modules inside file ins

Alisa Alikhani 2 Nov 09, 2022
Open Source API and interchange format for editorial timeline information.

OpenTimelineIO is currently in Public Beta. That means that it may be missing some essential features and there are large changes planned. During this phase we actively encourage you to provide feedb

Pixar Animation Studios 1.2k Jan 01, 2023
A light weight Python library for the Spotify Web API

Spotipy A light weight Python library for the Spotify Web API Documentation Spotipy's full documentation is online at Spotipy Documentation. Installat

Paul Lamere 4.2k Jan 06, 2023
The official Magenta Voice Skill SDK used to develop skills for the Magenta Voice Assistant using Voice Platform!

Magenta Voice Skill SDK Development • Support • Contribute • Contributors • Licensing Magenta Voice Skill SDK for Python is a package that assists in

Telekom Open Source Software 18 Nov 19, 2022
WhatsApp Status Tracker With Python

Warning!! This Repo is Purly educational purpose Don't use this to stalk on others, which is subjective to crime Pre-Req: Telegram bot of your own wit

Vignesh Karunagaran 10 Dec 09, 2022
Custom bot I've made to host events on my personal Discord server.

discord_events Custom bot I've made to host events on my personal Discord server. You can try the bot out in my personal server here: https://discord.

AlexFlipnote 5 Mar 16, 2022