diff options
| author | Kyomotoi <1172294279@qq.com> | 2020-08-18 00:26:58 +0800 | 
|---|---|---|
| committer | Kyomotoi <1172294279@qq.com> | 2020-08-18 00:26:58 +0800 | 
| commit | 0bd751a03a1c38b990caee19d7cc4e28c906bcea (patch) | |
| tree | a6a6d2854c643b42a8e9e020c8d2396c66a24985 /ATRI/plugins | |
| parent | 6804c8bab3280c1c9bcb22c01204233c0766d1b8 (diff) | |
| download | ATRI-0bd751a03a1c38b990caee19d7cc4e28c906bcea.tar.gz ATRI-0bd751a03a1c38b990caee19d7cc4e28c906bcea.tar.bz2 ATRI-0bd751a03a1c38b990caee19d7cc4e28c906bcea.zip | |
[Fix] switch
Diffstat (limited to 'ATRI/plugins')
| -rw-r--r-- | ATRI/plugins/AIchangeFace.py | 21 | ||||
| -rw-r--r-- | ATRI/plugins/BlackList.py | 2 | ||||
| -rw-r--r-- | ATRI/plugins/LearnRepo.py (renamed from ATRI/plugins/wordcloud.py) | 12 | ||||
| -rw-r--r-- | ATRI/plugins/LearnRepo/LearnRepo.json (renamed from ATRI/plugins/wordcloud/wordcloud.json) | 2 | ||||
| -rw-r--r-- | ATRI/plugins/chat.py | 93 | ||||
| -rw-r--r-- | ATRI/plugins/hbook.py | 2 | ||||
| -rw-r--r-- | ATRI/plugins/noobList/noobGroup.json | 1 | ||||
| -rw-r--r-- | ATRI/plugins/noobList/noobList.json | 2 | ||||
| -rw-r--r-- | ATRI/plugins/pixiv.py | 6 | ||||
| -rw-r--r-- | ATRI/plugins/richBISS.py | 2 | ||||
| -rw-r--r-- | ATRI/plugins/send.py | 84 | ||||
| -rw-r--r-- | ATRI/plugins/setu.py | 2 | ||||
| -rw-r--r-- | ATRI/plugins/switch.py | 85 | ||||
| -rw-r--r-- | ATRI/plugins/switch/switch.json | 2 | 
14 files changed, 192 insertions, 124 deletions
| diff --git a/ATRI/plugins/AIchangeFace.py b/ATRI/plugins/AIchangeFace.py index 786a65d..4cb1990 100644 --- a/ATRI/plugins/AIchangeFace.py +++ b/ATRI/plugins/AIchangeFace.py @@ -71,8 +71,9 @@ def change_face(image_1, image_2, user, number=99):  @on_command('ai_ch_face', aliases = ['AI换脸', 'ai换脸'], only_to_me = False) -async def _(session: CommandSession): +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( @@ -89,12 +90,16 @@ async def _(session: CommandSession):          with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f:              data = json.load(f) -        if data["change_face"] == 0: +        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              else:                  img1 = session.get('message1', prompt = '请发送需要换脸的图片')                  print(img1) @@ -141,6 +146,16 @@ async def _(session: CommandSession):                  await session.send(f'[CQ:image,file=file:///{img}]')                  files = f'ATRI/data/temp/face/{user}'                  os.remove(files) +         +        else: +            session.finish('该功能已关闭...') + + +@AIchFace.args_parser +async def _(session: CommandSession): +    if not session.is_first_run and session.current_arg.startswith('算了,'): +        session.switch(session.current_arg[len('算了,'):]) +  # def f_1(x, A, B): diff --git a/ATRI/plugins/BlackList.py b/ATRI/plugins/BlackList.py index d1a50d3..b23f22f 100644 --- a/ATRI/plugins/BlackList.py +++ b/ATRI/plugins/BlackList.py @@ -11,7 +11,7 @@ master = config.MASTER()  @on_command('add_noobList', aliases = ['屏蔽', '移除'], only_to_me = False)  async def _(session: CommandSession): -    if session.event.user_id in master: +    if session.event.user_id == master:          msg = session.event.raw_message.split(' ', 1)          b_type = msg[0]          user = msg[1] diff --git a/ATRI/plugins/wordcloud.py b/ATRI/plugins/LearnRepo.py index 90ed408..fb98854 100644 --- a/ATRI/plugins/wordcloud.py +++ b/ATRI/plugins/LearnRepo.py @@ -10,7 +10,7 @@ import config # type: ignore  bot = nonebot.get_bot()  master = config.MASTER() - +__plugin_name__ = "LearnRepo"  def now_time():      now_ = datetime.now() @@ -26,18 +26,18 @@ async def _(session: CommandSession):          msg = session.event.raw_message.split(' ', 3)          w_tpye = msg[0]          word = msg[1] -        repo = msg[2] -        prob = int(msg[3]) -        with open('ATRI/plugins/wordcloud/wordcloud.json', 'r') as f: +        with open('ATRI/plugins/LearnRepo/LearnRepo.json', 'r') as f:              data = json.load(f)          if w_tpye == '增加词汇': +            repo = msg[2] +            prob = int(msg[3])              if word in data.keys():                  await session.send('该词已存在~!')              else:                  data[f"{word}"] = [f"{repo}",prob] -                f = open('ATRI/plugins/wordcloud/wordcloud.json', 'w') +                f = open('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)}]") @@ -66,7 +66,7 @@ async def repo(context):          if str(user) in nL.keys():              pass          else: -            with open('ATRI/plugins/wordcloud/wordcloud.json', 'r') as f: +            with open('ATRI/plugins/LearnRepo/LearnRepo.json', 'r') as f:                  data = json.load(f)              if str(word) in data.keys(): diff --git a/ATRI/plugins/wordcloud/wordcloud.json b/ATRI/plugins/LearnRepo/LearnRepo.json index 251f666..ede00cd 100644 --- a/ATRI/plugins/wordcloud/wordcloud.json +++ b/ATRI/plugins/LearnRepo/LearnRepo.json @@ -1 +1 @@ -{"test": ["TesT is SuccEss!", 1], "\u4e09\u6b21\u5143\u722c": ["\u4e09\u6b21\u5143\u722c", 5]}
\ No newline at end of file +{"test": ["TesT is SuccEss!", 1], "\u4e09\u6b21\u5143\u722c": ["\u4e09\u6b21\u5143\u722c", 5], "you": ["you", 1]}
\ No newline at end of file diff --git a/ATRI/plugins/chat.py b/ATRI/plugins/chat.py index 6baacdc..13c6747 100644 --- a/ATRI/plugins/chat.py +++ b/ATRI/plugins/chat.py @@ -1,6 +1,7 @@  import os  import re  import json +import time  import nonebot  import warnings  from pathlib import Path @@ -10,6 +11,7 @@ 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 @@ -25,11 +27,12 @@ KC_URL = 'https://nmsl.shadiao.app/api.php?level=min&lang=zh_cn'      day_of_week = "mon,tue,wed,thu,fri,sat,sun",      hour = 7  ) -async def _(): +async def _(session: CommandSession):      """早安"""      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:              msg = choice( @@ -52,8 +55,11 @@ async def _():              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 +        for group in group_list: +            await bot.send_group_msg(group_id = group['group_id'], message = msg) #type: ignore +         +        end = time.perf_counter() +        await session.send(f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}')      except:          pass @@ -63,11 +69,12 @@ async def _():      day_of_week = "mon,tue,wed,thu,fri,sat,sun",      hour = 22  ) -async def _(): +async def _(session: CommandSession):      """晚安"""      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:              msg = choice( @@ -91,8 +98,11 @@ async def _():              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 +        for group in group_list: +            await bot.send_group_msg(group_id = group['group_id'], message = msg) #type: ignore +         +        end = time.perf_counter() +        await session.send(f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}')      except:          pass @@ -556,10 +566,54 @@ async def _(session: CommandSession):                  img = os.path.abspath(img)                  await session.send(f'[CQ:image,file=file:///{img}]') -noobList = [] +noobList0 = [] +@on_command('robot', 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) + +    if str(user) in data.keys(): +        pass +    else: +        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)) +                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, +                ) + + + +noobList1 = []  @on_command('ntr', patterns = [r"[nNηиɴИ][tT][rR]|[牛🐂]头人"], only_to_me = False)  async def _(session: CommandSession): -    global noobList +    global noobList1      user = session.event.user_id      with open('ATRI/plugins/noobList/noobList.json', 'r') as f:          data = json.load(f) @@ -575,13 +629,13 @@ async def _(session: CommandSession):              pattern = r"[nNηиɴИ][tT][rR]|[牛🐂]头人"              if re.findall(pattern, msg):                  await session.send('你妈的,牛头人,' + response.request_api(KC_URL)) -                noobList.append(user) -                print(noobList) -                print(countX(noobList, user)) -                if countX(noobList, user) == 5: +                noobList1.append(user) +                print(noobList1) +                print(countX(noobList1, user)) +                if countX(noobList1, user) == 5:                      if user == master:                          await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......') -                        noobList = list(set(noobList)) +                        noobList1 = list(set(noobList1))                          pass                      else: @@ -591,8 +645,8 @@ async def _(session: CommandSession):                          f = open(file, 'w')                          f.write(json.dumps(bL))                          f.close() -                        noobList = list(set(noobList)) -                        print(noobList) +                        noobList1 = list(set(noobList1)) +                        print(noobList1)                          delta = timedelta(minutes = 10)                          trigger = DateTrigger(                              run_date = datetime.now() + delta @@ -603,7 +657,4 @@ async def _(session: CommandSession):                              trigger = trigger,                              args = (user),                              misfire_grace_time = 60, -                        ) - -                else: -                    pass
\ No newline at end of file +                        )
\ No newline at end of file diff --git a/ATRI/plugins/hbook.py b/ATRI/plugins/hbook.py index 0a6d7b5..7ed14fe 100644 --- a/ATRI/plugins/hbook.py +++ b/ATRI/plugins/hbook.py @@ -43,7 +43,7 @@ async def _(session: CommandSession):              with open('ATRI/plugins/switch/switch.json', 'r') as f:                  data = json.load(f) -            if data["hbook"] == 0: +            if data["hbook"] == "on":                  num = 1                  tag = ''                  start = time.perf_counter() diff --git a/ATRI/plugins/noobList/noobGroup.json b/ATRI/plugins/noobList/noobGroup.json new file mode 100644 index 0000000..6e1ba39 --- /dev/null +++ b/ATRI/plugins/noobList/noobGroup.json @@ -0,0 +1 @@ +{"123": "123"}
\ No newline at end of file diff --git a/ATRI/plugins/noobList/noobList.json b/ATRI/plugins/noobList/noobList.json index 97784a6..6e1ba39 100644 --- a/ATRI/plugins/noobList/noobList.json +++ b/ATRI/plugins/noobList/noobList.json @@ -1 +1 @@ -{"2827187244": "2827187244"}
\ No newline at end of file +{"123": "123"}
\ No newline at end of file diff --git a/ATRI/plugins/pixiv.py b/ATRI/plugins/pixiv.py index c9aa694..717c54a 100644 --- a/ATRI/plugins/pixiv.py +++ b/ATRI/plugins/pixiv.py @@ -63,7 +63,7 @@ async def _(session: CommandSession):              with open('ATRI/plugins/switch/switch.json', 'r') as f:                  data = json.load(f) -            if data["pixiv_seach_img"] == 0: +            if data["pixiv_seach_img"] == "on":                  pid = session.current_arg.strip()                  if not pid: @@ -129,7 +129,7 @@ async def _(session: CommandSession):              with open('ATRI/plugins/switch/switch.json', 'r') as f:                  data = json.load(f) -            if data["pixiv_seach_author"] == 0: +            if data["pixiv_seach_author"] == "on":                  author_id = session.current_arg.strip()                  if not author_id: @@ -202,7 +202,7 @@ async def _(session: CommandSession):              with open('ATRI/plugins/switch/switch.json', 'r') as f:                  data = json.load(f) -            if data["pixiv_daily_rank"] == 0: +            if data["pixiv_daily_rank"] == "on":                  await session.send('ATRI正在获取P站每日排行榜前五作品...') diff --git a/ATRI/plugins/richBISS.py b/ATRI/plugins/richBISS.py index 79000f2..60d3315 100644 --- a/ATRI/plugins/richBISS.py +++ b/ATRI/plugins/richBISS.py @@ -65,7 +65,7 @@ async def Fuck_bili_rich(context):          else:              if bv:                  bv = bv[0] -                bv.replace('?', '') +                bv = bv.replace('?', '')                  aid = str(dec(bv))                  ad = 'av' + aid diff --git a/ATRI/plugins/send.py b/ATRI/plugins/send.py index 2f95da2..69fc1b0 100644 --- a/ATRI/plugins/send.py +++ b/ATRI/plugins/send.py @@ -37,38 +37,38 @@ async def send_all_group(session: CommandSession):          await session.send(f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}') -@on_command('send_to_group', aliases=['对群'], only_to_me=False) -async def send_to_group(session: CommandSession): -    if session.event.user_id in master: -        msg = session.current_arg.strip() +# @on_command('send_to_group', aliases=['对群'], only_to_me=False) +# async def send_to_group(session: CommandSession): +#     if session.event.user_id in master: +#         msg = session.current_arg.strip() -        if not msg: -            msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对群 12345647(群号) message 1') +#         if not msg: +#             msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对群 12345647(群号) message 1') -        lg = msg.split(' ') - -        group = lg[0] -        msg = lg[1] -        rei = 1  -        try: -            rei = int(lg[2]) + 1 -        except: -            pass - -        if rei: -            for i in range(1, rei): -                try: -                    await bot.send_group_msg(group_id = group, message = msg) # type: ignore -                except: -                    await session.send('发送失败,请重试') +#         lg = msg.split(' ') + +#         group = lg[0] +#         msg = lg[1] +#         rei = 1  +#         try: +#             rei = int(lg[2]) + 1 +#         except: +#             pass + +#         if rei: +#             for i in range(1, rei): +#                 try: +#                     await bot.send_group_msg(group_id = group, message = msg) # type: ignore +#                 except: +#                     await session.send('发送失败,请重试') -        else: -            try: -                await bot.send_group_msg(group_id = group, message = msg) # type: ignore -            except: -                await session.send('发送失败,请重试') +#         else: +#             try: +#                 await bot.send_group_msg(group_id = group, message = msg) # type: ignore +#             except: +#                 await session.send('发送失败,请重试') -        await session.send('推送完成!') +#         await session.send('推送完成!')  @on_command('send_all_friend', aliases = ['全体用户'], only_to_me = False) @@ -97,22 +97,22 @@ async def send_all_friend(session: CommandSession):          await session.send(f'已推送到[{f_list}]位用户\n耗时:{round(end - start, 3)}') -@on_command('send_to_qq', aliases=['对QQ'], only_to_me=False) -async def send_to_qq(session: CommandSession): -    if session.event.user_id in master: -        msg = session.current_arg.strip() +# @on_command('send_to_qq', aliases=['对QQ'], only_to_me=False) +# async def send_to_qq(session: CommandSession): +#     if session.event.user_id in master: +#         msg = session.current_arg.strip() -        if not msg: -            msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对QQ 12345647(QQ号) message') +#         if not msg: +#             msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对QQ 12345647(QQ号) message') -        lg = msg.split(' ') +#         lg = msg.split(' ') -        qq = lg[0] -        msg = lg[1] +#         qq = lg[0] +#         msg = lg[1] -        try: -            await bot.send_private_msg(user_id = qq, message = msg) # type: ignore -        except: -            await session.send('发送失败,请重试') +#         try: +#             await bot.send_private_msg(user_id = qq, message = msg) # type: ignore +#         except: +#             await session.send('发送失败,请重试') -        await session.send('推送完成!')
\ No newline at end of file +#         await session.send('推送完成!')
\ No newline at end of file diff --git a/ATRI/plugins/setu.py b/ATRI/plugins/setu.py index efd6147..796f6f7 100644 --- a/ATRI/plugins/setu.py +++ b/ATRI/plugins/setu.py @@ -61,7 +61,7 @@ async def setu(session: CommandSession):          if str(user) in data0.keys():              pass          else: -            if data1["setu"] == 0: +            if data1["setu"] == "on":                  res = randint(1,10)                  if 1 <= res < 9:                      res = randint(1,4) diff --git a/ATRI/plugins/switch.py b/ATRI/plugins/switch.py index 49a3ca7..c92b5aa 100644 --- a/ATRI/plugins/switch.py +++ b/ATRI/plugins/switch.py @@ -7,84 +7,85 @@ bot = nonebot.get_bot()  master = bot.config.SUPERUSERS -@on_command('switch', aliases = ['开启', '关闭'], only_to_me = False) +@on_command('switch', aliases = ['on', 'off'], only_to_me = False)  async def _(session: CommandSession):      with open("ATRI/plugins/switch/switch.json", 'r') as f:          data = json.load(f) +    print(data)      if session.event.user_id in master:          command = session.event.raw_message.split(' ', 1)          switch = command[0]          com = command[1] +        print(command) -        if switch == '开启': -            if com == 'p站搜图' or 'P站搜图': -                data["pixiv_seach_img"] = 0 +        if switch == 'on': +            if com == 'PixivSearchIMG': +                data["pixiv_seach_img"] = "on" -            elif com == '画师': -                data["pixiv_seach_author"] = 0 +            elif com == 'PixivSearchAuthor': +                data["pixiv_seach_author"] = "on" -            elif com == 'P站排行榜' or 'P站排行榜': -                data["pixiv_daily_rank"] = 0 +            elif com == 'PixivRank': +                data["pixiv_daily_rank"] = "on" -            elif com == '好友添加': -                data["approve_friend_add"] = 0 +            elif com == 'FriendADD': +                data["approve_friend_add"] = "on" -            elif com == '群邀请': -                data["approve_invite_join_group"] = 0 +            elif com == 'GroupInvite': +                data["approve_invite_join_group"] = "on" -            elif com == '涩图': -                data["setu"] = 0 +            elif com == 'Setu': +                data["setu"] = "on" -            elif com == '本子': -                data["hbook"] = 0 +            elif com == 'Hbook': +                data["hbook"] = "on" -            elif com == 'AI换脸' or 'ai换脸': -                data["change_face"] = 0 +            elif com == 'AIchFace': +                data["change_face"] = "on" -            elif com == '接头霸王': -                data["chouYou"] = 0 +            elif com == 'Kyaru': +                data["chouYou"] = "on"              else:                  pass -        elif switch == '关闭': -            if com == 'p站搜图' or 'P站搜图': -                data["pixiv_seach_img"] = 1 +        elif switch == 'off': +            if com == 'PixivSearchIMG': +                data["pixiv_seach_img"] = "off" -            elif com == '画师': -                data["pixiv_seach_author"] = 1 +            elif com == 'PixivSearchAuthor': +                data["pixiv_seach_author"] = "off" -            elif com == 'P站排行榜' or 'p站排行榜': -                data["pixiv_daily_rank"] = 1 +            elif com == 'PixivRank': +                data["pixiv_daily_rank"] = "off" -            elif com == '好友添加': -                data["approve_friend_add"] = 1 +            elif com == 'FriendADD': +                data["approve_friend_add"] = "off" -            elif com == '群邀请': -                data["approve_invite_join_group"] = 1 +            elif com == 'GroupInvite': +                data["approve_invite_join_group"] = "off" -            elif com == '涩图': -                data["setu"] = 1 +            elif com == 'Setu': +                data["setu"] = "off" -            elif com == '本子': -                data["hbook"] = 1 +            elif com == 'Hbook': +                data["hbook"] = "off" -            elif com == 'AI换脸' or 'ai换脸': -                data["change_face"] = 1 +            elif com == 'AIchFace': +                data["change_face"] = "off" -            elif com == '接头霸王': -                data["chouYou"] = 1 +            elif com == 'Kyaru': +                data["chouYou"] = "off"              else:                  pass -        a = json.dumps(data)          f2 = open("ATRI/plugins/switch/switch.json", 'w') -        f2.write(a) +        f2.write(json.dumps(data))          f2.close() -        await session.send('设置完成!') +        await session.send('Success!')      else:          await session.send('恁哪位?')
\ No newline at end of file diff --git a/ATRI/plugins/switch/switch.json b/ATRI/plugins/switch/switch.json index 45cbf5b..7e0dcbe 100644 --- a/ATRI/plugins/switch/switch.json +++ b/ATRI/plugins/switch/switch.json @@ -1 +1 @@ -{"pixiv_seach_img": 0, "pixiv_seach_author": 1, "pixiv_daily_rank": 0, "approve_friend_add": 0, "approve_invite_join_group": 0, "setu": 0, "hbook": 0, "change_face": 0}
\ No newline at end of file +{"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 | 
