预渲染数据,发送更快

This commit is contained in:
2024-04-22 21:05:35 +08:00
parent ae19113141
commit bd5f6c5205
14 changed files with 1178 additions and 93 deletions

View File

@ -6,6 +6,7 @@ import aiohttp
from PIL import Image
from ..base.config import get_config
from ..base.data import LiteModel
from ..base.ly_typing import T_Bot
@ -195,3 +196,14 @@ class Mqqapi:
# 若命令前缀不为空,则使用配置的第一个命令前缀
cmd = f"{command_start[0]}{cmd}"
return f"[{text}](mqqapi://aio/inlinecmd?command={quote(cmd)}&reply={str(reply).lower()}&enter={str(enter).lower()})"
class RenderData(LiteModel):
label: str
visited_label: str
style: int
class Button(LiteModel):
id: int
render_data: RenderData

View File

@ -64,28 +64,6 @@ class MarkdownMessage:
message_type = event.message_type
session_id = event.user_id if event.message_type == "private" else event.group_id
try:
# 构建Markdown消息并获取转发消息ID
# forward_id = await bot.call_api(
# api="send_forward_msg",
# messages=[
# v11.MessageSegment(
# type="node",
# data={
# "name" : "Liteyuki.OneBot",
# "uin" : bot.self_id,
# "content": [
# {
# "type": "markdown",
# "data": {
# "content": '{"content":"%s"}' % formatted_md
# }
# },
# ]
# },
# )
# ]
# )
# 发送Markdown longmsg并获取相应数据
data = await bot.send_msg(
user_id=session_id,
group_id=session_id,
@ -94,27 +72,39 @@ class MarkdownMessage:
{
"type": "markdown",
"data": {
"content": "{\"content\":\"%s\"}" % formatted_md
"content": "{\"content\":\"%s\"}" % formatted_md,
}
}
},
# {
# "type": "keyboard",
# "data": {
# "content": {
# "rows": [
# {
# "buttons": [
# {
# "render_data": {
# "label" : "NPM",
# "visited_label": "NPM已点击",
# "style" : 1
# },
# "action" : {
# "type" : 2,
# "enter" : True,
# "permission": {
# "type": 2
# },
# "data" : "npm"
#
# }
# }
# ]
# }
# ]
# }
# }
# }
],
# messages=[
# v11.MessageSegment(
# type="node",
# data={
# "name": "Liteyuki.OneBot",
# "uin": bot.self_id,
# "content": [
# {
# "type": "markdown",
# "data": {
# "content": '{"content":"%s"}' % formatted_md
# }
# }
# ]
# }
# ),
# ],
**kwargs
)
except BaseException as e: