summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-08-12 00:05:21 +0800
committerKyomotoi <[email protected]>2020-08-12 00:05:21 +0800
commitb11b204043451334c33d827b776f230b6c8e84ce (patch)
tree32a1e42a3871e34401775bf7843444f3eeaa904a
parent0cd82d9166c38fa455895cc236f406902e8e6549 (diff)
downloadATRI-b11b204043451334c33d827b776f230b6c8e84ce.tar.gz
ATRI-b11b204043451334c33d827b776f230b6c8e84ce.tar.bz2
ATRI-b11b204043451334c33d827b776f230b6c8e84ce.zip
[Fix]
-rw-r--r--ATRI/plugins/anime_search.py104
-rw-r--r--ATRI/plugins/bilibili.py108
-rw-r--r--ATRI/plugins/chat.py576
-rw-r--r--ATRI/plugins/cloudmusic.py85
-rw-r--r--ATRI/plugins/hbook.py98
-rw-r--r--ATRI/plugins/hitokoto.py32
-rw-r--r--ATRI/plugins/other.py110
-rw-r--r--ATRI/plugins/pixiv.py246
-rw-r--r--ATRI/plugins/setu.py115
-rw-r--r--ATRI/plugins/upload_sqlite.py71
10 files changed, 758 insertions, 787 deletions
diff --git a/ATRI/plugins/anime_search.py b/ATRI/plugins/anime_search.py
index edbdc91..eb2e26d 100644
--- a/ATRI/plugins/anime_search.py
+++ b/ATRI/plugins/anime_search.py
@@ -46,67 +46,69 @@ def toSimpleString(str):
return "".join(output_str_list)
-@on_command(
- 'anime_search',
- aliases = ['以图搜番'],
- only_to_me = False
+@on_command('anime_search', aliases = ['以图搜番'], only_to_me = False
)
async def _(session: CommandSession):
user = session.event.user_id
msg = session.current_arg.strip()
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ if not msg:
+ msg = session.get('message', prompt = "请发送一张图片")
+
+ await session.send("开始以图搜番\n(如搜索时间过长或无反应则为图片格式有问题)")
- if not msg:
- msg = session.get('message', prompt = "请发送一张图片")
-
- await session.send("开始以图搜番\n(如搜索时间过长或无反应则为图片格式有问题)")
-
- p = '\\[CQ\\:image\\,file\\=.*?\\,url\\=(.*?)\\]'
-
- img = re.findall(p, msg)
+ p = '\\[CQ\\:image\\,file\\=.*?\\,url\\=(.*?)\\]'
- if img:
- URL = f'https://trace.moe/api/search?url={img[0]}'
+ img = re.findall(p, msg)
- req = await get_bytes(URL)
+ if img:
+ URL = f'https://trace.moe/api/search?url={img[0]}'
- if req:
- data = json.loads(req.decode())
+ req = await get_bytes(URL)
- d = {}
+ if req:
+ data = json.loads(req.decode())
- for i in range(len(data['docs'])):
- if data['docs'][i]['title_chinese'] in d.keys():
- d[data['docs'][i]['title_chinese']][0] += data['docs'][i]['similarity']
-
- else:
- m = data['docs'][i]['at']/60
- s = data['docs'][i]['at']%60
+ d = {}
- if data['docs'][i]['episode'] == '':
- n = 1
-
+ for i in range(len(data['docs'])):
+ if data['docs'][i]['title_chinese'] in d.keys():
+ d[data['docs'][i]['title_chinese']][0] += data['docs'][i]['similarity']
+
else:
- n = data['docs'][i]['episode']
-
- d[toSimpleString(data['docs'][i]['title_chinese'])] = [data['docs'][i]['similarity'],f'第{n}集',f'{int(m)}分{int(s)}秒处']
-
- result = sorted(
- d.items(),
- key = lambda x:x[1],
- reverse = True
- )
-
- t = 0
-
- msg0 = f'[CQ:at,qq={user}]\n根据所提供的图片按照相似度找到{len(d)}个结果:'
-
- for i in result:
- t +=1
- lk = ('%.2f%%' % (i[1][0] * 100))
- msg = (f'\n——————————\n({t})\n相似度:{lk}\n动漫名:《{i[0]}》\n时间点:{i[1][1]} {i[1][2]}')
- msg0 += msg
+ m = data['docs'][i]['at']/60
+ s = data['docs'][i]['at']%60
+
+ if data['docs'][i]['episode'] == '':
+ n = 1
+
+ else:
+ n = data['docs'][i]['episode']
+
+ d[toSimpleString(data['docs'][i]['title_chinese'])] = [data['docs'][i]['similarity'],f'第{n}集',f'{int(m)}分{int(s)}秒处']
+
+ result = sorted(
+ d.items(),
+ key = lambda x:x[1],
+ reverse = True
+ )
+
+ t = 0
+
+ msg0 = f'[CQ:at,qq={user}]\n根据所提供的图片按照相似度找到{len(d)}个结果:'
+
+ for i in result:
+ t +=1
+ lk = ('%.2f%%' % (i[1][0] * 100))
+ msg = (f'\n——————————\n({t})\n相似度:{lk}\n动漫名:《{i[0]}》\n时间点:{i[1][1]} {i[1][2]}')
+ msg0 += msg
+
+ await session.send(msg0)
- await session.send(msg0)
-
- else:
- await session.send("搜索似乎失败了呢...") \ No newline at end of file
+ else:
+ await session.send("搜索似乎失败了呢...") \ No newline at end of file
diff --git a/ATRI/plugins/bilibili.py b/ATRI/plugins/bilibili.py
deleted file mode 100644
index e415048..0000000
--- a/ATRI/plugins/bilibili.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# -*- coding:utf-8 -*-
-import json
-import nonebot
-from orjson import loads
-from html import unescape
-import aiocqhttp
-
-from nonebot import on_command, CommandSession
-
-from ATRI.modules import response # type: ignore
-
-
-REPORT_FORMAT = """({aid})信息如下:
-Title: {title}
-aid: {aid}
-bid: {bid}
-观看: {view} 点赞: {like}
-投币: {coin} 转发: {share}
-观看链接:
-{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)
-
-
-def check(string, sub_str):
- if (string.find(sub_str) == -1):
- ch = 0
- return ch
- else:
- ch = 1
- return ch
-
-
[email protected]_natural_language(only_to_me = False, only_short_message = False)
-async def fk_tx_app_bilibili(session: nonebot.NLPSession):
- rich_message = [x for x in session.event['message'] if x.get('type') == 'rich']
-
- if not rich_message:
- return
-
- rich_message = rich_message[0]['data']
- print(rich_message)
-
- xch = '小程序'
- bili = '哔哩哔哩'
- if check(rich_message['text'], xch) == 0:
- return
- if check(rich_message['text'], bili) == 0:
- return
-
- print(rich_message['text'])
-
- rich_message = rich_message['content']
- data = loads(unescape(rich_message))
-
- if 'detail_1' not in str(rich_message):
- return
-
- URL = data['detail_1']['qqdocurl']
- rep = URL.replace('?', '/')
- rep = rep.split('/')
- biv = rep[4]
-
- aid = str(dec(biv))
-
- url = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'
- ad = 'av' + aid
-
- dc = json.loads(response.request_api(url))
-
- pic = dc["data"]["pic"]
-
- await session.send(REPORT_FORMAT.format(
- title = dc["data"]["title"],
-
- view = dc["data"]["stat"]["view"],
- coin = dc["data"]["stat"]["coin"],
- share = dc["data"]["stat"]["share"],
- like = dc["data"]["stat"]["like"],
-
- bid = biv,
- bid_link = dc["data"]["short_link"],
-
- aid = ad,
- aid_link = f'https://b23.tv/{ad}'
- )
- ) \ No newline at end of file
diff --git a/ATRI/plugins/chat.py b/ATRI/plugins/chat.py
index 3363339..87bd17c 100644
--- a/ATRI/plugins/chat.py
+++ b/ATRI/plugins/chat.py
@@ -105,320 +105,410 @@ def now_time():
@on_command('morning', patterns = [r"早[安哇]|早上好|ohayo|哦哈哟|お早う"], only_to_me = False)
async def _(session: CommandSession):
- if 5.5 <= now_time() < 9:
- await session.send(
- choice(
- [
- '啊......早上好...(哈欠)',
- '唔......吧唧...早上...哈啊啊~~~\n早上好......',
- '早上好......',
- '早上好呜......呼啊啊~~~~',
- '啊......早上好。\n昨晚也很激情呢!',
- '吧唧吧唧......怎么了...已经早上了么...',
- '早上好!',
- '......看起来像是傍晚,其实已经早上了吗?',
- '早上好......欸~~~脸好近呢'
- ]
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ if 5.5 <= now_time() < 9:
+ await session.send(
+ choice(
+ [
+ '啊......早上好...(哈欠)',
+ '唔......吧唧...早上...哈啊啊~~~\n早上好......',
+ '早上好......',
+ '早上好呜......呼啊啊~~~~',
+ '啊......早上好。\n昨晚也很激情呢!',
+ '吧唧吧唧......怎么了...已经早上了么...',
+ '早上好!',
+ '......看起来像是傍晚,其实已经早上了吗?',
+ '早上好......欸~~~脸好近呢'
+ ]
+ )
)
- )
-
- elif 9 <= now_time() < 18:
- await session.send(
- choice(
- [
- '哼!这个点还早啥,昨晚干啥去了!?',
- '熬夜了对吧熬夜了对吧熬夜了对吧???!',
- '是不是熬夜是不是熬夜是不是熬夜?!'
- ]
+
+ elif 9 <= now_time() < 18:
+ await session.send(
+ choice(
+ [
+ '哼!这个点还早啥,昨晚干啥去了!?',
+ '熬夜了对吧熬夜了对吧熬夜了对吧???!',
+ '是不是熬夜是不是熬夜是不是熬夜?!'
+ ]
+ )
)
- )
-
- elif 18 <= now_time() < 24:
- await session.send(
- choice(
- [
- '早个啥?哼唧!我都准备洗洗睡了!',
- '不是...你看看几点了,哼!',
- '晚上好哇'
- ]
+
+ elif 18 <= now_time() < 24:
+ await session.send(
+ choice(
+ [
+ '早个啥?哼唧!我都准备洗洗睡了!',
+ '不是...你看看几点了,哼!',
+ '晚上好哇'
+ ]
+ )
)
- )
-
- elif 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..',
- '...zzz....哧溜哧溜....'
- ]
+
+ elif 0 <= now_time() < 5.5:
+ await session.send(
+ choice(
+ [
+ 'zzzz......',
+ 'zzzzzzzz......',
+ 'zzz...好涩哦..zzz....',
+ '别...不要..zzz..那..zzz..',
+ '嘻嘻..zzz..呐~..zzzz..',
+ '...zzz....哧溜哧溜....'
+ ]
+ )
)
- )
@on_command('noon', patterns = [r"中午好|午安"], only_to_me = False)
async def _(session: CommandSession):
- if 11 <= now_time() <= 15:
- await session.send(
- choice(
- [
- '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w',
- '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o',
- '睡你午觉去!哼唧!!'
- ]
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ if 11 <= now_time() <= 15:
+ await session.send(
+ choice(
+ [
+ '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w',
+ '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o',
+ '睡你午觉去!哼唧!!'
+ ]
+ )
)
- )
@on_command('night', patterns = [r"晚安|oyasuminasai|おやすみなさい"], only_to_me = False)
async def _(session: CommandSession):
- if 5.5 <= now_time() < 11:
- await session.send(
- choice(
- [
- '你可猝死算了吧!',
- '?啊这',
- '亲,这边建议赶快去睡觉呢~~~',
- '不可忍不可忍不可忍!!为何这还不猝死!!'
- ]
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ if 5.5 <= now_time() < 11:
+ await session.send(
+ choice(
+ [
+ '你可猝死算了吧!',
+ '?啊这',
+ '亲,这边建议赶快去睡觉呢~~~',
+ '不可忍不可忍不可忍!!为何这还不猝死!!'
+ ]
+ )
)
- )
-
- elif 11 <= now_time() < 15:
- await session.send(
- choice(
- [
- '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w',
- '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o',
- '睡你午觉去!哼唧!!'
- ]
+
+ elif 11 <= now_time() < 15:
+ await session.send(
+ choice(
+ [
+ '午安w','午觉要好好睡哦,ATRI会陪伴在你身旁的w',
+ '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o',
+ '睡你午觉去!哼唧!!'
+ ]
+ )
)
- )
-
- elif 15 <= now_time() < 19:
- await session.send(
- choice(
- [
- '难不成??晚上不想睡觉??现在休息',
- '就......挺离谱的...现在睡觉',
- '现在还是白天哦,睡觉还太早了'
- ]
+
+ elif 15 <= now_time() < 19:
+ await session.send(
+ choice(
+ [
+ '难不成??晚上不想睡觉??现在休息',
+ '就......挺离谱的...现在睡觉',
+ '现在还是白天哦,睡觉还太早了'
+ ]
+ )
)
- )
-
- elif 19 <= now_time() < 24:
- await session.send(
- choice(
- [
- '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o',
- '......(打瞌睡)',
- '呼...呼...已经睡着了哦~...呼......',
- '......我、我会在这守着你的,请务必好好睡着'
- ]
+
+ elif 19 <= now_time() < 24:
+ await session.send(
+ choice(
+ [
+ '嗯哼哼~睡吧,就像平常一样安眠吧~o(≧▽≦)o',
+ '......(打瞌睡)',
+ '呼...呼...已经睡着了哦~...呼......',
+ '......我、我会在这守着你的,请务必好好睡着'
+ ]
+ )
)
- )
-
- elif 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
+
+ elif 0 <= now_time() < 5.5:
+ await session.send(
+ choice(
+ [
+ 'zzzz......',
+ 'zzzzzzzz......',
+ 'zzz...好涩哦..zzz....',
+ '别...不要..zzz..那..zzz..',
+ '嘻嘻..zzz..呐~..zzzz..'
+ ]
+ )
)
- )
@on_command('az', patterns = [r"[aA][zZ]|[阿啊]这"], only_to_me = False)
async def az(session: CommandSession):
- res = randint(1,3)
- if res == 1:
- # res = random.randint(1,10)
- img = choice(
- [
- 'AZ.jpg', 'AZ1.jpg', 'AZ2.jpg', 'AZ3.png', 'ZN.jpg'
- ]
- )
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
- img = os.path.abspath(img)
- await session.send(f'[CQ:image,file=file:///{img}]')
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ res = randint(1,3)
+ if res == 1:
+ # res = random.randint(1,10)
+ img = choice(
+ [
+ 'AZ.jpg', 'AZ1.jpg', 'AZ2.jpg', 'AZ3.png', 'ZN.jpg'
+ ]
+ )
+ img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
+ img = os.path.abspath(img)
+ await session.send(f'[CQ:image,file=file:///{img}]')
@on_command('suki', patterns = [r"喜欢|爱你|爱|suki|daisuki|すき|好き|贴贴|老婆|[Mm][Uu][Aa]|亲一个"], only_to_me = True)
async def az(session: CommandSession):
- res = randint(1,3)
- if res == 1:
- # res = random.randint(1,10)
- img = choice(
- [
- 'SUKI.jpg', 'SUKI1.jpg', 'HE1.jpg'
- ]
- )
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
- img = os.path.abspath(img)
- await session.send(f'[CQ:image,file=file:///{img}]')
-
- elif 2 <= res <= 3:
- img = choice(
- [
- 'TZ.jpg', 'TZ1.jpg', 'TZ1.jpg'
- ]
- )
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
- img = os.path.abspath(img)
- await session.send(f'[CQ:image,file=file:///{img}]')
-
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
-@on_command('wenhao', patterns = [r"'?'|?"], only_to_me = False)
-async def _(session: CommandSession):
- res = randint(1,3)
- if res == 1:
- res = randint(1,5)
- if 1 <= res < 2:
- await session.send(
- choice(
- [
- '?', '?', '嗯?', '(。´・ω・)ん?', 'ん?'
- ]
- )
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ res = randint(1,3)
+ if res == 1:
+ # res = random.randint(1,10)
+ img = choice(
+ [
+ 'SUKI.jpg', 'SUKI1.jpg', 'HE1.jpg'
+ ]
)
+ img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
+ img = os.path.abspath(img)
+ await session.send(f'[CQ:image,file=file:///{img}]')
- elif 2 <= res <= 5:
+ elif 2 <= res <= 3:
img = choice(
[
- 'WH.jpg', 'WH1.jpg', 'WH2.jpg', 'WH3.jpg', 'WH4.jpg'
+ 'TZ.jpg', 'TZ1.jpg', 'TZ1.jpg'
]
)
img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
img = os.path.abspath(img)
await session.send(f'[CQ:image,file=file:///{img}]')
-@on_command('yn', patterns = [r"是[吗]|是否"], only_to_me = False)
-async def _(session: CommandSession):
- if randint(1,3) == 1:
- img = choice(
- [
- 'YIQI_YES.png', 'YIQI_NO.jpg', 'KD.jpg', 'FD.jpg'
- ]
- )
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
- img = os.path.abspath(img)
- await session.send(f'[CQ:image,file=file:///{img}]')
-
-
-@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|2b|给👴爬|嘴臭"], only_to_me = False)
+@on_command('wenhao', patterns = [r"'?'|?"], only_to_me = False)
async def _(session: CommandSession):
- if randint(1,2) == 1:
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
res = randint(1,3)
if res == 1:
+ res = randint(1,5)
+ if 1 <= res < 2:
+ await session.send(
+ choice(
+ [
+ '?', '?', '嗯?', '(。´・ω・)ん?', 'ん?'
+ ]
+ )
+ )
+
+ elif 2 <= res <= 5:
+ img = choice(
+ [
+ 'WH.jpg', 'WH1.jpg', 'WH2.jpg', 'WH3.jpg', 'WH4.jpg'
+ ]
+ )
+ img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
+ img = os.path.abspath(img)
+ await session.send(f'[CQ:image,file=file:///{img}]')
+
+@on_command('yn', patterns = [r"是[吗]|是否"], only_to_me = False)
+async def _(session: CommandSession):
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ if randint(1,3) == 1:
img = choice(
[
- 'WQ.jpg', 'WQ.png', 'WQ2.jpg', 'WQ3.jpg', 'FN.jpg'
+ 'YIQI_YES.png', 'YIQI_NO.jpg', 'KD.jpg', 'FD.jpg'
]
)
img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
img = os.path.abspath(img)
await session.send(f'[CQ:image,file=file:///{img}]')
- elif res == 2:
+
+
+@on_command('kouchou', patterns = [r"草你妈|操|你妈|脑瘫|废柴|fw|five|废物|战斗|爬|爪巴|sb|SB|啥[b批比逼]|傻b|2b|给👴爬|嘴臭"], only_to_me = False)
+async def _(session: CommandSession):
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ if randint(1,2) == 1:
res = randint(1,3)
if res == 1:
- await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!')
-
+ img = choice(
+ [
+ 'WQ.jpg', 'WQ.png', 'WQ2.jpg', 'WQ3.jpg', 'FN.jpg'
+ ]
+ )
+ img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
+ img = os.path.abspath(img)
+ await session.send(f'[CQ:image,file=file:///{img}]')
+
elif res == 2:
- await session.send('鱼雷组合拳——————————————————啊————!!!')
+ res = randint(1,3)
+ if res == 1:
+ await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!')
+
+ elif res == 2:
+ await session.send('鱼雷组合拳——————————————————啊————!!!')
+
+ elif res == 3:
+ await session.send('火箭拳——————————————————————————!!!')
elif res == 3:
- await session.send('火箭拳——————————————————————————!!!')
-
- elif res == 3:
- await session.send(response.request_api(KC_URL))
+ await session.send(response.request_api(KC_URL))
@on_command('ciallo', patterns = [r"[Cc][iI][aA][lL][lL][oO]"], only_to_me = False)
async def _(session: CommandSession):
- 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~(∠・ω< )⌒★')
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ 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):
- if randint(1,3) == 1:
- await session.send(
- choice(
- [
- '呐', '呐呐呐', 'ねえ', 'ねえねえ'
- ]
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ 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):
- 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}]')
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ 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}]')
@on_command('hai', patterns = [r"青[洁结]"], only_to_me = False)
async def _(session: CommandSession):
- if randint(1,2) == 1:
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg'
- await session.send(f'[CQ:image,file=file:///{img}]')
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ if randint(1,2) == 1:
+ img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg'
+ await session.send(f'[CQ:image,file=file:///{img}]')
@on_command('ntr', patterns = [r"[nN][tT][rR]|[牛🐂]头人"], only_to_me = False)
async def _(session: CommandSession):
user = session.event.user_id
- msg = str(session.event.message)
- noobList = []
- bL = {}
- pattern = r"[nN][tT][rR]|[牛🐂]头人"
- if re.findall(pattern, msg):
- await session.send('你妈的,牛头人,' + response.request_api(KC_URL))
- noobList.append(user)
- if countX(noobList, user) == 10:
- if user == master:
- pass
- else:
- await session.send('哼!接下来10分钟别想让我理你!')
- 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(minutes = 10)
- trigger = DateTrigger(
- run_date = datetime.now() + delta
- )
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
- scheduler.add_job( #type: ignore
- func = rmQQfromNoobLIST,
- trigger = trigger,
- args = (user),
- misfire_grace_time = 60,
- )
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ msg = str(session.event.message)
+ noobList = []
+ bL = {}
+ pattern = r"[nN][tT][rR]|[牛🐂]头人"
+ if re.findall(pattern, msg):
+ await session.send('你妈的,牛头人,' + response.request_api(KC_URL))
+ noobList.append(user)
+ if countX(noobList, user) == 10:
+ if user == master:
+ pass
+ else:
+ await session.send('哼!接下来10分钟别想让我理你!')
+ 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(minutes = 10)
+ trigger = DateTrigger(
+ run_date = datetime.now() + delta
+ )
+
+ scheduler.add_job( #type: ignore
+ func = rmQQfromNoobLIST,
+ trigger = trigger,
+ args = (user),
+ misfire_grace_time = 60,
+ )
- else:
- pass
+ else:
+ pass
async def countX(lst, x):
count = 0
diff --git a/ATRI/plugins/cloudmusic.py b/ATRI/plugins/cloudmusic.py
deleted file mode 100644
index 73e8316..0000000
--- a/ATRI/plugins/cloudmusic.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# -*- coding:utf-8 -*-
-import json
-import nonebot
-from orjson import loads
-from html import unescape
-
-from ATRI.modules import response # type: ignore
-
-REPORT_FORMAT = """Status: {status}
-Song id: {id}
-Br: {br}
-Download: {url}
-MD5: {md5}"""
-
-
[email protected]_natural_language(only_to_me = False)
-async def fk_tx_app_cloudmusic(session: nonebot.NLPSession):
- rich_message = [x for x in session.event['message'] if x.get('CQ') == 'rich']
-
- if not rich_message:
- return
-
- rich_message = rich_message[0]['data']
- print(rich_message)
-
- if '网易云音乐' not in str(rich_message):
- return
-
- if 'music' not in str(rich_message):
- return
-
- data = loads(unescape(rich_message))
- print(data
- )
-
- URL = data['music']['jumpUrl']
- rep = URL.split('/')
- wid = rep[4]
-
- url = f'https://api.imjad.cn/cloudmusic/?type=song&id={wid}&br=320000'
- print(url)
-
- dc = json.loads(response.request_api(url))
-
- await session.send(
- REPORT_FORMAT.format(
- status = dc["code"],
- id = dc["data"][0]["id"],
- br = dc["data"][0]["br"],
- url = dc["data"][0]["url"],
- md5 = dc["data"][0]["md5"],
- )
- )
-
-
[email protected]_natural_language(only_to_me = False)
-async def cloudmusic_link(session: nonebot.NLPSession):
- share_message = [x for x in session.ctx['message'] if x.get('type') == 'share']
-
- if not share_message:
- return
-
- share_message = share_message[0]['data']['url']
-
- if 'music.163.com' not in str(share_message):
- return
-
- rep = share_message.replace('=', '/')
- rep = rep.replace('&', '/')
- wid = rep[4]
-
- url = f'https://api.imjad.cn/cloudmusic/?type=song&id={wid}&br=320000'
- print(url)
-
- dc = json.loads(response.request_api(url))
-
- await session.send(
- REPORT_FORMAT.format(
- status = dc["code"],
- id = dc["data"][0]["id"],
- br = dc["data"][0]["br"],
- url = dc["data"][0]["url"],
- md5 = dc["data"][0]["md5"],
- )
- ) \ No newline at end of file
diff --git a/ATRI/plugins/hbook.py b/ATRI/plugins/hbook.py
index 7cd7be0..395a43b 100644
--- a/ATRI/plugins/hbook.py
+++ b/ATRI/plugins/hbook.py
@@ -11,60 +11,66 @@ pattern = r"来(.*?)[点丶份张幅](.*?)的?本子"
@on_command('hbook', patterns = pattern, only_to_me = False)
async def _(session: CommandSession):
- with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ h_user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
data = json.load(f)
-
- if data["hbook"] == 0:
- num = 1
- tag = ''
- start = time.perf_counter()
- h_msg = str(session.event.message)
- info = re.findall(pattern, h_msg)
- if info:
- num = int(info[0][0] or 1)
- tag = str(info[0][1])
- if num > 5:
- await session.send('你是不是涩批啊!要那么多干啥?!我最多发5份!')
- num = 5
+ if data[f"{h_user}"] == str(h_user):
+ pass
+ else:
+ with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ data = json.load(f)
- h_type = session.event.detail_type
- h_user = session.event.user_id
+ if data["hbook"] == 0:
+ num = 1
+ tag = ''
+ start = time.perf_counter()
+ h_msg = str(session.event.message)
- try:
- header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'}
- keyword = {'show':'title,titleen,tags','keyboard':tag}
- print(keyword)
+ info = re.findall(pattern, h_msg)
+ if info:
+ num = int(info[0][0] or 1)
+ tag = str(info[0][1])
+ if num > 5:
+ await session.send('你是不是涩批啊!要那么多干啥?!我最多发5份!')
+ num = 5
+
+ h_type = session.event.detail_type
- res = await response.post_bytes('https://b-upp.com/search/', headers=header, data=keyword)
- res = res.decode()
- except:
- session.finish('貌似请求数据失败了...')
+ try:
+ header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'}
+ keyword = {'show':'title,titleen,tags','keyboard':tag}
+ print(keyword)
- if '没有搜索到相关的内容' in res:
- n_msg = '...似乎没有找到[{}]相关的本子呢'.format(tag)
- await session.send(message=n_msg)
-
- else:
- p = '<a href="(.*?)" target="_blank" title="(.*?)">'
- data = re.findall(p,res)
- n = len(data)
- limit = num
+ res = await response.post_bytes('https://b-upp.com/search/', headers=header, data=keyword)
+ res = res.decode()
+ except:
+ session.finish('貌似请求数据失败了...')
+
+ if '没有搜索到相关的内容' in res:
+ n_msg = '...似乎没有找到[{}]相关的本子呢'.format(tag)
+ await session.send(message=n_msg)
- if n > limit: # type: ignore
- n = limit # type: ignore
+ else:
+ p = '<a href="(.*?)" target="_blank" title="(.*?)">'
+ data = re.findall(p,res)
+ n = len(data)
+ limit = num
+
+ if n > limit: # type: ignore
+ n = limit # type: ignore
- msg = f'据提供信息,已查询到{n}本关键词为[{tag}]的本子:'
- if h_type == 'group':
- msg = f'[CQ:at,qq={h_user}]\n根据提供信息,已查询到{n}本关键词为[{tag}]的本子:'
- for i in range(n):
- msg0 = ('\n——————————\n本子链接:https://b-upp.com%s \n本子标题:%s '%(data[i]))
+ msg = f'据提供信息,已查询到{n}本关键词为[{tag}]的本子:'
+ if h_type == 'group':
+ msg = f'[CQ:at,qq={h_user}]\n根据提供信息,已查询到{n}本关键词为[{tag}]的本子:'
+ for i in range(n):
+ msg0 = ('\n——————————\n本子链接:https://b-upp.com%s \n本子标题:%s '%(data[i]))
+ msg += msg0
+ end = time.perf_counter()
+ msg0 = f'\n——————————\n耗时: {round(end - start, 3)}s'
msg += msg0
- end = time.perf_counter()
- msg0 = f'\n——————————\n耗时: {round(end - start, 3)}s'
- msg += msg0
- await session.send(message=msg)
+ await session.send(message=msg)
- else:
- await session.send('该功能已禁用...') \ No newline at end of file
+ else:
+ await session.send('该功能已禁用...') \ No newline at end of file
diff --git a/ATRI/plugins/hitokoto.py b/ATRI/plugins/hitokoto.py
index fdc58c0..94fec98 100644
--- a/ATRI/plugins/hitokoto.py
+++ b/ATRI/plugins/hitokoto.py
@@ -8,25 +8,23 @@ from ATRI.modules import response # type: ignore
url = 'https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source='
-HITOKOTO_REPLY = """{hitokoto}
- from {author}"""
-
-
@on_command('hitokoto', aliases = ['一言'], only_to_me = False)
async def hitokoto(session: CommandSession):
- rep = response.request_api(url)
-
- if not rep:
- session.finish('获取失败')
-
- dc = json.loads(response.request_api(url))
-
- await session.send(
- HITOKOTO_REPLY.format(
- hitokoto = dc["hitokoto"],
- author = dc["author"]
- )
- )
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ rep = response.request_api(url)
+
+ if not rep:
+ session.finish('获取失败')
+
+ dc = json.loads(response.request_api(url))
+
+ await session.send(dc["hitokoto"])
@on_natural_language('一言', only_to_me = False)
async def _(session: NLPSession):
diff --git a/ATRI/plugins/other.py b/ATRI/plugins/other.py
index 0e76c54..be0ed50 100644
--- a/ATRI/plugins/other.py
+++ b/ATRI/plugins/other.py
@@ -1,5 +1,6 @@
# -*- coding:utf-8 -*-
import time
+import json
import random
import nonebot
from nonebot import on_command, CommandSession
@@ -59,59 +60,94 @@ MENU_AND = '''
@on_command('抽签', only_to_me = False)
async def _(session: CommandSession):
- await session.send(
- str(
- random.choice(
- [
- '大凶',
- '大胸',
- '小凶',
- '小胸',
- '凶',
- '吉',
- '中吉',
- '大吉',
- '特大吉',
- '超特大吉'
- ]
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ await session.send(
+ str(
+ random.choice(
+ [
+ '大凶',
+ '大胸',
+ '小凶',
+ '小胸',
+ '凶',
+ '吉',
+ '中吉',
+ '大吉',
+ '特大吉',
+ '超特大吉'
+ ]
+ )
)
)
- )
@on_command('掷骰子', aliases = ['扔骰子', '骰子'], only_to_me = False)
async def _(session: CommandSession):
- await session.send(
- str(
- random.randint(
- 1,6
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ await session.send(
+ str(
+ random.randint(
+ 1,6
+ )
)
)
- )
@on_command('关于', aliases = ['关于机器人'], only_to_me = False)
async def _(session: CommandSession):
- await session.send(
- """想了解ATRI嘛
-写出咱的是Kyomotoi
-他的主页:https://blog.lolihub.icu/
-项目地址:https://github.com/Kyomotoi/ATRI
-欢迎star~w!"""
- )
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ await session.send(
+ """想了解ATRI嘛
+ 写出咱的是Kyomotoi
+ 他的主页:https://blog.lolihub.icu/
+ 项目地址:https://github.com/Kyomotoi/ATRI
+ 欢迎star~w!"""
+ )
@on_command('help', aliases = ['帮助', '如何使用ATRI', '机器人帮助'], only_to_me = False)
async def _(session: CommandSession):
- await session.send(
- f"""{render_expression(HELP_REPLY)}
-发送:菜单
-或看这吧!
-https://blog.lolihub.icu/#/ATRI/user"""
- )
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ await session.send(
+ f"""{render_expression(HELP_REPLY)}
+ 发送:菜单
+ 或看这吧!
+ https://blog.lolihub.icu/#/ATRI/user"""
+ )
@on_command('menu', aliases = ['菜单'], only_to_me = False)
async def _(session: CommandSession):
- await session.send(MENU_REPO)
- time.sleep(0.5)
- await session.send(MENU_AND)
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ await session.send(MENU_REPO)
+ time.sleep(0.5)
+ await session.send(MENU_AND)
@on_command('report', aliases = ['来杯红茶'], only_to_me = True)
async def _(session: CommandSession):
diff --git a/ATRI/plugins/pixiv.py b/ATRI/plugins/pixiv.py
index 4be60dc..5ca7b20 100644
--- a/ATRI/plugins/pixiv.py
+++ b/ATRI/plugins/pixiv.py
@@ -31,145 +31,163 @@ Link: {user_link}
@on_command('pixiv_seach_img', aliases = ['p站搜图', 'P站搜图', '批站搜图'], only_to_me = False)
async def _(session: CommandSession):
- with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
data = json.load(f)
- if data["pixiv_seach_img"] == 0:
- user = session.event.user_id
- pid = session.current_arg.strip()
-
- if not pid:
- pid = session.get('message', prompt = '请告诉ATRI需要查询的Pid码')
-
- start =time.perf_counter()
- await session.send('开始P站搜图\n如搜索时间过长或许为图片过大上传较慢')
-
- URL = URL_1 + pid
-
- dc = json.loads(response.request_api(URL))
-
- if not dc:
- session.finish('ATRI在网络上走散了...请重试...')
-
- img = f'https://pixiv.cat/{pid}.jpg'
-
-
- end = time.perf_counter()
-
- await session.send(
- IMG_SEACH_REPLY.format(
- user = user,
- pid = pid,
- title = dc["response"][0]["title"],
- width = dc["response"][0]["width"],
- height = dc["response"][0]["height"],
- tags = dc["response"][0]["tags"],
- account = dc["response"][0]["user"]["account"],
- name = dc["response"][0]["user"]["name"],
- user_link = f'https://www.pixiv.net/users/' + f'{dc["response"][0]["user"]["id"]}',
- img = img,
- time = round(end - start, 3)
- )
- )
-
+ if data[f"{user}"] == str(user):
+ pass
else:
- await session.send('该功能已被禁用...')
+ with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ data = json.load(f)
+
+ if data["pixiv_seach_img"] == 0:
+ pid = session.current_arg.strip()
+
+ if not pid:
+ pid = session.get('message', prompt = '请告诉ATRI需要查询的Pid码')
+
+ start =time.perf_counter()
+ await session.send('开始P站搜图\n如搜索时间过长或许为图片过大上传较慢')
+
+ URL = URL_1 + pid
+
+ dc = json.loads(response.request_api(URL))
+
+ if not dc:
+ session.finish('ATRI在网络上走散了...请重试...')
+
+ img = f'https://pixiv.cat/{pid}.jpg'
+
+
+ end = time.perf_counter()
+
+ await session.send(
+ IMG_SEACH_REPLY.format(
+ user = user,
+ pid = pid,
+ title = dc["response"][0]["title"],
+ width = dc["response"][0]["width"],
+ height = dc["response"][0]["height"],
+ tags = dc["response"][0]["tags"],
+ account = dc["response"][0]["user"]["account"],
+ name = dc["response"][0]["user"]["name"],
+ user_link = f'https://www.pixiv.net/users/' + f'{dc["response"][0]["user"]["id"]}',
+ img = img,
+ time = round(end - start, 3)
+ )
+ )
+
+ else:
+ await session.send('该功能已被禁用...')
@on_command('pixiv_seach_author', aliases = ['画师', '搜索画师', '画师搜索'], only_to_me = False)
async def _(session: CommandSession):
- with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
data = json.load(f)
-
- if data["pixiv_seach_author"] == 0:
- user = session.event.user_id
- author_id = session.current_arg.strip()
-
- if not author_id:
- author_id = session.get('message', prompt = '请告诉ATRI需要查询的画师ID')
-
- start =time.perf_counter()
- await session.send(f'开始获取画师{author_id}的前三项作品\n如获取时间过长或许为图片过大上传较慢')
-
- URL = URL_2 + author_id
- dc = json.loads(response.request_api(URL))
-
- if not dc:
- session.finish('ATRI在网络上走散了...请重试...')
-
- d ={}
-
- for i in range(0,3):
- pid = dc["response"][i]["id"]
- pidURL = f'https://pixiv.cat/{pid}.jpg'
- d[i] = [f'{pid}',f'{pidURL}']
-
- msg0 = (f'[CQ:at,qq={user}]\n画师id:{author_id},接下来展示前三作品')
-
- result = sorted(
- d.items(),
- key = lambda x:x[1],
- reverse = True
- )
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ data = json.load(f)
+
+ if data["pixiv_seach_author"] == 0:
+ author_id = session.current_arg.strip()
+
+ if not author_id:
+ author_id = session.get('message', prompt = '请告诉ATRI需要查询的画师ID')
+
+ start =time.perf_counter()
+ await session.send(f'开始获取画师{author_id}的前三项作品\n如获取时间过长或许为图片过大上传较慢')
+
+ URL = URL_2 + author_id
+
+ dc = json.loads(response.request_api(URL))
+
+ if not dc:
+ session.finish('ATRI在网络上走散了...请重试...')
+
+ d ={}
+
+ for i in range(0,3):
+ pid = dc["response"][i]["id"]
+ pidURL = f'https://pixiv.cat/{pid}.jpg'
+ d[i] = [f'{pid}',f'{pidURL}']
+
+ msg0 = (f'[CQ:at,qq={user}]\n画师id:{author_id},接下来展示前三作品')
+
+ result = sorted(
+ d.items(),
+ key = lambda x:x[1],
+ reverse = True
+ )
- t = 0
+ t = 0
- for i in result:
- t += 1
- msg = (f'\n---------------\n({t})\nPid: {i[1][0]}\n{i[1][1]}')
- msg0 += msg
- end = time.perf_counter()
+ for i in result:
+ t += 1
+ msg = (f'\n---------------\n({t})\nPid: {i[1][0]}\n{i[1][1]}')
+ msg0 += msg
+ end = time.perf_counter()
- msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s')
- msg0 += msg1
+ msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s')
+ msg0 += msg1
+
+ await session.send(msg0)
- await session.send(msg0)
-
- else:
- await session.send('该功能已被禁用...')
+ else:
+ await session.send('该功能已被禁用...')
@on_command('pixiv_daily_rank', aliases = ['P站排行榜', '批站排行榜', 'p站排行榜'], only_to_me = False)
async def _(session: CommandSession):
- with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
data = json.load(f)
-
- if data["pixiv_daily_rank"] == 0:
- user = session.event.user_id
- await session.send('ATRI正在获取P站每日排行榜前五作品...')
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ with open('ATRI/plugins/switch/switch.json', 'r') as f:
+ data = json.load(f)
+
+ if data["pixiv_daily_rank"] == 0:
- start =time.perf_counter()
- dc = json.loads(response.request_api(URL_3))
+ await session.send('ATRI正在获取P站每日排行榜前五作品...')
- d = {}
+ start =time.perf_counter()
+ dc = json.loads(response.request_api(URL_3))
- 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}']
+ d = {}
- msg0 = (f'[CQ:at,qq={user}]')
+ 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}']
- result = sorted(
- d.items(),
- key = lambda x:x[1],
- reverse = True
- )
+ msg0 = (f'[CQ:at,qq={user}]')
- t = 0
+ result = sorted(
+ d.items(),
+ key = lambda x:x[1],
+ reverse = True
+ )
- 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()
+ t = 0
- msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s')
- msg0 += msg1
+ 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()
- await session.send(msg0)
-
- else:
- await session.send('该功能已被禁用...') \ No newline at end of file
+ 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/setu.py b/ATRI/plugins/setu.py
index cbf8ff6..70ef0b4 100644
--- a/ATRI/plugins/setu.py
+++ b/ATRI/plugins/setu.py
@@ -30,71 +30,78 @@ Complete time:{time}s"""
@on_command('setu', patterns = (r"来[点丶张份副个幅][涩色瑟][图圖]|[涩色瑟][图圖]来|[涩色瑟][图圖][gkd|GKD|搞快点]|[gkd|GKD|搞快点][涩色瑟][图圖]|[图圖]来|[我你她他它]想要[点丶张份副][涩色瑟][图圖]|我想要[1一][张份幅副个只][涩色瑟][图圖]|[我你她他它]想[看|look][涩涩|色色]的东西"), only_to_me = False)
async def setu(session: CommandSession):
group = session.event.group_id
- with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f:
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
data = json.load(f)
- if data["setu"] == 0:
- await session.send('别急!正在找图!')
- start = time.perf_counter()
- values = {
- "apikey": apikey,
- "r18": "0",
- "num": "1"
- }
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f:
+ data = json.load(f)
- res = randint(1,10)
- if 1 <= res <= 9:
- res = randint(1,4)
- if 1 <= res <= 3:
- try:
- dc = json.loads(response.request_api_params(URL, values))
- title = dc["data"][0]["title"]
- pid = dc["data"][0]["pid"]
- setu = dc["data"][0]["url"] #b64.b64_str_img_url(dc["data"][0]["url"])
- except:
- await session.send('失败了失败了失败了失...')
- return
-
+ if data["setu"] == 0:
+ await session.send('别急!正在找图!')
+ start = time.perf_counter()
+ values = {
+ "apikey": apikey,
+ "r18": "0",
+ "num": "1"
+ }
- res = randint(1,3)
- if 1 <= res <= 2:
- end = time.perf_counter()
- await session.send(
- SETU_REPLY.format(
- title = title,
- pid = pid,
- setu = dc["data"][0]["url"],
- time = round(end - start, 3)
+ res = randint(1,10)
+ if 1 <= res <= 9:
+ res = randint(1,4)
+ if 1 <= res <= 3:
+ try:
+ dc = json.loads(response.request_api_params(URL, values))
+ title = dc["data"][0]["title"]
+ pid = dc["data"][0]["pid"]
+ setu = dc["data"][0]["url"] #b64.b64_str_img_url(dc["data"][0]["url"])
+ except:
+ await session.send('失败了失败了失败了失...')
+ return
+
+
+ res = randint(1,3)
+ if 1 <= res <= 2:
+ 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 == 3:
+ await session.send('我找到涩图了!但我发给主人了ο(=•ω<=)ρ⌒☆')
+ end = time.perf_counter()
+ await bot.send_private_msg( # type: ignore
+ user_id = master,
+ message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}"
)
- )
- elif res == 3:
- await session.send('我找到涩图了!但我发给主人了ο(=•ω<=)ρ⌒☆')
- end = time.perf_counter()
- await bot.send_private_msg( # type: ignore
- user_id = master,
- message = f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n{setu}\nComplete time: {round(end - start, 3)}"
+ elif res == 4:
+ img = choice(
+ [
+ 'SP.jpg', 'SP1.jpg', 'SP2.jpg'
+ ]
)
+ img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
+ img = os.path.abspath(img)
+ await session.send(f'[CQ:image,file=file:///{img}]')
+
- elif res == 4:
+ elif res == 10:
img = choice(
[
- 'SP.jpg', 'SP1.jpg', 'SP2.jpg'
+ 'GDZ.png', 'SHZY1.jpg', 'SHZY2.jpg', 'SHZY3.jpg', 'SHZY4.jpg', 'SHZY5.jpg', 'SHZY6.jpg'
]
)
- img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
- img = os.path.abspath(img)
+ img = Path('.') / 'ATRI' / 'data' / 'img' / 'niceIMG' / f'{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}'
- await session.send(f'[CQ:image,file=file:///{img}]')
-
- else:
- await session.send('该功能已被禁用...') \ No newline at end of file
+ else:
+ await session.send('该功能已被禁用...') \ No newline at end of file
diff --git a/ATRI/plugins/upload_sqlite.py b/ATRI/plugins/upload_sqlite.py
index a7c5b75..b399281 100644
--- a/ATRI/plugins/upload_sqlite.py
+++ b/ATRI/plugins/upload_sqlite.py
@@ -139,35 +139,42 @@ async def _(session: CommandSession):
@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()
-
- await session.send(
- f"""目前螃蟹™数据库收录了:
-涩图:
- normal: {data_normal}
- nearR18: {data_nearR18}
- r18:{data_r18}
-网抑云语录:{data_cloudmusic}"""
- ) \ No newline at end of file
+ user = session.event.user_id
+ with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
+ data = json.load(f)
+
+ if data[f"{user}"] == str(user):
+ pass
+ else:
+ con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'normal.db') # setu-normal
+ cur = con.cursor()
+ cur.execute("select * from normal")
+ data_normal = len(cur.fetchall())
+ con.close()
+
+ con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'nearR18.db') # setu-nearR18
+ cur = con.cursor()
+ cur.execute("select * from nearR18")
+ data_nearR18 = len(cur.fetchall())
+ con.close()
+
+ con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'setu' / 'r18.db') # setu-r18
+ cur = con.cursor()
+ cur.execute("select * from r18")
+ data_r18 = len(cur.fetchall())
+ con.close()
+
+ con = sqlite3.connect(Path('.') / 'ATRI' / 'data' / 'sqlite' / 'cloudmusic' / 'cloudmusic.db') # cloudmusic
+ cur = con.cursor()
+ cur.execute("select * from cloudmusic")
+ data_cloudmusic = len(cur.fetchall())
+ con.close()
+
+ await session.send(
+ f"""目前螃蟹™数据库收录了:
+ 涩图:
+ normal: {data_normal}
+ nearR18: {data_nearR18}
+ r18:{data_r18}
+ 网抑云语录:{data_cloudmusic}"""
+ ) \ No newline at end of file