From f5059aeccfc646f53ee05a35baf447b152c3a6e1 Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sat, 28 Nov 2020 21:23:22 +0800 Subject: [Fix] --- ATRI/utils/utils_rule/__init__.py | 46 ++----------------------------- ATRI/utils/utils_rule/ban_list_group.json | 1 - ATRI/utils/utils_rule/switch.json | 2 +- 3 files changed, 3 insertions(+), 46 deletions(-) delete mode 100644 ATRI/utils/utils_rule/ban_list_group.json (limited to 'ATRI/utils/utils_rule') diff --git a/ATRI/utils/utils_rule/__init__.py b/ATRI/utils/utils_rule/__init__.py index dcaeedc..cddf93e 100644 --- a/ATRI/utils/utils_rule/__init__.py +++ b/ATRI/utils/utils_rule/__init__.py @@ -13,12 +13,11 @@ __author__ = 'kyomotoi' import os import json from pathlib import Path -from typing import Optional from nonebot.rule import Rule from nonebot.typing import Bot, Event -def check_banlist(for_group: Optional[bool] = False) -> Rule: +def check_banlist() -> Rule: ''' 检查目标是否存在于封禁名单 @@ -27,62 +26,21 @@ def check_banlist(for_group: Optional[bool] = False) -> Rule: async def _chech_banlist(bot: Bot, event: Event, state: dict) -> bool: # 获取目标信息 user = str(event.user_id) - group = str(event.group_id) # 名单目录 BAN_LIST_USER_PATH = Path( '.') / 'ATRI' / 'utils' / 'utils_rule' / 'ban_list_user.json' - BAN_LIST_GROUP_PATH = Path( - '.') / 'ATRI' / 'utils' / 'utils_rule' / 'ban_list_group.json' # 检查文件是否存在,如不存在,自动创建并写入默认值 if not BAN_LIST_USER_PATH.is_file(): with open(BAN_LIST_USER_PATH, 'w') as f: f.write(json.dumps({})) - if not BAN_LIST_GROUP_PATH.is_file(): - with open(BAN_LIST_GROUP_PATH, 'w') as f: - f.write(json.dumps({})) - # 读取文件 with open(BAN_LIST_USER_PATH, 'r') as f: data_user = json.load(f) - with open(BAN_LIST_GROUP_PATH, 'r') as f: - data_group = json.load(f) - - # 判断目标 - if not for_group: - if user: - if user not in data_user: - if group: - if group not in data_group: - return True - else: - return False - else: - return True - else: - return False - - elif group: - if group not in data_group: - if user: - if user not in data_user: - return True - else: - return False - else: - return True - else: - return False - else: - return False - else: - if group not in data_group: - return True - else: - return False + return user not in data_user return Rule(_chech_banlist) diff --git a/ATRI/utils/utils_rule/ban_list_group.json b/ATRI/utils/utils_rule/ban_list_group.json deleted file mode 100644 index 9e26dfe..0000000 --- a/ATRI/utils/utils_rule/ban_list_group.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/ATRI/utils/utils_rule/switch.json b/ATRI/utils/utils_rule/switch.json index 1717be3..d7ac35e 100644 --- a/ATRI/utils/utils_rule/switch.json +++ b/ATRI/utils/utils_rule/switch.json @@ -1 +1 @@ -{"anime-setu": "False", "anime-pic-search": "True", "anime-vid-search": "True", "all-off-anime-setu": "True", "pixiv-pic-search": "True", "pixiv-author-search": "True", "pixiv-rank": "True", "one-key-adult": "True", "genshin-search": "True", "drifting-bottle": "True"} \ No newline at end of file +{"anime-setu": "True", "anime-pic-search": "True", "anime-vid-search": "True", "all-off-anime-setu": "True", "pixiv-pic-search": "True", "pixiv-author-search": "True", "pixiv-rank": "True", "one-key-adult": "True", "genshin-search": "True", "drifting-bottle": "True"} \ No newline at end of file -- cgit v1.2.3