diff options
Diffstat (limited to 'ATRI/service/banlist.py')
-rw-r--r-- | ATRI/service/banlist.py | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/ATRI/service/banlist.py b/ATRI/service/banlist.py deleted file mode 100644 index e1ce6b7..0000000 --- a/ATRI/service/banlist.py +++ /dev/null @@ -1,53 +0,0 @@ -import json -import aiofiles -from typing import Optional - -from ATRI.exceptions import WriteError -from . import SERVICE_DIR - - -class BanSystem: - - file_name = "banlist.service.json" - path = SERVICE_DIR / file_name - path.parent.mkdir(exist_ok=True, parents=True) - try: - data = json.loads(path.read_bytes()) - except: - data = {} - - @classmethod - def get_list(cls) -> dict: - return cls.data - - @classmethod - def is_in_list(cls, user: Optional[str]) -> bool: - return False if user in cls.data else True - - @classmethod - async def add_to_list(cls, user: Optional[str]) -> None: - cls.data[user] = user - try: - async with aiofiles.open( - cls.path, 'w', encoding='utf-8') as target: - await target.write( - json.dumps( - cls.data, indent=4 - ) - ) - except WriteError: - raise WriteError("Writing file failed!") - - @classmethod - async def del_from_list(cls, user: Optional[str]) -> None: - del cls.data[user] - try: - async with aiofiles.open( - cls.path, 'w', encoding='utf-8') as target: - await target.write( - json.dumps( - cls.data, indent=4 - ) - ) - except WriteError: - raise WriteError("Writing file failed!") |