Skip to content

Telegram: Partial-Quote-Reponses aren't properly handled. #2203

Open
@BenWiederhake

Description

@BenWiederhake

Describe the bug
When responding to a partial message quote, matterbridge sends garbage to discord, and it fails. Excerpt from my logs:

time="2024-12-12T22:01:13+01:00" level=debug msg="=> Receiving config.Message{Text:"<mycensoredtext>", Channel:"mycensoredchannel", Username:"mycensoredname", UserID:"123456789", Avatar:"https://mycensored.example.com/mb/abcd1234/123456789.png", Account:"telegram.mytelegram", Event:"", Protocol:"telegram", Gateway:"mycensoredgw", ParentID:"telegram 6185", Timestamp:time.Date(2024, time.December, 12, 22, 1, 13, 115482686, time.Local), ID:"", Extra:map[string][]interface {}{}}" func=Send file="/home/user/
workspace/go-matterbridge-myfork/bridge/discord/discord.go:254" prefix=discord
time="2024-12-12T22:01:13+01:00" level=debug msg="Broadcasting using token (API)" func=handleEventBotUser file="/home/user/workspace/go-matterbridge-myfork/bridge/discord/discord.go:290" 
prefix=discord
time="2024-12-12T22:01:13+01:00" level=debug msg="=> Send from telegram.mytelegram (-1001234567890) to discord.mydiscord (mycensoredchannel) took 186.837392ms" func=func1 file="/home/user/workspace/go-matterbridge-myfork/gateway/gateway.go:508" prefix=gateway time="2024-12-12T22:01:13+01:00" level=error msg="SendMessage failed: HTTP 400 Bad Request, {"message": "Invalid Form Body", "code": 50035, "errors": {"message_reference": {"message_id": {"_errors": [{"code": "NUMBER_TYPE_COERCE", "message": "Value \"telegram 6185\" is not snowflake."}]}}}}" func=handleMessage file="/home/user/workspace/go-matterbridge-myfork/gateway/handlers.go:228" prefix=gateway

To Reproduce
Steps to reproduce the behavior:

  • Write a message on Telegram, let it be bridged by matterbridge to discord, for example "Hello humans how are you today"
  • On Telegram (e.g. using the "Web A" client at https://web.telegram.org/a/) respond only to a part of the message. (For example selecting the word "humans", right-clicking it, and selecting "Quote & Reply", then typing a message like "But I'm a robot-cat-ninja, not a human! 🤪", and sending it)
  • I think that PreserveThreading is involved in this issue.

Expected behavior
The second message should arrive just fine, either as a reply, or as a regular message (in the worst case).

Actual behavior: See above; an error message is logged, but the message is lost.

Screenshots/debug logs

The screenshots are specific to the "Web A"-client, and some clients don't support sending such messages. However, most clients support displaying these messages perfectly correctly; all clients display the main reply text, at least.

Bildschirmfoto_2024-12-12_22-20-41

Bildschirmfoto_2024-12-12_22-21-30

Environment (please complete the following information):

Additional context

[telegram.mytelegram]
Token="lolnope"
RemoteNickFormat="{NICK}@<U+200D>{PROTOCOL}: "
MediaConvertWebPToPNG=true
MediaConvertTgs="png"
UseFirstName=true
PreserveThreading=true
# Disable qoute-by-copy, because of PreserveThreading=true in Discord:
QuoteFormat="{MESSAGE}"

[discord.mydiscord]
Token="lolnope"
Server="Unfaßbare Menschen"
# No trailing colon-space!
RemoteNickFormat="{NICK}@<U+200D>{PROTOCOL}"
AutoWebhooks=true
PreserveThreading=true

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions