From f9a92678951e0368f790950b8c58732347ba9a03 Mon Sep 17 00:00:00 2001 From: felinae98 <731499577@qq.com> Date: Thu, 18 Feb 2021 22:38:46 +0800 Subject: [PATCH 1/2] add compress for post --- src/plugins/hk_reporter/post.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/plugins/hk_reporter/post.py b/src/plugins/hk_reporter/post.py index 819c8fb..e0c209e 100644 --- a/src/plugins/hk_reporter/post.py +++ b/src/plugins/hk_reporter/post.py @@ -10,26 +10,28 @@ class Post: text: str url: str target_name: Optional[str] = None - show_text: bool = True + compress: bool = False + pics: list[str] = field(default_factory=list) async def generate_messages(self): msgs = [] - if self.show_text: - text = '来源: {}'.format(self.target_type) - if self.target_name: - text += '\n{}'.format(self.target_name) - if self.text: - text += '\n{}'.format(self.text) - if plugin_config.hk_reporter_use_pic: - msgs.append(await parse_text(text)) - if not self.target_type == 'rss': - msgs.append(self.url) - else: - text += '详情: {}'.format(self.url) - msgs.append(text) + text = '来源: {}'.format(self.target_type) + if self.target_name: + text += '\n{}'.format(self.target_name) + if self.text: + text += '\n{}'.format(self.text) + if plugin_config.hk_reporter_use_pic: + msgs.append(await parse_text(text)) + if not self.target_type == 'rss': + msgs.append(self.url) + else: + text += '详情: {}'.format(self.url) + msgs.append(text) for pic in self.pics: msgs.append("[CQ:image,file={url}]".format(url=pic)) + if not self.compress: + msgs = [''.join(msgs)] return msgs def __str__(self): From 37c3751f0a66f7bb39b123d6ec765b62533f8cf9 Mon Sep 17 00:00:00 2001 From: felinae98 <731499577@qq.com> Date: Thu, 18 Feb 2021 22:57:24 +0800 Subject: [PATCH 2/2] update post style --- src/plugins/hk_reporter/post.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/hk_reporter/post.py b/src/plugins/hk_reporter/post.py index e0c209e..5516c12 100644 --- a/src/plugins/hk_reporter/post.py +++ b/src/plugins/hk_reporter/post.py @@ -18,7 +18,7 @@ class Post: msgs = [] text = '来源: {}'.format(self.target_type) if self.target_name: - text += '\n{}'.format(self.target_name) + text += ' {}'.format(self.target_name) if self.text: text += '\n{}'.format(self.text) if plugin_config.hk_reporter_use_pic: @@ -35,8 +35,9 @@ class Post: return msgs def __str__(self): - return 'type: {}\ntext: {}\nurl: {}\npic: {}'.format( + return 'type: {}\nfrom: {}\ntext: {}\nurl: {}\npic: {}'.format( self.target_type, + self.target_name, self.text, self.url, ', '.join(map(lambda x: 'b64img' if x.startswith('base64') else x, self.pics))