Is there any way using Python / JS to forward messages which I, as a member, do receive in a private read-only group? I’m trying to set it up using python-telegram-bot but it seems I gotta add the bot to the group to have it interact with the contents sent in the group. But I can’t as Im just a reading / receiving member…
Is there maybe a way without using the Telegram API, but using some sort of JS Browser automation to forward those? This is the only thing which comes to my mind… Thanks in advance!
2
Answers
Answering my own question in case someone needs it.
As @CallMeStag pointed out, one needs a library which support "User bots". These are librarys directly implementing the MTProto.
For python, e.g. Pyrogram is suitable and very easy to use.
First of all, one needs an API key and API hash to identify the Python Script on the Telegram server to communicate in the MTProto.
https://my.telegram.org/auth?to=apps -> Login using your credentials and create an "App". Define those into
API_ID
andAPI_HASH
below.Now, I use this code to copy messages from the
SOURCE_CHAT
to theTARGET_chat
:To find out the
CHAT_ID
of Source and Target, I temporarly disabled the Filter, and printed the message.Doing so, enables you to: whenever receiving a message in the specific group, you can find
message.chat.id
(attention: negative Values!). Configure those forSOURCE_CHAT
andTARGET_CHAT
in the full script above.EDIT: Another option to get all chat IDs for all dialogues without first needing someone to send a message in the channel/group/private/chat:
Simply call it once and you'll get a list of dialogues :)
It’s indeed not possible with Telegram Bots – you’d have to add them to the group. You can however automate your personal account using so called "user bots". Here is an article about them.