fix generate bug

This commit is contained in:
felinae98 2021-09-07 22:47:25 +08:00
parent 8e61e27127
commit 01305c1cf6
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import base64 import base64
from dataclasses import dataclass, field from dataclasses import dataclass, field
from functools import reduce
from io import BytesIO from io import BytesIO
from typing import Optional, Union from typing import Optional, Union
@ -125,7 +126,7 @@ class Post:
# msgs.append(Message("[CQ:image,file={url}]".format(url=pic))) # msgs.append(Message("[CQ:image,file={url}]".format(url=pic)))
msgs.append(MessageSegment.image(pic)) msgs.append(MessageSegment.image(pic))
if self.compress: if self.compress:
msgs = [Message([msgs])] msgs = [reduce(lambda x, y: x.append(y), msgs, Message())]
msgs.extend(self.extra_msg) msgs.extend(self.extra_msg)
self._message = msgs self._message = msgs
return self._message return self._message

View File

@ -51,3 +51,4 @@ async def test_fetch_new(arknights, dummy_user_subinfo, arknights_list_0, arknig
assert(post.target_name == '明日方舟游戏内公告') assert(post.target_name == '明日方舟游戏内公告')
assert(len(post.pics) == 1) assert(len(post.pics) == 1)
assert(post.pics == ['https://ak-fs.hypergryph.com/announce/images/20210623/e6f49aeb9547a2278678368a43b95b07.jpg']) assert(post.pics == ['https://ak-fs.hypergryph.com/announce/images/20210623/e6f49aeb9547a2278678368a43b95b07.jpg'])
r = await post.generate_messages()