mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-06 20:06:12 +08:00
fix bugs
This commit is contained in:
parent
4f3325d988
commit
8e86fc7f02
@ -16,3 +16,6 @@
|
|||||||
- 修复不发送来源
|
- 修复不发送来源
|
||||||
- 发送RSS订阅的title
|
- 发送RSS订阅的title
|
||||||
- 修复浏览器渲染问题
|
- 修复浏览器渲染问题
|
||||||
|
|
||||||
|
## [0.3.2]
|
||||||
|
- 增加NoTargetGroup
|
||||||
|
@ -14,16 +14,15 @@ async def check_sub_target(target_type, target):
|
|||||||
return await platform_manager[target_type].get_target_name(target)
|
return await platform_manager[target_type].get_target_name(target)
|
||||||
|
|
||||||
_platform_list = defaultdict(list)
|
_platform_list = defaultdict(list)
|
||||||
for platform in Platform.registory:
|
for _platform in Platform.registory:
|
||||||
if not platform.enabled:
|
if not _platform.enabled:
|
||||||
continue
|
continue
|
||||||
_platform_list[platform.platform_name].append(platform)
|
_platform_list[_platform.platform_name].append(_platform)
|
||||||
|
|
||||||
platform_manager: dict[str, Platform] = dict()
|
platform_manager: dict[str, Platform] = dict()
|
||||||
for name, platform_list in _platform_list.items():
|
for name, platform_list in _platform_list.items():
|
||||||
if len(platform_list) == 1:
|
if len(platform_list) == 1:
|
||||||
platform_manager[name] = platform_list[0]()
|
platform_manager[name] = platform_list[0]()
|
||||||
else:
|
else:
|
||||||
platform_manager[name] = NoTargetGroup(platform_list)
|
platform_manager[name] = NoTargetGroup([_platform() for _platform in platform_list])
|
||||||
|
|
||||||
print(platform_manager)
|
|
||||||
|
@ -79,7 +79,7 @@ class AkVersion(NoTargetMixin, StatusChange):
|
|||||||
res.update(res_preanounce.json())
|
res.update(res_preanounce.json())
|
||||||
return res
|
return res
|
||||||
|
|
||||||
async def compare_status(self, _, old_status, new_status):
|
def compare_status(self, _, old_status, new_status):
|
||||||
res = []
|
res = []
|
||||||
if old_status.get('preAnnounceType') == 2 and new_status.get('preAnnounceType') == 0:
|
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='明日方舟更新信息'))
|
||||||
|
@ -346,7 +346,7 @@ class NoTargetGroup(
|
|||||||
async def fetch_new_post(self, target, users):
|
async def fetch_new_post(self, target, users):
|
||||||
res = defaultdict(list)
|
res = defaultdict(list)
|
||||||
for platform in self.platform_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:
|
for user, posts in platform_res:
|
||||||
res[user].extend(posts)
|
res[user].extend(posts)
|
||||||
return [[key, val] for key, val in res.items()]
|
return [[key, val] for key, val in res.items()]
|
||||||
|
@ -28,8 +28,12 @@ def arknights_list_1():
|
|||||||
async def test_fetch_new(arknights, dummy_user_subinfo, arknights_list_0, 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")
|
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")
|
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))
|
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')))
|
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 = ''
|
target = ''
|
||||||
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
|
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
|
||||||
assert(ak_list_router.called)
|
assert(ak_list_router.called)
|
||||||
|
@ -259,12 +259,12 @@ def mock_status_change(plugin_module: 'nonebot_hk_reporter'):
|
|||||||
else:
|
else:
|
||||||
return {'s': False}
|
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:
|
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:
|
elif old_status['s'] == True and new_status['s'] == False:
|
||||||
return {'text': 'off', 'cat': 2}
|
return [{'text': 'off', 'cat': 2}]
|
||||||
return None
|
return []
|
||||||
|
|
||||||
async def parse(self, raw_post) -> 'Post':
|
async def parse(self, raw_post) -> 'Post':
|
||||||
return plugin_module.post.Post('mock_status', raw_post['text'], '')
|
return plugin_module.post.Post('mock_status', raw_post['text'], '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user