mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
🚑 修正图片渲染逻辑
This commit is contained in:
parent
2a51b24ba9
commit
0ce0034a56
@ -51,11 +51,13 @@ class Arknights(NewMessage):
|
||||
raw_data = raw_data.json()["data"]
|
||||
|
||||
announce_title = raw_data.get("header") if raw_data.get("header") != "" else raw_data.get("title")
|
||||
# text = "游戏公告更新:" + announce_title.replace('\n','')
|
||||
text = ""
|
||||
|
||||
pics = []
|
||||
if "content" in raw_data:
|
||||
if raw_data["bannerImageUrl"]:
|
||||
pics.append(raw_post["bannerImageUrl"])
|
||||
|
||||
elif raw_data["content"]:
|
||||
require("nonebot_plugin_htmlrender")
|
||||
from nonebot_plugin_htmlrender import template_to_pic
|
||||
|
||||
@ -69,7 +71,7 @@ class Arknights(NewMessage):
|
||||
"content": raw_data["content"],
|
||||
},
|
||||
pages={
|
||||
"viewport": {"width": 500, "height": 100},
|
||||
"viewport": {"width": 400, "height": 100},
|
||||
"base_url": f"file://{template_path}",
|
||||
},
|
||||
)
|
||||
@ -82,8 +84,6 @@ class Arknights(NewMessage):
|
||||
pics.append(pic_data)
|
||||
else:
|
||||
text = "图片渲染失败"
|
||||
elif "bannerImageUrl" in raw_data:
|
||||
pics.append(raw_post["bannerImageUrl"]) # type: ignore
|
||||
else:
|
||||
raise CategoryNotRecognize("未找到可渲染部分")
|
||||
return Post(
|
||||
|
Loading…
x
Reference in New Issue
Block a user