Add weekly Blue Archive roster auto-refresh

This commit is contained in:
esef committed 2026-09-15 15:19:17 +03:00
1 parent 23b8c3722a
commit c8e3ab57cc
2 files changed
+30 -1

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ it started as a simple music bot and became a massive mess of features i actuall
- deepseek api for the ai stuff
- wavelink + lavalink (java) for music
- psutil + lm-sensors for hardware stats
- runs as systemd services: `discordbot` and `lavalink`
- runs as systemd services: `discordbot`, `lavalink`, and a weekly `discordbot-refresh.timer` that auto-updates the Blue Archive roster
## commands
+29
View File
@@ -0,0 +1,29 @@
"""Refresh the bundled Blue Archive roster from the live ennead.cc API.
Loads the current ba_students.json, merges any characters that have been
released since the last run, and atomically writes the result back. Run weekly
via the discordbot-refresh systemd timer so fresh clones stay current without
depending on the live API at startup.
"""
import asyncio
import json
from pathlib import Path
from blue_archive.data import db, fetch_banners
OUT = Path(__file__).with_name("ba_students.json")
async def main() -> None:
db.load()
banners = await fetch_banners()
added = await db.merge_ennead(banners)
tmp = OUT.with_suffix(".json.tmp")
tmp.write_text(json.dumps(db.students, ensure_ascii=False), encoding="utf-8")
tmp.replace(OUT) # atomic swap so a reader never sees a partial file
print(f"refreshed {OUT.name}: {len(db.students)} students (+{added} new)")
if __name__ == "__main__":
asyncio.run(main())