Telethon icon indicating copy to clipboard operation
Telethon copied to clipboard

receive event update twice on ChatAction with two different action_message on user_joined

Open winxen opened this issue 2 years ago • 5 comments

Code that causes the issue

image

Expected behavior

I was trying to write a bot to detect and record whenever a new user joining group chat. And trying to use event.user_joined to do so, but whenever user join the group the bot would receive update event twice, one come with action_message=MessageService and user_joined=True and another one action_message=None and user_added=True. Both events show it came from the same user and the same group, I wonder if this was cost by a bug in library or it just a normal behavior from telegram server itself, and the problem is that sometime it only send one among the two(randomly) which make it hard for which event I should focus on to determine if there a user joined group

Actual behavior

image image

Traceback

No response

Telethon version

Telethon 1.29.2

Python version

Python 3.11.4

Operating system (including distribution name and version)

macOS 13.4.1

Other details

No response

Checklist

  • [X] The error is in the library's code, and not in my own.
  • [X] I have searched for this issue before posting it and there isn't an open duplicate.
  • [X] I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.

winxen avatar Aug 07 '23 07:08 winxen

So hou you resolve this, at last?

absurdmemento avatar Oct 03 '24 12:10 absurdmemento

ChatAction continues being a mess in v1 and I'm too afraid to make changes. I´d suggest using events.Raw if that works for the usecase instead.

Lonami avatar Oct 03 '24 15:10 Lonami

@Lonami how to use events.Raw?

@bot.on(events.Raw()) ?

yarodevuci avatar Oct 18 '24 03:10 yarodevuci

Yes, according to the docs.

scudo005 avatar Apr 13 '25 12:04 scudo005

BTW, this issue persists in the latest stable version of the library, at least with events.Raw. This code

@client.on(events.Raw)
async def raw(event):
    print(event)

still triggers a double event:

Image

Note how msg_id is the same in the two events in the middle. This is not limited to UpdateBotMessageReaction events, it's a problem also with other types of events like UpdateNewMessage and UpdateDeleteMessages.

scudo005 avatar Apr 13 '25 13:04 scudo005