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