From da888ff020805a38a17e5f83705aeb42ffa992ba Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sun, 7 Mar 2021 15:24:17 +0800 Subject: =?UTF-8?q?=E2=99=BB=EF=B8=8F=E2=9A=A1=EF=B8=8F=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=20Service=EF=BC=8C=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/service/limit.py | 53 --------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 ATRI/service/limit.py (limited to 'ATRI/service/limit.py') diff --git a/ATRI/service/limit.py b/ATRI/service/limit.py deleted file mode 100644 index 2ea3f95..0000000 --- a/ATRI/service/limit.py +++ /dev/null @@ -1,53 +0,0 @@ -import json -from pathlib import Path -from typing import Optional - -from ATRI.utils.file import write_file -from . import SERVICE_DIR - - -class Limit: - @staticmethod - def _get_file(group: Optional[int] = None) -> Path: - file_name = f"{group}.service.json" - LIMIT_DIR = SERVICE_DIR / "limit" - path = LIMIT_DIR / file_name - - if not LIMIT_DIR.exists(): - LIMIT_DIR.mkdir() - return path - - @classmethod - def _read_file(cls, group: Optional[int] = None) -> dict: - try: - data = json.loads(cls._get_file(group).read_bytes()) - except: - data = {} - return data - - @classmethod - async def auth_service(cls, service: str, group: Optional[int] = None) -> bool: - data = cls._read_file(group) - if service not in data: - data[service] = True - await write_file(cls._get_file(group), json.dumps(data)) - - if data[service]: - return True - else: - return False - - @classmethod - async def control_service( - cls, - service: str, - status: bool, - group: Optional[int] = None - ) -> None: - data = cls._read_file(group) - if service not in data: - data[service] = True - await write_file(cls._get_file(group), json.dumps(data)) - - data[service] = status - await write_file(cls._get_file(group), json.dumps(data)) -- cgit v1.2.3