diff options
author | Kyomotoi <[email protected]> | 2020-10-07 13:03:27 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2020-10-07 13:03:27 +0800 |
commit | cec804951b97bcab81551bb8c7a1a1e1c473aaa7 (patch) | |
tree | 03b7204af6ebc869e887494ab2609a6e9b7fd72c /utils/utils_banList | |
parent | ab467e8788b7ef8382bab63fb1a91c8b6305c501 (diff) | |
download | ATRI-cec804951b97bcab81551bb8c7a1a1e1c473aaa7.tar.gz ATRI-cec804951b97bcab81551bb8c7a1a1e1c473aaa7.tar.bz2 ATRI-cec804951b97bcab81551bb8c7a1a1e1c473aaa7.zip |
[Update]
Diffstat (limited to 'utils/utils_banList')
-rw-r--r-- | utils/utils_banList/__init__.py | 55 | ||||
-rw-r--r-- | utils/utils_banList/banList_group.json | 1 | ||||
-rw-r--r-- | utils/utils_banList/banList_user.json | 1 |
3 files changed, 57 insertions, 0 deletions
diff --git a/utils/utils_banList/__init__.py b/utils/utils_banList/__init__.py new file mode 100644 index 0000000..66142cc --- /dev/null +++ b/utils/utils_banList/__init__.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import json +from pathlib import Path +from typing import Optional + +def banList(user: str, group: Optional[str] = None) -> bool: + """ + :说明: + + 判断某一 用户/群 是否处于封禁名单中。 + + :参数: + + * ``user: str``: 用户QQ号 + * ``group: Optional[str] = None``: 用户所在群号,若不传入则只检测用户 + + :返回: + + 是:False | 否:True + + :用法: + + .. code-block:: python + + banList(user=123456789, group=123456789) + + """ + file_user = Path('.') / 'utils' / 'utils_banList' / 'banList_user.json' + file_group = Path('.') / 'utils' / 'utils_banList' / 'banList_group.json' + + try: + with open(file_user, 'r') as f: + data_user = json.load(f) + except: + data_user = {} + + try: + with open(file_group, 'r') as f: + data_group = json.load(f) + except: + data_group = {} + + if user not in data_user: + if group: + if group not in data_group: + return True + else: + return False + else: + return True + else: + print(3) + return False
\ No newline at end of file diff --git a/utils/utils_banList/banList_group.json b/utils/utils_banList/banList_group.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/utils/utils_banList/banList_group.json @@ -0,0 +1 @@ +{}
\ No newline at end of file diff --git a/utils/utils_banList/banList_user.json b/utils/utils_banList/banList_user.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/utils/utils_banList/banList_user.json @@ -0,0 +1 @@ +{}
\ No newline at end of file |