feat(chuni.read): Only enable announcement events of the latest imported option

This commit is contained in:
2024-06-27 11:06:47 +07:00
parent 549fd88b32
commit 93b4052727
2 changed files with 10 additions and 1 deletions

View File

@ -117,6 +117,11 @@ class ChuniReader(BaseReader):
)
async def read_events(self, evt_dir: str) -> None:
# Disable all previous announcement events
# All new announcement events will be enabled, so we don't end up with banner spam
# every time we card in.
await self.data.static.disable_all_events(self.version, 1)
for root, dirs, files in walk(evt_dir):
for dir in dirs:
if path.exists(f"{root}/{dir}/Event.xml"):

View File

@ -339,6 +339,10 @@ class ChuniStaticData(BaseData):
if result is None:
return None
return result.fetchall()
async def disable_all_events(self, version: int, type: int):
sql = events.update().where((events.c.version == version) & (events.c.type == type))
await self.execute(sql)
async def put_music(
self,
@ -593,4 +597,4 @@ class ChuniStaticData(BaseData):
result = await self.execute(sql)
if result is None:
return None
return result.fetchone()
return result.fetchone()