42 lines
1.6 KiB
Python
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} |