-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
events.NewMessage event is not triggered for certain channels #4345
Comments
This comment was marked as duplicate.
This comment was marked as duplicate.
Please react with the thumbs-up emoji instead of posting "me too" comments. |
Update: |
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. |
Since when did you start noticing this issue? |
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. |
I've encountered a peculiar situation with a message delivery order, and I'd like to explain it in hopes of shedding light on the issue.
In my case, the following occurred:
To better understand and debug this issue, I have the following questions:
Checking the behavior of other packages written in other languages can also help us to confirm where the issue is from and why. |
Out-of-order messages shouldn't occur because the library checks that the incoming Telethon/telethon/_updates/messagebox.py Line 561 in 4767368
Make sure the message isn't being deleted and getting resent. I have observed official clients displaying messages that had been deleted multiple times, and not too long ago. If you really think Telethon is processing updates out of order, I either need someone with that problem to debug it themselves, or a way in which I can reliably reproduce it myself. Although I've already spent a significant amount of time going over the update handling code myself, so I doubt I would uncover anything. As far as I know https://core.telegram.org/api/updates doesn't say anything Telethon isn't doing already (at the time of writing). As for missing messages, or the library fetching them after a while. Yes, there is a default timeout after which the library will attempt to fetch updates: Telethon/telethon/_updates/messagebox.py Line 46 in 4767368
This is in line with Telegram's documentation above:
|
Dear @Lonami, I'm sure that I received message (C) before (B) but I'm not sure if it was deleted and sent again or not. If it was deleted, I expected to receive that exact same message again after a while, right? but as you know, sometimes messages do not get delayed, they simply get ignored and never get transmitted. Even after opening that channel on my phone, message (B) was not received "twice", just only once and I also didn't receive message (C) again (meaning that message (C) was not deleted and got resent). As far as I consider these messy updates complicated and not quite trackable, I cannot really guarantee that this unordered updates issue is valid but It was my observation that I decided to share with you because my whole project is now unusable after a few months of not being on the server. It's not working and I'm very concerned. :) P.S.: If you haven't any channel suffering from this updating issue (not the ordering one), I know one that I can send only privately to you. |
I do not have interest in submitting bug reports to Telegram. You can certainly message me privately (or include the channel in a GitHub comment between Perhaps trying this out would be a good excuse to make sure update handling works correctly in the (not ready for use) v2 version. |
Code that causes the issue
Expected behavior
When a new message is sent in a channel passed to
chats
, theevents.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
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip
and triggered the bug in the latest version.The text was updated successfully, but these errors were encountered: