mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-02-04 21:54:08 +08:00
add cache for gen msg
This commit is contained in:
parent
ad1bd7f6e0
commit
129269c193
@ -19,9 +19,10 @@ class Post:
|
||||
target_name: Optional[str] = None
|
||||
compress: bool = False
|
||||
override_use_pic: Optional[bool] = None
|
||||
|
||||
pics: list[str] = field(default_factory=list)
|
||||
|
||||
_message: Optional[list] = None
|
||||
|
||||
def _use_pic(self):
|
||||
if not self.override_use_pic is None:
|
||||
return self.override_use_pic
|
||||
@ -97,6 +98,7 @@ class Post:
|
||||
self.pics.insert(0, b64image)
|
||||
|
||||
async def generate_messages(self):
|
||||
if self._message is None:
|
||||
await self._pic_merge()
|
||||
msgs = []
|
||||
text = ''
|
||||
@ -117,7 +119,8 @@ class Post:
|
||||
msgs.append("[CQ:image,file={url}]".format(url=pic))
|
||||
if self.compress:
|
||||
msgs = [''.join(msgs)]
|
||||
return msgs
|
||||
self._message = msgs
|
||||
return self._message
|
||||
|
||||
def __str__(self):
|
||||
return 'type: {}\nfrom: {}\ntext: {}\nurl: {}\npic: {}'.format(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user