mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-03 18:06:13 +08:00
add terra-historicus
This commit is contained in:
parent
47eb826e82
commit
ee2a807ebf
@ -189,3 +189,47 @@ class MonsterSiren(NewMessage):
|
||||
compress=True,
|
||||
override_use_pic=False,
|
||||
)
|
||||
|
||||
|
||||
class TerraHistoricusComic(NewMessage):
|
||||
|
||||
categories = {4: "泰拉记事社漫画"}
|
||||
platform_name = "arknights"
|
||||
name = "明日方舟游戏信息"
|
||||
enable_tag = False
|
||||
enabled = True
|
||||
is_common = False
|
||||
schedule_type = "interval"
|
||||
schedule_kw = {"seconds": 30}
|
||||
has_target = False
|
||||
|
||||
async def get_target_name(self, _: Target) -> str:
|
||||
return "明日方舟游戏信息"
|
||||
|
||||
async def get_sub_list(self, _) -> list[RawPost]:
|
||||
async with httpx.AsyncClient() as client:
|
||||
raw_data = await client.get(
|
||||
"https://terra-historicus.hypergryph.com/api/recentUpdate"
|
||||
)
|
||||
return raw_data.json()["data"]
|
||||
|
||||
def get_id(self, post: RawPost) -> Any:
|
||||
return f'{post["comicCid"]}/{post["episodeCid"]}'
|
||||
|
||||
def get_date(self, _) -> None:
|
||||
return None
|
||||
|
||||
def get_category(self, _) -> Category:
|
||||
return Category(4)
|
||||
|
||||
async def parse(self, raw_post: RawPost) -> Post:
|
||||
url = f'https://terra-historicus.hypergryph.com/comic/{raw_post["comicCid"]}/episode/{raw_post["episodeCid"]}'
|
||||
return Post(
|
||||
"terra-historicus",
|
||||
text=f'{raw_post["title"]} - {raw_post["episodeShortTitle"]}',
|
||||
pics=[raw_post["coverUrl"]],
|
||||
url=url,
|
||||
target_name="泰拉记事社漫画",
|
||||
compress=True,
|
||||
override_use_pic=False,
|
||||
)
|
||||
|
1
tests/platforms/static/terra-hist-0.json
Normal file
1
tests/platforms/static/terra-hist-0.json
Normal file
@ -0,0 +1 @@
|
||||
{"code":0,"msg":"","data":[{"coverUrl":"https://web.hycdn.cn/comic/pic/20220507/c4da4fb95587101f1867a30fe85cb557.png","comicCid":"6253","title":"123罗德岛!?","subtitle":"你可能不知道的罗德岛小剧场!","episodeCid":"5771","episodeType":1,"episodeShortTitle":"「流明」篇","updateTime":1652025600},{"coverUrl":"https://web.hycdn.cn/comic/pic/20220505/5c296539f5dc808603f20dda86879c9c.png","comicCid":"0696","title":"A1行动预备组","subtitle":"","episodeCid":"2897","episodeType":1,"episodeShortTitle":"01","updateTime":1651852800},{"coverUrl":"https://web.hycdn.cn/comic/pic/20220428/f4dc1e91420d18eccb80d60bba322d42.png","comicCid":"6253","title":"123罗德岛!?","subtitle":"你可能不知道的罗德岛小剧场!","episodeCid":"6346","episodeType":1,"episodeShortTitle":"「艾丽妮」篇","updateTime":1651507200}]}
|
1
tests/platforms/static/terra-hist-1.json
Normal file
1
tests/platforms/static/terra-hist-1.json
Normal file
@ -0,0 +1 @@
|
||||
{"code":0,"msg":"","data":[{"coverUrl":"https://web.hycdn.cn/comic/pic/20220507/ab8a2ff408ec7d587775aed70b178ec0.png","comicCid":"6253","title":"123罗德岛!?","subtitle":"你可能不知道的罗德岛小剧场!","episodeCid":"4938","episodeType":1,"episodeShortTitle":"「掠风」篇","updateTime":1652112000},{"coverUrl":"https://web.hycdn.cn/comic/pic/20220507/c4da4fb95587101f1867a30fe85cb557.png","comicCid":"6253","title":"123罗德岛!?","subtitle":"你可能不知道的罗德岛小剧场!","episodeCid":"5771","episodeType":1,"episodeShortTitle":"「流明」篇","updateTime":1652025600},{"coverUrl":"https://web.hycdn.cn/comic/pic/20220505/5c296539f5dc808603f20dda86879c9c.png","comicCid":"0696","title":"A1行动预备组","subtitle":"","episodeCid":"2897","episodeType":1,"episodeShortTitle":"01","updateTime":1651852800},{"coverUrl":"https://web.hycdn.cn/comic/pic/20220428/f4dc1e91420d18eccb80d60bba322d42.png","comicCid":"6253","title":"123罗德岛!?","subtitle":"你可能不知道的罗德岛小剧场!","episodeCid":"6346","episodeType":1,"episodeShortTitle":"「艾丽妮」篇","updateTime":1651507200}]}
|
@ -61,6 +61,7 @@ async def test_fetch_new(
|
||||
"https://ak-conf.hypergryph.com/config/prod/announce_meta/IOS/preannouncement.meta.json"
|
||||
)
|
||||
monster_siren_router = respx.get("https://monster-siren.hypergryph.com/api/news")
|
||||
terra_list = respx.get("https://terra-historicus.hypergryph.com/api/recentUpdate")
|
||||
ak_list_router.mock(return_value=Response(200, json=arknights_list__1))
|
||||
detail_router.mock(
|
||||
return_value=Response(200, text=get_file("arknights-detail-807"))
|
||||
@ -72,6 +73,7 @@ async def test_fetch_new(
|
||||
return_value=Response(200, json=get_json("arknights-pre-0.json"))
|
||||
)
|
||||
monster_siren_router.mock(return_value=Response(200, json=monster_siren_list_0))
|
||||
terra_list.mock(return_value=Response(200, json=get_json("terra-hist-0.json")))
|
||||
target = ""
|
||||
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
|
||||
assert ak_list_router.called
|
||||
@ -90,7 +92,17 @@ async def test_fetch_new(
|
||||
assert len(post.pics) == 1
|
||||
# assert(post.pics == ['https://ak-fs.hypergryph.com/announce/images/20210623/e6f49aeb9547a2278678368a43b95b07.jpg'])
|
||||
print(res3[0][1])
|
||||
r = await post.generate_messages()
|
||||
await post.generate_messages()
|
||||
terra_list.mock(return_value=Response(200, json=get_json("terra-hist-1.json")))
|
||||
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
|
||||
assert len(res) == 1
|
||||
post = res[0][1][0]
|
||||
assert post.target_type == "terra-historicus"
|
||||
assert post.text == "123罗德岛!? - 「掠风」篇"
|
||||
assert post.url == "https://terra-historicus.hypergryph.com/comic/6253/episode/4938"
|
||||
assert post.pics == [
|
||||
"https://web.hycdn.cn/comic/pic/20220507/ab8a2ff408ec7d587775aed70b178ec0.png"
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.render
|
||||
@ -116,6 +128,7 @@ async def test_send_with_render(
|
||||
"https://ak-conf.hypergryph.com/config/prod/announce_meta/IOS/preannouncement.meta.json"
|
||||
)
|
||||
monster_siren_router = respx.get("https://monster-siren.hypergryph.com/api/news")
|
||||
terra_list = respx.get("https://terra-historicus.hypergryph.com/api/recentUpdate")
|
||||
ak_list_router.mock(return_value=Response(200, json=arknights_list_0))
|
||||
detail_router.mock(
|
||||
return_value=Response(200, text=get_file("arknights-detail-805"))
|
||||
@ -127,6 +140,7 @@ async def test_send_with_render(
|
||||
return_value=Response(200, json=get_json("arknights-pre-0.json"))
|
||||
)
|
||||
monster_siren_router.mock(return_value=Response(200, json=monster_siren_list_0))
|
||||
terra_list.mock(return_value=Response(200, json=get_json("terra-hist-0.json")))
|
||||
target = ""
|
||||
res = await arknights.fetch_new_post(target, [dummy_user_subinfo])
|
||||
assert ak_list_router.called
|
||||
|
Loading…
x
Reference in New Issue
Block a user