简体   繁体   中英

Telethon: Certain group chat messages are not returned

I am trying to stream live telegram messages using telethon. The below code works perfectly for some chats (ie FEGchatIR), however, for the chat FEGchat (and very likely others), there is no output even when the chat is clearly active. Does anyone have any idea why this is?

from telethon import TelegramClient, events, sync
from keys import api_id, api_hash


client = TelegramClient('anon', api_id, api_hash)

@client.on(events.NewMessage(chats=['FEGchat']))
async def my_event_handler(event):
    print(event.raw_text)
    
await client.start()
await client.run_until_disconnected()

Also, does anyone know the limit on the number of chats you can collect data with using this method? Telegram seem fairly vague on rate limits...

Thanks!

If I understand correctly you're using an actual account for the automation which is good.

But it's better to filter on the chat/channel ID and not the name since then it will pick it up better and have a lower failing rate because an ID is unique and a chat/channel name is not.

This part of the documentation should have what you search for https://docs.telethon.dev/en/latest/modules/utils.html?highlight=Chat%20forwarding#telethon.utils.get_display_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM