summaryrefslogtreecommitdiff
path: root/ATRI/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins')
-rw-r--r--ATRI/plugins/AIchangeFace.py209
-rw-r--r--ATRI/plugins/BlackList.py69
-rw-r--r--ATRI/plugins/Chat0.py690
-rw-r--r--ATRI/plugins/Chat1.py106
-rw-r--r--ATRI/plugins/Check.py242
-rw-r--r--ATRI/plugins/GetChatMSG.py33
-rw-r--r--ATRI/plugins/LearnRepo.py64
-rw-r--r--ATRI/plugins/LearnRepo/LearnRepo.json1
-rw-r--r--ATRI/plugins/SauceNAO.py95
-rw-r--r--ATRI/plugins/Scheduler.py152
-rw-r--r--ATRI/plugins/Setu.py327
-rw-r--r--ATRI/plugins/SingIN.py80
-rw-r--r--ATRI/plugins/UploadSqlite.py295
-rw-r--r--ATRI/plugins/UploadSqlite/cloudmusic.json1
-rw-r--r--ATRI/plugins/UploadSqlite/sepi.json1
-rw-r--r--ATRI/plugins/hitokoto.py34
-rw-r--r--ATRI/plugins/noobList/noobGroup.json1
-rw-r--r--ATRI/plugins/noobList/noobList.json1
-rw-r--r--ATRI/plugins/onMessage.py125
-rw-r--r--ATRI/plugins/other.py145
-rw-r--r--ATRI/plugins/pixiv.py239
-rw-r--r--ATRI/plugins/plugin_admin/__init__.py69
-rw-r--r--ATRI/plugins/plugin_anime/__init__.py (renamed from ATRI/plugins/animeSearch.py)345
-rw-r--r--ATRI/plugins/plugin_anime/body.py53
-rw-r--r--ATRI/plugins/plugin_chat/__init__.py25
-rw-r--r--ATRI/plugins/plugin_rich/__init__.py129
-rw-r--r--ATRI/plugins/plugin_rich/body.py23
-rw-r--r--ATRI/plugins/plugin_status/__init__.py97
-rw-r--r--ATRI/plugins/richBISS.py137
-rw-r--r--ATRI/plugins/send.py125
-rw-r--r--ATRI/plugins/switch.py193
-rw-r--r--ATRI/plugins/welcome.py48
32 files changed, 667 insertions, 3487 deletions
diff --git a/ATRI/plugins/AIchangeFace.py b/ATRI/plugins/AIchangeFace.py
deleted file mode 100644
index a56dc34..0000000
--- a/ATRI/plugins/AIchangeFace.py
+++ /dev/null
@@ -1,209 +0,0 @@
-import os
-import requests
-import base64
-import nonebot
-import time
-from datetime import datetime
-from random import choice
-from pathlib import Path
-from nonebot import on_command, CommandSession
-
-import config
-from ATRI.modules.error import errorBack
-from ATRI.modules.funcControl import checkSwitch, checkNoob
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-key = config.FaceplusAPI
-secret = config.FaceplusSECRET
-__plugin_name__ = "change_face"
-
-
-def now_time():
- now_ = datetime.now()
- hour = now_.hour
- minute = now_.minute
- now = hour + minute / 60
- return now
-
-
-#获取图片的人脸特征参数
-def find_face(imgpath):
- url='https://api-cn.faceplusplus.com/facepp/v3/detect'
- data = {'api_key':key,'api_secret':secret,'image_url':imgpath,'return_landmark':1}
- files = {'image_file':open(imgpath,'rb')}
- response = requests.post(url,data=data,files=files)
- res_json = response.json()
- faces = res_json['faces'][0]['face_rectangle'] #获取面部大小的四个值,分别为长宽高低{'width': 176, 'top': 128, 'left': 80, 'height': 176}
- return faces
-
-
-#换脸,函数传参中number表示两张脸的相似度为99%
-def change_face(image_1, image_2, user, number=99):
- url = "https://api-cn.faceplusplus.com/imagepp/v1/mergeface"
- find_p1 = find_face(image_1)
- find_p2 = find_face(image_2)
- rectangle1 = str(str(find_p1['top'])+','+str(find_p1['left'])+','+str(find_p1['width'])+','+str(find_p1['height'])) #得到一个坐标
- rectangle2 = str(str(find_p2['top'])+','+str(find_p2['left'])+','+str(find_p2['width'])+','+str(find_p2['height']))
-
- page1 = open(image_1,'rb') #以二进制打开图片1
- page1_64 = base64.b64encode(page1.read()) #将字符串转成成base64编码
- page1.close()
-
- page2 = open(image_2,'rb')
- page2_64 = base64.b64encode(page2.read())
- page2.close()
-
- data = {'api_key':key,'api_secret':secret,'template_base64':page1_64,
- 'template_rectangle':rectangle1,'merge_base64':page2_64,'merge_rectangele':rectangle2,'merge_rate':number}
- response = requests.post(url,data=data).json()
- results = response['result']
- image = base64.b64decode(results)
- files = 'test'
- files = f'ATRI/data/temp/face/{user}'
- if not os.path.exists(files):
- os.mkdir(files)
- with open(files + '/img3.jpg','wb') as file:
- file.write(image)
- print('success!')
-
-
-# change_face('1.jpg','2.jpg')
-
-
-@on_command('ai_ch_face', aliases = ['AI换脸', 'ai换脸'], only_to_me = False)
-async def AIchFace(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
- )
- else:
- if checkSwitch(__plugin_name__, group):
- img1 = session.get('message1', prompt = '请发送需要换脸的图片')
- img2 = session.get('message2', prompt = '请发送素材图片')
-
- try:
- # 我承认了,我是取名废!
- a = img1.split(',')
- a = a[2].replace(']', '')
- a = a.replace('url=', '')
- imgres1 = requests.get(a)
-
- b = img2.split(',')
- b = b[2].replace(']', '')
- b = b.replace('url=', '')
- imgres2 = requests.get(b)
- except:
- session.finish(errorBack('获取图片失败'))
-
- 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(errorBack('加载图片失败'))
-
- 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(errorBack('换脸操作失败'))
-
- 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('该功能已关闭...')
-
-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):
-# 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/BlackList.py b/ATRI/plugins/BlackList.py
deleted file mode 100644
index ce15c20..0000000
--- a/ATRI/plugins/BlackList.py
+++ /dev/null
@@ -1,69 +0,0 @@
-import json
-from pathlib import Path
-from nonebot import on_command, CommandSession
-
-import config
-
-
-master = config.SUPERUSERS
-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(' ', 2)
- b_type = msg[0]
- 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 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}]移出黑名单成功~!') \ No newline at end of file
diff --git a/ATRI/plugins/Chat0.py b/ATRI/plugins/Chat0.py
deleted file mode 100644
index 5b0cd99..0000000
--- a/ATRI/plugins/Chat0.py
+++ /dev/null
@@ -1,690 +0,0 @@
-import os
-import re
-import json
-import nonebot
-import warnings
-from pathlib import Path
-from random import randint, choice
-from datetime import datetime, timedelta
-from nonebot import on_command, scheduler
-from nonebot import CommandSession
-from apscheduler.triggers.date import DateTrigger
-
-import config
-from ATRI.modules.favoIMP import AddFavoIMP, DelFavoIMP, GetFavoIMP
-from ATRI.modules.time import now_time
-from ATRI.modules.response import request_api
-from ATRI.modules.funcControl import checkNoob
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-KC_URL = 'https://nmsl.shadiao.app/api.php?level=min&lang=zh_cn'
-
-
-def countX(lst, x):
- warnings.simplefilter('ignore', ResourceWarning)
- count = 0
- for ele in lst:
- if (ele == x):
- count = count + 1
- return count
-
-def rmQQfromNoobLIST(user):
- 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()
-
-
-@on_command('morning', patterns = [r"早[安哇]|早上好|ohayo|哦哈哟|お早う"], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 5.5 <= now_time() < 9:
- res = randint(1,2)
- if res == 1:
- await session.send(
- choice(
- [
- '啊......早上好...(哈欠)',
- '唔......吧唧...早上...哈啊啊~~~\n早上好......',
- '早上好......',
- '早上好呜......呼啊啊~~~~',
- '啊......早上好。\n昨晚也很激情呢!',
- '吧唧吧唧......怎么了...已经早上了么...',
- '早上好!',
- '......看起来像是傍晚,其实已经早上了吗?',
- '早上好......欸~~~脸好近呢'
- ]
- )
- )
-
- elif res == 2:
- voice = choice(
- [
- 'ohayo1.amr', 'ohayo2.amr', 'ohayo3.amr', 'ohayo4.amr'
- ]
- )
- voice = Path('.') / 'ATRI' / 'data' / 'voice' / f'{voice}'
- voice = os.path.abspath(voice)
- await session.send(f'[CQ:record,file=:///{voice}]')
-
- elif 9 <= now_time() < 18:
- 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....哧溜哧溜....'
- ]
- )
- )
-
-
-@on_command('noon', patterns = [r"中午好|午安"], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- 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
- group = session.event.group_id
- if checkNoob(user, group):
- 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 15 <= now_time() < 19:
- await session.send(
- choice(
- [
- '难不成??晚上不想睡觉??现在休息',
- '就......挺离谱的...现在睡觉',
- '现在还是白天哦,睡觉还太早了'
- ]
- )
- )
-
- elif 19 <= now_time() < 24:
- res = randint(1,2)
- if res == 1:
- await session.send(
- choice(
- [
- '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o',
- '......(打瞌睡)',
- '呼...呼...已经睡着了哦~...呼......',
- '......我、我会在这守着你的,请务必好好睡着'
- ]
- )
- )
-
- elif res == 2:
- voice = Path('.') / 'ATRI' / 'data' / 'voice' / 'oyasuminasai.amr'
- voice = os.path.abspath(voice)
- await session.send(f'[CQ:record,file=:///{voice}]')
-
- 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
- group = session.event.group_id
- if checkNoob(user, group):
- 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'
- ]
- )
- 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]|亲一个"])
-async def az(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- if 0 <= GetFavoIMP(user) < 250:
- 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 250 <= GetFavoIMP(user):
- res = randint(1,2)
- if res == 1:
- img = choice(
- [
- 'SUKI.jpg', 'SUKI1.jpg', 'SUKI2.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:
- voice = choice(
- [
- 'suki1.amr', 'suki2.amr'
- ]
- )
- voice = Path('.') / 'ATRI' / 'data' / 'voice' / f'{voice}'
- voice = os.path.abspath(voice)
- await session.send(f'[CQ:record,file=file:///{voice}]')
-
-@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- if randint(1,2) == 1:
- DelFavoIMP(u, 5, True)
- res = randint(1,3)
- if res == 1:
- 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:
- res = randint(1,3)
- if res == 1:
- await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!')
- voice = os.path.abspath(Path('.') / 'ATRI' / 'data' / 'voice' / 'ATR_b402_027.amr')
- await session.send(f'[CQ:record,file=file:///{voice}]')
-
- elif res == 2:
- await session.send('鱼雷组合拳——————————————————啊————!!!')
- voice = os.path.abspath(Path('.') / 'ATRI' / 'data' / 'voice' / 'CombinationTorpedoFist.amr')
- await session.send(f'[CQ:record,file=file:///{voice}]')
-
- elif res == 3:
- await session.send('火箭拳——————————————————————————!!!')
- voice = os.path.abspath(Path('.') / 'ATRI' / 'data' / 'voice' / 'RocketPunch.amr')
- await session.send(f'[CQ:record,file=file:///{voice}]')
-
- elif res == 3:
- await session.send(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
- group = session.event.group_id
- if checkNoob(user, group):
- 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
- if checkNoob(user, group):
- 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
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- 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}]')
-
- elif randint(1,2) == 2:
- voice = choice(
- [
- 'PX1.amr', 'PX2.amr', 'PX3.amr', 'PX4.amr', 'PX5.amr', 'PX6.amr'
- ]
- )
- voice = Path('.') / 'ATRI' / 'data' / 'voice' / f'{voice}'
- voice = os.path.abspath(voice)
- await session.send(f'[CQ:record,file=file:///{voice}]')
-
-@on_command('qingjie', patterns = [r"青[洁结]"], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- 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
- if checkNoob(user, group):
- 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('hai', patterns = [r"害|嗐"], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- 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('high_per', patterns = [r"高性能|[太最][棒好强猛]|[tT][qQ][lL]|[🐂牛nN][🍺批bB]|すごい|sugoi|[斯死]国一|よかった"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- msg = str(session.event.message)
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- pat = r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭"
- if re.findall(pat, msg):
- pass
- else:
- AddFavoIMP(user, 3, True)
- msg = choice(
- [
- '当然,我是高性能的嘛~!',
- '小事一桩,我是高性能的嘛',
- '怎么样?还是我比较高性能吧?',
- '哼哼!我果然是高性能的呢!',
- '因为我是高性能的嘛!嗯哼!',
- '因为我是高性能的呢!',
- '哎呀~,我可真是太高性能了',
- '正是,因为我是高性能的',
- '是的。我是高性能的嘛♪',
- '毕竟我可是高性能的!',
- '嘿嘿,我的高性能发挥出来啦♪',
- '我果然是很高性能的机器人吧!',
- '是吧!谁叫我这么高性能呢!哼哼!',
- '交给我吧,有高性能的我陪着呢',
- '呣......我的高性能,毫无遗憾地施展出来了......'
- ]
- )
- await session.send(msg)
-
-@on_command('dont_worry', patterns = [r"没事|没关系|大丈夫|还好|不要紧|没出大问题|没伤到哪"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- msg = str(session.event.message)
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- pat = r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|给[爷👴]爬|嘴臭"
- if re.findall(pat, msg):
- pass
- else:
- msg = choice(
- [
- '当然,我是高性能的嘛~!',
- '没事没事,因为我是高性能的嘛!嗯哼!',
- '没事的,因为我是高性能的呢!',
- '正是,因为我是高性能的',
- '是的。我是高性能的嘛♪',
- '毕竟我可是高性能的!',
- '那种程度的事不算什么的。\n别看我这样,我可是高性能的',
- '没问题的,我可是高性能的'
- ]
- )
- await session.send(msg)
-
-@on_command('mohead', patterns = [r"摸[头摸]"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- msg = str(session.event.message)
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- 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:
- AddFavoIMP(user, 1, False)
- msg = choice(
- [
- '头发的柔顺度上升,我的高性能更上一层楼......',
- '*蹭蹭'
- ]
- )
- await session.send(msg)
-
-@on_command('whl', patterns = [r"我好了|[wW][hH[lL]"], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- if randint(1,2) == 1:
- await session.send('不许好!憋回去!')
-
-@on_command('birthday', patterns = [r"生日快乐|生快|[bB]irthday|誕生日|tanjobi"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- if datetime.date.today().strftime('%y%m%d') == '200828':
- AddFavoIMP(user, 50, True)
- res = randint(1,3)
- if res == 1:
- msg = choice(
- [
- '谢谢,谢谢你!',
- '感谢...15551',
- '谢谢你们orz...'
- ]
- )
- await session.send(msg)
-
- elif 2 <= res <= 3:
- voice = choice(
- [
- 'THX.amr', 'THX1.amr', 'THX2.amr', 'THX3.amr', 'THX4.amr'
- ]
- )
- voice = Path('.') / 'ATRI' / 'data' / 'voice' / f'{voice}'
- voice = os.path.abspath(voice)
- await session.send(f'[CQ:record,file=file:///{voice}]')
-
- if randint(1,3) == 2:
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'SUKI.jpg'
- img = os.path.abspath(img)
- await session.send(f'[CQ:image,file=file:///{img}]')
-
- else:
- pass
-
-
-@on_command('nicesleep', patterns = [r"精致睡眠"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if user == master:
- await session.send('那...请主人自己闭上眼!哼唧')
- return
- else:
- await session.send('恭喜!您已被ATRI屏蔽7小时')
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:
- bL = json.load(f)
- except:
- bL = {}
- bL[f"{user}"] = f"{user}"
- file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json'
- f = open(file, 'w')
- f.write(json.dumps(bL))
- f.close()
- delta = timedelta(hours = 7)
- trigger = DateTrigger(
- run_date = datetime.now() + delta
- )
-
- scheduler.add_job( #type: ignore
- func = rmQQfromNoobLIST,
- trigger = trigger,
- args = (session.event.user_id,),
- misfire_grace_time = 60,
- )
-
-noobList0 = []
-@on_command('robozi', patterns = [r"萝卜子"], only_to_me = False)
-async def _(session: CommandSession):
- global noobList0
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:
- bL = json.load(f)
- except:
- bL = {}
- noobList0.append(user)
- if countX(noobList0, user) == 1:
- await session.send('萝卜子是对机器人的蔑称!')
-
- elif countX(noobList0, user) == 2:
- if user == master:
- await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......')
- noobList0 = list(set(noobList0))
- pass
-
- else:
- await session.send('是亚托莉......萝卜子可是对机器人的蔑称......\n这是第二次警告哦,接下来10分钟我不会再理你了!哼唧!\n(好感度-1)')
- DelFavoIMP(user, 1, False)
- 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 = 10)
- trigger = DateTrigger(
- run_date = datetime.now() + delta
- )
-
- scheduler.add_job( #type: ignore
- func = rmQQfromNoobLIST,
- trigger = trigger,
- args = (session.event.user_id,),
- misfire_grace_time = 60,
- )
-
-noobList1 = []
-@on_command('ntr', patterns = [r"[nNηиɴИ][tT][rR]|[牛🐂🐮]头人"], only_to_me = False)
-async def _(session: CommandSession):
- global noobList1
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- msg = str(session.event.message)
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:
- bL = json.load(f)
- except:
- bL = {}
- pattern = r"[nNηиɴИ][tT][rR]|[牛🐂🐮]头人"
- if re.findall(pattern, msg):
- noobList1.append(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}]哼!接下来30分钟别想让我理你!\n(好感度-2)')
- DelFavoIMP(user, 2, False)
- 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 = 30)
- trigger = DateTrigger(
- run_date = datetime.now() + delta
- )
-
- scheduler.add_job( #type: ignore
- func = rmQQfromNoobLIST,
- trigger = trigger,
- args = (session.event.user_id,),
- misfire_grace_time = 60,
- )
-
- else:
- await session.send('你妈的,牛头人,' + request_api(KC_URL)) \ No newline at end of file
diff --git a/ATRI/plugins/Chat1.py b/ATRI/plugins/Chat1.py
deleted file mode 100644
index 0f51541..0000000
--- a/ATRI/plugins/Chat1.py
+++ /dev/null
@@ -1,106 +0,0 @@
-import os
-import nonebot
-from pathlib import Path
-from random import choice, randint
-from datetime import datetime
-from nonebot import on_command, CommandSession
-
-from ATRI.modules.error import errorBack
-from ATRI.modules.funcControl import checkNoob
-
-
-bot = nonebot.get_bot()
-
-
-def now_time():
- now_ = datetime.now()
- hour = now_.hour
- minute = now_.minute
- now = hour + minute / 60
- return now
-
-
-@on_command('nanjya', patterns = [r"なんじゃ|何[がで]|どうして|为什么|为何|多[洗西]跌"], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- if randint(1,2) == 1:
- img = choice(
- [
- '1.jpg', '8.jpg', '14.jpg', '21.jpg'
- ]
- )
- img = os.path.abspath(Path('.') / 'ATRI' / 'data' / 'emoji' / 'senren' / f'{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
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- if randint(1,3) == 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('yesorno', patterns = [r"[好是]吗|[行能]不[行能]|彳亍不彳亍|可不可以"], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- pass
- else:
- res = randint(1,2)
- if res == 1:
- img = choice(
- [
- '2.png', '39.png'
- ]
- )
- img = os.path.abspath(Path('.') / 'ATRI' / 'data' / 'emoji' / 'senren' / f'{img}')
- await session.send(f'[CQ:image,file=file:///{img}]')
-
- elif res == 2:
- img = choice(
- [
- 'YIQI_YES.png', 'YIQI_NO.jpg', 'KD.jpg', 'FD.jpg'
- ]
- )
- img = os.path.abspath(Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}')
- await session.send(f'[CQ:image,file=file:///{img}]')
-
-@on_command('ysdd', aliases = [r"原声大碟"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- try:
- voice = Path('.') / 'ATRI' / 'data' / 'voice' / 'ysdd.amr'
- voice = os.path.abspath(voice)
- await session.send(f'[CQ:record,file=file:///{voice}]')
- except:
- session.finish(errorBack('读取音频时出错')) \ No newline at end of file
diff --git a/ATRI/plugins/Check.py b/ATRI/plugins/Check.py
deleted file mode 100644
index ab92310..0000000
--- a/ATRI/plugins/Check.py
+++ /dev/null
@@ -1,242 +0,0 @@
-import json
-import time
-import sqlite3
-import psutil
-from pathlib import Path
-import nonebot
-from nonebot import on_command, CommandSession
-
-import config
-from ATRI.modules.error import errorBack
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json'
-file1 = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json'
-
-
-@on_command('data_list', aliases = ['数据总量'], only_to_me = False)
-async def _(session: CommandSession):
- 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}"""
- )
-
-
-@on_command('look_noobList', aliases = ['查看黑名单'], only_to_me = False)
-async def _(session: CommandSession):
- start = time.perf_counter()
- try:
- with open(file, 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- try:
- with open(file1, 'r') as f:
- data0 = json.load(f)
- except:
- data0 = {}
-
- 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"
- msg += msg0
- await session.send(msg)
-
-
-@on_command('look_power', aliases = ['查看权限组'], only_to_me = False)
-async def _(session: CommandSession):
- start = time.perf_counter()
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'sepi.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'cloudmusic.json', 'r') as f:
- data0 = json.load(f)
- except:
- data0 = {}
-
- msg = f'主人: {master}\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"
- msg += msg0
- await session.send(msg)
-
-
-
-@on_command('check_status', patterns = [r"检查状态|检查运行|检查身体|查看状态"])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- try:
- with open(file1, 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- try:
- with open(file, '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:
- cpu = psutil.cpu_percent(interval=1)
- memory = psutil.virtual_memory().percent
- disk = psutil.disk_usage('/').percent
- inteSENT = psutil.net_io_counters().bytes_sent # type: ignore
- inteRECV = psutil.net_io_counters().bytes_recv # type: ignore
- except:
- await session.send(errorBack('获取状态数据失败'))
-
- status = 'アトリは、高性能ですから!'
-
- if cpu > 80:
- status = 'ATRI感觉头有点晕...'
- if memory > 80:
- status = 'ATRI感觉有点头晕并且有点累...'
-
- elif disk > 80:
- status = 'ATRI感觉身体要被塞满了...'
-
- await session.send(f"""ATRI Status:
-* cpu: {cpu}%
-* mem: {memory}%
-* disk: {disk}%
-* BytesSENT: {inteSENT}
-* BytesRECV: {inteRECV}
-{status}""".strip())
-
-@on_command('getUser', aliases = ['用户总数', '用户数量'])
-async def _(session: CommandSession):
- try:
- with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
- msg0 = f'用户总数: {len(data)}\n'
- msg0 += f'群总数: {len(await session.bot.get_group_list())}' # type: ignore
- await session.send(msg0)
-
-
-
-@on_command('trackERROR', aliases = ['track'], only_to_me = False)
-async def _(session: CommandSession):
- if session.event.user_id in master:
- msg = session.current_arg.strip()
- if not msg:
- msg = session.get('message', prompt = '请发送trackID')
-
- try:
- with open(Path('.') / 'ATRI' / 'data' / 'errorData' / 'errorData.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- if str(msg) in data.keys():
- err = data[f"{msg}"]
- msg0 = f'trackID: {msg}\n'
- msg0 += err
- await session.send(msg0)
-
- else:
- session.finish('未发现该ID')
-
- else:
- await session.send('恁哪位呀~?') \ No newline at end of file
diff --git a/ATRI/plugins/GetChatMSG.py b/ATRI/plugins/GetChatMSG.py
deleted file mode 100644
index 9b4adb8..0000000
--- a/ATRI/plugins/GetChatMSG.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import os
-import json
-import nonebot
-from pathlib import Path
-
-
-bot = nonebot.get_bot()
-
-
[email protected]_message('group')
-async def _(ctx):
- group = ctx['group_id']
- user = ctx['user_id']
- msgID = ctx['message_id']
- RAWmsg = ctx['message']
-
- try:
- with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'msgData.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- data[f'{msgID}'] = {"msg": f"{RAWmsg}", "user_id": f"{user}"}
-
- try:
- with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'msgData.json', 'w') as f:
- f.write(json.dumps(data))
- f.close()
- except:
- os.mkdir(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}')
- with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'msgData.json', 'w') as f:
- f.write(json.dumps(data))
- f.close() \ No newline at end of file
diff --git a/ATRI/plugins/LearnRepo.py b/ATRI/plugins/LearnRepo.py
deleted file mode 100644
index ae158f4..0000000
--- a/ATRI/plugins/LearnRepo.py
+++ /dev/null
@@ -1,64 +0,0 @@
-import json
-from datetime import datetime
-from pathlib import Path
-import nonebot
-from nonebot import on_command
-from nonebot import CommandSession
-
-import config
-from ATRI.modules.error import errorBack
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-__plugin_name__ = "LearnRepo"
-
-def now_time():
- now_ = datetime.now()
- hour = now_.hour
- minute = now_.minute
- now = hour + minute / 60
- return now
-
-
-@on_command('add_word', aliases = ['增加词汇', '删除词汇', '学习词汇'], only_to_me = False)
-async def _(session: CommandSession):
- if session.event.user_id == master:
- msg = session.event.raw_message.split(' ', 3)
- w_tpye = msg[0]
- word = msg[1]
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'LearnRepo' / 'LearnRepo.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- if w_tpye == '增加词汇' or w_tpye == '学习词汇':
- repo = msg[2]
- prob = int(msg[3])
- if word in data.keys():
- await session.send('该词已存在~!')
-
- else:
- try:
- data[f"{word}"] = [f"{repo}",prob]
- 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)}]")
- except:
- session.finish(errorBack('写入失败'))
-
- elif w_tpye == '删除词汇':
- if word in data.keys():
- try:
- data.pop(f"{word}")
- f = open(Path('.') / 'ATRI' / 'plugins' / 'LearnRepo' / 'LearnRepo.json', 'w')
- f.write(json.dumps(data))
- f.close()
- await session.send(f'已成功从ATRI记忆模块中抹除[{word}]')
- except:
- session.finish(errorBack('移除失败'))
-
- else:
- session.finish(f'ATRI貌似没法从记忆中找到关键词[{word}]呢...') \ No newline at end of file
diff --git a/ATRI/plugins/LearnRepo/LearnRepo.json b/ATRI/plugins/LearnRepo/LearnRepo.json
deleted file mode 100644
index fb478b5..0000000
--- a/ATRI/plugins/LearnRepo/LearnRepo.json
+++ /dev/null
@@ -1 +0,0 @@
-{"test": ["TesT is SuccEss!", 1]} \ No newline at end of file
diff --git a/ATRI/plugins/SauceNAO.py b/ATRI/plugins/SauceNAO.py
deleted file mode 100644
index 73178ab..0000000
--- a/ATRI/plugins/SauceNAO.py
+++ /dev/null
@@ -1,95 +0,0 @@
-import requests
-import json
-import re
-from nonebot import on_command, CommandSession
-
-import config
-from ATRI.modules.error import errorBack
-from ATRI.modules.time import sleepTime
-from ATRI.modules.funcControl import checkSwitch, checkNoob
-
-
-API_KEY = config.SauceNaoKEY
-__plugin_name__ = "saucenao_search"
-
-
-class SauceNAO:
-
- def __init__(self, api_key, output_type=2, testmode=0, dbmask=None, dbmaski=32768, db=5, numres=1):
- api = 'https://saucenao.com/search.php'
- self.api = api
- params = dict()
- params['api_key'] = api_key
- params['output_type'] = output_type
- params['testmode'] = testmode
- params['dbmask'] = dbmask
- params['dbmaski'] = dbmaski
- params['db'] = db
- params['numres'] = numres
- self.params = params
-
- def search(self, url):
- self.params['url'] = url
- res = requests.get(url=self.api,params=self.params)
- return res.content
-
-@on_command('SauceNAO', aliases = ['以图识图', '以图搜图'], only_to_me = False)
-async def SaucenaoSearch(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- msg = session.current_arg.strip()
-
- if checkNoob(user, group):
- if sleepTime():
- await session.send(sleepTime())
- else:
- if checkSwitch(__plugin_name__, group):
- if not msg:
- msg = session.get('message', prompt="请发送一张图片")
-
- await session.send("开始以图识图")
-
- try:
- p = '\\[CQ\\:image\\,file\\=.*?\\,url\\=(.*?)\\]'
-
- img = re.findall(p, msg)
-
- task = SauceNAO(api_key=API_KEY)
- data = task.search(url=img)
- msg0 = ''
-
- try:
- data = json.loads(data)['results'][0]
- title = data['data']['title']
- pixiv_id = data['data']['pixiv_id']
- member_name = data['data']['member_name']
- member_id = data['data']['member_id']
- similarity = data['header']['similarity']
- mini_url = data['header']['thumbnail']
- msg0 = f'[CQ:at,qq={user}]'
- msg0 += f'SauceNAO结果:'
- msg0 += f'[CQ:image,file={mini_url}]\n'
- msg0 += f'相似度:{similarity}%\n'
- msg0 += f'标题:{title}\n'
- msg0 += f'插画ID:{pixiv_id}\n'
- msg0 += f'画师:{member_name}\n'
- msg0 += f'画师ID:{member_id}\n'
- msg0 += f'直链:https://pixiv.cat/{pixiv_id}.jpg'
- except:
- msg = '数据处理失败'
-
- if float(similarity) > 70:
- await session.send(msg0)
- else:
- await session.send("找不到相似的图呢...")
-
- except Exception:
- session.finish(errorBack(msg))
- else:
- session.finish('该功能已关闭...')
-
-
-async def _(session: CommandSession):
- if not session.is_first_run and session.current_arg.startswith('算了'):
- session.switch(session.current_arg[len('算了'):])
diff --git a/ATRI/plugins/Scheduler.py b/ATRI/plugins/Scheduler.py
deleted file mode 100644
index 93c7824..0000000
--- a/ATRI/plugins/Scheduler.py
+++ /dev/null
@@ -1,152 +0,0 @@
-import time
-import nonebot
-import psutil
-import asyncio
-from datetime import datetime
-from random import randint, choice
-from nonebot.helpers import send_to_superusers
-
-bot = nonebot.get_bot()
-
-
- 'cron',
- hour = 7,
- misfire_grace_time= 60
-)
-async def _():
- """早安"""
- try:
- await send_to_superusers(bot, f'ATRI将在三秒后开始执行定时任务:早安')
- asyncio.sleep(3)
- 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)
- msg = choice(
- [
- '啊......早上好...(哈欠)',
- '唔......吧唧...早上...哈啊啊~~~\n早上好......',
- '早上好......',
- '早上好呜......呼啊啊~~~~',
- '啊......早上好。\n昨晚也很激情呢!',
- '吧唧吧唧......怎么了...已经早上了么...',
- '早上好!',
- '......看起来像是傍晚,其实已经早上了吗?',
- '早上好......欸~~~脸好近呢'
- '......(打瞌睡)',
- ]
- )
-
- try:
- for group in groups:
- asyncio.sleep(randint(1,5))
- await (group_id = group, message = msg) #type: ignore
- except:
- await send_to_superusers(bot, f'在推送[早安]到某些群的时候貌似失败了呢')
-
- end = time.perf_counter()
- await send_to_superusers(bot, f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}')
-
- except:
- pass
-
- 'cron',
- hour = 22,
- misfire_grace_time = 60
-)
-async def _():
- """晚安"""
- try:
- await send_to_superusers(bot, f'ATRI将在三秒后开始执行定时任务:晚安')
- asyncio.sleep(3)
- 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)
- msg = choice(
- [
- '忙累了一天,快休息吧',
- '辛苦了一天,准备睡觉吧',
- '一起睡觉吧~~~~~',
- '......该睡觉了',
- '还不睡等着猝死?嗯!?'
-
- ]
- )
-
- try:
- for group in groups:
- asyncio.sleep(randint(1,5))
- await bot.send_group_msg(group_id = group, message = msg) #type: ignore
- except:
- await send_to_superusers(bot, f'在推送[晚安]到某些群的时候貌似失败了呢')
-
- end = time.perf_counter()
- await send_to_superusers(bot, f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}')
-
- except:
- pass
-
- 'cron',
- hour = 0,
- misfire_grace_time = 60
-)
-async def _():
- """到 点 了"""
- try:
- await send_to_superusers(bot, f'ATRI将在三秒后开始执行定时任务:网抑云')
- asyncio.sleep(3)
- 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)
- msg = f'到点了叻~!'
-
- try:
- for group in groups:
- asyncio.sleep(randint(1,5))
- await bot.send_group_msg(group_id = group, message = msg) #type: ignore
- except:
- await send_to_superusers(bot, f'在推送[网抑云]到某些群的时候貌似失败了呢')
-
- end = time.perf_counter()
- await send_to_superusers(bot, f'已推送到[{g_list}]个群\n耗时:{round(end - start, 3)}')
-
- except:
- pass
-
- 'interval',
- minutes = 5,
- misfire_grace_time= 10
-)
-async def _():
- print('ATRI开始自检...')
- cpu = psutil.cpu_percent(interval=1)
- memory = psutil.virtual_memory().percent
- disk = psutil.disk_usage('/').percent
- today = datetime.now()
-
- if cpu > 80:
- await send_to_superusers(
- bot,
- f'ATRI感觉头有点晕...\n(cpu:{cpu}% mem:{memory}% disk:{disk}%)\n{today}'
- )
-
- elif memory > 80:
- await send_to_superusers(
- bot,
- f'ATRI感觉身体有点累...\n(cpu:{cpu}% mem:{memory}% disk:{disk}%)\n{today}'
- )
-
- elif disk > 80:
- await send_to_superusers(
- bot,
- f'ATRI感觉身体要被塞满了...\n(cpu:{cpu}% mem:{memory}% disk:{disk}%)\n{today}'
- )
-
- else:
- print('ATRI运作正常!') \ No newline at end of file
diff --git a/ATRI/plugins/Setu.py b/ATRI/plugins/Setu.py
deleted file mode 100644
index 42d8bdc..0000000
--- a/ATRI/plugins/Setu.py
+++ /dev/null
@@ -1,327 +0,0 @@
-import os
-import re
-import time
-import json
-import sqlite3
-import aiohttp
-from urllib.parse import urlencode
-from random import choice, randint
-from pathlib import Path
-from datetime import datetime
-from random import choice
-import nonebot
-from nonebot import on_command, CommandSession
-from nonebot.helpers import send_to_superusers
-
-import config
-from ATRI.modules.error import errorBack
-from ATRI.modules.b64 import b64_str_img_url
-from ATRI.modules.response import request_api_params
-from ATRI.modules.funcControl import checkSwitch, checkNoob
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-apikey_LOLI = config.LoliconAPI
-APP_ID = config.BaiduApiID
-API_KEY = config.BaiduApiKEY
-SECRECT_KEY = config.BaiduApiSECRET
-__plugin_name__ = "setu"
-__plugin_name1__ = "setu_img"
-
-URL = 'https://api.lolicon.app/setu/'
-
-SETU_REPLY = """Title: {title}
-Pid: {pid}
-{setu}
----------------
-Complete time:{time}s"""
-
-
-def now_time():
- now_ = datetime.now()
- hour = now_.hour
- minute = now_.minute
- now = hour + minute / 60
- return now
-
-
-setu_type = 1
-@on_command('setu', patterns = (r"来[点丶张份副个幅][涩色瑟][图圖]|[涩色瑟][图圖]来|[涩色瑟][图圖][gkd|GKD|搞快点]|[gkd|GKD|搞快点][涩色瑟][图圖]|[图圖]来|[我你她他它]想要[点丶张份副][涩色瑟][图圖]|我想要[1一][张份幅副个只][涩色瑟][图圖]|[我你她他它]想[看|look][涩涩|色色]的东西"), only_to_me = False)
-async def setu(session: CommandSession):
- start = time.perf_counter()
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
- )
- else:
- if checkSwitch(__plugin_name__, group):
- res = randint(1,10)
- if 1 <= res <= 9:
- res = randint(1,4)
- if 1 <= res <= 3:
- if setu_type == 1:
- res = randint(1,5)
- await session.send('别急!正在找图!')
- 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 <= 4:
- 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 == 5:
- for i in msg:
- pid = i[0]
- title = i[1]
- img = i[7]
- end = time.perf_counter()
- await session.send('我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆')
- await send_to_superusers(
- bot,
- message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{img}\nComplete time: {round(end - start, 3)}"
- )
-
- elif setu_type == 2:
- res = randint(1,5)
- 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:
- session.finish(errorBack('请求数据失败'))
-
- if 1 <= res <= 4:
- 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 == 5:
- end = time.perf_counter()
- await session.send('我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆')
- await send_to_superusers(
- bot,
- 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 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('该功能已关闭...')
-
-
-@on_command('change_setu_type', aliases = ['涩图导向'], only_to_me = False)
-async def _(session: CommandSession):
- global setu_type
- if session.event.user_id == master:
- msg = session.event.raw_message.split(' ', 1)
- s_type = msg[1]
-
- if s_type == '数据库':
- setu_type = 1
-
- elif s_type == '接口':
- setu_type = 2
-
- else:
- session.finish('请检查输入~~~(')
-
- await session.send('okay~~~~')
-
-
[email protected]_message("group")
-async def _(context):
- start = time.perf_counter()
- user = context["user_id"]
- group = context["group_id"]
- if checkNoob(user, group):
- if checkSwitch(__plugin_name1__, group):
- 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
-
- try:
- img = b64_str_img_url(img)
- print('转换图片至base64成功')
- except:
- return
-
- try:
- 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)
-
- async def func0(url, headers, data):
- async with aiohttp.ClientSession() as client:
- async with client.post(url, headers = headers, data = data) as req:
- res = await req.read()
- return res
-
- words = json.loads(str(func0(url, headers, data)))['words_result'][0]['words']
- print('BaiduAPI请求成功')
- except:
- return
-
- if re.findall(r"[涩色]图|炼铜", words):
- if checkSwitch(__plugin_name__, group):
- res = randint(1,10)
- if 1 <= res <= 9:
- res = randint(1,5)
- if 1 <= res <= 4:
- if setu_type == 1:
- res = randint(1,5)
- await bot.send_group_msg(group_id = group, message = '别急!正在找图!') # type: ignore
- 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 <= 4:
- 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 == 5:
- 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 send_to_superusers(
- bot,
- message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{img}\nComplete time: {round(end - start, 3)}"
- )
-
- elif setu_type == 2:
- res = randint(1,5)
- 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 = errorBack('数据请求失败')) # type: ignore
- return
- if 1 <= res <= 4:
- 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 == 5:
- end = time.perf_counter()
- await bot.send_group_msg(group_id = group, message = '我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆') # type: ignore
- await send_to_superusers(
- bot,
- message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}"
- )
- elif res == 5:
- 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
-
- else:
- pass \ No newline at end of file
diff --git a/ATRI/plugins/SingIN.py b/ATRI/plugins/SingIN.py
deleted file mode 100644
index 55b1b60..0000000
--- a/ATRI/plugins/SingIN.py
+++ /dev/null
@@ -1,80 +0,0 @@
-import json
-import datetime
-from pathlib import Path
-from random import randint
-from nonebot import on_command, CommandSession
-
-from ATRI.modules.time import sleepTime
-from ATRI.modules.funcControl import checkNoob
-
-
-
-# =========[好感度阶级说明]=========
-# - 0-100 陌生人
-# - 100-250 朋友
-# - 250-350 亲密的朋友
-# - 350-400 ???
-# - 400-* 开冲
-# =================================
-
-
-
-@on_command('SingIN', aliases = ['签到'])
-async def _(session: CommandSession):
- group = session.event.group_id
- user = session.event.user_id
- if sleepTime():
- await session.send(sleepTime())
- else:
- if checkNoob(user, group):
- try:
- with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- try:
- if data[f"{user}"][1] == datetime.date.today().strftime('%y%m%d'):
- await session.send('咱今天签到过啦~明天再来吧!')
- return
- except:
- pass
-
- favoIMP = randint(1,5)
-
- try:
- with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'r') as f:
- data = json.load(f)
- data[f"{user}"] = [f"{int(data[f'{user}'][0]) + favoIMP}", f"{datetime.date.today().strftime('%y%m%d')}"]
- with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'w') as f:
- f.write(json.dumps(data))
- f.close()
- except:
- data = {}
- data[f"{user}"] = [f"{favoIMP}", f"{datetime.date.today().strftime('%y%m%d')}"]
- with open(Path('.') / 'ATRI' / 'modules' / 'favoIMP' / 'user.json', 'w') as f:
- f.write(json.dumps(data))
- f.close()
-
- IMP = int(data[f"{user}"][0])
-
- msg0 = f'[CQ:at,qq={user}]\n'
- msg0 += '签到成功ヾ(≧∇≦*)ゝ\n'
- msg0 += f'+ 好感度 {favoIMP}|{IMP}\n'
-
- if 0 <= IMP < 100:
- msg0 += '今日もいい日ですよ!~頑張ってください!'
-
- elif 100 <= IMP < 250:
- msg0 += 'アトリが心から応援します!'
-
- elif 250 <= IMP < 350:
- msg0 += 'アトリはあなたを待ちます'
-
- elif 350 <= IMP < 400:
- msg0 += 'わ...わたし...えと...す...'
-
- elif 400 <= IMP:
- msg0 += '好きだあなた好きだ!永遠!'
-
- await session.send(msg0) \ No newline at end of file
diff --git a/ATRI/plugins/UploadSqlite.py b/ATRI/plugins/UploadSqlite.py
deleted file mode 100644
index a7e1cd0..0000000
--- a/ATRI/plugins/UploadSqlite.py
+++ /dev/null
@@ -1,295 +0,0 @@
-import os
-import time
-import json
-import asyncio
-import sqlite3
-import nonebot
-
-from pathlib import Path
-from nonebot import on_command, CommandSession
-
-import config
-from ATRI.modules.response import request_api
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-url = f'https://api.imjad.cn/pixiv/v1/?type=illust&id='
-
-
-try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'sepi.json', 'r') as f:
- sP = json.load(f)
-except:
- sP = {}
-sepi = list(sP.keys())
-
-try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'cloudmusic.json', 'r') as f:
- cD = json.load(f)
-except:
- cD = {}
-cloudmusic = list(cD.keys())
-
-
-
-@on_command('upload_setu', aliases = ['上传涩图'], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- if user in master or user in sepi:
- start = time.perf_counter()
- msg = session.event.raw_message.split(' ', 2)
- print(msg)
- i_tpye = msg[1]
- pid = msg[2]
-
- URL = url + pid
-
- dc = json.loads(request_api(URL))
- if not dc:
- session.finish('ATRI在尝试解析数据时出问题...等会再试试吧...')
- title = dc["response"][0]["title"]
- tags = dc["response"][0]["tags"]
- account = dc["response"][0]["user"]["account"]
- name = dc["response"][0]["user"]["name"]
- u_id = dc["response"][0]["user"]["id"]
- user_link = f'https://www.pixiv.net/users/' + f'{u_id}'
- img = f'https://pixiv.cat/{pid}.jpg'
-
- dataSETU = (f'{pid}', f'{title}', f'{tags}', f'{account}', f'{name}', f'{u_id}', f'{user_link}', f'{img}')
-
- if i_tpye == '正常':
- if os.path.exists('ATRI/data/sqlite/setu/normal.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- await asyncio.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE normal(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db')
- cur = con.cursor()
- cur.execute('INSERT INTO normal(pid, title, tags, account, name, u_id, user_link, img) VALUES(?, ?, ?, ?, ?, ?, ?, ?)', dataSETU)
- con.commit()
- con.close()
-
- elif i_tpye == '擦边球':
- if os.path.exists('ATRI/data/sqlite/setu/nearR18.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- await asyncio.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE nearR18(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db')
- cur = con.cursor()
- cur.execute('INSERT INTO nearR18(pid, title, tags, account, name, u_id, user_link, img) VALUES(?, ?, ?, ?, ?, ?, ?, ?)', dataSETU)
- con.commit()
- con.close()
-
- elif i_tpye == 'r18':
- if os.path.exists('ATRI/data/sqlite/cloudmusic/cloudmusic.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- await asyncio.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE r18(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db')
- cur = con.cursor()
- cur.execute('INSERT INTO r18(pid, title, tags, account, name, u_id, user_link, img) VALUES(?, ?, ?, ?, ?, ?, ?, ?)', dataSETU)
- con.commit()
- con.close()
-
- end = time.perf_counter()
-
- await session.send(f'数据上传完成!\n耗时: {round(end - start, 3)}s')
-
-@on_command('upload_cloudmusic', aliases = ['上传网抑语', '网抑云', '网易云'], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- if user in master or user in cloudmusic:
- start = time.perf_counter()
- msg = session.event.raw_message.split(' ', 1)
- msg = msg[1]
-
- if os.path.exists('ATRI/data/sqlite/cloudmusic/cloudmusic.db'):
- print('数据文件存在!')
- else:
- await session.send('数据库不存在,将在3秒后开始构建...')
- await asyncio.sleep(3)
- await session.send('开始构建数据库!')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db')
- cur = con.cursor()
- cur.execute('CREATE TABLE cloudmusic(msg MSG, UNIQUE(msg))')
- con.commit()
- cur.close()
- con.close()
- await session.send('完成')
-
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db')
- cur = con.cursor()
- cur.execute('INSERT INTO cloudmusic(msg) VALUES (?)', msg)
- con.commit()
- con.close()
-
- end = time.perf_counter()
-
- await session.send(f'数据上传完成!\n耗时: {round(end - start, 3)}s')
-
-
-@on_command('del_setu', aliases = ['删除涩图'], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- if user in master or user in sepi:
- start = time.perf_counter()
- msg = session.event.raw_message.split(' ', 2)
- i_tpye = msg[1]
- pid = msg[2]
-
- if i_tpye == '正常':
- if os.path.exists(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db'):
- print('数据文件存在!')
- else:
- session.finish('ERROR: 恁都没库删锤子')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db')
- cur = con.cursor()
- cur.execute(f'DELETE FROM COMPANY WHERE ID = {pid}')
- con.commit()
- con.close()
-
- elif i_tpye == '擦边球':
- if os.path.exists(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db'):
- print('数据文件存在!')
- else:
- session.finish('ERROR: 恁都没库删锤子')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db')
- cur = con.cursor()
- cur.execute(f'DELETE FROM COMPANY WHERE ID = {pid}')
- con.commit()
- con.close()
-
-
- elif i_tpye == 'r18':
- if os.path.exists(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db'):
- print('数据文件存在!')
- else:
- session.finish('ERROR: 恁都没库删锤子')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db')
- cur = con.cursor()
- cur.execute(f'DELETE FROM COMPANY WHERE ID = {pid}')
- con.commit()
- con.close()
-
- end = time.perf_counter()
-
- await session.send(f'数据删除完成!\n耗时: {round(end - start, 3)}s')
-
-@on_command('del_cloudmusic', aliases = ['删除网易云'], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- if user in master or user in cloudmusic:
- start = time.perf_counter()
- msg = session.event.raw_message.split(' ', 1)
- msg = msg[1]
-
- if os.path.exists('ATRI/data/sqlite/cloudmusic/cloudmusic.db'):
- print('数据文件存在!')
- else:
- session.finish('ERROR: 恁都没库删锤子')
- con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db')
- cur = con.cursor()
- cur.execute('INSERT INTO cloudmusic(msg) VALUES (?)', msg)
- con.commit()
- con.close()
-
- end = time.perf_counter()
-
- await session.send(f'数据删除完成!\n耗时: {round(end - start, 3)}s')
-
-
-@on_command('add_check_sepi', aliases=['添加涩批', '移除涩批'], only_to_me = False)
-async def _(session: CommandSession):
- if session.event.user_id in master:
- msg = session.event.raw_message.split(' ', 1)
- m_type = msg[0]
- u = msg[1]
-
- if m_type == '添加涩批':
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'sepi.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- data[f"{u}"] = f"{u}"
- f = open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'sepi.json', 'w')
- f.write(json.dumps(data))
- f.close()
- await session.send(f'成功添加涩批[{u}]!')
-
- elif m_type == '移除涩批':
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'sepi.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- data.pop(f"{u}")
- f = open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'sepi.json', 'w')
- f.write(json.dumps(data))
- f.close()
- await session.send(f'成功移除涩批[{u}]!')
-
-@on_command('add_check_cd', aliases = ['添加抑郁', '移除抑郁'], only_to_me = False)
-async def _(session: CommandSession):
- if session.event.user_id in master:
- msg = session.event.raw_message.split(' ', 1)
- m_type = msg[0]
- u = msg[1]
-
- if m_type == '添加抑郁':
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'cloudmusic.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- data[f"{u}"] = f"{u}"
- f = open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'cloudmusic.json', 'w')
- f.write(json.dumps(data))
- f.close()
- await session.send(f'成功添加抑郁[{u}]!')
-
- elif m_type == '移除抑郁':
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'cloudmusic.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- data.pop(f"{u}")
- f = open(Path('.') / 'ATRI' / 'plugins' / 'UploadSqlite' / 'cloudmusic.json', 'w')
- f.write(json.dumps(data))
- f.close()
- await session.send(f'成功移除抑郁[{u}]!') \ No newline at end of file
diff --git a/ATRI/plugins/UploadSqlite/cloudmusic.json b/ATRI/plugins/UploadSqlite/cloudmusic.json
deleted file mode 100644
index 9e26dfe..0000000
--- a/ATRI/plugins/UploadSqlite/cloudmusic.json
+++ /dev/null
@@ -1 +0,0 @@
-{} \ No newline at end of file
diff --git a/ATRI/plugins/UploadSqlite/sepi.json b/ATRI/plugins/UploadSqlite/sepi.json
deleted file mode 100644
index 9e26dfe..0000000
--- a/ATRI/plugins/UploadSqlite/sepi.json
+++ /dev/null
@@ -1 +0,0 @@
-{} \ No newline at end of file
diff --git a/ATRI/plugins/hitokoto.py b/ATRI/plugins/hitokoto.py
deleted file mode 100644
index a49c8fc..0000000
--- a/ATRI/plugins/hitokoto.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import json
-from nonebot import on_command, on_natural_language, CommandSession
-from nonebot import NLPSession, NLPResult
-
-from ATRI.modules.response import request_api
-from ATRI.modules.error import errorBack
-from ATRI.modules.time import sleepTime
-from ATRI.modules.funcControl import checkNoob
-
-
-
-url = 'https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source='
-
-
-@on_command('hitokoto', aliases = ['一言'], only_to_me = False)
-async def hitokoto(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if sleepTime():
- await session.send(sleepTime())
- else:
- try:
- rep = request_api(url)
- except:
- session.finish(errorBack('请求错误'))
-
- dc = json.loads(rep)
-
- await session.send(dc["hitokoto"])
-
-@on_natural_language('一言', only_to_me = False)
-async def _(session: NLPSession):
- return NLPResult(60.0, ('hitokoto'), None) \ No newline at end of file
diff --git a/ATRI/plugins/noobList/noobGroup.json b/ATRI/plugins/noobList/noobGroup.json
deleted file mode 100644
index 9e26dfe..0000000
--- a/ATRI/plugins/noobList/noobGroup.json
+++ /dev/null
@@ -1 +0,0 @@
-{} \ 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 9e26dfe..0000000
--- a/ATRI/plugins/noobList/noobList.json
+++ /dev/null
@@ -1 +0,0 @@
-{} \ No newline at end of file
diff --git a/ATRI/plugins/onMessage.py b/ATRI/plugins/onMessage.py
deleted file mode 100644
index 0ab8f88..0000000
--- a/ATRI/plugins/onMessage.py
+++ /dev/null
@@ -1,125 +0,0 @@
-import re
-import os
-import json
-import nonebot
-from pathlib import Path
-from random import randint, choice
-
-from ATRI.modules.error import errorBack
-from ATRI.modules.time import sleepTime
-from ATRI.modules.funcControl import checkSwitch, checkNoob
-from ATRI.plugins.SauceNAO import API_KEY, SauceNAO
-
-
-bot = nonebot.get_bot()
-
-
[email protected]_message("group")
-async def _(context):
- group = context["group_id"]
- user = context["user_id"]
- if sleepTime():
- pass
- else:
- if checkNoob(user, group):
- msg = str(context["message"])
- print(msg)
- if "搜图" in msg or "识图" in msg:
- if checkSwitch("saucenao_search", group):
- try:
- pattern = r"CQ:reply,id=(.*?)]"
- info = re.findall(pattern, msg)
- msgID = info[0]
- print(msgID)
- except:
- print('ERROR-onMessage')
- return
-
- try:
- with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'msgData.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- if msgID in data.keys():
- msgR = data[f"{msgID}"]["msg"]
-
- pattern = r"url=(.*?)]"
- info = re.findall(pattern, msgR)
- picURL = info[0]
-
- try:
- task = SauceNAO(api_key=API_KEY)
- data = task.search(url=picURL)
- msg0 = ''
- except:
- await bot.send_msg(group_id = group, message = errorBack('请求数据失败')) # type: ignore
- return
-
- print(data)
- try:
- data = json.loads(data)['results'][0]
- title = data['data']['title']
- pixiv_id = data['data']['pixiv_id']
- member_name = data['data']['member_name']
- member_id = data['data']['member_id']
- similarity = data['header']['similarity']
- mini_url = data['header']['thumbnail']
- msg0 = f'[CQ:at,qq={user}]'
- msg0 += f'SauceNAO结果:'
- msg0 += f'[CQ:image,file={mini_url}]\n'
- msg0 += f'相似度:{similarity}%\n'
- msg0 += f'标题:{title}\n'
- msg0 += f'插画ID:{pixiv_id}\n'
- msg0 += f'画师:{member_name}\n'
- msg0 += f'画师ID:{member_id}\n'
- msg0 += f'直链:https://pixiv.cat/{pixiv_id}.jpg'
- except:
- await bot.send_msg(group_id = group, message = errorBack('处理数据失败')) # type: ignore
- return
- if msg0:
- if float(similarity) > 70:
- await bot.send_msg(group_id = group, message = msg0) # type: ignore
- else:
- await bot.send_msg(group_id = group, message = 'ATRI无法找到相似的图呢...') # type: ignore
-
- else:
- await bot.send_msg(group_id = group, message = '该功能已关闭...') # type: ignore
-
- else:
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'LearnRepo' / 'LearnRepo.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
-
- if str(msg) in data.keys():
- lt = data[f"{msg}"]
- 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
-
[email protected]_message('group')
-async def _(context):
- user = context["user_id"]
- group = context["group_id"]
- if checkNoob(user, group):
- if sleepTime():
- pass
- else:
- if randint(1,20) == 4:
- img = choice(
- [
- '11.jpg', '12.jpg', '23.jpg'
- ]
- )
- img = os.path.abspath(Path('.') / 'ATRI' / 'data' / 'emoji' / 'senren' / f'{img}')
- await bot.send_msg(message = f'[CQ:image,file=file:///{img}]', auto_escape = False) # type: ignore
-
- else:
- pass \ No newline at end of file
diff --git a/ATRI/plugins/other.py b/ATRI/plugins/other.py
deleted file mode 100644
index 2278547..0000000
--- a/ATRI/plugins/other.py
+++ /dev/null
@@ -1,145 +0,0 @@
-import random
-import nonebot
-import warnings
-from nonebot import on_command, CommandSession
-from nonebot.helpers import render_expression
-
-import config
-from ATRI.modules.time import sleepTime
-from ATRI.modules.funcControl import checkNoob
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-
-def countX(lst, x):
- warnings.simplefilter('ignore', ResourceWarning)
- count = 0
- for ele in lst:
- if (ele == x):
- count = count + 1
- return count
-
-
-HELP_REPLY = (
- 'ええと...让我想想...',
- '嗯...',
- '阿这',
- '不会使用嘛...ええと'
-)
-
-
-@on_command('抽签', only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if sleepTime():
- await session.send(sleepTime())
- else:
- await session.send(
- str(
- random.choice(
- [
- '大凶',
- '大胸',
- '小凶',
- '小胸',
- '凶',
- '吉',
- '中吉',
- '大吉',
- '特大吉',
- '超特大吉'
- ]
- )
- )
- )
-
-@on_command('掷骰子', aliases = ['扔骰子', '骰子'], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if sleepTime():
- await session.send(sleepTime())
- else:
- await session.send(
- str(
- random.randint(
- 1,6
- )
- )
- )
-
-@on_command('关于', aliases = ['关于'])
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- 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
- group = session.event.group_id
- if checkNoob(user, group):
- await session.send(
- f"""{render_expression(HELP_REPLY)}
-请仔细阅读文档哦~~https://blog.lolihub.icu/#/ATRI/user"""
- )
-
-
-RepoList = []
-@on_command('report', aliases = ['来杯红茶'], only_to_me = True)
-async def EMMAAAA(session: CommandSession):
- global RepoList
- h_type = session.event.detail_type
- msg = session.current_arg.strip()
- user = session.event.user_id
- group = session.event.group_id
-
- if not msg:
- msg = session.get('message', prompt='请键入需要反馈的信息')
-
- RepoList.append(user)
-
- if countX(RepoList, user) == 5:
- session.finish('您今天已经喝了5杯红茶啦!明天再来吧!')
-
- if h_type == 'group':
- await bot.send_private_msg(
- user_id = master,
- message = f"来自群[{group}],用户[{user}]的反馈:\n{msg}"
- ) # type: ignore
-
- elif h_type == 'private':
- await bot.send_private_msg(
- user_id = master,
- message = f"来自用户[{user}]的反馈:\n{msg}"
- ) # type: ignore
-
-async def _(session: CommandSession):
- if not session.is_first_run and session.current_arg.startswith('算了'):
- session.switch(session.current_arg[len('算了'):])
-
- 'cron',
- hour = 0,
- misfire_grace_time = 10
-)
-async def _():
- global RepoList
- try:
- RepoList = []
- except:
- await bot.send_private_msg(user_id = master, message = f'红茶重置失败...请手动重启ATRI以重置红茶...') # type: ignore
- return
- await bot.send_private_msg(user_id = master, message = '红茶重置成功!') # type: ignore \ No newline at end of file
diff --git a/ATRI/plugins/pixiv.py b/ATRI/plugins/pixiv.py
deleted file mode 100644
index fa6fa05..0000000
--- a/ATRI/plugins/pixiv.py
+++ /dev/null
@@ -1,239 +0,0 @@
-import time
-import json
-from datetime import datetime
-from random import choice
-import nonebot
-from nonebot import on_command, CommandSession
-
-import config
-from ATRI.modules.response import request_api
-from ATRI.modules.error import errorBack
-from ATRI.modules.funcControl import checkSwitch, checkNoob
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-__plugin_name__ = "pixiv"
-__plugin_name1__ = "pixiv_seach_img"
-__plugin_name2__ = "pixiv_seach_author"
-__plugin_name3__ = "pixiv_daily_rank"
-
-URL_1 = 'https://api.imjad.cn/pixiv/v1/?type=illust&id=' #单图搜索
-URL_2 = 'https://api.imjad.cn/pixiv/v1/?type=member_illust&id=' #画师作品搜索
-URL_3 = 'https://api.imjad.cn/pixiv/v1/?type=rank' #每日排行榜
-
-
-IMG_SEACH_REPLY = """[CQ:at,qq={user}]
-搜索结果如下:
-Pid: {pid}
-Title: {title}
-宽高: {width}x{height}
-Tags: {tags}
-账号名称: {account}
-名称: {name}
-Link: {user_link}
-{img}
----------------
-完成时间:{time}s"""
-
-
-def now_time():
- now_ = datetime.now()
- hour = now_.hour
- minute = now_.minute
- now = hour + minute / 60
- return now
-
-
-@on_command('pixiv_seach_img', aliases = ['p站搜图', 'P站搜图', '批站搜图'], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
- )
- else:
- if checkSwitch(__plugin_name1__, group):
- pid = session.current_arg.strip()
-
- if not pid:
- pid = session.get('message', prompt = '请告诉ATRI需要查询的Pid码')
-
- start =time.perf_counter()
- await session.send('开始P站搜图')
-
- URL = URL_1 + pid
-
- try:
- dc = json.loads(request_api(URL))
- except:
- session.finish(errorBack('请求数据失败'))
-
- img = f'https://pixiv.cat/{pid}.jpg'
-
-
- end = time.perf_counter()
-
- try:
- 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)
- )
- )
- except:
- session.finish(errorBack('处理数据失败'))
-
- else:
- await session.send('该功能已关闭...')
-
-
-@on_command('pixiv_seach_author', aliases = ['画师', '搜索画师', '画师搜索'], only_to_me = False)
-async def _(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
- )
- else:
- if checkSwitch(__plugin_name2__, group):
- 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
-
- try:
- dc = json.loads(request_api(URL))
- except:
- session.finish(errorBack('请求数据失败'))
-
- d ={}
-
- try:
- for i in range(0,3):
- pid = dc["response"][i]["id"]
- pidURL = f'https://pixiv.cat/{pid}.jpg'
- d[i] = [f'{pid}',f'{pidURL}']
- except:
- session.finish(errorBack('处理数据失败'))
-
- msg0 = (f'[CQ:at,qq={user}]\n画师id:{author_id},接下来展示前三作品')
-
- result = sorted(
- d.items(),
- key = lambda x:x[1],
- reverse = True
- )
-
- 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()
-
- msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s')
- msg0 += msg1
-
- await session.send(msg0)
-
- 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
- group = session.event.group_id
- if checkNoob(user, group):
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
- )
- else:
- if checkSwitch(__plugin_name__, group):
- await session.send('ATRI正在获取P站每日排行榜前五作品...')
-
- start =time.perf_counter()
-
- try:
- dc = json.loads(request_api(URL_3))
- except:
- session.finish(errorBack('请求数据失败'))
-
- d = {}
-
- try:
- 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}']
- except:
- session.finish('处理数据失败')
-
- msg0 = (f'[CQ:at,qq={user}]')
-
- result = sorted(
- d.items(),
- key = lambda x:x[1],
- reverse = True
- )
-
- 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()
-
- 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
diff --git a/ATRI/plugins/plugin_admin/__init__.py b/ATRI/plugins/plugin_admin/__init__.py
new file mode 100644
index 0000000..3a7175c
--- /dev/null
+++ b/ATRI/plugins/plugin_admin/__init__.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import re
+
+from nonebot.plugin import on_command
+from nonebot.adapters.cqhttp import Bot, Event
+from nonebot.permission import GROUP_ADMIN, GROUP_OWNER, SUPERUSER
+
+from utils.utils_banList import banList
+from utils.utils_switch import controlSwitch
+
+import ATRI
+
+
+master = ATRI.config_SUPERUSERS
+
+
+switch = on_command('switch', permission=(SUPERUSER|GROUP_OWNER|GROUP_ADMIN))
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+
+ if banList(user, group):
+ func = str(event.message).strip()
+
+ if func:
+ pass
+ else:
+ msg0 = "-==ATRI Switch Control System==-\n"
+ msg0 += "┌Usage: switch on/off-{service}\n"
+ msg0 += "├For SUPERUSER:\n"
+ msg0 += "│ └Usage: switch all-on/off-{service}\n"
+ msg0 += "└Service:\n"
+ msg0 += " ├anime-setu\n"
+ msg0 += " ├anime-pic-search\n"
+ msg0 += " └anime-vid-search\n"
+
+ await switch.finish(msg0)
+
+ funct = re.findall(r"[on|off]-(.*)", func)
+ print(func, funct)
+
+ print(type(master[0]), type(user))
+
+ if "all-on" in func:
+ if int(user) in master:
+ await switch.finish(controlSwitch(funct[0], True))
+
+ else:
+ await switch.finish("You don't have enough permissions do THIS!")
+
+ elif "all-off" in func:
+ if int(user) in master:
+ await switch.finish(controlSwitch(funct[0], False))
+
+ else:
+ await switch.finish("You don't have enough permissions do THIS!")
+
+ elif "on" in func:
+ await switch.finish(controlSwitch(funct[0], True, group))
+
+ elif "off" in func:
+ await switch.finish(controlSwitch(funct[0], False, group))
+
+ else:
+ await switch.finish("请检查拼写是否正确嗷~~!") \ No newline at end of file
diff --git a/ATRI/plugins/animeSearch.py b/ATRI/plugins/plugin_anime/__init__.py
index 24db31d..7abf59d 100644
--- a/ATRI/plugins/animeSearch.py
+++ b/ATRI/plugins/plugin_anime/__init__.py
@@ -1,23 +1,114 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
import re
import json
-from datetime import datetime
-from random import choice
-from aiohttp import ClientSession
-from nonebot import on_command, CommandSession
+import sqlite3
+from pathlib import Path
+from random import randint
+
+from nonebot.log import logger
+from nonebot.adapters.cqhttp import Bot, Event
+from nonebot.permission import SUPERUSER
+from nonebot.plugin import on_message, on_command, on_regex
+
+from utils.utils_banList import banList
+from utils.utils_error import errorRepo
+from utils.utils_history import getMessage
+from utils.utils_switch import checkSwitch
+from utils.utils_request import aio_get_bytes, request_get
+
+from .body import resultRepo
+import ATRI
+
+
+plugin_name_0 = "anime-pic-search"
+key_SauceNAO = ATRI.key_SauceNaoKEY
+
+SaucenaoSearch = on_command('以图搜图')
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+
+ state["user"] = user
+ state["group"] = group
+
+ if banList(user, group):
+ if checkSwitch(plugin_name_0, group):
+ img = str(event.message).strip()
+
+ if img:
+ state["img_url"] = img
+ else:
+ await SaucenaoSearch.finish(f"Service-{plugin_name_0} has been closed.")
+
[email protected]("img_url", prompt="请发送一张目标图片") # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ img = state["img_url"]
+ img = re.findall(r"(http://.*?)]", img)
+
+ if len(img):
+ pass
+ else:
+ await SaucenaoSearch.reject("请发送一张目标图片,而非文字或其他非图片成分( -'`-; )")
+
+ await bot.send_msg(
+ user_id=state["user"],
+ group_id=state["group"],
+ message="别急!正在找图!"
+ )
+
+ await SaucenaoSearch.finish(resultRepo(state['user'], key_SauceNAO, img[0]))
-from ATRI.modules.time import sleepTime
-from ATRI.modules.error import errorBack
-from ATRI.modules.funcControl import checkSwitch, checkNoob
+SaucenaoSearch_repo = on_message()
-__plugin_name__ = "anime_search"
+@SaucenaoSearch_repo.handle() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+ msg = str(event.message)
+
+ if banList(user, group):
+ if checkSwitch(plugin_name_0, group):
+ if "[CQ:reply" in msg:
+ if "搜图" in msg or "识图" in msg:
+ if group == "None":
+ await SaucenaoSearch_repo.finish("ごめんなさい...\n该功能只对群聊开放哦~~")
+
+ try:
+ repo_info = re.findall(r"CQ:reply,id=([0-9]\S+)]", msg)
+ msg_id = repo_info[0]
+ except Exception:
+ logger.warning(f"Get message_id ERROR!")
+ await SaucenaoSearch_repo.finish(errorRepo('定位消息内容失败'))
+ return
+
+ aim = getMessage(msg_id)[f"{msg_id}"]["message"]
+ img = img = re.findall(r"(http://.*?)]", aim)
+
+ if len(img):
+ pass
+ else:
+ await SaucenaoSearch_repo.finish('这消息内貌似没图片呢...')
+
+ await bot.send_msg(
+ user_id=state["user"],
+ group_id=state["group"],
+ message="别急!正在找图!"
+ )
+
+ await SaucenaoSearch.finish(resultRepo(state['user'], key_SauceNAO, img[0]))
+
+ else:
+ await SaucenaoSearch.finish(f"Service-{plugin_name_0} has been closed.")
-async def get_bytes(url, headers = None):
- async with ClientSession() as asyncSession:
- async with asyncSession.get(url, headers = headers) as response:
- a = await response.read()
- return a
+plugin_name_1 = "anime-vid-search"
+
+AnimeSearch = on_command('以图搜番')
SIMPLE = "万与丑专业丛东丝丢两严丧个丬丰临为丽举么义乌乐乔习乡书买乱争于亏云亘亚产亩亲亵亸亿仅从仑仓仪们价众优伙会伛伞伟传伤伥伦伧伪伫体余佣佥侠侣侥侦侧侨侩侪侬俣俦俨俩俪俭债倾偬偻偾偿傥傧储傩儿兑兖党兰关兴兹养兽冁内冈册写军农冢冯冲决况冻净凄凉凌减凑凛几凤凫凭凯击凼凿刍划刘则刚创删别刬刭刽刿剀剂剐剑剥剧劝办务劢动励劲劳势勋勐勚匀匦匮区医华协单卖卢卤卧卫却卺厂厅历厉压厌厍厕厢厣厦厨厩厮县参叆叇双发变叙叠叶号叹叽吁后吓吕吗吣吨听启吴呒呓呕呖呗员呙呛呜咏咔咙咛咝咤咴咸哌响哑哒哓哔哕哗哙哜哝哟唛唝唠唡唢唣唤唿啧啬啭啮啰啴啸喷喽喾嗫呵嗳嘘嘤嘱噜噼嚣嚯团园囱围囵国图圆圣圹场坂坏块坚坛坜坝坞坟坠垄垅垆垒垦垧垩垫垭垯垱垲垴埘埙埚埝埯堑堕塆墙壮声壳壶壸处备复够头夸夹夺奁奂奋奖奥妆妇妈妩妪妫姗姜娄娅娆娇娈娱娲娴婳婴婵婶媪嫒嫔嫱嬷孙学孪宁宝实宠审宪宫宽宾寝对寻导寿将尔尘尧尴尸尽层屃屉届属屡屦屿岁岂岖岗岘岙岚岛岭岳岽岿峃峄峡峣峤峥峦崂崃崄崭嵘嵚嵛嵝嵴巅巩巯币帅师帏帐帘帜带帧帮帱帻帼幂幞干并广庄庆庐庑库应庙庞废庼廪开异弃张弥弪弯弹强归当录彟彦彻径徕御忆忏忧忾怀态怂怃怄怅怆怜总怼怿恋恳恶恸恹恺恻恼恽悦悫悬悭悯惊惧惨惩惫惬惭惮惯愍愠愤愦愿慑慭憷懑懒懔戆戋戏戗战戬户扎扑扦执扩扪扫扬扰抚抛抟抠抡抢护报担拟拢拣拥拦拧拨择挂挚挛挜挝挞挟挠挡挢挣挤挥挦捞损捡换捣据捻掳掴掷掸掺掼揸揽揿搀搁搂搅携摄摅摆摇摈摊撄撑撵撷撸撺擞攒敌敛数斋斓斗斩断无旧时旷旸昙昼昽显晋晒晓晔晕晖暂暧札术朴机杀杂权条来杨杩杰极构枞枢枣枥枧枨枪枫枭柜柠柽栀栅标栈栉栊栋栌栎栏树栖样栾桊桠桡桢档桤桥桦桧桨桩梦梼梾检棂椁椟椠椤椭楼榄榇榈榉槚槛槟槠横樯樱橥橱橹橼檐檩欢欤欧歼殁殇残殒殓殚殡殴毁毂毕毙毡毵氇气氢氩氲汇汉污汤汹沓沟没沣沤沥沦沧沨沩沪沵泞泪泶泷泸泺泻泼泽泾洁洒洼浃浅浆浇浈浉浊测浍济浏浐浑浒浓浔浕涂涌涛涝涞涟涠涡涢涣涤润涧涨涩淀渊渌渍渎渐渑渔渖渗温游湾湿溃溅溆溇滗滚滞滟滠满滢滤滥滦滨滩滪漤潆潇潋潍潜潴澜濑濒灏灭灯灵灾灿炀炉炖炜炝点炼炽烁烂烃烛烟烦烧烨烩烫烬热焕焖焘煅煳熘爱爷牍牦牵牺犊犟状犷犸犹狈狍狝狞独狭狮狯狰狱狲猃猎猕猡猪猫猬献獭玑玙玚玛玮环现玱玺珉珏珐珑珰珲琎琏琐琼瑶瑷璇璎瓒瓮瓯电画畅畲畴疖疗疟疠疡疬疮疯疱疴痈痉痒痖痨痪痫痴瘅瘆瘗瘘瘪瘫瘾瘿癞癣癫癯皑皱皲盏盐监盖盗盘眍眦眬着睁睐睑瞒瞩矫矶矾矿砀码砖砗砚砜砺砻砾础硁硅硕硖硗硙硚确硷碍碛碜碱碹磙礼祎祢祯祷祸禀禄禅离秃秆种积称秽秾稆税稣稳穑穷窃窍窑窜窝窥窦窭竖竞笃笋笔笕笺笼笾筑筚筛筜筝筹签简箓箦箧箨箩箪箫篑篓篮篱簖籁籴类籼粜粝粤粪粮糁糇紧絷纟纠纡红纣纤纥约级纨纩纪纫纬纭纮纯纰纱纲纳纴纵纶纷纸纹纺纻纼纽纾线绀绁绂练组绅细织终绉绊绋绌绍绎经绐绑绒结绔绕绖绗绘给绚绛络绝绞统绠绡绢绣绤绥绦继绨绩绪绫绬续绮绯绰绱绲绳维绵绶绷绸绹绺绻综绽绾绿缀缁缂缃缄缅缆缇缈缉缊缋缌缍缎缏缐缑缒缓缔缕编缗缘缙缚缛缜缝缞缟缠缡缢缣缤缥缦缧缨缩缪缫缬缭缮缯缰缱缲缳缴缵罂网罗罚罢罴羁羟羡翘翙翚耢耧耸耻聂聋职聍联聩聪肃肠肤肷肾肿胀胁胆胜胧胨胪胫胶脉脍脏脐脑脓脔脚脱脶脸腊腌腘腭腻腼腽腾膑臜舆舣舰舱舻艰艳艹艺节芈芗芜芦苁苇苈苋苌苍苎苏苘苹茎茏茑茔茕茧荆荐荙荚荛荜荞荟荠荡荣荤荥荦荧荨荩荪荫荬荭荮药莅莜莱莲莳莴莶获莸莹莺莼萚萝萤营萦萧萨葱蒇蒉蒋蒌蓝蓟蓠蓣蓥蓦蔷蔹蔺蔼蕲蕴薮藁藓虏虑虚虫虬虮虽虾虿蚀蚁蚂蚕蚝蚬蛊蛎蛏蛮蛰蛱蛲蛳蛴蜕蜗蜡蝇蝈蝉蝎蝼蝾螀螨蟏衅衔补衬衮袄袅袆袜袭袯装裆裈裢裣裤裥褛褴襁襕见观觃规觅视觇览觉觊觋觌觍觎觏觐觑觞触觯詟誉誊讠计订讣认讥讦讧讨让讪讫训议讯记讱讲讳讴讵讶讷许讹论讻讼讽设访诀证诂诃评诅识诇诈诉诊诋诌词诎诏诐译诒诓诔试诖诗诘诙诚诛诜话诞诟诠诡询诣诤该详诧诨诩诪诫诬语诮误诰诱诲诳说诵诶请诸诹诺读诼诽课诿谀谁谂调谄谅谆谇谈谊谋谌谍谎谏谐谑谒谓谔谕谖谗谘谙谚谛谜谝谞谟谠谡谢谣谤谥谦谧谨谩谪谫谬谭谮谯谰谱谲谳谴谵谶谷豮贝贞负贠贡财责贤败账货质贩贪贫贬购贮贯贰贱贲贳贴贵贶贷贸费贺贻贼贽贾贿赀赁赂赃资赅赆赇赈赉赊赋赌赍赎赏赐赑赒赓赔赕赖赗赘赙赚赛赜赝赞赟赠赡赢赣赪赵赶趋趱趸跃跄跖跞践跶跷跸跹跻踊踌踪踬踯蹑蹒蹰蹿躏躜躯车轧轨轩轪轫转轭轮软轰轱轲轳轴轵轶轷轸轹轺轻轼载轾轿辀辁辂较辄辅辆辇辈辉辊辋辌辍辎辏辐辑辒输辔辕辖辗辘辙辚辞辩辫边辽达迁过迈运还这进远违连迟迩迳迹适选逊递逦逻遗遥邓邝邬邮邹邺邻郁郄郏郐郑郓郦郧郸酝酦酱酽酾酿释里鉅鉴銮錾钆钇针钉钊钋钌钍钎钏钐钑钒钓钔钕钖钗钘钙钚钛钝钞钟钠钡钢钣钤钥钦钧钨钩钪钫钬钭钮钯钰钱钲钳钴钵钶钷钸钹钺钻钼钽钾钿铀铁铂铃铄铅铆铈铉铊铋铍铎铏铐铑铒铕铗铘铙铚铛铜铝铞铟铠铡铢铣铤铥铦铧铨铪铫铬铭铮铯铰铱铲铳铴铵银铷铸铹铺铻铼铽链铿销锁锂锃锄锅锆锇锈锉锊锋锌锍锎锏锐锑锒锓锔锕锖锗错锚锜锞锟锠锡锢锣锤锥锦锨锩锫锬锭键锯锰锱锲锳锴锵锶锷锸锹锺锻锼锽锾锿镀镁镂镃镆镇镈镉镊镌镍镎镏镐镑镒镕镖镗镙镚镛镜镝镞镟镠镡镢镣镤镥镦镧镨镩镪镫镬镭镮镯镰镱镲镳镴镶长门闩闪闫闬闭问闯闰闱闲闳间闵闶闷闸闹闺闻闼闽闾闿阀阁阂阃阄阅阆阇阈阉阊阋阌阍阎阏阐阑阒阓阔阕阖阗阘阙阚阛队阳阴阵阶际陆陇陈陉陕陧陨险随隐隶隽难雏雠雳雾霁霉霭靓静靥鞑鞒鞯鞴韦韧韨韩韪韫韬韵页顶顷顸项顺须顼顽顾顿颀颁颂颃预颅领颇颈颉颊颋颌颍颎颏颐频颒颓颔颕颖颗题颙颚颛颜额颞颟颠颡颢颣颤颥颦颧风飏飐飑飒飓飔飕飖飗飘飙飚飞飨餍饤饥饦饧饨饩饪饫饬饭饮饯饰饱饲饳饴饵饶饷饸饹饺饻饼饽饾饿馀馁馂馃馄馅馆馇馈馉馊馋馌馍馎馏馐馑馒馓馔馕马驭驮驯驰驱驲驳驴驵驶驷驸驹驺驻驼驽驾驿骀骁骂骃骄骅骆骇骈骉骊骋验骍骎骏骐骑骒骓骔骕骖骗骘骙骚骛骜骝骞骟骠骡骢骣骤骥骦骧髅髋髌鬓魇魉鱼鱽鱾鱿鲀鲁鲂鲄鲅鲆鲇鲈鲉鲊鲋鲌鲍鲎鲏鲐鲑鲒鲓鲔鲕鲖鲗鲘鲙鲚鲛鲜鲝鲞鲟鲠鲡鲢鲣鲤鲥鲦鲧鲨鲩鲪鲫鲬鲭鲮鲯鲰鲱鲲鲳鲴鲵鲶鲷鲸鲹鲺鲻鲼鲽鲾鲿鳀鳁鳂鳃鳄鳅鳆鳇鳈鳉鳊鳋鳌鳍鳎鳏鳐鳑鳒鳓鳔鳕鳖鳗鳘鳙鳛鳜鳝鳞鳟鳠鳡鳢鳣鸟鸠鸡鸢鸣鸤鸥鸦鸧鸨鸩鸪鸫鸬鸭鸮鸯鸰鸱鸲鸳鸴鸵鸶鸷鸸鸹鸺鸻鸼鸽鸾鸿鹀鹁鹂鹃鹄鹅鹆鹇鹈鹉鹊鹋鹌鹍鹎鹏鹐鹑鹒鹓鹔鹕鹖鹗鹘鹚鹛鹜鹝鹞鹟鹠鹡鹢鹣鹤鹥鹦鹧鹨鹩鹪鹫鹬鹭鹯鹰鹱鹲鹳鹴鹾麦麸黄黉黡黩黪黾鼋鼌鼍鼗鼹齄齐齑齿龀龁龂龃龄龅龆龇龈龉龊龋龌龙龚龛龟志制咨只里系范松没尝尝闹面准钟别闲干尽脏拼"
TRADITION = "萬與醜專業叢東絲丟兩嚴喪個爿豐臨為麗舉麼義烏樂喬習鄉書買亂爭於虧雲亙亞產畝親褻嚲億僅從侖倉儀們價眾優夥會傴傘偉傳傷倀倫傖偽佇體餘傭僉俠侶僥偵側僑儈儕儂俁儔儼倆儷儉債傾傯僂僨償儻儐儲儺兒兌兗黨蘭關興茲養獸囅內岡冊寫軍農塚馮衝決況凍淨淒涼淩減湊凜幾鳳鳧憑凱擊氹鑿芻劃劉則剛創刪別剗剄劊劌剴劑剮劍剝劇勸辦務勱動勵勁勞勢勳猛勩勻匭匱區醫華協單賣盧鹵臥衛卻巹廠廳曆厲壓厭厙廁廂厴廈廚廄廝縣參靉靆雙發變敘疊葉號歎嘰籲後嚇呂嗎唚噸聽啟吳嘸囈嘔嚦唄員咼嗆嗚詠哢嚨嚀噝吒噅鹹呱響啞噠嘵嗶噦嘩噲嚌噥喲嘜嗊嘮啢嗩唕喚呼嘖嗇囀齧囉嘽嘯噴嘍嚳囁嗬噯噓嚶囑嚕劈囂謔團園囪圍圇國圖圓聖壙場阪壞塊堅壇壢壩塢墳墜壟壟壚壘墾坰堊墊埡墶壋塏堖塒塤堝墊垵塹墮壪牆壯聲殼壺壼處備復夠頭誇夾奪奩奐奮獎奧妝婦媽嫵嫗媯姍薑婁婭嬈嬌孌娛媧嫻嫿嬰嬋嬸媼嬡嬪嬙嬤孫學孿寧寶實寵審憲宮寬賓寢對尋導壽將爾塵堯尷屍盡層屭屜屆屬屢屨嶼歲豈嶇崗峴嶴嵐島嶺嶽崠巋嶨嶧峽嶢嶠崢巒嶗崍嶮嶄嶸嶔崳嶁脊巔鞏巰幣帥師幃帳簾幟帶幀幫幬幘幗冪襆幹並廣莊慶廬廡庫應廟龐廢廎廩開異棄張彌弳彎彈強歸當錄彠彥徹徑徠禦憶懺憂愾懷態慫憮慪悵愴憐總懟懌戀懇惡慟懨愷惻惱惲悅愨懸慳憫驚懼慘懲憊愜慚憚慣湣慍憤憒願懾憖怵懣懶懍戇戔戲戧戰戩戶紮撲扡執擴捫掃揚擾撫拋摶摳掄搶護報擔擬攏揀擁攔擰撥擇掛摯攣掗撾撻挾撓擋撟掙擠揮撏撈損撿換搗據撚擄摑擲撣摻摜摣攬撳攙擱摟攪攜攝攄擺搖擯攤攖撐攆擷擼攛擻攢敵斂數齋斕鬥斬斷無舊時曠暘曇晝曨顯晉曬曉曄暈暉暫曖劄術樸機殺雜權條來楊榪傑極構樅樞棗櫪梘棖槍楓梟櫃檸檉梔柵標棧櫛櫳棟櫨櫟欄樹棲樣欒棬椏橈楨檔榿橋樺檜槳樁夢檮棶檢欞槨櫝槧欏橢樓欖櫬櫚櫸檟檻檳櫧橫檣櫻櫫櫥櫓櫞簷檁歡歟歐殲歿殤殘殞殮殫殯毆毀轂畢斃氈毿氌氣氫氬氳彙漢汙湯洶遝溝沒灃漚瀝淪滄渢溈滬濔濘淚澩瀧瀘濼瀉潑澤涇潔灑窪浹淺漿澆湞溮濁測澮濟瀏滻渾滸濃潯濜塗湧濤澇淶漣潿渦溳渙滌潤澗漲澀澱淵淥漬瀆漸澠漁瀋滲溫遊灣濕潰濺漵漊潷滾滯灩灄滿瀅濾濫灤濱灘澦濫瀠瀟瀲濰潛瀦瀾瀨瀕灝滅燈靈災燦煬爐燉煒熗點煉熾爍爛烴燭煙煩燒燁燴燙燼熱煥燜燾煆糊溜愛爺牘犛牽犧犢強狀獷獁猶狽麅獮獰獨狹獅獪猙獄猻獫獵獼玀豬貓蝟獻獺璣璵瑒瑪瑋環現瑲璽瑉玨琺瓏璫琿璡璉瑣瓊瑤璦璿瓔瓚甕甌電畫暢佘疇癤療瘧癘瘍鬁瘡瘋皰屙癰痙癢瘂癆瘓癇癡癉瘮瘞瘺癟癱癮癭癩癬癲臒皚皺皸盞鹽監蓋盜盤瞘眥矓著睜睞瞼瞞矚矯磯礬礦碭碼磚硨硯碸礪礱礫礎硜矽碩硤磽磑礄確鹼礙磧磣堿镟滾禮禕禰禎禱禍稟祿禪離禿稈種積稱穢穠穭稅穌穩穡窮竊竅窯竄窩窺竇窶豎競篤筍筆筧箋籠籩築篳篩簹箏籌簽簡籙簀篋籜籮簞簫簣簍籃籬籪籟糴類秈糶糲粵糞糧糝餱緊縶糸糾紆紅紂纖紇約級紈纊紀紉緯紜紘純紕紗綱納紝縱綸紛紙紋紡紵紖紐紓線紺絏紱練組紳細織終縐絆紼絀紹繹經紿綁絨結絝繞絰絎繪給絢絳絡絕絞統綆綃絹繡綌綏絛繼綈績緒綾緓續綺緋綽緔緄繩維綿綬繃綢綯綹綣綜綻綰綠綴緇緙緗緘緬纜緹緲緝縕繢緦綞緞緶線緱縋緩締縷編緡緣縉縛縟縝縫縗縞纏縭縊縑繽縹縵縲纓縮繆繅纈繚繕繒韁繾繰繯繳纘罌網羅罰罷羆羈羥羨翹翽翬耮耬聳恥聶聾職聹聯聵聰肅腸膚膁腎腫脹脅膽勝朧腖臚脛膠脈膾髒臍腦膿臠腳脫腡臉臘醃膕齶膩靦膃騰臏臢輿艤艦艙艫艱豔艸藝節羋薌蕪蘆蓯葦藶莧萇蒼苧蘇檾蘋莖蘢蔦塋煢繭荊薦薘莢蕘蓽蕎薈薺蕩榮葷滎犖熒蕁藎蓀蔭蕒葒葤藥蒞蓧萊蓮蒔萵薟獲蕕瑩鶯蓴蘀蘿螢營縈蕭薩蔥蕆蕢蔣蔞藍薊蘺蕷鎣驀薔蘞藺藹蘄蘊藪槁蘚虜慮虛蟲虯蟣雖蝦蠆蝕蟻螞蠶蠔蜆蠱蠣蟶蠻蟄蛺蟯螄蠐蛻蝸蠟蠅蟈蟬蠍螻蠑螿蟎蠨釁銜補襯袞襖嫋褘襪襲襏裝襠褌褳襝褲襇褸襤繈襴見觀覎規覓視覘覽覺覬覡覿覥覦覯覲覷觴觸觶讋譽謄訁計訂訃認譏訐訌討讓訕訖訓議訊記訒講諱謳詎訝訥許訛論訩訟諷設訪訣證詁訶評詛識詗詐訴診詆謅詞詘詔詖譯詒誆誄試詿詩詰詼誠誅詵話誕詬詮詭詢詣諍該詳詫諢詡譸誡誣語誚誤誥誘誨誑說誦誒請諸諏諾讀諑誹課諉諛誰諗調諂諒諄誶談誼謀諶諜謊諫諧謔謁謂諤諭諼讒諮諳諺諦謎諞諝謨讜謖謝謠謗諡謙謐謹謾謫譾謬譚譖譙讕譜譎讞譴譫讖穀豶貝貞負貟貢財責賢敗賬貨質販貪貧貶購貯貫貳賤賁貰貼貴貺貸貿費賀貽賊贄賈賄貲賃賂贓資賅贐賕賑賚賒賦賭齎贖賞賜贔賙賡賠賧賴賵贅賻賺賽賾贗讚贇贈贍贏贛赬趙趕趨趲躉躍蹌蹠躒踐躂蹺蹕躚躋踴躊蹤躓躑躡蹣躕躥躪躦軀車軋軌軒軑軔轉軛輪軟轟軲軻轤軸軹軼軤軫轢軺輕軾載輊轎輈輇輅較輒輔輛輦輩輝輥輞輬輟輜輳輻輯轀輸轡轅轄輾轆轍轔辭辯辮邊遼達遷過邁運還這進遠違連遲邇逕跡適選遜遞邐邏遺遙鄧鄺鄔郵鄒鄴鄰鬱郤郟鄶鄭鄆酈鄖鄲醞醱醬釅釃釀釋裏钜鑒鑾鏨釓釔針釘釗釙釕釷釺釧釤鈒釩釣鍆釹鍚釵鈃鈣鈈鈦鈍鈔鍾鈉鋇鋼鈑鈐鑰欽鈞鎢鉤鈧鈁鈥鈄鈕鈀鈺錢鉦鉗鈷缽鈳鉕鈽鈸鉞鑽鉬鉭鉀鈿鈾鐵鉑鈴鑠鉛鉚鈰鉉鉈鉍鈹鐸鉶銬銠鉺銪鋏鋣鐃銍鐺銅鋁銱銦鎧鍘銖銑鋌銩銛鏵銓鉿銚鉻銘錚銫鉸銥鏟銃鐋銨銀銣鑄鐒鋪鋙錸鋱鏈鏗銷鎖鋰鋥鋤鍋鋯鋨鏽銼鋝鋒鋅鋶鐦鐧銳銻鋃鋟鋦錒錆鍺錯錨錡錁錕錩錫錮鑼錘錐錦鍁錈錇錟錠鍵鋸錳錙鍥鍈鍇鏘鍶鍔鍤鍬鍾鍛鎪鍠鍰鎄鍍鎂鏤鎡鏌鎮鎛鎘鑷鐫鎳鎿鎦鎬鎊鎰鎔鏢鏜鏍鏰鏞鏡鏑鏃鏇鏐鐔钁鐐鏷鑥鐓鑭鐠鑹鏹鐙鑊鐳鐶鐲鐮鐿鑔鑣鑞鑲長門閂閃閆閈閉問闖閏闈閑閎間閔閌悶閘鬧閨聞闥閩閭闓閥閣閡閫鬮閱閬闍閾閹閶鬩閿閽閻閼闡闌闃闠闊闋闔闐闒闕闞闤隊陽陰陣階際陸隴陳陘陝隉隕險隨隱隸雋難雛讎靂霧霽黴靄靚靜靨韃鞽韉韝韋韌韍韓韙韞韜韻頁頂頃頇項順須頊頑顧頓頎頒頌頏預顱領頗頸頡頰頲頜潁熲頦頤頻頮頹頷頴穎顆題顒顎顓顏額顳顢顛顙顥纇顫顬顰顴風颺颭颮颯颶颸颼颻飀飄飆飆飛饗饜飣饑飥餳飩餼飪飫飭飯飲餞飾飽飼飿飴餌饒餉餄餎餃餏餅餑餖餓餘餒餕餜餛餡館餷饋餶餿饞饁饃餺餾饈饉饅饊饌饢馬馭馱馴馳驅馹駁驢駔駛駟駙駒騶駐駝駑駕驛駘驍罵駰驕驊駱駭駢驫驪騁驗騂駸駿騏騎騍騅騌驌驂騙騭騤騷騖驁騮騫騸驃騾驄驏驟驥驦驤髏髖髕鬢魘魎魚魛魢魷魨魯魴魺鮁鮃鯰鱸鮋鮓鮒鮊鮑鱟鮍鮐鮭鮚鮳鮪鮞鮦鰂鮜鱠鱭鮫鮮鮺鯗鱘鯁鱺鰱鰹鯉鰣鰷鯀鯊鯇鮶鯽鯒鯖鯪鯕鯫鯡鯤鯧鯝鯢鯰鯛鯨鯵鯴鯔鱝鰈鰏鱨鯷鰮鰃鰓鱷鰍鰒鰉鰁鱂鯿鰠鼇鰭鰨鰥鰩鰟鰜鰳鰾鱈鱉鰻鰵鱅鰼鱖鱔鱗鱒鱯鱤鱧鱣鳥鳩雞鳶鳴鳲鷗鴉鶬鴇鴆鴣鶇鸕鴨鴞鴦鴒鴟鴝鴛鴬鴕鷥鷙鴯鴰鵂鴴鵃鴿鸞鴻鵐鵓鸝鵑鵠鵝鵒鷳鵜鵡鵲鶓鵪鶤鵯鵬鵮鶉鶊鵷鷫鶘鶡鶚鶻鶿鶥鶩鷊鷂鶲鶹鶺鷁鶼鶴鷖鸚鷓鷚鷯鷦鷲鷸鷺鸇鷹鸌鸏鸛鸘鹺麥麩黃黌黶黷黲黽黿鼂鼉鞀鼴齇齊齏齒齔齕齗齟齡齙齠齜齦齬齪齲齷龍龔龕龜誌製谘隻裡係範鬆冇嚐嘗鬨麵準鐘彆閒乾儘臟拚"
@@ -52,80 +143,186 @@ def toSimpleString(str):
return "".join(output_str_list)
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
-@on_command('anime_search', aliases = ['以图搜番'], only_to_me = False)
-async def AnimeSearch(session: CommandSession):
- user = session.event.user_id
- group = session.event.group_id
- msg = session.current_arg.strip()
-
- if checkNoob(user, group):
- if sleepTime():
- await session.send(sleepTime())
+ state["user"] = user
+ state["group"] = group
+
+ if banList(user, group):
+ if checkSwitch(plugin_name_1, group):
+ img = str(event.message).strip()
+
+ if img:
+ state["img_url"] = img
else:
- if checkSwitch(__plugin_name__, group):
- if not msg:
- msg = session.get('message', prompt = "请发送一张图片")
+ await AnimeSearch.finish(f"Service-{plugin_name_1} has been closed.")
+
[email protected]("img_url", prompt="请发送一张目标图片") # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ img = state["img_url"]
+ img = re.findall(r"(http://.*?)]", img)
+
+ if len(img):
+ pass
+ else:
+ await SaucenaoSearch.reject("请发送一张目标图片,而非文字或其他非图片成分( -'`-; )")
+
+ await bot.send_msg(
+ user_id=state["user"],
+ group_id=state["group"],
+ message="别急!正在搜索!"
+ )
+
+ URL = f'https://trace.moe/api/search?url={img[0]}'
+ try:
+ req = await aio_get_bytes(URL)
+ except:
+ await AnimeSearch.finish(errorRepo("请求数据失败"))
+
+ data = json.loads(req.decode()) # type: ignore
+
+ try:
+ d = {}
+
+ for i in range(len(data['docs'])):
+ if data['docs'][i]['title_chinese'] in d:
+ d[data['docs'][i]['title_chinese']][0] += data['docs'][i]['similarity']
+
+ else:
+ m = data['docs'][i]['at']/60
+ s = data['docs'][i]['at']%60
+
+ if data['docs'][i]['episode'] == '':
+ n = 1
- await session.send("开始以图搜番\n(如搜索时间过长或无反应则为图片格式有问题)")
+ else:
+ n = data['docs'][i]['episode']
+
+ d[toSimpleString(data['docs'][i]['title_chinese'])] = [data['docs'][i]['similarity'],f'第{n}集',f'{int(m)}分{int(s)}秒处']
+ except:
+ await AnimeSearch.finish(errorRepo("处理数据失败"))
+
+ result = sorted(
+ d.items(), # type: ignore
+ key=lambda x:x[1],
+ reverse=True)
+
+ t = 0
+ msg0 = f'[CQ:at,qq={state["user"]}]\n根据所提供的图片按照相似度找到{len(d)}个结果:' # type: ignore
+
+ 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 AnimeSearch.finish(msg0)
- p = '\\[CQ\\:image\\,file\\=.*?\\,url\\=(.*?)\\]'
- img = re.findall(p, msg)
+plugin_name_2 = "anime-setu"
+key_LoliconAPI = ATRI.key_LoliconAPI
+setu_type = 1 # setu-type: 1(local), 2(url: https://api.lolicon.app/#/setu) default: 1(local)
- if img:
- URL = f'https://trace.moe/api/search?url={img[0]}'
+setu = on_regex(r"来[点丶张份副个幅][涩色瑟][图圖]|[涩色瑟][图圖]来|[涩色瑟][图圖][gkd|GKD|搞快点]|[gkd|GKD|搞快点][涩色瑟][图圖]")
- try:
- req = await get_bytes(URL)
- except:
- session.finish(errorBack('请求数据失败'))
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
- data = json.loads(req.decode())
+ if banList(user, group):
+ if checkSwitch(plugin_name_2, group):
- try:
- d = {}
-
- 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
-
- 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)}秒处']
- except:
- session.finish(errorBack('处理数据失败'))
-
- result = sorted(
- d.items(),
- key = lambda x:x[1],
- reverse = True
- )
+ await bot.send_msg(
+ user_id=int(user),
+ group_id=int(group),
+ message="别急!正在找图!"
+ )
- t = 0
+ res = randint(1,5)
- msg0 = f'[CQ:at,qq={user}]\n根据所提供的图片按照相似度找到{len(d)}个结果:'
+ if setu_type == 1:
- 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
+ con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / 'nearR18.db')
+ cur = con.cursor()
+ msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;')
+
+ for i in msg:
+ pid = i[0]
+ title = i[1]
+ img = i[7]
- await session.send(msg0)
+ msg0 = f"setu info:\n"
+ msg0 += f"Title: {title}\n"
+ msg0 += f"Pid: {pid}\n"
+ msg0 += f"{img}"
+
+ if 1 <= res < 5:
+ await setu.finish(msg0)
+
+ elif res == 5:
+ await bot.send_msg(
+ user_id=int(user),
+ group_id=int(group),
+ message="我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆"
+ )
+
+ await bot.send_msg(
+ user_id=ATRI.config_SUPERUSERS,
+ message=f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{img}"
+ )
else:
- session.finish('该功能已关闭...')
+ params = {
+ "apikey": key_LoliconAPI,
+ "r18": "0",
+ "num": "1"
+ }
+
+ try:
+ data = json.loads(request_get('https://api.lolicon.app/setu/', params))
+ except Exception:
+ await setu.finish(errorRepo("请求数据失败,也可能为接口调用次数达上限"))
+
+ msg0 = f"setu info:"
+ msg0 += f'Title: {data["data"][0]["title"]}' # type: ignore
+ msg0 += f'Pid: {data["data"][0]["pid"]}' # type: ignore
+ msg0 += f'{data["data"][0]["url"]}' # type: ignore
+
+ await setu.finish(msg0)
+
+ else:
+ await setu.finish(f"Service-{plugin_name_2} has been closed.")
+
+setuType = on_command("setu-type", permission=SUPERUSER)
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ global setu_type
+ msg = str(event.message).strip()
+
+ if msg:
+ pass
+ else:
+ msg0 = "-==Setu Type Control System==-\n"
+ msg0 += "**Tips: For SUPERUSERS**\n"
+ msg0 += "┌Usage: setu-type {type}\n"
+ msg0 += "└Type:\n"
+ msg0 += " ├local\n"
+ msg0 += " └url"
-async def _(session: CommandSession):
- if not session.is_first_run and session.current_arg.startswith('算了'):
- session.switch(session.current_arg[len('算了'):]) \ No newline at end of file
+ await setuType.finish(msg0)
+
+ if msg == "local":
+ setu_type = 1
+
+ elif msg == "url":
+ setu_type = 2
+
+ else:
+ await setuType.finish("请检查类型是否输入正确嗷!")
+
+ await setuType.finish("Type conversion completed!")
diff --git a/ATRI/plugins/plugin_anime/body.py b/ATRI/plugins/plugin_anime/body.py
new file mode 100644
index 0000000..02c57bb
--- /dev/null
+++ b/ATRI/plugins/plugin_anime/body.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import json
+
+from utils.utils_error import errorRepo
+from utils.utils_request import request_get
+
+class SauceNAO:
+
+ def __init__(self, api_key, output_type=2, testmode=0, dbmask=None, dbmaski=32768, db=5, numres=1):
+ api = 'https://saucenao.com/search.php'
+ self.api = api
+ params = dict()
+ params['api_key'] = api_key
+ params['output_type'] = output_type
+ params['testmode'] = testmode
+ params['dbmask'] = dbmask
+ params['dbmaski'] = dbmaski
+ params['db'] = db
+ params['numres'] = numres
+ self.params = params
+
+ def search(self, url):
+ self.params['url'] = url
+ return request_get(self.api, self.params)
+
+def resultRepo(user: str, key: str, img_url: str):
+ try:
+ task = SauceNAO(key)
+ data = task.search(img_url)
+ except Exception:
+ return errorRepo('请求数据失败')
+
+ data = json.loads(data)['results'][0]
+ msg0 = ''
+ print(data)
+
+ msg0 += f'[CQ:at,qq={user}]\n'
+ msg0 += f"SauceNAO INFO:\n"
+ msg0 += f"[CQ:image,file={data['header'].get('thumbnail', None)}]\n"
+ msg0 += f"Like:{data['header'].get('similarity', 0)}%\n"
+ msg0 += f"Title:{data['data'].get('title', None)}\n"
+ msg0 += f"Pixiv ID:{data['data'].get('pixiv_id', None)}\n"
+ msg0 += f"Author:{data['data'].get('member_name', None)}\n"
+ msg0 += f"Autoor ID:{data['data'].get('member_id', None)}\n"
+ msg0 += f"Pixiv URL: https://www.pixiv.net/artworks/{data['data'].get('pixiv_id', None)}\n"
+ msg0 += f"Pic URL: https://pixiv.cat/{data['data'].get('pixiv_id', None)}.jpg"
+
+ if float(data['header'].get('similarity', 0)) < 65:
+ msg0 += '注:相似率小于65%不一定正确'
+
+ return msg0 \ No newline at end of file
diff --git a/ATRI/plugins/plugin_chat/__init__.py b/ATRI/plugins/plugin_chat/__init__.py
new file mode 100644
index 0000000..6fd7099
--- /dev/null
+++ b/ATRI/plugins/plugin_chat/__init__.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from nonebot.log import logger
+from nonebot.plugin import on_message
+from nonebot.adapters.cqhttp import Bot, Event
+
+from utils.utils_history import saveMessage
+
+
+MessageSave = on_message()
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+ message = str(event.message)
+ message_id = str(event.id)
+
+ if group == "None":
+ saveMessage(message_id, message, user)
+ else:
+ saveMessage(message_id, message, user, group)
+
+ logger.opt(colors=True).info(f"[<yellow>{group}</yellow>]-U: (<blue>{user}</blue>) | Message: (<green>{message}</green>) Saved successfully") \ No newline at end of file
diff --git a/ATRI/plugins/plugin_rich/__init__.py b/ATRI/plugins/plugin_rich/__init__.py
new file mode 100644
index 0000000..2639188
--- /dev/null
+++ b/ATRI/plugins/plugin_rich/__init__.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import re
+import json
+import requests
+from datetime import datetime
+
+from nonebot.log import logger
+from nonebot.plugin import on_message
+from nonebot.adapters.cqhttp import Bot, Event
+
+from utils.utils_banList import banList
+from utils.utils_request import request_get
+
+from .body import dec, enc
+
+
+BILI_REPORT_FORMAT = """[{aid}] Info:
+Title: {title}
+bid: {bid}
+Viev: {view} Like: {like}
+Coin: {coin} Share: {share}
+Link:
+{aid_link}
+{bid_link}"""
+
+bilibiliRich = on_message()
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+
+ if banList(user, group):
+ msg = str(event.message)
+
+ if "qqdocurl" not in msg:
+ try:
+ bv = re.findall(r"(BV\w+)", msg)
+ except:
+ return
+ else:
+ bvURL = re.findall(r"(........b23...\S+\=)", msg)
+
+ try:
+ r = requests.get(bvURL[0], stream=True, allow_redirects = True)
+ except:
+ logger.waring("Get BV ERROR. (Request ERROR)")
+ return
+
+ bv = re.findall(r"(BV\w+)", r.url)
+
+ if bv:
+ aid = str(dec(bv[0]))
+ ad = 'av' + aid
+ URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'
+
+ try:
+ res = request_get(URL)
+ except:
+ logger.waring("Request ERROR")
+ return
+
+ data = json.loads(res)
+ msg = BILI_REPORT_FORMAT.format(
+ title = data["data"]["title"],
+
+ view = data["data"]["stat"]["view"],
+ coin = data["data"]["stat"]["coin"],
+ share = data["data"]["stat"]["share"],
+ like = data["data"]["stat"]["like"],
+
+ bid = data["data"]["bvid"],
+ bid_link = data["data"]["short_link"],
+
+ aid = ad,
+ aid_link = f'https://b23.tv/{ad}'
+ )
+
+ await bilibiliRich.finish(msg)
+
+ else:
+ return
+
+
+CLOUDMUSIC_REPORT_FORMAT = """Status: {status}
+Song id: {id}
+Br: {br}
+Download: {url}
+MD5: {md5}"""
+
+cloudmusicRich = on_message()
+
[email protected]() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+
+ if banList(user, group):
+ msg = str(event.message)
+
+ if "music.163.com" in msg:
+ music_id = re.findall(r"song\S+\/|id=\S+\&", 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'
+
+ try:
+ res = request_get(URL)
+ except:
+ logger.waring("Request ERROR")
+ return
+
+ data = json.loads(res)
+ msg = CLOUDMUSIC_REPORT_FORMAT.format(
+ status = data["code"],
+ id = data["data"][0]["id"],
+ br = data["data"][0]["br"],
+ url = data["data"][0]["url"],
+ md5 = data["data"][0]["md5"],
+ )
+
+ await cloudmusicRich.finish(msg)
+
+ else:
+ return
diff --git a/ATRI/plugins/plugin_rich/body.py b/ATRI/plugins/plugin_rich/body.py
new file mode 100644
index 0000000..2c743c0
--- /dev/null
+++ b/ATRI/plugins/plugin_rich/body.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'
+tr={}
+for i in range(58):
+ tr[table[i]]=i
+s=[11,10,3,8,4,6]
+xor=177451812
+add=8728348608
+
+def dec(x) -> int:
+ r=0
+ for i in range(6):
+ r+=tr[x[s[i]]]*58**i
+ return (r-add)^xor
+
+def enc(x) -> str:
+ x=(x^xor)+add
+ r=list('BV1 4 1 7 ')
+ for i in range(6):
+ r[s[i]]=table[x//58**i%58]
+ return ''.join(r) \ No newline at end of file
diff --git a/ATRI/plugins/plugin_status/__init__.py b/ATRI/plugins/plugin_status/__init__.py
new file mode 100644
index 0000000..ddd9e60
--- /dev/null
+++ b/ATRI/plugins/plugin_status/__init__.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import psutil
+import sqlite3
+from pathlib import Path
+
+from nonebot.plugin import on_command
+from nonebot.adapters.cqhttp import Bot, Event
+
+from utils.utils_banList import banList
+from utils.utils_error import errorRepo
+
+
+status_info = on_command('status')
+
+@status_info.handle() # type: ignore
+async def _(bot: Bot, event: Event, state: dict) -> None:
+ user = str(event.user_id)
+ group = str(event.group_id)
+
+ if banList(user, group):
+ msg = str(event.message).strip()
+
+ if msg:
+ pass
+ else:
+ msg0 = "States parameter:\n"
+ msg0 += "- info\n"
+ msg0 += "- sqlite\n"
+ msg0 += "DEMO: status info"
+
+ await status_info.finish(msg0)
+
+ if msg == "info":
+ try:
+ cpu = psutil.cpu_percent(interval=1)
+ memory = psutil.virtual_memory().percent
+ disk = psutil.disk_usage('/').percent
+ inteSENT = psutil.net_io_counters().bytes_sent # type: ignore
+ inteRECV = psutil.net_io_counters().bytes_recv # type: ignore
+ except:
+ await status_info.finish(errorRepo("读取系统状态失败"))
+
+ status = "アトリは、高性能ですから!"
+
+ if cpu > 80: # type: ignore
+ status = 'ATRI感觉头有点晕...'
+ if memory > 80: # type: ignore
+ status = 'ATRI感觉有点头晕并且有点累...'
+ elif disk > 80: # type: ignore
+ status = 'ATRI感觉身体要被塞满了...'
+
+ msg0 = "ATRI status-info:\n"
+ msg0 += f"* CPU: {cpu}%\n" # type: ignore
+ msg0 += f"* MEM: {memory}%\n" # type: ignore
+ msg0 += f"* Disk {disk}%\n" # type: ignore
+ msg0 += f"* BytesSENT: {inteSENT}\n" # type: ignore
+ msg0 += f"* BytesRECV: {inteRECV}\n" # type: ignore
+ msg0 += status
+
+ await status_info.finish(msg0)
+
+ elif msg == "sqlite":
+ con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / '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' / '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' / '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' / 'data_Sqlite' / 'cloudmusic' / 'cloudmusic.db') # cloudmusic
+ cur = con.cursor()
+ cur.execute("select * from cloudmusic")
+ data_cloudmusic = len(cur.fetchall())
+ con.close()
+
+ msg0 = "ATRI status-sqlite:\n"
+ msg0 += "Setu:\n"
+ msg0 += f"│ │ └ normal: {data_normal}\n"
+ msg0 += f"│ └ nearR18: {data_nearR18}\n"
+ msg0 += f"└ R18: {data_r18}\n"
+ msg0 += "CloudMusic:\n"
+ msg0 += f"└ Message: {data_cloudmusic}"
+
+ await status_info.finish(msg0) \ No newline at end of file
diff --git a/ATRI/plugins/richBISS.py b/ATRI/plugins/richBISS.py
deleted file mode 100644
index 88d4277..0000000
--- a/ATRI/plugins/richBISS.py
+++ /dev/null
@@ -1,137 +0,0 @@
-import re
-import json
-import nonebot
-from datetime import datetime
-
-from ATRI.modules.response import request_api
-from ATRI.modules.funcControl import checkNoob
-
-
-bot = nonebot.get_bot()
-
-def now_time():
- now_ = datetime.now()
- hour = now_.hour
- minute = now_.minute
- now = hour + minute / 60
- return now
-
-
-BILI_REPORT_FORMAT = """[{aid}] Info:
-Title: {title}
-bid: {bid}
-Viev: {view} Like: {like}
-Coin: {coin} Share: {share}
-Link:
-{aid_link}
-{bid_link}"""
-
-table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'
-tr={}
-for i in range(58):
- tr[table[i]]=i
-s=[11,10,3,8,4,6]
-xor=177451812
-add=8728348608
-
-def dec(x):
- r=0
- for i in range(6):
- r+=tr[x[s[i]]]*58**i
- return (r-add)^xor
-
-def enc(x):
- x=(x^xor)+add
- r=list('BV1 4 1 7 ')
- for i in range(6):
- r[s[i]]=table[x//58**i%58]
- return ''.join(r)
-
-
[email protected]_message("group")
-async def Fuck_bili_rich(context):
- user = str(context["user_id"])
- group = context["group_id"]
- if checkNoob(user, group):
- 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('?', '')
- print(bv)
-
- aid = str(dec(bv))
- ad = 'av' + aid
- URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'
-
- try:
- res = 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"],
-
- bid = mg["data"]["bvid"],
- bid_link = mg["data"]["short_link"],
-
- aid = ad,
- aid_link = f'https://b23.tv/{ad}'
- )
-
- await bot.send_msg( # type: ignore
- group_id = group,
- message = msg
- )
- except:
- pass
-
-
-REPORT_FORMAT = """Status: {status}
-Song id: {id}
-Br: {br}
-Download: {url}
-MD5: {md5}"""
-
[email protected]_message("group")
-async def Fuck_CloudMusic(context):
- user = str(context["user_id"])
- group = context["group_id"]
- if checkNoob(user, group):
- 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 = 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
deleted file mode 100644
index 1ec164d..0000000
--- a/ATRI/plugins/send.py
+++ /dev/null
@@ -1,125 +0,0 @@
-import time
-import json
-from pathlib import Path
-import nonebot
-from nonebot.helpers import send_to_superusers
-from nonebot import on_command, CommandSession
-
-import config
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-
-
-@on_command('send_all_group', aliases = ['公告', '群发', '推送'], only_to_me=False)
-async def send_all_group(session: CommandSession):
- if session.event.user_id in master:
- msg = session.current_arg.strip()
-
- 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='请告诉吾辈需要群发的内容~!')
-
- group_list = await session.bot.get_group_list() # type: ignore
- g_list = len(group_list)
-
- for group in group_list:
-
- if group['group_id'] not in ban_group:
-
- try:
- await bot.send_group_msg(group_id = group['group_id'], message = msg) # type: ignore
-
- except:
- pass
-
- end = time.perf_counter()
-
- 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()
-
-# 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('发送失败,请重试')
-
-# else:
-# try:
-# await bot.send_group_msg(group_id = group, message = msg) # type: ignore
-# except:
-# await session.send('发送失败,请重试')
-
-# await session.send('推送完成!')
-
-
-@on_command('send_all_friend', aliases = ['全体用户'], only_to_me = False)
-async def send_all_friend(session: CommandSession):
- if session.event.user_id in master:
- msg = session.current_arg.strip()
-
- start = time.perf_counter()
-
- if not msg:
- msg = session.get('message', prompt='请告诉吾辈需要群发的内容~!')
-
- friend_list = await session.bot.get_friend_list() # type: ignore
- print(friend_list)
- f_list = len(friend_list)
- try:
- await send_all_friend(user_id = friend['user_id'], message = msg) # type: ignore
-
- except:
- await send_to_superusers(bot, f"推送时部分失败了呢") # type: ignore
-
- end = time.perf_counter()
-
- 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()
-
-# if not msg:
-# msg = session.get('message', prompt='请告诉吾辈完整内容呢...\n例:对QQ 12345647(QQ号) message')
-
-# lg = msg.split(' ')
-
-# qq = lg[0]
-# msg = lg[1]
-
-# 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
diff --git a/ATRI/plugins/switch.py b/ATRI/plugins/switch.py
deleted file mode 100644
index e9b04c5..0000000
--- a/ATRI/plugins/switch.py
+++ /dev/null
@@ -1,193 +0,0 @@
-import os
-import json
-import nonebot
-from nonebot import on_command, CommandSession
-from pathlib import Path
-
-from nonebot.permission import GROUP_ADMIN
-
-import config
-
-
-bot = nonebot.get_bot()
-master = config.SUPERUSERS
-
-
-@on_command('switch', aliases = ['on', 'off'], only_to_me = False, permission = GROUP_ADMIN)
-async def _(session: CommandSession):
- group = session.event.group_id
- try:
- with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'switch.json', 'r') as f:
- data = json.load(f)
- except:
- try:
- os.mkdir(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}')
- except:
- pass
- data = {}
- data["pixiv_seach_img"] = "on"
- data["pixiv_seach_author"] = "on"
- data["pixiv_daily_rank"] = "on"
- data["setu"] = "on"
- data["setu_img"] = "on"
- data["anime_search"] = "on"
- data["change_face"] = "on"
- data["chouYou"] = "on"
- data["saucenao_search"] = "on"
- with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'switch.json', 'w') as f:
- f.write(json.dumps(data))
- f.close()
-
-
- command = session.event.raw_message.split(' ', 1)
- switch = command[0]
- com = command[1]
- print(command)
-
- if switch == 'on':
- if com == 'PixivSearchIMG':
- data["pixiv_seach_img"] = "on"
-
- elif com == 'PixivSearchAuthor':
- data["pixiv_seach_author"] = "on"
-
- elif com == 'PixivRank':
- data["pixiv_daily_rank"] = "on"
-
- elif com == 'Setu':
- data["setu"] = "on"
-
- elif com == 'SetuIMG':
- data["setu_img"] = "on"
-
- elif com == "AnimeSearch":
- data["anime_search"] = "on"
-
- elif com == 'AIchFace':
- data["change_face"] = "on"
-
- elif com == 'Kyaru':
- data["chouYou"] = "on"
-
- elif com == 'SauceNAO':
- data["saucenao_search"] = "on"
-
- else:
- session.finish('未找到此功能...请检查拼写奥...')
-
- elif switch == 'off':
- if com == 'PixivSearchIMG':
- data["pixiv_seach_img"] = "off"
-
- elif com == 'PixivSearchAuthor':
- data["pixiv_seach_author"] = "off"
-
- elif com == 'PixivRank':
- data["pixiv_daily_rank"] = "off"
-
- elif com == 'Setu':
- data["setu"] = "off"
-
- elif com == 'SetuIMG':
- data["setu_img"] = "off"
-
- elif com == "AnimeSearch":
- data["anime_search"] = "off"
-
- elif com == 'AIchFace':
- data["change_face"] = "off"
-
- elif com == 'Kyaru':
- data["chouYou"] = "off"
-
- elif com == 'SauceNAO':
- data["saucenao_search"] = "off"
-
- else:
- session.finish('未找到此功能...请检查拼写奥...')
-
- f2 = open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'switch.json', 'w')
- f2.write(json.dumps(data))
- f2.close()
-
- await session.send('Success!')
-
-
-@on_command('allSwitch', aliases = ['allon', 'alloff'], only_to_me = False)
-async def _(session: CommandSession):
- if session.event.user_id in master:
- with open(Path('.') / 'ATRI' / 'modules' / 'funcControl' / 'ALLswitch.json', 'r') as f:
- data = json.load(f)
-
- command = session.event.raw_message.split(' ', 1)
- switch = command[0]
- com = command[1]
- print(command)
-
- if switch == 'on':
- if com == 'PixivSearchIMG':
- data["pixiv_seach_img"] = "on"
-
- elif com == 'PixivSearchAuthor':
- data["pixiv_seach_author"] = "on"
-
- elif com == 'PixivRank':
- data["pixiv_daily_rank"] = "on"
-
- elif com == 'Setu':
- data["setu"] = "on"
-
- elif com == 'SetuIMG':
- data["setu_img"] = "on"
-
- elif com == "AnimeSearch":
- data["anime_search"] = "on"
-
- elif com == 'AIchFace':
- data["change_face"] = "on"
-
- elif com == 'Kyaru':
- data["chouYou"] = "on"
-
- elif com == 'SauceNAO':
- data["saucenao_search"] = "on"
-
- else:
- session.finish('未找到此功能...请检查拼写奥...')
-
- elif switch == 'off':
- if com == 'PixivSearchIMG':
- data["pixiv_seach_img"] = "off"
-
- elif com == 'PixivSearchAuthor':
- data["pixiv_seach_author"] = "off"
-
- elif com == 'PixivRank':
- data["pixiv_daily_rank"] = "off"
-
- elif com == 'Setu':
- data["setu"] = "off"
-
- elif com == 'SetuIMG':
- data["setu_img"] = "off"
-
- elif com == "AnimeSearch":
- data["anime_search"] = "off"
-
- elif com == 'AIchFace':
- data["change_face"] = "off"
-
- elif com == 'Kyaru':
- data["chouYou"] = "off"
-
- elif com == 'SauceNAO':
- data["saucenao_search"] = "off"
-
- else:
- session.finish('未找到此功能...请检查拼写奥...')
-
- f2 = open(Path('.') / 'ATRI' / 'modules' / 'funcControl' / 'ALLswitch.json', 'w')
- f2.write(json.dumps(data))
- f2.close()
-
- await session.send('Success!') \ No newline at end of file
diff --git a/ATRI/plugins/welcome.py b/ATRI/plugins/welcome.py
deleted file mode 100644
index 457b895..0000000
--- a/ATRI/plugins/welcome.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from nonebot import on_notice
-from nonebot.plugin import on_request
-from nonebot.notice_request import NoticeSession, RequestSession
-
-import config
-from ATRI.modules.funcControl import checkNoob
-
-
-master = config.SUPERUSERS
-
-
-@on_notice('group_increase')
-async def _(session: NoticeSession):
- user = session.event.user_id
- group = session.event.group_id
- me = session.event.self_id
-
- if checkNoob(group):
- if user == me:
- await session.send('在下アトリ,今后请多指教呐❤')
- else:
- await session.send(f'[CQ:at,qq={user}]\nねえ❤...是新人欸!\nここでは遠慮はいらないのだからね❤')
-
-@on_notice('group_decrease.leave')
-async def _(session: NoticeSession):
- user = session.event.user_id
- group = session.event.group_id
- now = session.event.operator_id
- if checkNoob(user, group):
- if now == user:
- await session.send(f'[{user}]离开了我们......')
-
-
-@on_request('friend', 'group.invite')
-async def _(session: RequestSession):
- user = session.event.user_id
- if checkNoob(user):
- try:
- group = session.event.group_id
- except:
- group = False
-
- if group:
- await bot.send_private_msg(user_id = user, message = f'如有需要,请联系维护组{master}哦~') # type: ignore
- await bot.send_private_msg(user_id = master, message = f'报告主人!ATRI收到一条请求:\n类型:邀请入群\n邀请人:{user}\n对象群:{group}') # type: ignore
-
- else:
- await bot.send_private_msg(user_id = master, message = f'报告主人!ATRI收到一条请求:\n类型:添加好友\n申请人:{user}') # type: ignore \ No newline at end of file