ForcePilot/backend/package/yuxi/channels/adapters/wechat/notification_adapter.py

28 lines
799 B
Python
Raw Normal View History

from __future__ import annotations
from typing import Any
class WeChatNotificationAdapter:
@staticmethod
def build_subscribe_message(open_id: str, template_id: str, data: dict[str, Any]) -> dict[str, Any]:
return {
"touser": open_id,
"template_id": template_id,
"data": data,
}
@staticmethod
def build_announce_message(config: dict[str, Any], content: str) -> dict[str, Any]:
return {
"msgtype": "text",
"text": {"content": content},
}
@staticmethod
def resolve_announce_targets(config: dict[str, Any]) -> list[str]:
targets: list[str] = []
for chat_id, chat_config in config.get("groups", {}).items():
targets.append(chat_id)
return targets