ForcePilot/backend/package/yuxi/channel/extensions/workplace/actions.py
Kris 7215418610 feat(channel): 添加企业微信、微博、WhatsApp 和 Workplace 渠道扩展
新增企业微信、微博、WhatsApp、Workplace 四个渠道扩展。

企业微信渠道扩展主要模块:config, gateway, webhook, webhook_bot, outbound, streaming, pairing, security, crypto, dedupe, persistent_dedupe, card, directory, events, externalcontact, media, mentions, menu, message, oauth, status

微博渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, passive_reply, broadcast, message, menu, media, subscription, template, status

WhatsApp 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, actions, monitor, status

Workplace 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, actions, challenge, groups, media, mentions, menu, monitor, persona, quick_reply, signature, subscriptions, template, threading, users, status
2026-05-21 12:01:56 +08:00

50 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from yuxi.channel.protocols import MessageActionCapability
class WorkplaceActions:
def get_message_actions(self) -> list[MessageActionCapability]:
return [
MessageActionCapability(
action="send_template",
description="发送模板消息Button/Generic/Media Template",
),
MessageActionCapability(
action="send_quick_replies",
description="发送带快捷回复按钮的消息(最多 13 个选项)",
),
MessageActionCapability(
action="create_group_chat",
description="创建新的 Work Chat 群聊",
),
MessageActionCapability(
action="add_to_group_chat",
description="将用户添加到已有群聊",
),
MessageActionCapability(
action="create_persistent_menu",
description="创建/更新聊天持久化菜单",
),
MessageActionCapability(
action="post_to_group",
description="向 Workplace 小组发布帖子",
),
]
async def execute_message_action(self, action_name: str, params: dict) -> dict:
_tpl = "delegated to outbound.send_template"
if action_name == "send_template":
return {"success": True, "action": "send_template", "message": _tpl}
if action_name == "send_quick_replies":
_msg = "delegated to outbound.send_quick_replies"
return {"success": True, "action": "send_quick_replies", "message": _msg}
if action_name == "create_group_chat":
_msg = "delegated to outbound.create_group_chat"
return {"success": True, "action": "create_group_chat", "message": _msg}
if action_name == "post_to_group":
_msg = "delegated to workplace.groups.post_to_group"
return {"success": True, "action": "post_to_group", "message": _msg}
if action_name == "create_persistent_menu":
_msg = "delegated to Messenger Profile API"
return {"success": True, "action": "create_persistent_menu", "message": _msg}
return {"success": False, "error": f"Unknown action: {action_name}"}