From fe2ca8b05b76a386f4adb6a2bcccfb112575f8b9 Mon Sep 17 00:00:00 2001 From: snowy Date: Wed, 24 Apr 2024 15:20:32 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=93=88=E5=93=88=E5=93=88=E5=93=88?= =?UTF-8?q?=E5=93=88=E5=93=88=E5=93=88=EF=BC=8Cmarkdown=E5=AF=84=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E5=8F=91=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/utils/message/message.py | 39 +++++-------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/liteyuki/utils/message/message.py b/liteyuki/utils/message/message.py index 89b671a..56274e7 100644 --- a/liteyuki/utils/message/message.py +++ b/liteyuki/utils/message/message.py @@ -22,7 +22,8 @@ from nonebot_plugin_htmlrender import md_to_pic config = load_from_yaml("config.yml") can_send_markdown = {} # 用于存储机器人是否支持发送markdown消息,id->bool - +class TencentBannedMarkdownError(BaseException): + pass async def broadcast_to_superusers(message: str | T_Message, markdown: bool = False): """广播消息给超级用户""" @@ -64,6 +65,7 @@ class MarkdownMessage: message_type = event.message_type session_id = event.user_id if event.message_type == "private" else event.group_id try: + raise TencentBannedMarkdownError("Tencent banned markdown") data = await bot.send_msg( user_id=session_id, group_id=session_id, @@ -75,45 +77,16 @@ class MarkdownMessage: "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" - # - # } - # } - # ] - # } - # ] - # } - # } - # } ], **kwargs ) except BaseException as e: nonebot.logger.error(f"send markdown error, retry as image: {e}") # 发送失败,渲染为图片发送 - if not retry_as_image: - return None + # if not retry_as_image: + # return None - plain_markdown = markdown.replace("🔗", "") + plain_markdown = markdown.replace("[🔗", "[") md_image_bytes = await md_to_pic( md=plain_markdown, width=540,