from __future__ import annotations import logging logger = logging.getLogger(__name__) async def react( outbound, target_id: str, message_id: str, level: str, account_id: str | None = None, ) -> None: if level == "off": return emoji = _resolve_reaction_emoji(level) if not emoji: return await outbound.send_reaction(target_id, message_id, emoji, account_id=account_id) async def clear_reaction( outbound, target_id: str, message_id: str, account_id: str | None = None, ) -> None: try: await outbound.send_reaction(target_id, message_id, "", account_id=account_id) except Exception: logger.debug("Failed to clear reaction", exc_info=True) async def send_typing( outbound, target_id: str, thread_id: str | None = None, account_id: str | None = None, ) -> None: try: await outbound.send_typing(target_id, True, account_id=account_id) except Exception: logger.debug("Failed to send typing indicator", exc_info=True) def get_action_whitelist(account: dict) -> list[str]: actions = ["send", "react", "edit", "delete"] if not account.get("reactions", True): actions.remove("react") if not account.get("edit", True): actions.remove("edit") return actions def _resolve_reaction_emoji(level: str) -> str | None: emoji_map = { "ack": "👀", "minimal": "✅", "error": "❌", "thinking": "🤔", } return emoji_map.get(level)