Giter Club home page Giter Club logo

pywardbot's Introduction

PyWardBot

Telegram forwarder written in Python

PyWardBot is an open source Telegram message forwarder powered by Pyrogram

img_1

Features

  • Set by Telegram ID or by username
  • Telegram protected content bypass
  • Message reply detection
  • Message edit detection
  • Messaged delete detection
  • Enable and disable options
  • Replace words
  • Block words
  • Add origin chats
  • Get chat info
  • Two sending mode: copy message or forward message

Use cases

  • Forward messages from one chat to another
  • Download protected media files
  • Backup messages
  • Send messages to multiple chats

Installation and configuration

Installation

First, you will need to have Python and [^1] Git installed on your system. Also you will need to create a new Telegram bot and get the bot token.

After installing Python and Git, and creating a bot, open a terminal and do the following:

# Clone repository
git clone https://github.com/nunnito/PyWardBot.git

# Change directory to the cloned repository
cd PyWardBot

# Install dependencies
pip install -r requirements.txt

# Run the bot
python3 app/main.py

Configuration

After running the bot for the first time, you will get the following output:

25-05-2022 18:00:00 - config:23 - ERROR: bot.json not found
25-05-2022 18:00:00 - config:24 - WARNING: bot.json has been created with default values. Please edit it with your own api_id and api_hash values. You can find them on https://my.telegram.org/apps

You will need to edit the bot.json file with your own api_id and api_hash values in order to run the bot.

Get those values from this tutorial or just go to My Telegram Org and create a new app.

Once you have these values go to the PyWardBot/app/config/ folder and open the bot.json file.

You will see a content like this:

{
    "api_id": 1234567,
    "api_hash": "0123456789abcdef0123456789abcdef",
    "admins": []
}

Replace 1234567 and 0123456789abcdef0123456789abcdef with your own api_id and api_hash values.

Then run the bot again:

python3 app/main.py

You will be prompted to enter your phone number:

25-05-2022 18:00:00 - main:839 - INFO: Log-in with your phone number
Welcome to Pyrogram (version 1.4.8)
Pyrogram is free software and comes with ABSOLUTELY NO WARRANTY. Licensed
under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+).

Enter phone number or bot token:

Remember to enter your phone number in the international format (e.g. +11234567890).

After entering your phone number, a code will be sent to your Telegram account. Enter the code and press enter.

Then you will be prompted to enter your bot token:

25-05-2022 18:00:0 - main:843 - INFO: Log-in with you bot token
Welcome to Pyrogram (version 1.4.8)
Pyrogram is free software and comes with ABSOLUTELY NO WARRANTY. Licensed
under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+).

Enter phone number or bot token:

After entering your bot token, and if everything went well, you will see the following output:

25-05-2022 20:15:08 - main:845 - INFO: Bot started
25-05-2022 20:20:08 - main:846 - INFO: Bot username: @YOURBOTUSERNAME

That's it! Now you can start the bot and set it up!

FAQ

Is necessary to install Git?

No, you can download the source code as a zip file from here. Then unzip it and follow the installation instructions

How to add a new admin?

By default, the bot is configured to run only for yourself. If you want to add a new admin, you can do it by adding the new Telegram ID to the admins array in the bot.json file.

What are the different modes of sending messages?

There are two modes of sending messages:

  • copy message: the bot will copy the message to the destination chat.
  • forward message: the bot will forward the message to the destination chat.

How to send only outgoing or only incoming messages?

For this you need to open the forwarding.json file and modify the outgoing and incoming properties. By default, the bot will forward all messages.

pywardbot's People

Contributors

nunnito avatar revealedsouleven avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pywardbot's Issues

Bot not running - newbie here

Hello

I made all the steps, and got "18-10-2023 15:39:02 - main:1209 - INFO: Bot started
18-10-2023 15:39:02 - main:1210 - INFO: Bot username:"

But when I go to telegram, open the bot chat and do /start nothing happens.

What am I doing wrong?

Thanks in advance

topic support

Your project does not support supergroup topics, please add them

getting SyntaxError: invalid syntax error

root@telegram:/PyWardBot/app# python3 main.py
Traceback (most recent call last):
File "/root/PyWardBot/app/main.py", line 16, in
from forward import user
File "/root/PyWardBot/app/forward.py", line 88
match message.media:
^
SyntaxError: invalid syntax
root@telegram:
/PyWardBot/app#

adding captions to posts

Hi, how are you?

I've been playing around with the bot a bit, and was wondering.
I have two channels set to forward messages to a single channel. problem is, I don't have any way of knowing from which channel the message was sent.
my setup has to be copy, rather then forward because the whole purpose of my use case is to get around the problem of some channels being block on telegram by Google and Apple (telegram has not blocked the channels).

Is there a way I could say that is a message was sent from channel X, then add to the bottom of the message "XYZ" (as in, I define what the description/caption says)?

for example, the text that is sent in the source channel is:
"Hi, this is a test message."

and the text eventually sent to the destination channel is:
"Hi, this is a test message.

Luci6666666 channel"

Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid

pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: Telegram says: [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 am using source as one of the channel from i want to copy the msg to another group. I have captured the id from url after clicking on the that channel. What am I doing wrong
{
"forwarders": [
{
"name": "test",
"target": -1002091619145,
"enabled": true,
"forwarding_mode": "copy",
"incoming": true,
"outgoing": true,
"reply": true,
"duplicated_text": false,
"send_text_only": false,
"translate": false,
"translate_to": "en",
"translate_from": "auto",
"translate_show_original": false,
"translate_original_prefix": "Original:",
"translate_translation_prefix": "Translated:",
"replace_words_mode": "word_boundary_match",
"replace_words": {},
"blocked_words": [],
"source": {
"-1001995434407": "test"
},
"patterns": []
}
],
"blocked_images": []
}

hosting on vps

Getting this error when trying to host on heroku ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.