events.NewMessage event is not triggered for certain channels
M4jx opened this issue · 27 comments
Code that causes the issue
@client.on(events.NewMessage(chats = list(channels_hashmap.keys())))
async def main(event):
print(now.strftime("%d/%m/%Y %H:%M:%S") + f" Received from channel: {event.chat_id}")
Expected behavior
When a new message is sent in a channel passed to chats
, the events.NewMessage
should be triggered.
Actual behavior
When a new message is sent, the events.NewMessage
is not being triggered for certain channels.
I have tested to create a channel in an account A and monitor it in account B (where telethon is running) and the events.NewMessage
was triggered instantly. However, for certain public channels that I do not own, the event is not being triggered.
Tested on a newly created channel with 2 subscribers and it worked.
Tested on a public channel with 500K subscribers and it did not work.
Traceback
No crashes are happening.
Telethon version
1.34.0
Python version
3.10.12
Operating system (including distribution name and version)
Ubuntu 22.04.4 LTS
Other details
No response
Checklist
- The error is in the library's code, and not in my own.
- I have searched for this issue before posting it and there isn't an open duplicate.
- I ran
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip
and triggered the bug in the latest version.
Same with me, doesn't work for some public channels
Please react with the thumbs-up emoji instead of posting "me too" comments.
Update:
While Telethon is running, if a message is sent in the monitored channel and the events.NewMessage
event is not triggered. It can be triggered manually if you open the channel and read the message in the Telegram app (from the same user account telethon is running on).
Once the channel is opened, and the message is read, telethon triggers the event instantly.
Update:
While Telethon is running, if a message is sent in the monitored channel and theevents.NewMessage
event is not triggered. It can be triggered manually if you open the channel and read the message in the Telegram app (from the same user account telethon is running on).
Once the channel is opened, and the message is read, telethon triggers the event instantly.
Telegram doesn't always send all updates to the client. Some channels can only be updated after manually calling for updates. You can try restarting your app, creating a new session, changing the IP or the account itself.
Same problem for me, and it's not the library. Same problem with Pyrogram
I noticed the same ,,, few months back i was runing multiple clients via mobile IP , and received 100% all updates ,,, few months later , after a pause , i started a single client over VPN , and not all updates where being registered .
Some people have reported that some channels must be polled manually to receive updates as of recently.
Telethon does not have any built-in way to do this yet (but of course can be done via raw API; I just haven't checked so I don't know exactly how).
I don't know if this will ever be "fixed" to work automatically, because if the need for manual polling is true, Telethon would have no way to know what it needs to poll manually.
I noticed the same ,,, few months back i was runing multiple clients via mobile IP , and received 100% all updates ,,, few months later , after a pause , i started a single client over VPN , and not all updates where being registered .
Since when did you start noticing this issue?
Update: While Telethon is running, if a message is sent in the monitored channel and the
events.NewMessage
event is not triggered. It can be triggered manually if you open the channel and read the message in the Telegram app (from the same user account telethon is running on). Once the channel is opened, and the message is read, telethon triggers the event instantly.
Actually, in my case, even the read of the message from the Telegram app does not trigger it. Is it only a problem of mine?
In my case the whole app just blackouts for randomly 1-2 minutes and then it receives the new messages updates properly. I have 10 channels subscribed and for 2 minutes app did not receive any update from any channels between 9:27-9:29 AM and 10:02-10:04 AM. Afterward, for the rest of the day, all updates were received properly.
So as suggested here NewMessage event is not reliable and we should poll those channels manually. I will try that and let you know how it goes.