mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-05 19:36:43 +08:00
add compress for post
This commit is contained in:
parent
30447f1299
commit
f9a9267895
@ -10,26 +10,28 @@ class Post:
|
|||||||
text: str
|
text: str
|
||||||
url: str
|
url: str
|
||||||
target_name: Optional[str] = None
|
target_name: Optional[str] = None
|
||||||
show_text: bool = True
|
compress: bool = False
|
||||||
|
|
||||||
pics: list[str] = field(default_factory=list)
|
pics: list[str] = field(default_factory=list)
|
||||||
|
|
||||||
async def generate_messages(self):
|
async def generate_messages(self):
|
||||||
msgs = []
|
msgs = []
|
||||||
if self.show_text:
|
text = '来源: {}'.format(self.target_type)
|
||||||
text = '来源: {}'.format(self.target_type)
|
if self.target_name:
|
||||||
if self.target_name:
|
text += '\n{}'.format(self.target_name)
|
||||||
text += '\n{}'.format(self.target_name)
|
if self.text:
|
||||||
if self.text:
|
text += '\n{}'.format(self.text)
|
||||||
text += '\n{}'.format(self.text)
|
if plugin_config.hk_reporter_use_pic:
|
||||||
if plugin_config.hk_reporter_use_pic:
|
msgs.append(await parse_text(text))
|
||||||
msgs.append(await parse_text(text))
|
if not self.target_type == 'rss':
|
||||||
if not self.target_type == 'rss':
|
msgs.append(self.url)
|
||||||
msgs.append(self.url)
|
else:
|
||||||
else:
|
text += '详情: {}'.format(self.url)
|
||||||
text += '详情: {}'.format(self.url)
|
msgs.append(text)
|
||||||
msgs.append(text)
|
|
||||||
for pic in self.pics:
|
for pic in self.pics:
|
||||||
msgs.append("[CQ:image,file={url}]".format(url=pic))
|
msgs.append("[CQ:image,file={url}]".format(url=pic))
|
||||||
|
if not self.compress:
|
||||||
|
msgs = [''.join(msgs)]
|
||||||
return msgs
|
return msgs
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user