update arknights

This commit is contained in:
felinae98 2021-11-01 13:26:52 +08:00
parent 9e7ecfbada
commit 3bd66c5f36
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 21 additions and 2 deletions

View File

@ -82,9 +82,13 @@ class AkVersion(NoTargetMixin, StatusChange):
def compare_status(self, _, old_status, new_status):
res = []
if old_status.get('preAnnounceType') == 2 and new_status.get('preAnnounceType') == 0:
res.append(Post('arknights', text='开始维护!', target_name='明日方舟更新信息'))
res.append(Post('arknights',
text='登录界面维护公告上线(大概是开始维护了)',
target_name='明日方舟更新信息'))
elif old_status.get('preAnnounceType') == 0 and new_status.get('preAnnounceType') == 2:
res.append(Post('arknights', text='维护结束!冲!(可能不太准确)', target_name='明日方舟更新信息'))
res.append(Post('arknights',
text='登录界面维护公告下线(大概是开服了,冲!)',
target_name='明日方舟更新信息'))
if old_status.get('clientVersion') != new_status.get('clientVersion'):
res.append(Post('arknights', text='游戏本体更新(大更新)', target_name='明日方舟更新信息'))
if old_status.get('resVersion') != new_status.get('resVersion'):

View File

@ -3,6 +3,7 @@ import base64
from html import escape
import os
from time import asctime
import re
from typing import Awaitable, Callable, Optional
from nonebot.adapters.cqhttp.message import MessageSegment
@ -12,6 +13,8 @@ from pyppeteer.browser import Browser
from pyppeteer.chromium_downloader import check_chromium, download_chromium
from pyppeteer.page import Page
from bs4 import BeautifulSoup as bs
from .plugin_config import plugin_config
class Singleton(type):
@ -121,3 +124,15 @@ async def parse_text(text: str) -> MessageSegment:
return await render.text_to_pic_cqcode(text)
else:
return MessageSegment.text(text)
def html_to_text(html: str, query_dict: dict = {}) -> str:
html = re.sub(r'<br\s*/?>', '<br>\n', html)
html = html.replace('</p>', '</p>\n')
soup = bs(html, 'html.parser')
if query_dict:
node = soup.find(**query_dict)
else:
node = soup
assert node is not None
return node.text.strip()