Skip to content

feat(reactions): support custom emoji reactions - #163

Open
errogaht wants to merge 2 commits into
chigwell:mainfrom
errogaht:agent/custom-emoji-reactions
Open

feat(reactions): support custom emoji reactions#163
errogaht wants to merge 2 commits into
chigwell:mainfrom
errogaht:agent/custom-emoji-reactions

Conversation

@errogaht

Copy link
Copy Markdown
Contributor

Problem

get_message_reactions already exposes custom reactions as
custom:<document_id>, but send_reaction always constructs
ReactionEmoji. Passing the value returned by the read API back into the write
API therefore cannot reproduce the custom reaction.

This breaks an otherwise useful read-modify-write flow for MCP clients: they can
identify a Telegram custom reaction, but cannot send the same reaction.

Change

  • Accept custom:<positive document id> in send_reaction.
  • Build a Telethon ReactionCustomEmoji for that representation.
  • Set add_to_recent=True, matching the behavior expected when a custom
    reaction is selected from Telegram's reaction picker.
  • If Telegram rejects that optional picker-state flag with
    REACTION_INVALID, retry the same custom reaction once without the flag.
    This handles private-chat behavior without hiding errors for normal Unicode
    reactions.
  • Preserve the existing Unicode emoji path unchanged.
  • Reject malformed custom identifiers before resolving a peer or sending a
    request.

The input representation intentionally matches the existing
get_message_reactions output, so custom reactions now round-trip without a
new tool field or breaking schema change.

Validation

  • uv run pytest tests/test_reactions.py -q — 7 passed.
  • uv run pytest — 170 passed.
  • uv run black --check telegram_mcp/tools/messages.py tests/test_reactions.py
  • uv run flake8 telegram_mcp/tools/messages.py tests/test_reactions.py --count --select=E9,F63,F7,F82 --show-source --statistics
  • git diff --check

The regression coverage includes:

  • unchanged Unicode reaction behavior;
  • successful custom:<document_id> conversion;
  • the narrow retry without add_to_recent;
  • malformed and non-positive custom document IDs.

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.

1 participant