diff options
| author | Kyomotoi <1172294279@qq.com> | 2020-08-18 22:47:39 +0800 | 
|---|---|---|
| committer | Kyomotoi <1172294279@qq.com> | 2020-08-18 22:47:39 +0800 | 
| commit | 0d3d479a9b98aab47fb84ce0f5eadff17ff5d046 (patch) | |
| tree | f57fb390c6155060d8119b6f1d2895e2aa07fb8e /ATRI/plugins | |
| parent | 636a16033ccb426a888e4f8a7d411e5fcb68faf2 (diff) | |
| download | ATRI-0d3d479a9b98aab47fb84ce0f5eadff17ff5d046.tar.gz ATRI-0d3d479a9b98aab47fb84ce0f5eadff17ff5d046.tar.bz2 ATRI-0d3d479a9b98aab47fb84ce0f5eadff17ff5d046.zip | |
[Update]
Diffstat (limited to 'ATRI/plugins')
54 files changed, 1872 insertions, 1070 deletions
| diff --git a/ATRI/plugins/AIchangeFace.py b/ATRI/plugins/AIchangeFace.py index 4cb1990..4b2d76e 100644 --- a/ATRI/plugins/AIchangeFace.py +++ b/ATRI/plugins/AIchangeFace.py @@ -74,81 +74,88 @@ def change_face(image_1, image_2, user, number=99):  async def AIchFace(session: CommandSession):      user = session.event.user_id      group = session.event.group_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) -         -        if data["change_face"] == "on": -            with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: -                data0 = json.load(f) -            with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: -                data1 = json.load(f) - -            if str(user) in data0.keys(): -                pass -            elif str(group) in data1.keys(): -                pass +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys(): +            pass +        else: +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                )              else: -                img1 = session.get('message1', prompt = '请发送需要换脸的图片') -                print(img1) -                img2 = session.get('message2', prompt = '请发送素材图片') - -                # 我承认了,我是取名废! -                a = img1.split(',') -                a = a[2].replace(']', '') -                a = a.replace('url=', '') -                print(a) -                imgres1 = requests.get(a) - -                b = img2.split(',') -                b = b[2].replace(']', '') -                b = b.replace('url=', '') -                imgres2 = requests.get(b) - -                try: -                    file1 = f'ATRI/data/temp/face/{user}' -                    if not os.path.exists(file1): -                        os.mkdir(file1) -                    with open(file1 + '/img1.jpg', 'wb') as f: -                        f.write(imgres1.content) - -                    file2 = f'ATRI/data/temp/face/{user}' -                    if not os.path.exists(file2): -                        os.mkdir(file2) -                    with open(file2 + '/img2.jpg', 'wb') as f: -                        f.write(imgres2.content) -                except: -                    session.finish('请求数据貌似失败了...') +                with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +                    data = json.load(f) -                img1File = Path('.') / 'ATRI' / 'data' / 'temp' / 'face' / f'{user}' / 'img1.jpg' -                img2File = Path('.') / 'ATRI' / 'data' / 'temp' / 'face' / f'{user}' / 'img2.jpg' - -                try: -                    change_face(img1File, img2File, user, 1) -                except: -                    session.finish('emm...貌似失败了呢......') -                 -                time.sleep(0.5) -                doneIMG = Path('.') / 'ATRI' / 'data' / 'temp' / 'face' / f'{user}' / 'img3.jpg' -                img = os.path.abspath(doneIMG) -                await session.send(f'[CQ:image,file=file:///{img}]') -                files = f'ATRI/data/temp/face/{user}' -                os.remove(files) +                if data["change_face"] == "on": +                    img1 = session.get('message1', prompt = '请发送需要换脸的图片') +                    print(img1) +                    img2 = session.get('message2', prompt = '请发送素材图片') + +                    # 我承认了,我是取名废! +                    a = img1.split(',') +                    a = a[2].replace(']', '') +                    a = a.replace('url=', '') +                    print(a) +                    imgres1 = requests.get(a) + +                    b = img2.split(',') +                    b = b[2].replace(']', '') +                    b = b.replace('url=', '') +                    imgres2 = requests.get(b) + +                    try: +                        file1 = f'ATRI/data/temp/face/{user}' +                        if not os.path.exists(file1): +                            os.mkdir(file1) +                        with open(file1 + '/img1.jpg', 'wb') as f: +                            f.write(imgres1.content) + +                        file2 = f'ATRI/data/temp/face/{user}' +                        if not os.path.exists(file2): +                            os.mkdir(file2) +                        with open(file2 + '/img2.jpg', 'wb') as f: +                            f.write(imgres2.content) +                    except: +                        session.finish('请求数据貌似失败了...') +                     +                    img1File = Path('.') / 'ATRI' / 'data' / 'temp' / 'face' / f'{user}' / 'img1.jpg' +                    img2File = Path('.') / 'ATRI' / 'data' / 'temp' / 'face' / f'{user}' / 'img2.jpg' + +                    try: +                        change_face(img1File, img2File, user, 1) +                    except: +                        session.finish('emm...貌似失败了呢......') +                     +                    time.sleep(0.5) +                    doneIMG = Path('.') / 'ATRI' / 'data' / 'temp' / 'face' / f'{user}' / 'img3.jpg' +                    img = os.path.abspath(doneIMG) +                    await session.send(f'[CQ:image,file=file:///{img}]') +                    files = f'ATRI/data/temp/face/{user}' +                    os.remove(files) -        else: -            session.finish('该功能已关闭...') +                else: +                    session.finish('该功能已关闭...')  @AIchFace.args_parser diff --git a/ATRI/plugins/BlackList.py b/ATRI/plugins/BlackList.py index 5a470ed..ec851b5 100644 --- a/ATRI/plugins/BlackList.py +++ b/ATRI/plugins/BlackList.py @@ -7,46 +7,105 @@ import config # type: ignore  master = config.MASTER() +file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' +file1 = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json'  @on_command('add_noobList', aliases = ['屏蔽', '移除'], only_to_me = False)  async def _(session: CommandSession):      if session.event.user_id == master: -        msg = session.event.raw_message.split(' ', 1) +        msg = session.event.raw_message.split(' ', 2)          b_type = msg[0] -        user = msg[1] - -        if b_type == '屏蔽': -            bL = {} -            bL[f"{user}"] = f"{user}" -            file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' -            f = open(file, 'w') -            f.write(json.dumps(bL)) -            f.close() -            await session.send(f'正义执行!![{user}]已被ATRI屏蔽!') +        g_type = msg[1] +        u = msg[2] + +        if g_type == 'qq': +            if b_type == '屏蔽': +                try: +                    with open(file, 'r') as f: +                        bL = json.load(f) +                except: +                    bL = {} +                bL[f"{u}"] = f"{u}" +                f = open(file, 'w') +                f.write(json.dumps(bL)) +                f.close() +                await session.send(f'正义执行!![{u}]已被ATRI屏蔽!') +             +            elif b_type == '移除': +                try: +                    with open(file, 'r') as f: +                        bL = json.load(f) +                except: +                    bL = {} +                bL.pop(f"{u}") +                f = open(file, 'w') +                f.write(json.dumps(bL)) +                f.close() +                await session.send(f'将[{u}]移出黑名单成功~!') -        elif b_type == '移除': -            file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' -            with open(file, 'r') as f: -                bL = json.load(f) -            bL.pop(f"{user}") -            f = open(file, 'w') -            f.write(json.dumps(bL)) -            f.close() -            await session.send('将[{user}]移出黑名单成功~!') +        elif g_type == 'group': +            if b_type == '屏蔽': +                try: +                    with open(file1, 'r') as f: +                        bL = json.load(f) +                except: +                    bL = {} +                bL[f"{u}"] = f"{u}" +                f = open(file1, 'w') +                f.write(json.dumps(bL)) +                f.close() +                await session.send(f'正义执行!!群[{u}]已被ATRI屏蔽!')  +             +            elif b_type == '移除': +                try: +                    with open(file1, 'r') as f: +                        bL = json.load(f) +                except: +                    bL = {} +                bL.pop(f"{u}") +                f = open(file1, 'w') +                f.write(json.dumps(bL)) +                f.close() +                await session.send(f'将群[{u}]移出黑名单成功~!')  @on_command('look_noobList', aliases = ['查看黑名单'], only_to_me = False)  async def _(session: CommandSession):      start = time.perf_counter() -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    with open(file, 'r') as f:          data = json.load(f) +    with open(file1, 'r') as f: +        data0 = json.load(f) -    msg = f'被ATRI列入黑名单有以下账号:\n=============\n' -    for i in data.keys(): -        msg0 = f'{i}\n' +    msg = f'被ATRI列入黑名单有以下列表:\n' +    try: +        msg1 = f'=====[用户]=====\n' +        msg += msg1 +        for i in data.keys(): +            msg0 = f'{i}\n' +            msg += msg0 +    except: +        end = time.perf_counter() +        msg0 = f"==============\nDone time: {round(end - start, 3)}s" +        msg += msg0 +        await session.send(msg) +        return + +    try: +        msg1 = f'======[群]======\n' +        msg += msg1 +        for i in data0.keys(): +            msg0 = f'{i}\n' +            msg += msg0 +    except: +        end = time.perf_counter() +        msg0 = f"==============\nDone time: {round(end - start, 3)}s"          msg += msg0 +        await session.send(msg) +        return +      end = time.perf_counter() -    msg0 = f"=============\nDone time: {round(end - start, 3)}s" +    msg0 = f"==============\nDone time: {round(end - start, 3)}s"      msg += msg0 -    await session.send(msg) +    await session.send(msg)
\ No newline at end of file diff --git a/ATRI/plugins/LearnRepo.py b/ATRI/plugins/LearnRepo.py index fb98854..36f4374 100644 --- a/ATRI/plugins/LearnRepo.py +++ b/ATRI/plugins/LearnRepo.py @@ -1,6 +1,7 @@  import json -from random import randint, choice +from random import randint  from datetime import datetime +from pathlib import Path  import nonebot  from nonebot import on_command  from nonebot import CommandSession @@ -26,8 +27,11 @@ async def _(session: CommandSession):          msg = session.event.raw_message.split(' ', 3)          w_tpye = msg[0]          word = msg[1] -        with open('ATRI/plugins/LearnRepo/LearnRepo.json', 'r') as f: -            data = json.load(f) +        try: +            with open(Path('.') / 'ATRI' / 'plugins' / 'LearnRepo' / 'LearnRepo.json', 'r') as f: +                data = json.load(f) +        except: +            data = {}          if w_tpye == '增加词汇':              repo = msg[2] @@ -37,7 +41,7 @@ async def _(session: CommandSession):              else:                  data[f"{word}"] = [f"{repo}",prob] -                f = open('ATRI/plugins/LearnRepo/LearnRepo.json', 'w') +                f = open(Path('.') / 'ATRI' / 'plugins' / 'LearnRepo' / 'LearnRepo.json', 'w')                  f.write(json.dumps(data))                  f.close()                  session.finish(f"学習しました!\nWord:[{word}]\nRepo:[{repo}]\nProbability:[{'%.2f%%' % (round(1 / prob , 1) * 100)}]") @@ -60,23 +64,37 @@ async def repo(context):      if 0 <= now_time() < 5.5:          pass      else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -            nL = json.load(f) +        try: +            with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +                data = json.load(f) +        except: +            data = {} +        try: +            with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +                data1 = json.load(f) +        except: +            data1 = {} -        if str(user) in nL.keys(): +        if str(group) in data.keys():              pass          else: -            with open('ATRI/plugins/LearnRepo/LearnRepo.json', 'r') as f: -                data = json.load(f) +            if str(user) in data1.keys(): +                pass +            else: +                try: +                    with open(Path('.') / 'ATRI' / 'plugins' / 'LearnRepo' / 'LearnRepo.json', 'r') as f: +                        data = json.load(f) +                except: +                    data = {} -            if str(word) in data.keys(): -                lt = data[f"{word}"] -                print(lt) -                msg = lt[0] -                prob = int(lt[1]) -                res = randint(1,prob) -                if res == 1: -                    await bot.send_msg( -                        group_id = group, -                        message = msg -                    ) # type: ignore
\ No newline at end of file +                if str(word) in data.keys(): +                    lt = data[f"{word}"] +                    print(lt) +                    msg = lt[0] +                    prob = int(lt[1]) +                    res = randint(1,prob) +                    if res == 1: +                        await bot.send_msg( +                            group_id = group, +                            message = msg +                        ) # type: ignore
\ No newline at end of file diff --git a/ATRI/plugins/LearnRepo/LearnRepo.json b/ATRI/plugins/LearnRepo/LearnRepo.json index ede00cd..fb478b5 100644 --- a/ATRI/plugins/LearnRepo/LearnRepo.json +++ b/ATRI/plugins/LearnRepo/LearnRepo.json @@ -1 +1 @@ -{"test": ["TesT is SuccEss!", 1], "\u4e09\u6b21\u5143\u722c": ["\u4e09\u6b21\u5143\u722c", 5], "you": ["you", 1]}
\ No newline at end of file +{"test": ["TesT is SuccEss!", 1]}
\ No newline at end of file diff --git a/ATRI/plugins/__pycache__/AIchangeFace.cpython-38.pyc b/ATRI/plugins/__pycache__/AIchangeFace.cpython-38.pycBinary files differ index 6d580a7..7b41688 100644 --- a/ATRI/plugins/__pycache__/AIchangeFace.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/AIchangeFace.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/BlackList.cpython-38.pyc b/ATRI/plugins/__pycache__/BlackList.cpython-38.pycBinary files differ new file mode 100644 index 0000000..8857835 --- /dev/null +++ b/ATRI/plugins/__pycache__/BlackList.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/LearnRepo.cpython-38.pyc b/ATRI/plugins/__pycache__/LearnRepo.cpython-38.pycBinary files differ new file mode 100644 index 0000000..354e866 --- /dev/null +++ b/ATRI/plugins/__pycache__/LearnRepo.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/upload_sqlite.cpython-38.pyc b/ATRI/plugins/__pycache__/UploadSqlite.cpython-38.pycBinary files differ index 291f33e..23bfbca 100644 --- a/ATRI/plugins/__pycache__/upload_sqlite.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/UploadSqlite.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/animeSearch.cpython-38.pyc b/ATRI/plugins/__pycache__/animeSearch.cpython-38.pycBinary files differ index bdedd1e..0eb788d 100644 --- a/ATRI/plugins/__pycache__/animeSearch.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/animeSearch.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/anime_search.cpython-37.pyc b/ATRI/plugins/__pycache__/anime_search.cpython-37.pycBinary files differ deleted file mode 100644 index c7c40bc..0000000 --- a/ATRI/plugins/__pycache__/anime_search.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/anime_search.cpython-38.pyc b/ATRI/plugins/__pycache__/anime_search.cpython-38.pycBinary files differ deleted file mode 100644 index 89e470a..0000000 --- a/ATRI/plugins/__pycache__/anime_search.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/audio.cpython-38.pyc b/ATRI/plugins/__pycache__/audio.cpython-38.pycBinary files differ deleted file mode 100644 index 93235c9..0000000 --- a/ATRI/plugins/__pycache__/audio.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/bilibili.cpython-37.pyc b/ATRI/plugins/__pycache__/bilibili.cpython-37.pycBinary files differ deleted file mode 100644 index 8e47f80..0000000 --- a/ATRI/plugins/__pycache__/bilibili.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/bilibili.cpython-38.pyc b/ATRI/plugins/__pycache__/bilibili.cpython-38.pycBinary files differ deleted file mode 100644 index b950fbb..0000000 --- a/ATRI/plugins/__pycache__/bilibili.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/chat.cpython-38.pyc b/ATRI/plugins/__pycache__/chat.cpython-38.pycBinary files differ index c458680..554119a 100644 --- a/ATRI/plugins/__pycache__/chat.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/chat.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/checkData.cpython-38.pyc b/ATRI/plugins/__pycache__/checkData.cpython-38.pycBinary files differ index 0bc957b..5b80933 100644 --- a/ATRI/plugins/__pycache__/checkData.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/checkData.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/check_data.cpython-38.pyc b/ATRI/plugins/__pycache__/check_data.cpython-38.pycBinary files differ deleted file mode 100644 index bc17da5..0000000 --- a/ATRI/plugins/__pycache__/check_data.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/cloudmusic.cpython-37.pyc b/ATRI/plugins/__pycache__/cloudmusic.cpython-37.pycBinary files differ deleted file mode 100644 index d9be200..0000000 --- a/ATRI/plugins/__pycache__/cloudmusic.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/cloudmusic.cpython-38.pyc b/ATRI/plugins/__pycache__/cloudmusic.cpython-38.pycBinary files differ deleted file mode 100644 index b907dbd..0000000 --- a/ATRI/plugins/__pycache__/cloudmusic.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/dynamic_config.cpython-38.pyc b/ATRI/plugins/__pycache__/dynamic_config.cpython-38.pycBinary files differ deleted file mode 100644 index 5670095..0000000 --- a/ATRI/plugins/__pycache__/dynamic_config.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/hbook.cpython-38.pyc b/ATRI/plugins/__pycache__/hbook.cpython-38.pycBinary files differ index a5b647d..dacd7b0 100644 --- a/ATRI/plugins/__pycache__/hbook.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/hbook.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/hitokoto.cpython-37.pyc b/ATRI/plugins/__pycache__/hitokoto.cpython-37.pycBinary files differ deleted file mode 100644 index 64721e3..0000000 --- a/ATRI/plugins/__pycache__/hitokoto.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/hitokoto.cpython-38.pyc b/ATRI/plugins/__pycache__/hitokoto.cpython-38.pycBinary files differ index fbe7090..6cbbbb4 100644 --- a/ATRI/plugins/__pycache__/hitokoto.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/hitokoto.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/img_search.cpython-38.pyc b/ATRI/plugins/__pycache__/img_search.cpython-38.pycBinary files differ deleted file mode 100644 index 12163bb..0000000 --- a/ATRI/plugins/__pycache__/img_search.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/other.cpython-37.pyc b/ATRI/plugins/__pycache__/other.cpython-37.pycBinary files differ deleted file mode 100644 index 3395bcb..0000000 --- a/ATRI/plugins/__pycache__/other.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/other.cpython-38.pyc b/ATRI/plugins/__pycache__/other.cpython-38.pycBinary files differ index 35bf088..929d9da 100644 --- a/ATRI/plugins/__pycache__/other.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/other.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/pixiv.cpython-37.pyc b/ATRI/plugins/__pycache__/pixiv.cpython-37.pycBinary files differ deleted file mode 100644 index 636e8ba..0000000 --- a/ATRI/plugins/__pycache__/pixiv.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/pixiv.cpython-38.pyc b/ATRI/plugins/__pycache__/pixiv.cpython-38.pycBinary files differ index 9e70b4d..7465bf7 100644 --- a/ATRI/plugins/__pycache__/pixiv.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/pixiv.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/richBISS.cpython-38.pyc b/ATRI/plugins/__pycache__/richBISS.cpython-38.pycBinary files differ index c0df9d6..41c6d8f 100644 --- a/ATRI/plugins/__pycache__/richBISS.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/richBISS.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/send.cpython-38.pyc b/ATRI/plugins/__pycache__/send.cpython-38.pycBinary files differ index 2b98618..32a2760 100644 --- a/ATRI/plugins/__pycache__/send.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/send.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/setu.cpython-37.pyc b/ATRI/plugins/__pycache__/setu.cpython-37.pycBinary files differ deleted file mode 100644 index 2cd406d..0000000 --- a/ATRI/plugins/__pycache__/setu.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/setu.cpython-38.pyc b/ATRI/plugins/__pycache__/setu.cpython-38.pycBinary files differ index 94c589b..f7d0f07 100644 --- a/ATRI/plugins/__pycache__/setu.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/setu.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/switch.cpython-37.pyc b/ATRI/plugins/__pycache__/switch.cpython-37.pycBinary files differ deleted file mode 100644 index 3ed1f40..0000000 --- a/ATRI/plugins/__pycache__/switch.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/switch.cpython-38.pyc b/ATRI/plugins/__pycache__/switch.cpython-38.pycBinary files differ index 3197411..06e154a 100644 --- a/ATRI/plugins/__pycache__/switch.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/switch.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/test.cpython-37.pyc b/ATRI/plugins/__pycache__/test.cpython-37.pycBinary files differ deleted file mode 100644 index f0040dc..0000000 --- a/ATRI/plugins/__pycache__/test.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/upload_setu.cpython-38.pyc b/ATRI/plugins/__pycache__/upload_setu.cpython-38.pycBinary files differ deleted file mode 100644 index 1847b9f..0000000 --- a/ATRI/plugins/__pycache__/upload_setu.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/voice.cpython-38.pyc b/ATRI/plugins/__pycache__/voice.cpython-38.pycBinary files differ deleted file mode 100644 index b051a68..0000000 --- a/ATRI/plugins/__pycache__/voice.cpython-38.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/welcome.cpython-37.pyc b/ATRI/plugins/__pycache__/welcome.cpython-37.pycBinary files differ deleted file mode 100644 index 9877bbc..0000000 --- a/ATRI/plugins/__pycache__/welcome.cpython-37.pyc +++ /dev/null diff --git a/ATRI/plugins/__pycache__/welcome.cpython-38.pyc b/ATRI/plugins/__pycache__/welcome.cpython-38.pycBinary files differ index 25b8468..cd6e3a0 100644 --- a/ATRI/plugins/__pycache__/welcome.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/welcome.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/wordCloud.cpython-38.pyc b/ATRI/plugins/__pycache__/wordCloud.cpython-38.pycBinary files differ index 49556bf..2aec1e7 100644 --- a/ATRI/plugins/__pycache__/wordCloud.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/wordCloud.cpython-38.pyc diff --git a/ATRI/plugins/animeSearch.py b/ATRI/plugins/animeSearch.py index c8f0007..5323e53 100644 --- a/ATRI/plugins/animeSearch.py +++ b/ATRI/plugins/animeSearch.py @@ -1,5 +1,6 @@  import re  import json +from pathlib import Path  from datetime import datetime  from random import choice  from aiohttp import ClientSession @@ -58,78 +59,90 @@ def toSimpleString(str):  )  async def _(session: CommandSession):      user = session.event.user_id +    group = session.event.group_id      msg = session.current_arg.strip() -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) - -        if str(user) in data.keys(): +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            if not msg: -                msg = session.get('message', prompt = "请发送一张图片") -             -            await session.send("开始以图搜番\n(如搜索时间过长或无反应则为图片格式有问题)") - -            p = '\\[CQ\\:image\\,file\\=.*?\\,url\\=(.*?)\\]' +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                if not msg: +                    msg = session.get('message', prompt = "请发送一张图片") +                 +                await session.send("开始以图搜番\n(如搜索时间过长或无反应则为图片格式有问题)") -            img = re.findall(p, msg) +                p = '\\[CQ\\:image\\,file\\=.*?\\,url\\=(.*?)\\]' -            if img: -                URL = f'https://trace.moe/api/search?url={img[0]}' +                img = re.findall(p, msg) -                req = await get_bytes(URL) +                if img: +                    URL = f'https://trace.moe/api/search?url={img[0]}' -                if req: -                    data = json.loads(req.decode()) +                    req = await get_bytes(URL) -                    d = {} +                    if req: +                        data = json.loads(req.decode()) -                    for i in range(len(data['docs'])): -                        if data['docs'][i]['title_chinese'] in d.keys(): -                            d[data['docs'][i]['title_chinese']][0] += data['docs'][i]['similarity'] -                     -                        else: -                            m = data['docs'][i]['at']/60 -                            s = data['docs'][i]['at']%60 +                        d = {} -                            if data['docs'][i]['episode'] == '': -                                n = 1 -                             +                        for i in range(len(data['docs'])): +                            if data['docs'][i]['title_chinese'] in d.keys(): +                                d[data['docs'][i]['title_chinese']][0] += data['docs'][i]['similarity'] +                                                      else: -                                n = data['docs'][i]['episode'] -                             -                            d[toSimpleString(data['docs'][i]['title_chinese'])] = [data['docs'][i]['similarity'],f'第{n}集',f'{int(m)}分{int(s)}秒处'] - -                    result = sorted( -                        d.items(), -                        key = lambda x:x[1], -                        reverse = True -                    ) - -                    t = 0 - -                    msg0 = f'[CQ:at,qq={user}]\n根据所提供的图片按照相似度找到{len(d)}个结果:' - -                    for i in result: -                        t +=1 -                        lk = ('%.2f%%' % (i[1][0] * 100)) -                        msg = (f'\n——————————\n({t})\n相似度:{lk}\n动漫名:《{i[0]}》\n时间点:{i[1][1]} {i[1][2]}') -                        msg0 += msg +                                m = data['docs'][i]['at']/60 +                                s = data['docs'][i]['at']%60 + +                                if data['docs'][i]['episode'] == '': +                                    n = 1 +                                 +                                else: +                                    n = data['docs'][i]['episode'] +                                 +                                d[toSimpleString(data['docs'][i]['title_chinese'])] = [data['docs'][i]['similarity'],f'第{n}集',f'{int(m)}分{int(s)}秒处'] + +                        result = sorted( +                            d.items(), +                            key = lambda x:x[1], +                            reverse = True +                        ) + +                        t = 0 + +                        msg0 = f'[CQ:at,qq={user}]\n根据所提供的图片按照相似度找到{len(d)}个结果:' + +                        for i in result: +                            t +=1 +                            lk = ('%.2f%%' % (i[1][0] * 100)) +                            msg = (f'\n——————————\n({t})\n相似度:{lk}\n动漫名:《{i[0]}》\n时间点:{i[1][1]} {i[1][2]}') +                            msg0 += msg +                         +                        await session.send(msg0) -                    await session.send(msg0) -                 -                else: -                    await session.send("搜索似乎失败了呢...")
\ No newline at end of file +                    else: +                        await session.send("搜索似乎失败了呢...")
\ No newline at end of file diff --git a/ATRI/plugins/chat.py b/ATRI/plugins/chat.py index 13c6747..1089b43 100644 --- a/ATRI/plugins/chat.py +++ b/ATRI/plugins/chat.py @@ -9,13 +9,13 @@ from random import randint, choice  from datetime import datetime, timedelta  from nonebot import on_command, scheduler  from nonebot import CommandSession -from nonebot import on_command  from apscheduler.triggers.date import DateTrigger  from nonebot import session  from ATRI.modules import response # type: ignore  import config # type: ignore +# 手搓仿生人回复,争取破1MB!  bot = nonebot.get_bot()  master = config.MASTER() @@ -25,13 +25,15 @@ KC_URL = 'https://nmsl.shadiao.app/api.php?level=min&lang=zh_cn'  @nonebot.scheduler.scheduled_job(      'cron',      day_of_week = "mon,tue,wed,thu,fri,sat,sun", -    hour = 7 +    hour = 7, +    misfire_grace_time=60  ) -async def _(session: CommandSession): +async def _():      """早安"""      try:          start = time.perf_counter()          group_list = await bot.get_group_list() #type: ignore +        groups = [group['group_id'] for group in group_list]          g_list = len(group_list)          res = randint(1,2)          if res == 1: @@ -55,11 +57,11 @@ async def _(session: CommandSession):              img = os.path.abspath(img)              msg = f'[CQ:image,file=file:///{os.path.abspath(img)}]' -        for group in group_list: -            await bot.send_group_msg(group_id = group['group_id'], message = msg) #type: ignore +        for group in groups: +            await bot.send_group_msg(group_id = group, message = msg) #type: ignore          end = time.perf_counter() -        await session.send(f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}') +        await bot.send_private_msg(user_id = master, message = f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}') # type: ignore      except:          pass @@ -67,13 +69,15 @@ async def _(session: CommandSession):  @nonebot.scheduler.scheduled_job(      'cron',      day_of_week = "mon,tue,wed,thu,fri,sat,sun", -    hour = 22 +    hour = 22, +    misfire_grace_time=60  ) -async def _(session: CommandSession): +async def _():      """晚安"""      try:          start = time.perf_counter()          group_list = await bot.get_group_list() #type: ignore +        groups = [group['group_id'] for group in group_list]          g_list = len(group_list)          res = randint(1,2)          if res == 1: @@ -98,15 +102,45 @@ async def _(session: CommandSession):              img = os.path.abspath(img)              msg = f'[CQ:image,file=file:///{os.path.abspath(img)}]' -        for group in group_list: -            await bot.send_group_msg(group_id = group['group_id'], message = msg) #type: ignore +        for group in groups: +            await bot.send_group_msg(group_id = group, message = msg) #type: ignore          end = time.perf_counter() -        await session.send(f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}') +        await bot.send_private_msg(user_id = master, message = f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}') # type: ignore      except:          pass +@nonebot.scheduler.scheduled_job( +    'cron', +    day_of_week = "mon,tue,wed,thu,fri,sat,sun", +    hour = 0, +    misfire_grace_time=60 +) +async def _(): +    """到 点 了""" +    try: +        start = time.perf_counter() +        group_list = await bot.get_group_list() # type: ignore +        groups = [group['group_id'] for group in group_list] +        g_list = len(group_list) +        img = choice( +            [ +                'WYY.gif', 'WYY.jpg', 'WYY1.jpg' +            ] +        ) +        img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +        img = os.path.abspath(img) +        msg = f'[CQ:image,file=file:///{os.path.abspath(img)}]' +        for group in groups: +            await bot.send_group_msg(group_id = group, message = msg) #type: ignore +         +        end = time.perf_counter() +        await bot.send_private_msg(user_id = master, message = f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}') # type: ignore +     +    except: +        pass +  def now_time():      now_ = datetime.now() @@ -136,477 +170,790 @@ def rmQQfromNoobLIST(user):  @on_command('morning', patterns = [r"早[安哇]|早上好|ohayo|哦哈哟|お早う"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 5.5 <= now_time() < 9: -            await session.send( -                choice( -                    [ -                        '啊......早上好...(哈欠)', -                        '唔......吧唧...早上...哈啊啊~~~\n早上好......', -                        '早上好......', -                        '早上好呜......呼啊啊~~~~', -                        '啊......早上好。\n昨晚也很激情呢!', -                        '吧唧吧唧......怎么了...已经早上了么...', -                        '早上好!', -                        '......看起来像是傍晚,其实已经早上了吗?', -                        '早上好......欸~~~脸好近呢' -                    ] +        if str(user) in data1.keys(): +            pass +        else: +            if 5.5 <= now_time() < 9: +                await session.send( +                    choice( +                        [ +                            '啊......早上好...(哈欠)', +                            '唔......吧唧...早上...哈啊啊~~~\n早上好......', +                            '早上好......', +                            '早上好呜......呼啊啊~~~~', +                            '啊......早上好。\n昨晚也很激情呢!', +                            '吧唧吧唧......怎么了...已经早上了么...', +                            '早上好!', +                            '......看起来像是傍晚,其实已经早上了吗?', +                            '早上好......欸~~~脸好近呢' +                        ] +                    )                  ) -            ) -         -        elif 9 <= now_time() < 18: -            await session.send( -                choice( -                    [ -                        '哼!这个点还早啥,昨晚干啥去了!?', -                        '熬夜了对吧熬夜了对吧熬夜了对吧???!', -                        '是不是熬夜是不是熬夜是不是熬夜?!' -                    ] +             +            elif 9 <= now_time() < 18: +                await session.send( +                    choice( +                        [ +                            '哼!这个点还早啥,昨晚干啥去了!?', +                            '熬夜了对吧熬夜了对吧熬夜了对吧???!', +                            '是不是熬夜是不是熬夜是不是熬夜?!' +                        ] +                    )                  ) -            ) -         -        elif 18 <= now_time() < 24: -            await session.send( -                choice( -                    [ -                        '早个啥?哼唧!我都准备洗洗睡了!', -                        '不是...你看看几点了,哼!', -                        '晚上好哇' -                    ] +             +            elif 18 <= now_time() < 24: +                await session.send( +                    choice( +                        [ +                            '早个啥?哼唧!我都准备洗洗睡了!', +                            '不是...你看看几点了,哼!', +                            '晚上好哇' +                        ] +                    )                  ) -            ) -         -        elif 0 <= now_time() < 5.5: -            await session.send( -                choice( -                    [ -                        'zzzz......', -                        'zzzzzzzz......', -                        'zzz...好涩哦..zzz....', -                        '别...不要..zzz..那..zzz..', -                        '嘻嘻..zzz..呐~..zzzz..', -                        '...zzz....哧溜哧溜....' -                    ] +             +            elif 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..', +                            '...zzz....哧溜哧溜....' +                        ] +                    )                  ) -            )  @on_command('noon', patterns = [r"中午好|午安"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 11 <= now_time() <= 15: -            await session.send( -                choice( -                    [ -                        '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w', -                        '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o', -                        '睡你午觉去!哼唧!!' -                    ] +        if str(user) in data1.keys(): +            pass +        else: +            if 11 <= now_time() <= 15: +                await session.send( +                    choice( +                        [ +                            '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w', +                            '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o', +                            '睡你午觉去!哼唧!!' +                        ] +                    )                  ) -            )  @on_command('night', patterns = [r"晚安|oyasuminasai|おやすみなさい"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 5.5 <= now_time() < 11: -            await session.send( -                choice( -                    [ -                        '你可猝死算了吧!', -                        '?啊这', -                        '亲,这边建议赶快去睡觉呢~~~', -                        '不可忍不可忍不可忍!!为何这还不猝死!!' -                    ] +        if str(user) in data1.keys(): +            pass +        else: +            if 5.5 <= now_time() < 11: +                await session.send( +                    choice( +                        [ +                            '你可猝死算了吧!', +                            '?啊这', +                            '亲,这边建议赶快去睡觉呢~~~', +                            '不可忍不可忍不可忍!!为何这还不猝死!!' +                        ] +                    )                  ) -            ) -         -        elif 11 <= now_time() < 15: -            await session.send( -                choice( -                    [ -                        '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w', -                        '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o', -                        '睡你午觉去!哼唧!!' -                    ] +             +            elif 11 <= now_time() < 15: +                await session.send( +                    choice( +                        [ +                            '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w', +                            '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o', +                            '睡你午觉去!哼唧!!' +                        ] +                    )                  ) -            ) -         -        elif 15 <= now_time() < 19: -            await session.send( -                choice( -                    [ -                        '难不成??晚上不想睡觉??现在休息', -                        '就......挺离谱的...现在睡觉', -                        '现在还是白天哦,睡觉还太早了' -                    ] +             +            elif 15 <= now_time() < 19: +                await session.send( +                    choice( +                        [ +                            '难不成??晚上不想睡觉??现在休息', +                            '就......挺离谱的...现在睡觉', +                            '现在还是白天哦,睡觉还太早了' +                        ] +                    )                  ) -            ) -         -        elif 19 <= now_time() < 24: -            await session.send( -                choice( -                    [ -                        '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o', -                        '......(打瞌睡)', -                        '呼...呼...已经睡着了哦~...呼......', -                        '......我、我会在这守着你的,请务必好好睡着' -                    ] +             +            elif 19 <= now_time() < 24: +                await session.send( +                    choice( +                        [ +                            '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o', +                            '......(打瞌睡)', +                            '呼...呼...已经睡着了哦~...呼......', +                            '......我、我会在这守着你的,请务必好好睡着' +                        ] +                    )                  ) -            ) -         -        elif 0 <= now_time() < 5.5: -            await session.send( -                choice( -                    [ -                        'zzzz......', -                        'zzzzzzzz......', -                        'zzz...好涩哦..zzz....', -                        '别...不要..zzz..那..zzz..', -                        '嘻嘻..zzz..呐~..zzzz..' -                    ] +             +            elif 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    )                  ) -            )  @on_command('az', patterns = [r"[aA][zZ]|[阿啊]这"], only_to_me = False)  async def az(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            res = randint(1,3) -            if res == 1: -                # res = random.randint(1,10) -                img = choice( -                    [ -                        'AZ.jpg', 'AZ1.jpg', 'AZ2.jpg', 'AZ3.png', 'ZN.jpg' -                    ] -                ) -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') +            if 0 <= now_time() < 5.5: +                pass +            else: +                res = randint(1,3) +                if res == 1: +                    # res = random.randint(1,10) +                    img = choice( +                        [ +                            'AZ.jpg', 'AZ1.jpg', 'AZ2.jpg', 'AZ3.png', 'ZN.jpg' +                        ] +                    ) +                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                    img = os.path.abspath(img) +                    await session.send(f'[CQ:image,file=file:///{img}]')  @on_command('suki', patterns = [r"喜欢|爱你|爱|suki|daisuki|すき|好き|贴贴|老婆|[Mm][Uu][Aa]|亲一个"], only_to_me = True)  async def az(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) - -    if str(user) in data.keys(): -        pass -    else: -        if 0 <= now_time() < 5.5: -            pass -        else: -            res = randint(1,3) -            if res == 1: -                # res = random.randint(1,10) -                img = choice( -                    [ -                        'SUKI.jpg', 'SUKI1.jpg', 'SUKI2.png', 'HE1.jpg' -                    ] -                ) -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') -             -            elif 2 <= res <= 3: -                img = choice( -                    [ -                        'TZ.jpg', 'TZ1.jpg', 'TZ2.jpg' -                    ] -                ) -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') - - -@on_command('wenhao', patterns = [r"'?'|?"], only_to_me = False) -async def _(session: CommandSession): -    user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            res = randint(1,3) -            if res == 1: -                res = randint(1,5) -                if 1 <= res < 2: -                    await session.send( -                        choice( -                            [ -                                '?', '?', '嗯?', '(。´・ω・)ん?', 'ん?' -                            ] -                        ) +            if 0 <= now_time() < 5.5: +                pass +            else: +                res = randint(1,3) +                if res == 1: +                    # res = random.randint(1,10) +                    img = choice( +                        [ +                            'SUKI.jpg', 'SUKI1.jpg', 'SUKI2.png', 'HE1.jpg' +                        ]                      ) +                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                    img = os.path.abspath(img) +                    await session.send(f'[CQ:image,file=file:///{img}]') -                elif 2 <= res <= 5: +                elif 2 <= res <= 3:                      img = choice(                          [ -                            'WH.jpg', 'WH1.jpg', 'WH2.jpg', 'WH3.jpg', 'WH4.jpg' +                            'TZ.jpg', 'TZ1.jpg', 'TZ2.jpg'                          ]                      )                      img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'                      img = os.path.abspath(img)                      await session.send(f'[CQ:image,file=file:///{img}]') -@on_command('yn', patterns = [r"是[吗]|是否"], only_to_me = False) + +@on_command('wenhao', patterns = [r"'?'|?|¿"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,3) == 1: -                img = choice( -                    [ -                        'YIQI_YES.png', 'YIQI_NO.jpg', 'KD.jpg', 'FD.jpg' -                    ] -                ) -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') - - +            if 0 <= now_time() < 5.5: +                pass +            else: +                res = randint(1,3) +                if res == 1: +                    res = randint(1,5) +                    if 1 <= res < 2: +                        await session.send( +                            choice( +                                [ +                                    '?', '?', '嗯?', '(。´・ω・)ん?', 'ん?' +                                ] +                            ) +                        ) +                     +                    elif 2 <= res <= 5: +                        img = choice( +                            [ +                                'WH.jpg', 'WH1.jpg', 'WH2.jpg', 'WH3.jpg', 'WH4.jpg' +                            ] +                        ) +                        img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                        img = os.path.abspath(img) +                        await session.send(f'[CQ:image,file=file:///{img}]') -@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭"], only_to_me = False) +@on_command('yn', patterns = [r"是[吗]|是否"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,2) == 1: -                res = randint(1,3) -                if res == 1: +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,3) == 1:                      img = choice(                          [ -                            'WQ.jpg', 'WQ.png', 'WQ1.jpg', 'WQ2.jpg', 'FN.jpg' +                            'YIQI_YES.png', 'YIQI_NO.jpg', 'KD.jpg', 'FD.jpg'                          ]                      )                      img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'                      img = os.path.abspath(img)                      await session.send(f'[CQ:image,file=file:///{img}]') -                elif res == 2: + + +@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭"], only_to_me = False) +async def _(session: CommandSession): +    user = session.event.user_id +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys(): +            pass +        else: +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,2) == 1:                      res = randint(1,3)                      if res == 1: -                        await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!') -                     +                        img = choice( +                            [ +                                'WQ.jpg', 'WQ.png', 'WQ1.jpg', 'WQ2.jpg', 'FN.jpg' +                            ] +                        ) +                        img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                        img = os.path.abspath(img) +                        await session.send(f'[CQ:image,file=file:///{img}]') +                      elif res == 2: -                        await session.send('鱼雷组合拳——————————————————啊————!!!') +                        res = randint(1,3) +                        if res == 1: +                            await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!') +                         +                        elif res == 2: +                            await session.send('鱼雷组合拳——————————————————啊————!!!') +                         +                        elif res == 3: +                            await session.send('火箭拳——————————————————————————!!!')                      elif res == 3: -                        await session.send('火箭拳——————————————————————————!!!') -                 -                elif res == 3: -                    await session.send(response.request_api(KC_URL)) +                        await session.send(response.request_api(KC_URL))  @on_command('ciallo', patterns = [r"[Cc][iI][aA][lL][lL][oO]"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys(): +            pass +        else: +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,2) == 1: +                    res = randint(1,2) +                    if res == 1: +                        img = choice( +                            [ +                                'CIALLO.jpg', 'CIALLO1.jpg', 'CIALLO2.jpg', 'CIALLO3.jpg', 'CIALLO4.jpg', 'CIALLO5.jpg' +                            ] +                        ) +                        img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                        img = os.path.abspath(img) +                        await session.send(f'[CQ:image,file=file:///{img}]') +                     +                    elif res == 2: +                        await session.send('Ciallo~(∠・ω< )⌒★') + +@on_command('ne', patterns = [r"呐|ねえ|口内"], only_to_me = False) +async def _(session: CommandSession): +    user = session.event.user_id +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,2) == 1: -                res = randint(1,2) -                if res == 1: +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,3) == 1: +                    await session.send( +                        choice( +                            [ +                                '呐', '呐呐呐', 'ねえ', 'ねえねえ' +                            ] +                        ) +                    ) + +@on_command('kani', patterns = [r"螃蟹|🦀|カニ|[kK]ani"], only_to_me = False) +async def _(session: CommandSession): +    user = session.event.user_id +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys(): +            pass +        else: +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,2) == 1:                      img = choice(                          [ -                            'CIALLO.jpg', 'CIALLO1.jpg', 'CIALLO2.jpg', 'CIALLO3.jpg', 'CIALLO4.jpg', 'CIALLO5.jpg' +                            'KN.png', 'KN.jpg', 'KN1.jpg', 'KN2.jpg', 'KN3.png'                          ]                      )                      img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'                      img = os.path.abspath(img)                      await session.send(f'[CQ:image,file=file:///{img}]') -                 -                elif res == 2: -                    await session.send('Ciallo~(∠・ω< )⌒★') -@on_command('ne', patterns = [r"呐|ねえ|口内"], only_to_me = False) +@on_command('qingjie', patterns = [r"青[洁结]"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,3) == 1: -                await session.send( -                    choice( +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,2) == 1: +                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg' +                    img = os.path.abspath(img) +                    await session.send(f'[CQ:image,file=file:///{img}]') + +@on_command('jz', patterns = [r"就这"], only_to_me = False) +async def _(session: CommandSession): +    user = session.event.user_id +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys(): +            pass +        else: +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,2) == 1: +                    img = choice(                          [ -                            '呐', '呐呐呐', 'ねえ', 'ねえねえ' +                            'JZ.png', 'JZ1.png'                          ]                      ) -                ) +                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                    img = os.path.abspath(img) +                    await session.send(f'[CQ:image,file=file:///{img}]') -@on_command('kani', patterns = [r"螃蟹|🦀|カニ|[kK]ani"], only_to_me = False) +@on_command('hai', patterns = [r"害|嗐"], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,2) == 1: -                img = choice( -                    [ -                        'KN.png', 'KN.jpg', 'KN1.jpg', 'KN2.jpg', 'KN3.png' -                    ] -                ) -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') +            if 0 <= now_time() < 5.5: +                pass +            else: +                if randint(1,2) == 1: +                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg' +                    img = os.path.abspath(img) +                    await session.send(f'[CQ:image,file=file:///{img}]') -@on_command('qingjie', patterns = [r"青[洁结]"], only_to_me = False) +@on_command('high_per', patterns = [r"高性能|[太最][棒好强猛]|[tT][qQ][lL]|[🐂牛nN][🍺批bB]|すごい|sugoi|[斯死]国一|よかった"])  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    msg = str(session.event.message) +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,2) == 1: -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') +            pat = r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭" +            if re.findall(pat, msg): +                pass +            else: +                msg = choice( +                    [ +                       '当然,我是高性能的嘛~!', +                       '小事一桩,我是高性能的嘛', +                       '怎么样?还是我比较高性能吧?', +                       '哼哼!我果然是高性能的呢!', +                       '因为我是高性能的嘛!嗯哼!', +                       '因为我是高性能的呢!', +                       '哎呀~,我可真是太高性能了', +                       '正是,因为我是高性能的', +                       '是的。我是高性能的嘛♪', +                       '毕竟我可是高性能的!', +                       '嘿嘿,我的高性能发挥出来啦♪', +                       '我果然是很高性能的机器人吧!', +                       '是吧!谁叫我这么高性能呢!哼哼!', +                       '交给我吧,有高性能的我陪着呢', +                       '呣......我的高性能,毫无遗憾地施展出来了......' +                    ] +                ) +                await session.send(msg) -@on_command('jz', patterns = [r"就这"], only_to_me = False) +@on_command('dont_worry', patterns = [r"没事|没关系|大丈夫|还好|不要紧|没出大问题|没伤到哪"])  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    msg = str(session.event.message) +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,2) == 1: -                img = choice( +            pat = r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭" +            if re.findall(pat, msg): +                pass +            else: +                msg = choice(                      [ -                        'JZ.png', 'JZ1.png' +                       '当然,我是高性能的嘛~!', +                       '没事没事,因为我是高性能的嘛!嗯哼!', +                       '没事的,因为我是高性能的呢!', +                       '正是,因为我是高性能的', +                       '是的。我是高性能的嘛♪', +                       '毕竟我可是高性能的!', +                       '那种程度的事不算什么的。\n别看我这样,我可是高性能的', +                       '没问题的,我可是高性能的'                      ]                  ) -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') +                await session.send(msg) -@on_command('hai', patterns = [r"害|嗐"], only_to_me = False) +@on_command('mohead', patterns = [r"摸[头摸]"])  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    msg = str(session.event.message) +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            if randint(1,2) == 1: -                img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg' -                img = os.path.abspath(img) -                await session.send(f'[CQ:image,file=file:///{img}]') +            pat = r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭" +            if re.findall(pat, msg): +                pass +            else: +                res = randint(1,3) +                if 1 <= res <= 2: +                    img = choice( +                        [ +                            'TZ.jpg', 'TZ1.jpg', 'TZ2.jpg' +                        ] +                    ) +                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                    img = os.path.abspath(img) +                    await session.send(f'[CQ:image,file=file:///{img}]') +                 +                elif res == 3: +                    msg = choice( +                        [ +                            '头发的柔顺度上升,我的高性能更上一层楼......', +                            '*蹭蹭' +                        ] +                    ) +                    await session.send(msg)  noobList0 = [] -@on_command('robot', patterns = [r"萝卜子"], only_to_me = False) +@on_command('robozi', patterns = [r"萝卜子"], only_to_me = False)  async def _(session: CommandSession):      global noobList0      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            bL = {} -            await session.send('萝卜子是对机器人的蔑称!') -            noobList0.append(user) -            if countX(noobList0, user) == 2: -                if user == master: -                    await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......') +            if 0 <= now_time() < 5.5: +                pass +            else: +                bL = {} +                await session.send('萝卜子是对机器人的蔑称!') +                noobList0.append(user) +                if countX(noobList0, user) == 2: +                    if user == master: +                        await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......') +                        noobList0 = list(set(noobList0)) +                        pass +                    await session.send('是亚托莉......萝卜子可是对机器人的蔑称......\n这是第二次警告哦,接下来5分钟我不会再理你了!哼唧!') +                    bL[f"{user}"] = f"{user}" +                    file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' +                    f = open(file, 'w') +                    f.write(json.dumps(bL)) +                    f.close()                      noobList0 = list(set(noobList0)) -                    pass -                await session.send('是亚托莉......萝卜子可是对机器人的蔑称......\n这是第二次警告哦,接下来5分钟我不会再理你了!哼唧!') -                bL[f"{user}"] = f"{user}" -                file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' -                f = open(file, 'w') -                f.write(json.dumps(bL)) -                f.close() -                noobList0 = list(set(noobList0)) -                print(noobList0) -                delta = timedelta(minutes = 5) -                trigger = DateTrigger( -                    run_date = datetime.now() + delta -                ) +                    print(noobList0) +                    delta = timedelta(minutes = 5) +                    trigger = DateTrigger( +                        run_date = datetime.now() + delta +                    ) -                scheduler.add_job( #type: ignore -                    func = rmQQfromNoobLIST, -                    trigger = trigger, -                    args = (user), -                    misfire_grace_time = 60, -                ) +                    scheduler.add_job( #type: ignore +                        func = rmQQfromNoobLIST, +                        trigger = trigger, +                        args = (user), +                        misfire_grace_time = 60, +                    ) @@ -615,46 +962,58 @@ noobList1 = []  async def _(session: CommandSession):      global noobList1      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if str(user) in data1.keys():              pass          else: -            msg = str(session.event.message) -            bL = {} -            pattern = r"[nNηиɴИ][tT][rR]|[牛🐂]头人" -            if re.findall(pattern, msg): -                await session.send('你妈的,牛头人,' + response.request_api(KC_URL)) -                noobList1.append(user) -                print(noobList1) -                print(countX(noobList1, user)) -                if countX(noobList1, user) == 5: -                    if user == master: -                        await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......') -                        noobList1 = list(set(noobList1)) -                        pass - -                    else: -                        await session.send(f'[CQ:at,qq={user}]哼!接下来10分钟别想让我理你!') -                        bL[f"{user}"] = f"{user}" -                        file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' -                        f = open(file, 'w') -                        f.write(json.dumps(bL)) -                        f.close() -                        noobList1 = list(set(noobList1)) -                        print(noobList1) -                        delta = timedelta(minutes = 10) -                        trigger = DateTrigger( -                            run_date = datetime.now() + delta -                        ) - -                        scheduler.add_job( #type: ignore -                            func = rmQQfromNoobLIST, -                            trigger = trigger, -                            args = (user), -                            misfire_grace_time = 60, -                        )
\ No newline at end of file +            if 0 <= now_time() < 5.5: +                pass +            else: +                msg = str(session.event.message) +                bL = {} +                pattern = r"[nNηиɴИ][tT][rR]|[牛🐂]头人" +                if re.findall(pattern, msg): +                    await session.send('你妈的,牛头人,' + response.request_api(KC_URL)) +                    noobList1.append(user) +                    print(noobList1) +                    print(countX(noobList1, user)) +                    if countX(noobList1, user) == 5: +                        if user == master: +                            await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......') +                            noobList1 = list(set(noobList1)) +                            pass + +                        else: +                            await session.send(f'[CQ:at,qq={user}]哼!接下来10分钟别想让我理你!') +                            bL[f"{user}"] = f"{user}" +                            file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' +                            f = open(file, 'w') +                            f.write(json.dumps(bL)) +                            f.close() +                            noobList1 = list(set(noobList1)) +                            print(noobList1) +                            delta = timedelta(minutes = 10) +                            trigger = DateTrigger( +                                run_date = datetime.now() + delta +                            ) + +                            scheduler.add_job( #type: ignore +                                func = rmQQfromNoobLIST, +                                trigger = trigger, +                                args = (user), +                                misfire_grace_time = 60, +                            )
\ No newline at end of file diff --git a/ATRI/plugins/checkData.py b/ATRI/plugins/checkData.py index 0fd7217..6e4925b 100644 --- a/ATRI/plugins/checkData.py +++ b/ATRI/plugins/checkData.py @@ -8,46 +8,59 @@ from nonebot import on_command, CommandSession  @on_command('data_list', aliases = ['数据总量'], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +     +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -    if str(user) in data.keys(): +    if str(group) in data.keys():          pass      else: -        con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db') # setu-normal -        cur = con.cursor() -        cur.execute("select * from normal") -        data_normal = len(cur.fetchall()) -        con.close() - -        con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db') # setu-nearR18 -        cur = con.cursor() -        cur.execute("select * from nearR18") -        data_nearR18 = len(cur.fetchall()) -        con.close() - -        con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db') # setu-r18 -        cur = con.cursor() -        cur.execute("select * from r18") -        data_r18 = len(cur.fetchall()) -        con.close() - -        con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db') # cloudmusic -        cur = con.cursor() -        cur.execute("select * from cloudmusic") -        data_cloudmusic = len(cur.fetchall()) -        con.close() - -        with open('ATRI/plugins/wordcloud/wordcloud.json', 'r') as f: -            data = json.load(f) -        data_repo = len(data) - -        await session.send( -            f"""目前螃蟹™数据库收录了: -涩图: -    normal: {data_normal} -    nearR18: {data_nearR18} -    r18:{data_r18} -网抑云语录:{data_cloudmusic} -词汇量:{data_repo}""" -        )
\ No newline at end of file +        if str(user) in data1.keys(): +            pass +        else: +            con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db') # setu-normal +            cur = con.cursor() +            cur.execute("select * from normal") +            data_normal = len(cur.fetchall()) +            con.close() + +            con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db') # setu-nearR18 +            cur = con.cursor() +            cur.execute("select * from nearR18") +            data_nearR18 = len(cur.fetchall()) +            con.close() + +            con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db') # setu-r18 +            cur = con.cursor() +            cur.execute("select * from r18") +            data_r18 = len(cur.fetchall()) +            con.close() + +            con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db') # cloudmusic +            cur = con.cursor() +            cur.execute("select * from cloudmusic") +            data_cloudmusic = len(cur.fetchall()) +            con.close() + +            with open(Path('.') / 'ATRI' / 'plugins' / 'LearnRepo' / 'LearnRepo.json', 'r') as f: +                data = json.load(f) +            data_repo = len(data) + +            await session.send( +                f"""目前螃蟹™数据库收录了: +    涩图: +        normal: {data_normal} +        nearR18: {data_nearR18} +        r18:{data_r18} +    网抑云语录:{data_cloudmusic} +    词汇量:{data_repo}""" +            )
\ No newline at end of file diff --git a/ATRI/plugins/hbook.py b/ATRI/plugins/hbook.py index 7ed14fe..465d3b1 100644 --- a/ATRI/plugins/hbook.py +++ b/ATRI/plugins/hbook.py @@ -1,6 +1,7 @@  import re  import time  import json +from pathlib import Path  from datetime import datetime  from random import choice  from nonebot import on_command, CommandSession @@ -21,78 +22,90 @@ pattern = r"来(.*?)[点丶份张幅](.*?)的?本子"  @on_command('hbook', patterns = pattern, only_to_me = False)  async def _(session: CommandSession):      h_user = session.event.user_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -        if str(h_user) in data.keys(): +    if str(group) in data.keys(): +        pass +    else: +        if str(h_user) in data1.keys():              pass          else: -            with open('ATRI/plugins/switch/switch.json', 'r') as f: -                data = json.load(f) -             -            if data["hbook"] == "on": -                num = 1 -                tag = '' -                start = time.perf_counter() -                h_msg = str(session.event.message) - -                info = re.findall(pattern, h_msg) -                if info: -                    num = int(info[0][0] or 1) -                    tag = str(info[0][1]) -                if num > 5: -                    await session.send('你是不是涩批啊!要那么多干啥?!我最多发5份!') -                    num = 5 +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +                    data = json.load(f) -                h_type = session.event.detail_type +                if data["hbook"] == "on": +                    num = 1 +                    tag = '' +                    start = time.perf_counter() +                    h_msg = str(session.event.message) + +                    info = re.findall(pattern, h_msg) +                    if info: +                        num = int(info[0][0] or 1) +                        tag = str(info[0][1]) +                    if num > 5: +                        await session.send('你是不是涩批啊!要那么多干啥?!我最多发5份!') +                        num = 5 +                     +                    h_type = session.event.detail_type -                try: -                    header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'} -                    keyword = {'show':'title,titleen,tags','keyboard':tag} -                    print(keyword) +                    try: +                        header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'} +                        keyword = {'show':'title,titleen,tags','keyboard':tag} +                        print(keyword) -                    res = await response.post_bytes('https://b-upp.com/search/', headers=header, data=keyword) -                    res = res.decode() -                except: -                    session.finish('貌似请求数据失败了...') +                        res = await response.post_bytes('https://b-upp.com/search/', headers=header, data=keyword) +                        res = res.decode() +                    except: +                        session.finish('貌似请求数据失败了...') -                if '没有搜索到相关的内容' in res: -                    n_msg = '...似乎没有找到[{}]相关的本子呢'.format(tag) -                    await session.send(message=n_msg) -                 -                else: -                    p = '<a href="(.*?)" target="_blank" title="(.*?)">' -                    data = re.findall(p,res) -                    n = len(data) -                    limit = num +                    if '没有搜索到相关的内容' in res: +                        n_msg = '...似乎没有找到[{}]相关的本子呢'.format(tag) +                        await session.send(message=n_msg) -                    if n > limit: # type: ignore -                        n = limit # type: ignore +                    else: +                        p = '<a href="(.*?)" target="_blank" title="(.*?)">' +                        data = re.findall(p,res) +                        n = len(data) +                        limit = num +                         +                        if n > limit: # type: ignore +                            n = limit # type: ignore -                    msg = f'据提供信息,已查询到{n}本关键词为[{tag}]的本子:' -                    if h_type == 'group': -                        msg = f'[CQ:at,qq={h_user}]\n根据提供信息,已查询到{n}本关键词为[{tag}]的本子:' -                    for i in range(n): -                        msg0 = ('\n——————————\n本子链接:https://b-upp.com%s \n本子标题:%s '%(data[i])) +                        msg = f'据提供信息,已查询到{n}本关键词为[{tag}]的本子:' +                        if h_type == 'group': +                            msg = f'[CQ:at,qq={h_user}]\n根据提供信息,已查询到{n}本关键词为[{tag}]的本子:' +                        for i in range(n): +                            msg0 = ('\n——————————\n本子链接:https://b-upp.com%s \n本子标题:%s '%(data[i])) +                            msg += msg0 +                        end = time.perf_counter() +                        msg0 = f'\n——————————\n耗时: {round(end - start, 3)}s'                          msg += msg0 -                    end = time.perf_counter() -                    msg0 = f'\n——————————\n耗时: {round(end - start, 3)}s' -                    msg += msg0 -                    await session.send(msg) +                        await session.send(msg) -            else: -                await session.send('该功能已禁用...')
\ No newline at end of file +                else: +                    await session.send('该功能已禁用...')
\ No newline at end of file diff --git a/ATRI/plugins/hitokoto.py b/ATRI/plugins/hitokoto.py index e5fbe36..e72a37e 100644 --- a/ATRI/plugins/hitokoto.py +++ b/ATRI/plugins/hitokoto.py @@ -1,6 +1,7 @@  import json  from datetime import datetime  from random import choice +from pathlib import Path  from nonebot import on_command, on_natural_language, CommandSession  from nonebot import NLPSession, NLPResult @@ -21,33 +22,45 @@ url = 'https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&  @on_command('hitokoto', aliases = ['一言'], only_to_me = False)  async def hitokoto(session: CommandSession):      user = session.event.user_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} -        if str(user) in data.keys(): +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            rep = response.request_api(url) -             -            if not rep: -                session.finish('获取失败') -             -            dc = json.loads(response.request_api(url)) - -            await session.send(dc["hitokoto"]) +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                rep = response.request_api(url) +                 +                if not rep: +                    session.finish('获取失败') +                 +                dc = json.loads(response.request_api(url)) + +                await session.send(dc["hitokoto"])  @on_natural_language('一言', only_to_me = False)  async def _(session: NLPSession): diff --git a/ATRI/plugins/noobList/noobGroup.json b/ATRI/plugins/noobList/noobGroup.json deleted file mode 100644 index 6e1ba39..0000000 --- a/ATRI/plugins/noobList/noobGroup.json +++ /dev/null @@ -1 +0,0 @@ -{"123": "123"}
\ No newline at end of file diff --git a/ATRI/plugins/noobList/noobList.json b/ATRI/plugins/noobList/noobList.json deleted file mode 100644 index 021e00a..0000000 --- a/ATRI/plugins/noobList/noobList.json +++ /dev/null @@ -1 +0,0 @@ -{"123": "123"} diff --git a/ATRI/plugins/other.py b/ATRI/plugins/other.py index dd34dda..5946905 100644 --- a/ATRI/plugins/other.py +++ b/ATRI/plugins/other.py @@ -3,6 +3,7 @@ import random  import nonebot  from datetime import datetime  from random import choice +from pathlib import Path  from nonebot import on_command, CommandSession  from nonebot.helpers import render_expression @@ -32,104 +33,178 @@ HELP_REPLY = (  @on_command('抽签', only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) - -        if str(user) in data.keys(): +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            await session.send( -                str( -                    random.choice( +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice(                          [ -                            '大凶', -                            '大胸', -                            '小凶', -                            '小胸', -                            '凶', -                            '吉', -                            '中吉', -                            '大吉', -                            '特大吉', -                            '超特大吉' +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..'                          ]                      )                  ) -            ) +            else: +                await session.send( +                    str( +                        random.choice( +                            [ +                                '大凶', +                                '大胸', +                                '小凶', +                                '小胸', +                                '凶', +                                '吉', +                                '中吉', +                                '大吉', +                                '特大吉', +                                '超特大吉' +                            ] +                        ) +                    ) +                )  @on_command('掷骰子', aliases = ['扔骰子', '骰子'], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) - -        if str(user) in data.keys(): +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            await session.send( -                str( -                    random.randint( -                        1,6 +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                await session.send( +                    str( +                        random.randint( +                            1,6 +                        )                      )                  ) -            )  @on_command('关于', aliases = ['关于机器人'], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) - -    if str(user) in data.keys(): +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys():          pass      else: -        await session.send( -            """想了解ATRI嘛 -    写出咱的是Kyomotoi -    他的主页:https://blog.lolihub.icu/ -    项目地址:https://github.com/Kyomotoi/ATRI -    欢迎star~w!""" -        ) +        if str(user) in data1.keys(): +            pass +        else: +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                await session.send( +                    """想了解ATRI嘛 +            写出咱的是Kyomotoi +            他的主页:https://blog.lolihub.icu/ +            项目地址:https://github.com/Kyomotoi/ATRI +            欢迎star~w!""" +                )  @on_command('help', aliases = ['帮助', '如何使用ATRI', '机器人帮助'], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) - -    if str(user) in data.keys(): +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys():          pass      else: -        await session.send( -            f"""{render_expression(HELP_REPLY)} -请仔细阅读文档哦~~https://blog.lolihub.icu/#/ATRI/user""" -        ) +        if str(user) in data1.keys(): +            pass +        else: +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                await session.send( +                    f"""{render_expression(HELP_REPLY)} +        请仔细阅读文档哦~~https://blog.lolihub.icu/#/ATRI/user""" +                )  @on_command('report', aliases = ['来杯红茶'], only_to_me = True) diff --git a/ATRI/plugins/pixiv.py b/ATRI/plugins/pixiv.py index 717c54a..58a2203 100644 --- a/ATRI/plugins/pixiv.py +++ b/ATRI/plugins/pixiv.py @@ -2,6 +2,7 @@ import time  import json  from datetime import datetime  from random import choice +from pathlib import Path  import nonebot  from nonebot import on_command, CommandSession @@ -41,201 +42,237 @@ def now_time():  @on_command('pixiv_seach_img', aliases = ['p站搜图', 'P站搜图', '批站搜图'], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) - -        if str(user) in data.keys(): +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            with open('ATRI/plugins/switch/switch.json', 'r') as f: -                data = json.load(f) - -            if data["pixiv_seach_img"] == "on": -                pid = session.current_arg.strip() - -                if not pid: -                    pid = session.get('message', prompt = '请告诉ATRI需要查询的Pid码') -                 -                start =time.perf_counter() -                await session.send('开始P站搜图\n如搜索时间过长或许为图片过大上传较慢') - -                URL = URL_1 + pid - -                dc = json.loads(response.request_api(URL)) - -                if not dc: -                    session.finish('ATRI在网络上走散了...请重试...') - -                img = f'https://pixiv.cat/{pid}.jpg' -                 - -                end = time.perf_counter() - +            if 0 <= now_time() < 5.5:                  await session.send( -                    IMG_SEACH_REPLY.format( -                        user = user, -                        pid = pid, -                        title = dc["response"][0]["title"], -                        width = dc["response"][0]["width"], -                        height = dc["response"][0]["height"], -                        tags = dc["response"][0]["tags"], -                        account = dc["response"][0]["user"]["account"], -                        name = dc["response"][0]["user"]["name"], -                        user_link = f'https://www.pixiv.net/users/' + f'{dc["response"][0]["user"]["id"]}', -                        img = img, -                        time = round(end - start, 3) +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ]                      )                  ) -                          else: -                await session.send('该功能已被禁用...') +                with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +                    data = json.load(f) + +                if data["pixiv_seach_img"] == "on": +                    pid = session.current_arg.strip() + +                    if not pid: +                        pid = session.get('message', prompt = '请告诉ATRI需要查询的Pid码') +                     +                    start =time.perf_counter() +                    await session.send('开始P站搜图\n如搜索时间过长或许为图片过大上传较慢') + +                    URL = URL_1 + pid + +                    dc = json.loads(response.request_api(URL)) + +                    if not dc: +                        session.finish('ATRI在网络上走散了...请重试...') + +                    img = f'https://pixiv.cat/{pid}.jpg' +                     + +                    end = time.perf_counter() + +                    await session.send( +                        IMG_SEACH_REPLY.format( +                            user = user, +                            pid = pid, +                            title = dc["response"][0]["title"], +                            width = dc["response"][0]["width"], +                            height = dc["response"][0]["height"], +                            tags = dc["response"][0]["tags"], +                            account = dc["response"][0]["user"]["account"], +                            name = dc["response"][0]["user"]["name"], +                            user_link = f'https://www.pixiv.net/users/' + f'{dc["response"][0]["user"]["id"]}', +                            img = img, +                            time = round(end - start, 3) +                        ) +                    ) +                 +                else: +                    await session.send('该功能已被禁用...')  @on_command('pixiv_seach_author', aliases = ['画师', '搜索画师', '画师搜索'], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) - -        if str(user) in data.keys(): +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            with open('ATRI/plugins/switch/switch.json', 'r') as f: -                data = json.load(f) -                 -            if data["pixiv_seach_author"] == "on": -                author_id = session.current_arg.strip() - -                if not author_id: -                    author_id = session.get('message', prompt = '请告诉ATRI需要查询的画师ID') -                 -                start =time.perf_counter() -                await session.send(f'开始获取画师{author_id}的前三项作品\n如获取时间过长或许为图片过大上传较慢') - -                URL = URL_2 + author_id - -                dc = json.loads(response.request_api(URL)) - -                if not dc: -                    session.finish('ATRI在网络上走散了...请重试...') - -                d ={} - -                for i in range(0,3): -                    pid = dc["response"][i]["id"] -                    pidURL = f'https://pixiv.cat/{pid}.jpg' -                    d[i] = [f'{pid}',f'{pidURL}'] -                 -                msg0 = (f'[CQ:at,qq={user}]\n画师id:{author_id},接下来展示前三作品') - -                result = sorted( -                            d.items(), -                            key = lambda x:x[1], -                            reverse = True +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    )                  ) +            else: +                with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +                    data = json.load(f) +                     +                if data["pixiv_seach_author"] == "on": +                    author_id = session.current_arg.strip() + +                    if not author_id: +                        author_id = session.get('message', prompt = '请告诉ATRI需要查询的画师ID') +                     +                    start =time.perf_counter() +                    await session.send(f'开始获取画师{author_id}的前三项作品\n如获取时间过长或许为图片过大上传较慢') + +                    URL = URL_2 + author_id + +                    dc = json.loads(response.request_api(URL)) + +                    if not dc: +                        session.finish('ATRI在网络上走散了...请重试...') + +                    d ={} + +                    for i in range(0,3): +                        pid = dc["response"][i]["id"] +                        pidURL = f'https://pixiv.cat/{pid}.jpg' +                        d[i] = [f'{pid}',f'{pidURL}'] +                     +                    msg0 = (f'[CQ:at,qq={user}]\n画师id:{author_id},接下来展示前三作品') + +                    result = sorted( +                                d.items(), +                                key = lambda x:x[1], +                                reverse = True +                    ) -                t = 0 +                    t = 0 -                for i in result: -                    t += 1 -                    msg = (f'\n---------------\n({t})\nPid: {i[1][0]}\n{i[1][1]}') -                    msg0 += msg -                end = time.perf_counter() +                    for i in result: +                        t += 1 +                        msg = (f'\n---------------\n({t})\nPid: {i[1][0]}\n{i[1][1]}') +                        msg0 += msg +                    end = time.perf_counter() -                msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s') -                msg0 += msg1 +                    msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s') +                    msg0 += msg1 +                     +                    await session.send(msg0) -                await session.send(msg0) -             -            else: -                await session.send('该功能已被禁用...') +                else: +                    await session.send('该功能已被禁用...')  @on_command('pixiv_daily_rank', aliases = ['P站排行榜', '批站排行榜', 'p站排行榜'], only_to_me = False)  async def _(session: CommandSession):      user = session.event.user_id -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:              data = json.load(f) - -        if str(user) in data.keys(): +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            with open('ATRI/plugins/switch/switch.json', 'r') as f: -                data = json.load(f) +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +                    data = json.load(f) -            if data["pixiv_daily_rank"] == "on": +                if data["pixiv_daily_rank"] == "on": -                await session.send('ATRI正在获取P站每日排行榜前五作品...') +                    await session.send('ATRI正在获取P站每日排行榜前五作品...') -                start =time.perf_counter() -                dc = json.loads(response.request_api(URL_3)) +                    start =time.perf_counter() +                    dc = json.loads(response.request_api(URL_3)) -                d = {} +                    d = {} -                for i in range(0,5): -                    pid = dc["response"][0]["works"][i]["work"]["id"] -                    pidURL = f'https://pixiv.cat/{pid}.jpg' -                    d[i] = [f'{pid}',f'{pidURL}'] +                    for i in range(0,5): +                        pid = dc["response"][0]["works"][i]["work"]["id"] +                        pidURL = f'https://pixiv.cat/{pid}.jpg' +                        d[i] = [f'{pid}',f'{pidURL}'] -                msg0 = (f'[CQ:at,qq={user}]') +                    msg0 = (f'[CQ:at,qq={user}]') -                result = sorted( -                    d.items(), -                    key = lambda x:x[1], -                    reverse = True -                ) +                    result = sorted( +                        d.items(), +                        key = lambda x:x[1], +                        reverse = True +                    ) -                t = 0 +                    t = 0 -                for i in result: -                    t += 1 -                    msg = (f'\n---------------\n({t})\nPid: {i[1][0]}\n{i[1][1]}') -                    msg0 += msg -                end = time.perf_counter() +                    for i in result: +                        t += 1 +                        msg = (f'\n---------------\n({t})\nPid: {i[1][0]}\n{i[1][1]}') +                        msg0 += msg +                    end = time.perf_counter() -                msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s') -                msg0 += msg1 +                    msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s') +                    msg0 += msg1 -                await session.send(msg0) -             -            else: -                await session.send('该功能已被禁用...')
\ No newline at end of file +                    await session.send(msg0) +                 +                else: +                    await session.send('该功能已被禁用...')
\ No newline at end of file diff --git a/ATRI/plugins/richBISS.py b/ATRI/plugins/richBISS.py index 60d3315..bea06af 100644 --- a/ATRI/plugins/richBISS.py +++ b/ATRI/plugins/richBISS.py @@ -1,6 +1,7 @@  import re  import json  import nonebot +from pathlib import Path  from datetime import datetime  from ATRI.modules import response # type: ignore @@ -49,52 +50,63 @@ def enc(x):  @bot.on_message("group")  async def Fuck_bili_rich(context): -    msg = str(context["message"])      user = str(context["user_id"])      group = context["group_id"] -    pattern = re.compile(r"BV\S+\?") -    bv = re.findall(pattern, msg) -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) - -    if user in data.keys(): +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if user in data1.keys():              pass          else: -            if bv: -                bv = bv[0] -                bv = bv.replace('?', '') - -                aid = str(dec(bv)) -                ad = 'av' + aid -                URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}' +            if 0 <= now_time() < 5.5: +                pass +            else: +                msg = str(context["message"]) +                pattern = re.compile(r"BV\S+\?") +                bv = re.findall(pattern, msg) +                if bv: +                    bv = bv[0] +                    bv = bv.replace('?', '') + +                    aid = str(dec(bv)) +                    ad = 'av' + aid +                    URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}' -                try: -                    res = response.request_api(URL) -                    mg = json.loads(res) -                    msg = BILI_REPORT_FORMAT.format( -                        title = mg["data"]["title"], +                    try: +                        res = response.request_api(URL) +                        mg = json.loads(res) +                        msg = BILI_REPORT_FORMAT.format( +                            title = mg["data"]["title"], -                        view = mg["data"]["stat"]["view"], -                        coin = mg["data"]["stat"]["coin"], -                        share = mg["data"]["stat"]["share"], -                        like = mg["data"]["stat"]["like"], +                            view = mg["data"]["stat"]["view"], +                            coin = mg["data"]["stat"]["coin"], +                            share = mg["data"]["stat"]["share"], +                            like = mg["data"]["stat"]["like"], -                        bid = mg["data"]["bvid"], -                        bid_link = mg["data"]["short_link"], +                            bid = mg["data"]["bvid"], +                            bid_link = mg["data"]["short_link"], -                        aid = ad, -                        aid_link = f'https://b23.tv/{ad}' -                        ) +                            aid = ad, +                            aid_link = f'https://b23.tv/{ad}' +                            ) -                    await bot.send_msg( # type: ignore -                        group_id = group, -                        message = msg -                        ) -                except: -                    pass +                        await bot.send_msg( # type: ignore +                            group_id = group, +                            message = msg +                            ) +                    except: +                        pass  REPORT_FORMAT = """Status: {status} @@ -105,44 +117,52 @@ MD5: {md5}"""  @bot.on_message("group")  async def Fuck_CloudMusic(context): -    msg = str(context["message"])      user = str(context["user_id"])      group = context["group_id"] -    m_type = context["sub_type"] -    pattern = re.compile(r"song\S+\/|id=\S+\&") -    music_id = re.findall(pattern, msg) -    print(music_id) - -    with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -        data = json.load(f) - -    if user in data.keys(): +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +            data1 = json.load(f) +    except: +        data1 = {} + +    if str(group) in data.keys():          pass      else: -        if 0 <= now_time() < 5.5: +        if user in data1.keys():              pass          else: -            if 'music.163.com' in msg: -                if music_id: -                    music_id = str(music_id[0]) -                    music_id = re.findall(r"-?[1-9]\d*", music_id) -                    URL = f'https://api.imjad.cn/cloudmusic/?type=song&id={music_id[0]}&br=320000' -                    print(URL) - -                    try: -                        res = response.request_api(URL) -                        mg = json.loads(res) - -                        msg = REPORT_FORMAT.format( -                            status = mg["code"], -                            id = mg["data"][0]["id"], -                            br = mg["data"][0]["br"], -                            url = mg["data"][0]["url"], -                            md5 = mg["data"][0]["md5"], -                            ) -                        await bot.send_msg( -                            group_id = group, -                            message = msg -                            ) # type: ignore -                    except: -                        pass
\ No newline at end of file +            if 0 <= now_time() < 5.5: +                pass +            else: +                msg = str(context["message"]) +                pattern = re.compile(r"song\S+\/|id=\S+\&") +                music_id = re.findall(pattern, msg) +                if 'music.163.com' in msg: +                    if music_id: +                        music_id = str(music_id[0]) +                        music_id = re.findall(r"-?[1-9]\d*", music_id) +                        URL = f'https://api.imjad.cn/cloudmusic/?type=song&id={music_id[0]}&br=320000' +                        print(URL) + +                        try: +                            res = response.request_api(URL) +                            mg = json.loads(res) + +                            msg = REPORT_FORMAT.format( +                                status = mg["code"], +                                id = mg["data"][0]["id"], +                                br = mg["data"][0]["br"], +                                url = mg["data"][0]["url"], +                                md5 = mg["data"][0]["md5"], +                                ) +                            await bot.send_msg( +                                group_id = group, +                                message = msg +                                ) # type: ignore +                        except: +                            pass
\ No newline at end of file diff --git a/ATRI/plugins/send.py b/ATRI/plugins/send.py index 69fc1b0..a04dc83 100644 --- a/ATRI/plugins/send.py +++ b/ATRI/plugins/send.py @@ -1,13 +1,12 @@  import time +import json +from pathlib import Path  import nonebot  from nonebot import on_command, CommandSession -import config # type: ignore -  bot = nonebot.get_bot()  master = bot.config.SUPERUSERS -ban_group = bot.config.BANGROUP # type: ignore  @on_command('send_all_group', aliases = ['公告', '群发', '推送'], only_to_me=False) @@ -17,6 +16,14 @@ async def send_all_group(session: CommandSession):          start = time.perf_counter() +        try: +            with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +                data = json.load(f) +        except: +            data = {} + +        ban_group = list(data.keys()) +          if not msg:              msg = session.get('message', prompt='请告诉吾辈需要群发的内容~!') diff --git a/ATRI/plugins/setu.py b/ATRI/plugins/setu.py index 796f6f7..3a667fb 100644 --- a/ATRI/plugins/setu.py +++ b/ATRI/plugins/setu.py @@ -1,7 +1,10 @@  import os +import re  import time  import json  import sqlite3 +import requests +from urllib.parse import urlencode  from random import choice, randint  from pathlib import Path  from datetime import datetime @@ -10,12 +13,16 @@ import nonebot  from nonebot import on_command, CommandSession  import config # type: ignore -from ATRI.modules import response # type: ignore +from ATRI.modules.response import request_api_params # type: ignore +from ATRI.modules.b64 import b64_str_img_url # type: ignore  bot = nonebot.get_bot()  master = config.MASTER() -apikey = bot.config.LOLICONAPI # type: ignore +apikey_LOLI = bot.config.LOLICONAPI # type: ignore +APP_ID = config.BAIDU_APP_ID() +API_KEY = config.BAIDU_API_KEY() +SECRECT_KEY = config.BAIDU_SECRET()  URL = 'https://api.lolicon.app/setu/' @@ -37,127 +44,139 @@ def now_time():  setu_type = 1  @on_command('setu', patterns = (r"来[点丶张份副个幅][涩色瑟][图圖]|[涩色瑟][图圖]来|[涩色瑟][图圖][gkd|GKD|搞快点]|[gkd|GKD|搞快点][涩色瑟][图圖]|[图圖]来|[我你她他它]想要[点丶张份副][涩色瑟][图圖]|我想要[1一][张份幅副个只][涩色瑟][图圖]|[我你她他它]想[看|look][涩涩|色色]的东西"), only_to_me = False)  async def setu(session: CommandSession): -    group = session.event.group_id -    user = session.event.user_id      start = time.perf_counter() -    if 0 <= now_time() < 5.5: -        await session.send( -            choice( -                [ -                    'zzzz......', -                    'zzzzzzzz......', -                    'zzz...好涩哦..zzz....', -                    '别...不要..zzz..那..zzz..', -                    '嘻嘻..zzz..呐~..zzzz..' -                ] -            ) -        ) -    else: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: -            data0 = json.load(f) -        with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +    user = session.event.user_id +    group = session.event.group_id +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +            data = json.load(f) +    except: +        data = {} +    try: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:              data1 = json.load(f) +    except: +        data1 = {} -        if str(user) in data0.keys(): +    if str(group) in data.keys(): +        pass +    else: +        if str(user) in data1.keys():              pass          else: -            if data1["setu"] == "on": -                res = randint(1,10) -                if 1 <= res < 9: -                    res = randint(1,4) -                    if 1 <= res < 3: -                        if setu_type == 1: -                            res = randint(1,4) -                            con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db') -                            cur = con.cursor() -                            msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;') -                         -                            if 1 <= res < 3: -                                for i in msg: -                                    pid = i[0] -                                    title = i[1] -                                    img = i[7] +            if 0 <= now_time() < 5.5: +                await session.send( +                    choice( +                        [ +                            'zzzz......', +                            'zzzzzzzz......', +                            'zzz...好涩哦..zzz....', +                            '别...不要..zzz..那..zzz..', +                            '嘻嘻..zzz..呐~..zzzz..' +                        ] +                    ) +                ) +            else: +                with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +                    data1 = json.load(f) + +                if data1["setu"] == "on": +                    res = randint(1,10) +                    if 1 <= res < 9: +                        res = randint(1,4) +                        if 1 <= res < 3: +                            if setu_type == 1: +                                res = randint(1,4) +                                con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db') +                                cur = con.cursor() +                                msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;') +                             +                                if 1 <= res < 3: +                                    for i in msg: +                                        pid = i[0] +                                        title = i[1] +                                        img = i[7] +                                        end = time.perf_counter() +                                        await session.send( +                                            SETU_REPLY.format( +                                            title = title, +                                            pid = pid, +                                            setu = img, +                                            time = round(end - start, 3) +                                            ) +                                        ) +                                elif res == 4: +                                    for i in msg: +                                        pid = i[0] +                                        title = i[1] +                                        img = i[7] +                                        end = time.perf_counter() +                                        await session.send('我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆') +                                        await bot.send_private_msg( # type: ignore +                                            user_id = master, +                                            message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{img}\nComplete time: {round(end - start, 3)}" +                                        ) +                             +                            elif setu_type == 2: +                                res = randint(1,4) +                                await session.send('别急!正在找图!') +                                start = time.perf_counter() +                                values = { +                                    "apikey": apikey_LOLI, +                                    "r18": "0", +                                    "num": "1" +                                } + +                                try: +                                    dc = json.loads(request_api_params(URL, values)) +                                    title = dc["data"][0]["title"] +                                    pid = dc["data"][0]["pid"] +                                    setu = dc["data"][0]["url"] #b64.b64_str_img_url(dc["data"][0]["url"]) +                                except: +                                    await session.send('失败了失败了失败了失...') +                                    return +                                if 1 <= res < 3:                                      end = time.perf_counter()                                      await session.send(                                          SETU_REPLY.format(                                          title = title,                                          pid = pid, -                                        setu = img, +                                        setu = dc["data"][0]["url"],                                          time = round(end - start, 3)                                          )                                      ) -                            elif res == 4: -                                for i in msg: -                                    pid = i[0] -                                    title = i[1] -                                    img = i[7] +                                elif res == 4:                                      end = time.perf_counter()                                      await session.send('我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆')                                      await bot.send_private_msg( # type: ignore                                          user_id = master, -                                        message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{img}\nComplete time: {round(end - start, 3)}" +                                        message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}"                                      ) -                         -                        elif setu_type == 2: -                            res = randint(1,4) -                            await session.send('别急!正在找图!') -                            start = time.perf_counter() -                            values = { -                                "apikey": apikey, -                                "r18": "0", -                                "num": "1" -                            } - -                            try: -                                dc = json.loads(response.request_api_params(URL, values)) -                                title = dc["data"][0]["title"] -                                pid = dc["data"][0]["pid"] -                                setu = dc["data"][0]["url"] #b64.b64_str_img_url(dc["data"][0]["url"]) -                            except: -                                await session.send('失败了失败了失败了失...') -                                return -                            if 1 <= res < 3: -                                end = time.perf_counter() -                                await session.send( -                                    SETU_REPLY.format( -                                    title = title, -                                    pid = pid, -                                    setu = dc["data"][0]["url"], -                                    time = round(end - start, 3) -                                    ) -                                ) -                            elif res == 4: -                                end = time.perf_counter() -                                await session.send('我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆') -                                await bot.send_private_msg( # type: ignore -                                    user_id = master, -                                    message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}" -                                ) -                    elif res == 4: +                        elif res == 4: +                            img = choice( +                                [ +                                    'SP.jpg', 'SP1.jpg', 'SP2.jpg' +                                ] +                            ) +                            img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                            img = os.path.abspath(img) +                            await session.send(f'[CQ:image,file=file:///{img}]') +                     +                    elif res == 10:                          img = choice(                              [ -                                'SP.jpg', 'SP1.jpg', 'SP2.jpg' +                                'GDZ.png', 'SHZY1.jpg', 'SHZY2.jpg', 'SHZY3.jpg', 'SHZY4.jpg', 'SHZY5.jpg', 'SHZY6.jpg'                              ]                          ) -                        img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                        img = Path('.') / 'ATRI' / 'data' / 'img' / 'niceIMG' / f'{img}'                          img = os.path.abspath(img)                          await session.send(f'[CQ:image,file=file:///{img}]') -                 -                elif res == 10: -                    img = choice( -                        [ -                            'GDZ.png', 'SHZY1.jpg', 'SHZY2.jpg', 'SHZY3.jpg', 'SHZY4.jpg', 'SHZY5.jpg', 'SHZY6.jpg' -                        ] -                    ) -                    img = Path('.') / 'ATRI' / 'data' / 'img' / 'niceIMG' / f'{img}' -                    img = os.path.abspath(img) -                    await session.send(f'[CQ:image,file=file:///{img}]') -            else: -                await session.send('该功能已被禁用...') +                else: +                    await session.send('该功能已被禁用...') -@on_command('change_setu_type', aliases = ['涩图导向'], only_to_me =False) +@on_command('change_setu_type', aliases = ['涩图导向'], only_to_me = False)  async def _(session: CommandSession):      global setu_type      if session.event.user_id == master: @@ -174,3 +193,154 @@ async def _(session: CommandSession):              pass          await session.send('okay~~~~') + + +@bot.on_message("group") +async def _(context): +    start = time.perf_counter() +    user = context["user_id"] +    group = context["group_id"] +    if 0 <= now_time() < 5.5: +        pass +    else: +        try: +            with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: +                data = json.load(f) +        except: +            data = {} +        try: +            with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: +                data1 = json.load(f) +        except: +            data1 = {} + +        if str(group) in data.keys(): +            pass +        else: +            if str(user) in data1.keys(): +                pass +            else: +                try: +                    img = str(context["message"]) +                    pattern = re.compile(r"url=(.*)]") +                    img = re.findall(pattern, img) +                    img = img[0].replace('url=', '') +                    img = img.replace(']', '') +                    print(img) +                except: +                    return +                img = b64_str_img_url(img) +                if img: +                    host = f'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={API_KEY}&client_secret={SECRECT_KEY}' +                    headers = { +                        'Content-Type': 'application/json;charset=UTF-8' +                    } +                    res = json.loads(request_api_params(host, headers)) +                    access_token=res['access_token'] +                    url = f'https://aip.baidubce.com/rest/2.0/ocr/v1/general?access_token={access_token}' +                    headers = {'Content-Type': 'application/x-www-form-urlencoded'} +                    data = urlencode({'image': img}) +                    res = requests.post(url=url, headers=headers, data=data) +                     +                    try: +                        words = json.loads(res.content)['words_result'][0]['words'] +                        print(words) +                    except: +                        return + +                    if re.findall(r"[涩色]图", words): +                        with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: +                            data1 = json.load(f) + +                        if data1["setu"] == "on": +                            res = randint(1,10) +                            if 1 <= res < 9: +                                res = randint(1,4) +                                if 1 <= res < 3: +                                    if setu_type == 1: +                                        res = randint(1,4) +                                        con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db') +                                        cur = con.cursor() +                                        msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;') +                                     +                                        if 1 <= res < 3: +                                            for i in msg: +                                                pid = i[0] +                                                title = i[1] +                                                img = i[7] +                                                end = time.perf_counter() +                                                msg = SETU_REPLY.format( +                                                    title = title, +                                                    pid = pid, +                                                    setu = img, +                                                    time = round(end - start, 3) +                                                ) +                                                await bot.send_group_msg(group_id = group, message = msg) # type: ignore +                                        elif res == 4: +                                            for i in msg: +                                                pid = i[0] +                                                title = i[1] +                                                img = i[7] +                                                end = time.perf_counter() +                                                await bot.send_group_msg(group_id = group, message = '我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆') # type: ignore +                                                await bot.send_private_msg( # type: ignore +                                                    user_id = master, +                                                    message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{img}\nComplete time: {round(end - start, 3)}" +                                                ) +                                     +                                    elif setu_type == 2: +                                        res = randint(1,4) +                                        await bot.send_group_msg(group_id = group, message = '别急!正在找图!') # type: ignore +                                        start = time.perf_counter() +                                        values = { +                                            "apikey": apikey_LOLI, +                                            "r18": "0", +                                            "num": "1" +                                        } + +                                        try: +                                            dc = json.loads(request_api_params(URL, values)) +                                            title = dc["data"][0]["title"] +                                            pid = dc["data"][0]["pid"] +                                            setu = dc["data"][0]["url"] #b64.b64_str_img_url(dc["data"][0]["url"]) +                                        except: +                                            await bot.send_group_msg(group_id = group, message = '失败了失败了失...') # type: ignore +                                            return +                                        if 1 <= res < 3: +                                            end = time.perf_counter() +                                            msg = SETU_REPLY.format( +                                                    title = title, +                                                    pid = pid, +                                                    setu = img, +                                                    time = round(end - start, 3) +                                                ) +                                            await bot.send_group_msg(group_id = group, message = msg) # type: ignore +                                        elif res == 4: +                                            end = time.perf_counter() +                                            await bot.send_group_msg(group_id = group, message = '我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆') # type: ignore +                                            await bot.send_private_msg( # type: ignore +                                                user_id = master, +                                                message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}" +                                            ) +                                elif res == 4: +                                    img = choice( +                                        [ +                                            'SP.jpg', 'SP1.jpg', 'SP2.jpg' +                                        ] +                                    ) +                                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' +                                    img = os.path.abspath(img) +                                    await bot.send_group_msg(group_id = group, message = f'[CQ:image,file=file:///{img}]') # type: ignore +                             +                            elif res == 10: +                                img = choice( +                                    [ +                                        'GDZ.png', 'SHZY1.jpg', 'SHZY2.jpg', 'SHZY3.jpg', 'SHZY4.jpg', 'SHZY5.jpg', 'SHZY6.jpg' +                                    ] +                                ) +                                img = Path('.') / 'ATRI' / 'data' / 'img' / 'niceIMG' / f'{img}' +                                img = os.path.abspath(img) +                                await bot.send_group_msg(group_id = group, message = f'[CQ:image,file=file:///{img}]') # type: ignore + +                        else: +                            pass
\ No newline at end of file diff --git a/ATRI/plugins/switch/switch.json b/ATRI/plugins/switch/switch.json index 7e0dcbe..3f0c66a 100644 --- a/ATRI/plugins/switch/switch.json +++ b/ATRI/plugins/switch/switch.json @@ -1 +1 @@ -{"pixiv_seach_img": "on", "pixiv_seach_author": "off", "pixiv_daily_rank": "on", "approve_friend_add": "on", "approve_invite_join_group": "on", "setu": "on", "hbook": "on", "change_face": "on", "chouYou": "off"}
\ No newline at end of file +{"pixiv_seach_img": "on", "pixiv_seach_author": "on", "pixiv_daily_rank": "on", "approve_friend_add": "on", "approve_invite_join_group": "on", "setu": "on", "hbook": "on", "change_face": "on", "chouYou": "off"}
\ No newline at end of file diff --git a/ATRI/plugins/welcome.py b/ATRI/plugins/welcome.py index b0ac8ac..b61c5bf 100644 --- a/ATRI/plugins/welcome.py +++ b/ATRI/plugins/welcome.py @@ -25,13 +25,13 @@ async def _(session: NoticeSession):  @on_notice('group_decrease')  async def _(session: NoticeSession): -    user = str(session.event.user_id) -    now = str(session.event.operator_id) +    user = session.event.user_id +    now = session.event.operator_id      if now == user:          inf = await bot.get_stranger_info(user_id = user) # type: ignore          name = inf['nickname'] -        await session.send(f'{name}({user}) 跑了') +        await session.send(f'{name}({user}) 跑了......')  @on_request('friend_add') | 
