Element appends U+FE0F to emoji reactions (👍️ vs 👍). Strip before matching against approval map. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
21 lines
734 B
Python
21 lines
734 B
Python
"""Approval handling — maps Matrix reactions to pipeline approvals."""
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Reaction emoji to response mapping
|
|
APPROVAL_REACTIONS = {
|
|
"\U0001f44d": "approve", # thumbs up
|
|
"\U0001f44e": "decline", # thumbs down
|
|
"\u2705": "approve", # check mark
|
|
"\u274c": "decline", # cross mark
|
|
}
|
|
|
|
|
|
def reaction_to_response(reaction_key: str) -> str | None:
|
|
"""Map a reaction emoji to an approval response."""
|
|
# Strip variation selectors (U+FE0E, U+FE0F) — Element often appends these
|
|
cleaned = reaction_key.replace("\ufe0f", "").replace("\ufe0e", "")
|
|
return APPROVAL_REACTIONS.get(cleaned) or APPROVAL_REACTIONS.get(reaction_key)
|