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

Categories

0 votes
829 views
in Technique[技术] by (71.8m points)

python - Fetching messages in real time with Telethon from a Telegram channel

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

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

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...