ForcePilot/backend/package/yuxi/channel/extensions/bluebubbles/effects.py

65 lines
2.4 KiB
Python
Raw Normal View History

EFFECT_MAP: dict[str, str] = {
"slam": "com.apple.MobileSMS.expressivesend.impact",
"loud": "com.apple.MobileSMS.expressivesend.loud",
"gentle": "com.apple.MobileSMS.expressivesend.gentle",
"invisible-ink": "com.apple.MobileSMS.expressivesend.invisibleink",
"invisible ink": "com.apple.MobileSMS.expressivesend.invisibleink",
"invisibleink": "com.apple.MobileSMS.expressivesend.invisibleink",
"invisible": "com.apple.MobileSMS.expressivesend.invisibleink",
"echo": "com.apple.messages.effect.CKEchoEffect",
"spotlight": "com.apple.messages.effect.CKSpotlightEffect",
"balloons": "com.apple.messages.effect.CKHappyBirthdayEffect",
"confetti": "com.apple.messages.effect.CKConfettiEffect",
"love": "com.apple.messages.effect.CKHeartEffect",
"heart": "com.apple.messages.effect.CKHeartEffect",
"hearts": "com.apple.messages.effect.CKHeartEffect",
"lasers": "com.apple.messages.effect.CKLasersEffect",
"fireworks": "com.apple.messages.effect.CKFireworksEffect",
"celebration": "com.apple.messages.effect.CKSparklesEffect",
}
BUBBLE_EFFECTS = frozenset(
{
"com.apple.MobileSMS.expressivesend.impact",
"com.apple.MobileSMS.expressivesend.loud",
"com.apple.MobileSMS.expressivesend.gentle",
"com.apple.MobileSMS.expressivesend.invisibleink",
}
)
SCREEN_EFFECTS = frozenset(
{
"com.apple.messages.effect.CKEchoEffect",
"com.apple.messages.effect.CKSpotlightEffect",
"com.apple.messages.effect.CKHappyBirthdayEffect",
"com.apple.messages.effect.CKConfettiEffect",
"com.apple.messages.effect.CKHeartEffect",
"com.apple.messages.effect.CKLasersEffect",
"com.apple.messages.effect.CKFireworksEffect",
"com.apple.messages.effect.CKSparklesEffect",
}
)
def resolve_effect_id(raw: str) -> str:
key = raw.strip().lower()
if key in EFFECT_MAP:
return EFFECT_MAP[key]
normalized = key.replace(" ", "").replace("_", "").replace("-", "")
for k, v in EFFECT_MAP.items():
if k.replace(" ", "").replace("_", "").replace("-", "") == normalized:
return v
return raw
def is_bubble_effect(effect_id: str) -> bool:
return effect_id in BUBBLE_EFFECTS
def is_screen_effect(effect_id: str) -> bool:
return effect_id in SCREEN_EFFECTS
def is_valid_effect(effect_id: str) -> bool:
return effect_id in BUBBLE_EFFECTS or effect_id in SCREEN_EFFECTS