update post

This commit is contained in:
felinae98 2021-02-10 19:48:12 +08:00
parent 1956b3ebc5
commit cac1bb6ef8
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610

View File

@ -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)))