mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-05-09 18:27:56 +08:00
add ncm
This commit is contained in:
@@ -45,9 +45,9 @@ class NcmArtist(TargetMixin, NewMessage):
|
||||
def get_date(self, post: RawPost) -> int:
|
||||
return post['publishTime'] // 1000
|
||||
|
||||
def parse(self, raw_post: RawPost) -> Post:
|
||||
text = '新专辑发布:{}'.format(raw_post.name)
|
||||
target_name = raw_post.artist.name
|
||||
async def parse(self, raw_post: RawPost) -> Post:
|
||||
text = '新专辑发布:{}'.format(raw_post['name'])
|
||||
target_name = raw_post['artist']['name']
|
||||
pics = [raw_post['picUrl']]
|
||||
url = "https://music.163.com/#/album?id={}".format(raw_post['id'])
|
||||
return Post('ncm-artist', text=text, url=url, pics=pics, target_name=target_name)
|
||||
|
||||
@@ -114,9 +114,9 @@ class MessageProcessMixin(PlatformNameMixin, CategoryMixin, ParsePostMixin, abst
|
||||
self.parse_cache[post_id] = await self.parse(raw_post)
|
||||
break
|
||||
except Exception as err:
|
||||
retry_times -= 1
|
||||
if not retry_times:
|
||||
raise err
|
||||
retry_times -= 1
|
||||
return self.parse_cache[post_id]
|
||||
|
||||
@abstractmethod
|
||||
|
||||
@@ -21,7 +21,7 @@ class Post:
|
||||
compress: bool = False
|
||||
override_use_pic: Optional[bool] = None
|
||||
pics: list[Union[str,bytes]] = field(default_factory=list)
|
||||
extra_msg = list[Message]
|
||||
extra_msg: list[Message] = field(default_factory=list)
|
||||
|
||||
_message: Optional[list] = None
|
||||
|
||||
@@ -125,8 +125,8 @@ class Post:
|
||||
# msgs.append(Message("[CQ:image,file={url}]".format(url=pic)))
|
||||
msgs.append(MessageSegment.image(pic))
|
||||
if self.compress:
|
||||
msgs = Message([msgs])
|
||||
msgs += self.extra_msg
|
||||
msgs = [Message([msgs])]
|
||||
msgs.extend(self.extra_msg)
|
||||
self._message = msgs
|
||||
return self._message
|
||||
|
||||
|
||||
Reference in New Issue
Block a user