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