新增企业微信、微博、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
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}"}
|