新增了完整的GitHub集成插件,包含认证、会话管理、Webhook处理、消息收发、反应支持等核心功能,支持Issues、Discussions、Pull Request的交互与通知。
38 lines
910 B
Python
38 lines
910 B
Python
from __future__ import annotations
|
|
|
|
GITHUB_REACTION_CONTENT_MAP: dict[str, str] = {
|
|
"+1": "+1",
|
|
"👍": "+1",
|
|
"thumbs_up": "+1",
|
|
"-1": "-1",
|
|
"👎": "-1",
|
|
"thumbs_down": "-1",
|
|
"laugh": "laugh",
|
|
"😄": "laugh",
|
|
"confused": "confused",
|
|
"😕": "confused",
|
|
"heart": "heart",
|
|
"❤️": "heart",
|
|
"hooray": "hooray",
|
|
"🎉": "hooray",
|
|
"rocket": "rocket",
|
|
"🚀": "rocket",
|
|
"eyes": "eyes",
|
|
"👀": "eyes",
|
|
}
|
|
|
|
SUPPORTED_REACTIONS = frozenset({
|
|
"+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", "eyes",
|
|
})
|
|
|
|
|
|
def normalize_reaction_content(emoji: str) -> str:
|
|
stripped = emoji.strip()
|
|
if stripped in SUPPORTED_REACTIONS:
|
|
return stripped
|
|
return GITHUB_REACTION_CONTENT_MAP.get(stripped.lower(), "heart")
|
|
|
|
|
|
def is_supported(emoji: str) -> bool:
|
|
return normalize_reaction_content(emoji) in SUPPORTED_REACTIONS
|