This commit is contained in:
baiqwerdvd 2024-12-28 17:09:59 +08:00
parent 2cfe45d2cf
commit 0f99c7ff47
2 changed files with 17 additions and 8 deletions

View File

@ -122,7 +122,7 @@ async def check_ark_ann():
img = await get_ann_img(data)
title = data.title.replace("\\n", "")
msg = [
MessageSegment.text(f"[明日方舟公告] {title}\n"),
MessageSegment.text(f"[明日方舟公告更新] {title}\n"),
MessageSegment.image(img),
]

View File

@ -3,11 +3,12 @@ from pathlib import Path
from typing import cast
import aiohttp
from gsuid_core.data_store import get_res_path
from gsuid_core.logger import logger
from msgspec import convert
from msgspec import json as msgjson
from gsuid_core.data_store import get_res_path
from gsuid_core.logger import logger
from .model import (
BulletinData,
BulletinMeta,
@ -73,15 +74,20 @@ async def check_bulletin_update() -> dict[str, BulletinData]:
if cur_meta.get("code") == 0:
match target:
case "Android":
android_data = convert(cur_meta.get("data", {}), BulletinTargetData)
android_data = convert(
cur_meta.get("data", {}), BulletinTargetData
)
bulletin_meta.target.Android = android_data
case "Bilibili":
bilibili_data = convert(cur_meta.get("data", {}), BulletinTargetData)
bilibili_data = convert(
cur_meta.get("data", {}), BulletinTargetData
)
bulletin_meta.target.Bilibili = bilibili_data
case "IOS":
ios_data = convert(cur_meta.get("data", {}), BulletinTargetData)
ios_data = convert(
cur_meta.get("data", {}), BulletinTargetData
)
bulletin_meta.target.IOS = ios_data
logger.info("The file 'bulletin.meta.json' has been successfully updated.")
assert android_data is not None
assert bilibili_data is not None
@ -123,13 +129,16 @@ async def check_bulletin_update() -> dict[str, BulletinData]:
new_ann[item.cid] = ann
logger.info(f"New bulletin found: {item.cid}:{item.title}")
bulletin_meta.data = dict(sorted(bulletin_meta.data.items(), key=lambda x: int(x[0])))
bulletin_meta.data = dict(
sorted(bulletin_meta.data.items(), key=lambda x: int(x[0]))
)
bulletin_meta.update = dict(
sorted(bulletin_meta.update.items(), key=lambda x: x[1].cid, reverse=False)
)
data = msgjson.decode(msgjson.encode(bulletin_meta))
write_json(data, bulletin_path)
logger.info("The file 'bulletin.meta.json' has been successfully updated.")
if is_first:
logger.info("Initial success, will be updated in the next polling.")