1
0
forked from bot/app

feat: 对部分消息回复用markdown进行了重新排版

This commit is contained in:
2024-03-20 18:27:49 +08:00
parent fdefedf288
commit 8a1c981666
8 changed files with 152 additions and 118 deletions

View File

@ -3,11 +3,14 @@ from nonebot.adapters.onebot import v11, v12
from typing_extensions import Any
from .tools import de_escape
from .typing import T_Bot
from .typing import T_Bot, T_MessageEvent
async def send_markdown(markdown: str, bot: T_Bot, message_type: str, session_id: str | int) -> tuple[dict[str, Any], dict[str, Any]]:
async def send_markdown(markdown: str, bot: T_Bot, *, message_type: str=None, session_id: str | int=None, event: T_MessageEvent=None) -> dict[str, Any]:
formatted_md = de_escape(markdown).replace("\n", r"\n").replace("\"", r'\\\"')
if event is not None and message_type is None:
message_type = event.message_type
session_id = event.user_id if event.message_type == "private" else event.group_id
try:
forward_data = await bot.call_api(
api="send_private_forward_msg",
@ -67,4 +70,4 @@ async def send_markdown(markdown: str, bot: T_Bot, message_type: str, session_id
else:
nonebot.logger.error("send_markdown: bot type not supported")
data = {}
return data, forward_data
return data