Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to fetch messages in real time from some Telegram channels. My code is as follow:

from telethon import TelegramClient, events, sync
import config

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

@client.on(events.NewMessage(chats='channel'))
async def my_event_handler(event):
    print(event.raw_text) 

The config document contains my credentials. Now this works, except that at some points there are delays of some seconds. And for some channels it completely misses some of the messages if I let the script run long enough. I also use Anaconda. Is there some workaround to get real time messages without missing any of them?

question from:https://stackoverflow.com/questions/66068726/fetching-messages-in-real-time-with-telethon-from-a-telegram-channel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
838 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...