neonize icon indicating copy to clipboard operation
neonize copied to clipboard

Quoted messages with preview links trigger the command twice

Open Debanjan-San opened this issue 6 months ago • 2 comments

When a user sends a command like ping, the bot responds once as expected. However, if the command is sent with a preview-generating link (like a YouTube URL) and quotes another message, the bot triggers the command twice.

After testing, I found that when a preview link is present, the quoted message content is also included in message.Message.extendedTextMessage.text. As a result, the bot treats both the actual message and the quoted message as part of the incoming text and processes the command twice.

Steps to Reproduce:

  1. Send a message like ping — bot replies once (✅ expected).
  2. Send ping <YouTube URL> — bot replies once (✅ expected).
  3. Send ping <YouTube URL> while quoting another message — bot replies twice (❌ unexpected).

Expected Behaviour: The bot should execute the command only once, even when the message includes a preview link and quotes another message.

Actual Behaviour: The command is executed twice because the text from the quoted message is included in message.Message.extendedTextMessage.text, leading the handler to interpret it as a separate message or trigger.

Relevant Code Snippet:

def on_message(self, client, message: MessageEv):
    text = message.Message.conversation or message.Message.extendedTextMessage.text
    print(text)
    chat = message.Info.MessageSource.Chat
    if text.startswith("ping"):
        client.reply_message("pong", message)

Technical Note: When a preview-generating link is present in a quoted message, the entire content (including the quoted text) is injected into message.Message.extendedTextMessage.text, making it difficult to distinguish between the actual command and the quoted text.

Suggestion: Consider filtering out quoted message content when processing extendedTextMessage.text to prevent double execution.

Debanjan-San avatar Jul 18 '25 09:07 Debanjan-San

Fixed it by adding a checker to check that no same message id repeats.

Debanjan-San avatar Jul 18 '25 18:07 Debanjan-San

I'm not sure that's what's really happening You shouldn't receive an event twice because extendedTextMessage.text has some messed up values (I checked and they seem normal on my end even after replying a message with text containing a video preview) I couldn't however check if it's indeed triggering the handler twice because I have an anti message duplication and was too lazy to disable it (XD) The only duplication I'm aware of is when a client with shaky Internet connection sends a message twice.

Nubuki-all avatar Jul 25 '25 18:07 Nubuki-all