Skip to content

fix: emoji reactions rejected on U+FE0F, and caption editing for media messages - #71

Merged
Alex2772 merged 2 commits into
Alex2772:masterfrom
fenixvd:fix/reactions-and-caption
Jul 21, 2026
Merged

fix: emoji reactions rejected on U+FE0F, and caption editing for media messages#71
Alex2772 merged 2 commits into
Alex2772:masterfrom
fenixvd:fix/reactions-and-caption

Conversation

@fenixvd

@fenixvd fenixvd commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Two independent bug fixes in tools, both found while running the bot against real Telegram chats.

1. react_with_emoji: reactions failing with REACTION_INVALID

Setting a reaction failed with TDLib error REACTION_INVALID ("The reaction isn't available for the message") for some emoji, seemingly at random.

Root cause: Telegram stores active emoji reactions without the variation selector U+FE0F. The heart is (U+2764), not ❤️ (U+2764 U+FE0F). The model tends to emit the U+FE0F form, and addMessageReaction rejects it.

Confirmed from logs: only ❤️ and ⚡️ ever failed, while every single-codepoint emoji (🔥 ×165, 🤔 ×188, 🥰, 👍, 🤣, 😁, 🌚, 👌, 👀, 💔) went through fine.

Fix: stripVariationSelector() removes the U+FE0F bytes before the emoji is passed to addMessageReaction.

The commit also adds two smaller robustness improvements:

  • check chat->available_reactions_ — when it is chatAvailableReactionsSome, verify membership and return a meaningful answer listing the allowed reactions instead of failing opaquely;
  • wrap the call in try/catch with a graceful response, so a restricted chat doesn't blow up the tool call.

Note: the availability check alone does not fix the bug — in a private chat the set is All, so the call reaches addMessageReaction and still fails on U+FE0F. Stripping the selector is the actual fix.

2. edit_message_text: cannot edit captions of photo/video messages

The tool always called editMessageText, which TDLib rejects for media messages, so the bot could never edit a caption of a photo it had sent.

Fix: branch on message->content_->get_id() — text messages go to editMessageText, media with a caption (photo/video) goes to editMessageCaption.


Both fixes have been running in production in my fork for several days. Branch is rebased onto current master.

fenixvd added 2 commits July 20, 2026 09:41
… chats

Telegram's active emoji reactions are stored without the U+FE0F variation
selector (the heart is U+2764, not U+2764 U+FE0F). Sending the FE0F form made
addMessageReaction fail with REACTION_INVALID ("The reaction isn't available
for the message") - this hit reactions like the heart while single-codepoint
emojis worked. Strip the variation selector before reacting.

Also inspect the chat's available_reactions: when a chat restricts its
reaction set (many channels do), return a clear, non-error message listing the
allowed reactions instead of surfacing the raw TDLib exception, and degrade
gracefully if the request still fails - so the model doesn't treat reactions
as globally broken.
editMessageText only works on text messages; TDLib rejects it for a message
whose content is a photo/video/etc., so editing a sent photo's caption failed.
Inspect the message content type and use editMessageCaption for media
messages, keeping editMessageText for plain text.
@Alex2772
Alex2772 merged commit 3bbf87d into Alex2772:master Jul 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants