'Capture specific telegram group messages with Telethon python
Good evening everyone.
I'm trying to get messages from a specific telegram group, using telethon. Can anyone give me a light? I can already get messages from my bot, but how to get messages from other conversations?
Sorry if this post is in the wrong place.
async def main():
me = await client.get_me()
async for message in client.iter_messages('me'):
print(message.id, message.text)
Solution 1:[1]
Take a look at iter_messages docs.
It takes entity as first argument:
The entity from whom to retrieve the message history.
So, replace client.iter_messages('me') with client.iter_messages(chat_id) in your code
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alex Kosh |
