diff --git a/bot/feishu.py b/bot/feishu.py index 63505c9..8b1b416 100644 --- a/bot/feishu.py +++ b/bot/feishu.py @@ -57,55 +57,8 @@ def _split_message(text: str) -> list[str]: async def send_text(receive_id: str, receive_id_type: str, text: str) -> None: - """ - Send a plain-text message to a Feishu chat or user. - Automatically splits long messages into multiple parts with [1/N] headers. - - Args: - receive_id: chat_id or open_id depending on receive_id_type. - receive_id_type: "chat_id" | "open_id" | "user_id" | "union_id". - text: message content. - """ - parts = _split_message(text) - loop = asyncio.get_running_loop() - - for i, part in enumerate(parts): - logger.debug( - "[feishu] send_text to=%s type=%s part=%d/%d len=%d", - receive_id, receive_id_type, i + 1, len(parts), len(part), - ) - content = json.dumps({"text": part}, ensure_ascii=False) - - request = ( - CreateMessageRequest.builder() - .receive_id_type(receive_id_type) - .request_body( - CreateMessageRequestBody.builder() - .receive_id(receive_id) - .msg_type("text") - .content(content) - .build() - ) - .build() - ) - - response = await loop.run_in_executor( - None, - lambda: _client.im.v1.message.create(request), - ) - - if not response.success(): - logger.error( - "Feishu send_text failed: code=%s msg=%s", - response.code, - response.msg, - ) - return - else: - logger.debug("Sent message part %d/%d to %s (%s)", i + 1, len(parts), receive_id, receive_id_type) - - if len(parts) > 1 and i < len(parts) - 1: - await asyncio.sleep(0.3) + """Alias for send_markdown. All messages are sent as markdown cards.""" + await send_markdown(receive_id, receive_id_type, text) async def send_markdown(receive_id: str, receive_id_type: str, content: str) -> None: