mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
nv setting time format check before commit
This commit is contained in:
parent
371d4b1f94
commit
6eeb6377ff
1 changed files with 12 additions and 1 deletions
13
dist/ba_root/mods/setting.py
vendored
13
dist/ba_root/mods/setting.py
vendored
|
|
@ -7,7 +7,7 @@ from __future__ import annotations
|
|||
|
||||
from typing import TYPE_CHECKING
|
||||
from functools import lru_cache
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import _ba
|
||||
|
||||
|
|
@ -43,7 +43,18 @@ def commit(data: dict) -> None:
|
|||
data : dict
|
||||
data to be commited
|
||||
"""
|
||||
if is_invalid_time_format(data['autoNightMode']['startTime']) or is_invalid_time_format(data['autoNightMode']['endTime']):
|
||||
data['autoNightMode']['startTime'] = "18:30"
|
||||
data['autoNightMode']['endTime'] = "6:30"
|
||||
print("resetting night mode time")
|
||||
with open(SETTINGS_PATH, mode="w", encoding="utf-8") as setting_file:
|
||||
json.dump(data, setting_file, indent=4)
|
||||
# settings updated ok now update the cache
|
||||
refresh_cache()
|
||||
|
||||
def is_invalid_time_format(time_string, time_format='%H:%M'):
|
||||
try:
|
||||
datetime.datetime.strptime(time_string, time_format)
|
||||
return False
|
||||
except ValueError:
|
||||
return True
|
||||
Loading…
Add table
Add a link
Reference in a new issue