This commit is contained in:
felinae98 2021-08-01 16:15:55 +08:00
parent 4f3325d988
commit 8e86fc7f02
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
6 changed files with 17 additions and 11 deletions

View File

@ -16,3 +16,6 @@
- 修复不发送来源
- 发送RSS订阅的title
- 修复浏览器渲染问题
## [0.3.2]
- 增加NoTargetGroup

View File

@ -14,16 +14,15 @@ async def check_sub_target(target_type, target):
return await platform_manager[target_type].get_target_name(target)
_platform_list = defaultdict(list)
for platform in Platform.registory:
if not platform.enabled:
for _platform in Platform.registory:
if not _platform.enabled:
continue
_platform_list[platform.platform_name].append(platform)
_platform_list[_platform.platform_name].append(_platform)
platform_manager: dict[str, Platform] = dict()
for name, platform_list in _platform_list.items():
if len(platform_list) == 1:
platform_manager[name] = platform_list[0]()
else:
platform_manager[name] = NoTargetGroup(platform_list)
platform_manager[name] = NoTargetGroup([_platform() for _platform in platform_list])
print(platform_manager)

View File

@ -79,7 +79,7 @@ class AkVersion(NoTargetMixin, StatusChange):
res.update(res_preanounce.json())
return res
async def compare_status(self, _, old_status, new_status):
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='明日方舟更新信息'))

View File

@ -346,7 +346,7 @@ class NoTargetGroup(
async def fetch_new_post(self, target, users):
res = defaultdict(list)
for platform in self.platform_list:
platform_res = await platform.fetch_new_post(target, users)
platform_res = await platform.fetch_new_post(target=target, users=users)
for user, posts in platform_res:
res[user].extend(posts)
return [[key, val] for key, val in res.items()]

View File

@ -28,8 +28,12 @@ def arknights_list_1():
async def test_fetch_new(arknights, dummy_user_subinfo, arknights_list_0, arknights_list_1):
ak_list_router = respx.get("https://ak-conf.hypergryph.com/config/prod/announce_meta/IOS/announcement.meta.json")
detail_router = respx.get("https://ak-fs.hypergryph.com/announce/IOS/announcement/675.html")
version_router = respx.get('https://ak-conf.hypergryph.com/config/prod/official/IOS/version')
preannouncement_router = respx.get('https://ak-conf.hypergryph.com/config/prod/announce_meta/IOS/preannouncement.meta.json')
ak_list_router.mock(return_value=Response(200, json=arknights_list_0))
detail_router.mock(return_value=Response(200, text=get_file('arknights-detail-675.html')))
version_router.mock(return_value=Response(200, json=get_json('arknights-version-0.json')))
preannouncement_router.mock(return_value=Response(200, json=get_json('arknights-pre-0.json')))
target = ''
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
assert(ak_list_router.called)

View File

@ -259,12 +259,12 @@ def mock_status_change(plugin_module: 'nonebot_hk_reporter'):
else:
return {'s': False}
def compare_status(self, target, old_status, new_status) -> Optional['RawPost']:
def compare_status(self, target, old_status, new_status) -> list['RawPost']:
if old_status['s'] == False and new_status['s'] == True:
return {'text': 'on', 'cat': 1}
return [{'text': 'on', 'cat': 1}]
elif old_status['s'] == True and new_status['s'] == False:
return {'text': 'off', 'cat': 2}
return None
return [{'text': 'off', 'cat': 2}]
return []
async def parse(self, raw_post) -> 'Post':
return plugin_module.post.Post('mock_status', raw_post['text'], '')