ForcePilot/backend/package/yuxi/channel/extensions/googlechat/actions.py
Kris c4e301a5e0 feat(googlechat): 新增Google Chat渠道完整实现
新增Google Chat插件的所有核心功能模块,包括账户配置、消息收发、权限控制、媒体处理、会话管理等完整能力
2026-05-21 10:49:33 +08:00

42 lines
1.6 KiB
Python

from __future__ import annotations
import logging
logger = logging.getLogger(__name__)
async def execute_send_action(account, space_name: str, text: str, thread_name: str | None = None) -> dict:
from yuxi.channel.extensions.googlechat.api import send_message
result = await send_message(account, space_name, text, thread_name=thread_name)
return {"success": True, "action": "send", "result": result}
async def execute_upload_file_action(
account, space_name: str, file_path: str, content_type: str | None = None
) -> dict:
from yuxi.channel.extensions.googlechat.media import upload_media_file
result = await upload_media_file(account, space_name, file_path, content_type)
token = result.get("attachmentUploadToken")
if token:
from yuxi.channel.extensions.googlechat.api import send_message_with_attachments
msg = await send_message_with_attachments(
account, space_name, "", [{"attachmentUploadToken": token}]
)
return {"success": True, "action": "upload-file", "result": msg}
return {"success": True, "action": "upload-file", "result": result}
async def execute_react_action(account, message_name: str, emoji: str, remove: bool = False) -> dict:
from yuxi.channel.extensions.googlechat.reactions import execute_react_action as _execute
return await _execute(account, message_name, emoji, remove)
async def execute_reactions_action(account, message_name: str) -> dict:
from yuxi.channel.extensions.googlechat.reactions import get_reactions
reactions = await get_reactions(account, message_name)
return {"success": True, "action": "reactions", "result": reactions}