mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 10:17:56 +08:00
🐛 补充主题渲染时遗漏的转发推文中的图片 (#554)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from nonebot_plugin_saa import Text, Image, MessageSegmentFactory
|
||||
@@ -44,8 +46,14 @@ class BasicTheme(Theme):
|
||||
|
||||
client = await post.platform.ctx.get_client_for_static()
|
||||
msgs: list[MessageSegmentFactory] = [Text(text)]
|
||||
|
||||
pics_group: list[list[str | bytes | Path | BytesIO]] = []
|
||||
if post.images:
|
||||
pics = post.images
|
||||
pics_group.append(post.images)
|
||||
if rp and rp.images:
|
||||
pics_group.append(rp.images)
|
||||
|
||||
for pics in pics_group:
|
||||
if is_pics_mergable(pics):
|
||||
pics = await pic_merge(list(pics), client)
|
||||
msgs.extend(map(Image, pics))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
@@ -8,6 +9,7 @@ from nonebot_plugin_saa import Text, Image, MessageSegmentFactory
|
||||
|
||||
from nonebot_bison.compat import model_validator
|
||||
from nonebot_bison.theme.utils import convert_to_qr
|
||||
from nonebot_bison.utils.image import pic_merge, is_pics_mergable
|
||||
from nonebot_bison.theme import Theme, ThemeRenderError, ThemeRenderUnsupportError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -109,6 +111,16 @@ class CeobeCanteenTheme(Theme):
|
||||
text += f"详情: {post.url}"
|
||||
msgs.append(Text(text))
|
||||
|
||||
pics_group: list[list[str | bytes | Path | BytesIO]] = []
|
||||
if post.images:
|
||||
msgs.extend(map(Image, post.images))
|
||||
pics_group.append(post.images)
|
||||
if post.repost and post.repost.images:
|
||||
pics_group.append(post.repost.images)
|
||||
|
||||
client = await post.platform.ctx.get_client_for_static()
|
||||
for pics in pics_group:
|
||||
if is_pics_mergable(pics):
|
||||
pics = await pic_merge(list(pics), client)
|
||||
msgs.extend(map(Image, pics))
|
||||
|
||||
return msgs
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Literal
|
||||
|
||||
from nonebot_plugin_saa import Text, Image, MessageSegmentFactory
|
||||
@@ -53,9 +55,15 @@ class Ht2iTheme(Theme):
|
||||
if urls:
|
||||
msgs.append(Text("\n".join(urls)))
|
||||
|
||||
pics_group: list[list[str | bytes | Path | BytesIO]] = []
|
||||
if post.images:
|
||||
client = await post.platform.ctx.get_client_for_static()
|
||||
pics = post.images
|
||||
pics_group.append(post.images)
|
||||
if rp and rp.images:
|
||||
pics_group.append(rp.images)
|
||||
|
||||
client = await post.platform.ctx.get_client_for_static()
|
||||
|
||||
for pics in pics_group:
|
||||
if is_pics_mergable(pics):
|
||||
pics = await pic_merge(list(pics), client)
|
||||
msgs.extend(map(Image, pics))
|
||||
|
||||
Reference in New Issue
Block a user