diff options
| author | Kyomotoi <1172294279@qq.com> | 2020-08-14 21:22:17 +0800 | 
|---|---|---|
| committer | Kyomotoi <1172294279@qq.com> | 2020-08-14 21:22:17 +0800 | 
| commit | f73fc19dbe0c4fc0c21c11491cd6d3794cb681a3 (patch) | |
| tree | 6ffcd2afeb786eca61aa640ec773701f31d3c704 /ATRI/plugins | |
| parent | 6a7b2671fb3891938fdd10f0286df376cc183112 (diff) | |
| download | ATRI-f73fc19dbe0c4fc0c21c11491cd6d3794cb681a3.tar.gz ATRI-f73fc19dbe0c4fc0c21c11491cd6d3794cb681a3.tar.bz2 ATRI-f73fc19dbe0c4fc0c21c11491cd6d3794cb681a3.zip | |
[Fix]
Diffstat (limited to 'ATRI/plugins')
| -rw-r--r-- | ATRI/plugins/AIchangeFace.py | 87 | ||||
| -rw-r--r-- | ATRI/plugins/__pycache__/AIchangeFace.cpython-38.pyc | bin | 0 -> 5412 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/animeSearch.cpython-38.pyc | bin | 0 -> 18271 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/chat.cpython-38.pyc | bin | 12124 -> 14336 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/checkData.cpython-38.pyc | bin | 0 -> 1596 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/check_data.cpython-38.pyc | bin | 0 -> 1621 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/setu.cpython-38.pyc | bin | 2906 -> 3882 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/switch.cpython-38.pyc | bin | 1458 -> 1654 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/upload_sqlite.cpython-38.pyc | bin | 5451 -> 4344 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/welcome.cpython-38.pyc | bin | 3023 -> 3172 bytes | |||
| -rw-r--r-- | ATRI/plugins/__pycache__/wordCloud.cpython-38.pyc | bin | 0 -> 1963 bytes | 
11 files changed, 76 insertions, 11 deletions
| diff --git a/ATRI/plugins/AIchangeFace.py b/ATRI/plugins/AIchangeFace.py index 1d82e12..3b72997 100644 --- a/ATRI/plugins/AIchangeFace.py +++ b/ATRI/plugins/AIchangeFace.py @@ -1,9 +1,11 @@  import os +import cv2  import json  import requests  import base64  import nonebot  import time +from pathlib import Path  from nonebot import on_command, CommandSession  import config # type: ignore @@ -13,6 +15,7 @@ bot = nonebot.get_bot()  master = config.MASTER()  key = config.FACE_KEY()  secret = config.FACE_SECRET() +SCALE_FACTOR = 1 # 图像的放缩比  #获取图片的人脸特征参数 @@ -27,7 +30,7 @@ def find_face(imgpath):  #换脸,函数传参中number表示两张脸的相似度为99% -def change_face(image_1, image_2, user, number=99): +def change_face(image_1, image_2, user, kyaru, number=99):      url = "https://api-cn.faceplusplus.com/imagepp/v1/mergeface"      find_p1 = find_face(image_1)      find_p2 = find_face(image_2) @@ -47,7 +50,13 @@ def change_face(image_1, image_2, user, number=99):      response = requests.post(url,data=data).json()      results = response['result']      image = base64.b64decode(results) -    files = f'ATRI/data/temp/face/{user}' +    files = 'test' +    if int(kyaru) == 1: +        files = f'ATRI/data/temp/face/{user}' +    elif int(kyaru) == 2: +        files = f'ATRI/data/temp/head/{user}' +    print(files) +      if not os.path.exists(files):          os.mkdir(files)      with open(files + '/img3.jpg','wb') as file: @@ -61,11 +70,11 @@ 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):      user = session.event.user_id -    with open("ATRI/plugins/switch/switch.json", 'r') as f: +    with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f:          data = json.load(f)      if data["change_face"] == 0: -        with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +        with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:              data0 = json.load(f)          if str(user) in data0.keys(): @@ -102,22 +111,78 @@ async def _(session: CommandSession):              except:                  session.finish('请求数据貌似失败了...') -            img1File = f'ATRI/data/temp/face/{user}/img1.jpg' -            img2File = f'ATRI/data/temp/face/{user}/img2.jpg' +            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) +                change_face(img1File, img2File, user, 1)              except:                  session.finish('emm...貌似失败了呢......')              time.sleep(0.5) -            doneIMG = f'ATRI/data/temp/face/{user}/img3.jpg' +            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) -@on_command('change_u_head', aliases = ['接头霸王'], only_to_me = False) -async def _(session: CommandSession): -    pass # 明天做
\ No newline at end of file +# def f_1(x, A, B): +#     return A*x + B + +# @on_command('change_u_head', aliases = ['接头霸王'], only_to_me = False) +# async def _(session: CommandSession): +#     user = session.event.user_id +#     with open("ATRI/plugins/switch/switch.json", 'r') as f: +#         data = json.load(f) +     +#     if data["change_face"] == 0: +#         with open('ATRI/plugins/noobList/noobList.json', 'r') as f: +#             data0 = json.load(f) +         +#         if str(user) in data0.keys(): +#             pass +#         else: +#             img1 = session.get('img1', prompt = '请发送需要换头的图片') +#             a = img1.split(',') +#             a = a[2].replace(']', '') +#             a = a.replace('url=', '') +#             print(a) +#             try: +#                 imgres1 = requests.get(a) +#                 file1 = f'ATRI/data/temp/head/{user}' +#                 if not os.path.exists(file1): +#                     os.mkdir(file1) +#                 with open(file1 + '/img1.jpg', 'wb') as f: +#                     f.write(imgres1.content) +#             except: +#                 session.finish('获取数据貌似失败了呢...') +#             img1File = Path('.') / 'ATRI' / 'data' / 'temp' / 'head' / f'{user}' / 'img1.jpg' + +#             imgN = Path('.') / 'ATRI' / 'data' / 'img' / 'kyaru' / 'idk.png ' +#             img = os.path.abspath(imgN) +#             await session.send(f'[CQ:image,file=:///{img}]') +#             head = session.get('head', prompt = '请输入头的序号,例如选择:1,发送:1') +#             if head.isdigit(): +#                 pass +#             else: +#                 await session.send('请输入阿拉伯数字!') +#                 return +#             headIMG = Path('.') / 'ATRI' / 'data' / 'img' / 'kyaru' / f'{int(head)}.png' + +#             try: +#                 img = cv2.imread(img1File) +#                 face_cascade = cv2.CascadeClassifier(cv2.haarcascades + r'haarcascade_frontalface_default.xml') +#                 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) +#                 faces = face_cascade.detectMultiScale(gray, scaleFactor = 1.15, minNeighbors = 5, minSize = (5, 5)) +#                 await session.send(faces) + +#             except: +#                 session.finish('emm...貌似焊接失败了呢......') +             +#             time.sleep(0.5) +#             doneIMG = Path('.') / 'ATRI' / 'data' / 'temp' / 'head' / f'{user}' / 'img3.jpg' +#             img = os.path.abspath(doneIMG) +#             await session.send(f'[CQ:image,file=file:///{img}]') +#             files = f'ATRI/data/temp/head/{user}' +#             os.remove(files)
\ 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 new file mode 100644 index 0000000..bb2e1bb --- /dev/null +++ b/ATRI/plugins/__pycache__/AIchangeFace.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/animeSearch.cpython-38.pyc b/ATRI/plugins/__pycache__/animeSearch.cpython-38.pycBinary files differ new file mode 100644 index 0000000..bdedd1e --- /dev/null +++ b/ATRI/plugins/__pycache__/animeSearch.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/chat.cpython-38.pyc b/ATRI/plugins/__pycache__/chat.cpython-38.pycBinary files differ index 6dd0d2a..c514c22 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 new file mode 100644 index 0000000..0bc957b --- /dev/null +++ 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 new file mode 100644 index 0000000..bc17da5 --- /dev/null +++ b/ATRI/plugins/__pycache__/check_data.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/setu.cpython-38.pyc b/ATRI/plugins/__pycache__/setu.cpython-38.pycBinary files differ index 8da12f5..94c589b 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-38.pyc b/ATRI/plugins/__pycache__/switch.cpython-38.pycBinary files differ index df8416c..3197411 100644 --- a/ATRI/plugins/__pycache__/switch.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/switch.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/upload_sqlite.cpython-38.pyc b/ATRI/plugins/__pycache__/upload_sqlite.cpython-38.pycBinary files differ index 6d1153c..291f33e 100644 --- a/ATRI/plugins/__pycache__/upload_sqlite.cpython-38.pyc +++ b/ATRI/plugins/__pycache__/upload_sqlite.cpython-38.pyc diff --git a/ATRI/plugins/__pycache__/welcome.cpython-38.pyc b/ATRI/plugins/__pycache__/welcome.cpython-38.pycBinary files differ index d0736b6..25b8468 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 new file mode 100644 index 0000000..49556bf --- /dev/null +++ b/ATRI/plugins/__pycache__/wordCloud.cpython-38.pyc | 
