diff --git a/src/plugins/hk_reporter/post.py b/src/plugins/hk_reporter/post.py index a6b2feb..de6bd4a 100644 --- a/src/plugins/hk_reporter/post.py +++ b/src/plugins/hk_reporter/post.py @@ -1,12 +1,14 @@ +from dataclasses import dataclass, field from . import plugin_config from .utils import parse_text +@dataclass class Post: target_type: str text: str url: str - pics: list[str] + pics: list[str] = field(default_factory=list) async def generate_messages(self): if plugin_config.hk_reporter_use_pic: @@ -22,11 +24,5 @@ class Post: res.append("[CQ:image,file={url}]".format(url=pic)) return res - def __init__(self, target_type, text, url, pics=[]): - self.target_type = target_type - self.text = text - self.url = url - self.pics = pics - def __str__(self): return 'type: {}\ntext: {}\nurl: {}\npic: {}'.format(self.target_type, self.text[:50], self.url, ','.join(map(lambda x: 'b64img' if x.startswith('base64') else x, self.pics)))