Code Monkey home page Code Monkey logo

telegram-bot-forward-messages's Introduction

telegram-bot-forward-messages

Telegram bot which will forward a message from a channel/chat to another chat.

Installation

Requires Telethon

# Install Telethon
$ pip3 install -U telethon --user

# Verify Telethon's version:
$ python3 -c "import telethon; print(telethon.__version__)"

API Keys

The script requires your Telegram API keys.

  • Proceed to https://my.telegram.org
  • Enter your phone number and confirmation code.
  • Click on API development tools -> App configuration
  • Copy App api_id and App api_hash

Variables

# Telegram 'api_id' Key
API_ID = environ['API_ID']

# Telegram 'api_hash' Key
API_HASH = environ['API_HASH']

# Channel/Chat's name for incoming messages
GROUP = environ['GROUP']

# The recipient of the message. @username or me 
RECIPIENT = environ['RECIPIENT']

# [OPTIONAL] Embed your login credentials.
SESSION = environ['SESSION']

Get Login Session String

with TelegramClient(StringSession(), API_ID, API_HASH) as client:
    print(client.session.save())

telegram-bot-forward-messages's People

Contributors

salam81 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

lmarianow

telegram-bot-forward-messages's Issues

Help me friend i've been using ur code and now i receive this error when message comes what happened?

Unhandled exception on newMessageListener Traceback (most recent call last): File "C:\Users\LMariano\AppData\Roaming\Python\Python37\site-packages\telethon\client\updates.py", line 454, in _dispatch_update await callback(event) File "C:\Users\LMariano\Downloads\telegram-bot-forward-messages-main (1)\telegram-bot-forward-messages-main\script.py", line 52, in newMessageListener await client.forward_messages(entity=VIRTUALMAXIMA, messages=msg) File "C:\Users\LMariano\AppData\Roaming\Python\Python37\site-packages\telethon\client\messages.py", line 923, in forward_messages entity = await self.get_input_entity(entity) File "C:\Users\LMariano\AppData\Roaming\Python\Python37\site-packages\telethon\client\users.py", line 465, in get_input_entity .format(peer, type(peer).__name__) **ValueError: Could not find the input entity for PeerUser(user_id=1440822220) (PeerUser). Please read https://docs.telethon.dev/en/latest/concepts/entities.html to find out more details.**

I will be very grateful if u can find the solution to this error, ur code is the best telegram forwarder i see

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.