Merge branch 'main' into dev

This commit is contained in:
felinae98 2021-11-03 15:14:59 +08:00
commit 7f46d87c3f
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 29 additions and 1 deletions

View File

@ -52,6 +52,7 @@ class Arknights(NewMessage, NoTargetMixin):
pic_data = await render.render(announce_url, viewport=viewport, target='div.main')
if pic_data:
pics.append(pic_data)
else:
text = '图片渲染失败'
elif (pic := soup.find('img', class_='banner-image')):
pics.append(pic['src'])

View File

@ -241,7 +241,7 @@ class Platform(PlatformNameMixin, UserCustomFilterMixin, base=True):
...
class NewMessage(
Platform,
Platform,
NewMessageProcessMixin,
UserCustomFilterMixin,
abstract=True
@ -306,6 +306,33 @@ class StatusChange(
logger.warning("network connection error: {}, url: {}".format(type(err), err.request.url))
return []
class SimplePost(
Platform,
MessageProcessMixin,
UserCustomFilterMixin,
StorageMixinProto,
abstract=True
):
"Fetch a list of messages, dispatch it to different users"
async def fetch_new_post(self, target: Target, users: list[UserSubInfo]) -> list[tuple[User, list[Post]]]:
try:
new_posts = await self.get_sub_list(target)
if not new_posts:
return []
else:
for post in new_posts:
logger.info('fetch new post from {} {}: {}'.format(
self.platform_name,
target if self.has_target else '-',
self.get_id(post)))
res = await self.dispatch_user_post(target, new_posts, users)
self.parse_cache = {}
return res
except httpx.RequestError as err:
logger.warning("network connection error: {}, url: {}".format(type(err), err.request.url))
return []
class NoTargetGroup(
Platform,
NoTargetMixin,