mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 00:56:10 +08:00
fix pic merge
This commit is contained in:
parent
5d1108d635
commit
103ea69a3f
@ -117,3 +117,4 @@ class Weibo(NewMessage, TargetMixin):
|
||||
detail_url = 'https://weibo.com/{}/{}'.format(info['user']['id'], info['bid'])
|
||||
# return parsed_text, detail_url, pic_urls
|
||||
return Post('weibo', text=parsed_text, url=detail_url, pics=pic_urls, target_name=info['user']['screen_name'])
|
||||
|
||||
|
@ -21,7 +21,7 @@ class Post:
|
||||
target_name: Optional[str] = None
|
||||
compress: bool = False
|
||||
override_use_pic: Optional[bool] = None
|
||||
pics: list[Union[str,bytes]] = field(default_factory=list)
|
||||
pics: Union[list[Union[str,bytes]], list[str], list[bytes]] = field(default_factory=list)
|
||||
extra_msg: list[Message] = field(default_factory=list)
|
||||
|
||||
_message: Optional[list] = None
|
||||
@ -66,6 +66,8 @@ class Post:
|
||||
x_coord.append(_tmp)
|
||||
y_coord = [0, first_image.size[1]]
|
||||
async def process_row(row: int) -> bool:
|
||||
if len(self.pics) < (row + 1) * 3:
|
||||
return False
|
||||
row_first_img = await self._pic_url_to_image(self.pics[row * 3])
|
||||
if not self._check_image_square(row_first_img.size):
|
||||
return False
|
||||
|
@ -40,3 +40,15 @@ async def test_3_merge(plugin_module):
|
||||
post = plugin_module.post.Post('', '', '', pics=merge_source_9[0:3]+merge_source_9[9:])
|
||||
await post._pic_merge()
|
||||
assert len(post.pics) == 5
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_6_merge_only(plugin_module):
|
||||
post = plugin_module.post.Post('', '', '', pics=merge_source_9[0:6])
|
||||
await post._pic_merge()
|
||||
assert len(post.pics) == 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_3_merge_only(plugin_module):
|
||||
post = plugin_module.post.Post('', '', '', pics=merge_source_9[0:3])
|
||||
await post._pic_merge()
|
||||
assert len(post.pics) == 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user