diff options
| author | Kyomotoi <1172294279@qq.com> | 2020-09-06 16:26:49 +0800 | 
|---|---|---|
| committer | Kyomotoi <1172294279@qq.com> | 2020-09-06 16:26:49 +0800 | 
| commit | b5eaf0283065673389ecf997541d217cf7fc7541 (patch) | |
| tree | 4f37746e2971f45f05612ccd0e0bac4432346f47 /ATRI/modules | |
| parent | a36b6ecc37491b5cbf8c8750d252fbd53dc301ca (diff) | |
| download | ATRI-b5eaf0283065673389ecf997541d217cf7fc7541.tar.gz ATRI-b5eaf0283065673389ecf997541d217cf7fc7541.tar.bz2 ATRI-b5eaf0283065673389ecf997541d217cf7fc7541.zip | |
[Update]
Diffstat (limited to 'ATRI/modules')
| -rw-r--r-- | ATRI/modules/b64/__init__.py | 1 | ||||
| -rw-r--r-- | ATRI/modules/error/__init__.py | 36 | ||||
| -rw-r--r-- | ATRI/modules/funcControl/ALLswitch.json | 1 | ||||
| -rw-r--r-- | ATRI/modules/funcControl/__init__.py | 12 | 
4 files changed, 47 insertions, 3 deletions
| diff --git a/ATRI/modules/b64/__init__.py b/ATRI/modules/b64/__init__.py index a8a6bb6..8cce6e0 100644 --- a/ATRI/modules/b64/__init__.py +++ b/ATRI/modules/b64/__init__.py @@ -16,6 +16,7 @@ def b64_str_img_url(url: str):          f.write(img_d.content)      if find_img.stat().st_size >= 1000000:          print('超过1MB,跳过!') +        return      else:          with open(find_img, 'rb') as f:              content = f.read() diff --git a/ATRI/modules/error/__init__.py b/ATRI/modules/error/__init__.py new file mode 100644 index 0000000..0f69608 --- /dev/null +++ b/ATRI/modules/error/__init__.py @@ -0,0 +1,36 @@ +import json +import string +from pathlib import Path +from random import sample +from traceback import format_exc +from datetime import datetime +from typing import Optional + + +def errorBack(Lmsg: Optional[str] = None): +    try: +        with open(Path('.') / 'ATRI' / 'data' / 'errorData' / 'errorData.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +     +    ran_str = ''.join(sample(string.ascii_letters + string.digits, 8)) +    msg0 = f"{datetime.now()}\n" +    msg0 += f"{format_exc()}" +    data[f"{ran_str}"] = f"{msg0}" + +    with open(Path('.') / 'ATRI' / 'data' / 'errorData' / 'errorData.json', 'w') as f: +        f.write(json.dumps(data)) +        f.close() + +    if Lmsg: +        pass +    else: +        Lmsg = 'unknown' + +    msg0 = f'ERROR! Reason: [{Lmsg}]\n' +    msg0 += f'trackID: {ran_str}\n' +    msg0 += "请使用[来杯红茶]功能以联系维护者\n" +    msg0 += "并附上 trackID" + +    return msg0
\ No newline at end of file diff --git a/ATRI/modules/funcControl/ALLswitch.json b/ATRI/modules/funcControl/ALLswitch.json new file mode 100644 index 0000000..1b87087 --- /dev/null +++ b/ATRI/modules/funcControl/ALLswitch.json @@ -0,0 +1 @@ +{"pixiv_seach_img": "on", "pixiv_seach_author": "on", "pixiv_daily_rank": "on", "setu": "on", "setu_img": "off", "anime_search": "on", "change_face": "on", "chouYou": "on", "saucenao_search": "on"}
\ No newline at end of file diff --git a/ATRI/modules/funcControl/__init__.py b/ATRI/modules/funcControl/__init__.py index f8e9259..c111b61 100644 --- a/ATRI/modules/funcControl/__init__.py +++ b/ATRI/modules/funcControl/__init__.py @@ -3,13 +3,19 @@ from pathlib import Path  from typing import Optional -def checkSwitch(funcName: str): -    file = Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json' +def checkSwitch(funcName: str, g: int): +    file = Path('.') / 'ATRI' / 'modules' / 'funcControl' / 'ALLswitch.json'      with open(file, 'r') as f:          data = json.load(f) -          if data[funcName] == "on":          return True +    else: +        file = Path('.') / 'ATRI' / 'data' / 'groupData' / f'{g}' / 'switch.json' +        with open(file, 'r') as f: +            data = json.load(f) +         +        if data[funcName] == "on": +            return True  def checkNoob(user: int, group: Optional[int] = None):      fileU = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' | 
