50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
|
|
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}"}
|