From 5afc34bd246ecee15f7eb91d9a16c925cca40c92 Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Wed, 12 Aug 2020 23:44:55 +0800 Subject: [Fix] For ntr --- ATRI/plugins/chat.py | 54 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 22 deletions(-) (limited to 'ATRI/plugins/chat.py') diff --git a/ATRI/plugins/chat.py b/ATRI/plugins/chat.py index 1975610..2d18156 100644 --- a/ATRI/plugins/chat.py +++ b/ATRI/plugins/chat.py @@ -3,7 +3,9 @@ import re import json import nonebot import random +import warnings from pathlib import Path +import numpy as np from random import randint, choice from datetime import datetime, timedelta from nonebot import on_command, scheduler @@ -103,6 +105,24 @@ def now_time(): now = hour + minute / 60 return now +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 @@ -290,7 +310,7 @@ async def az(session: CommandSession): # res = random.randint(1,10) img = choice( [ - 'SUKI.jpg', 'SUKI1.jpg', 'HE1.jpg' + 'SUKI.jpg', 'SUKI1.jpg', 'SUKI2.jpg','HE1.jpg' ] ) img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}' @@ -469,8 +489,10 @@ async def _(session: CommandSession): img = Path('.') / 'ATRI' / 'data' / 'emoji' / 'H.jpg' await session.send(f'[CQ:image,file=file:///{img}]') +noobList = [] @on_command('ntr', patterns = [r"[nN][tT][rR]|[牛🐂]头人"], only_to_me = False) async def _(session: CommandSession): + global noobList user = session.event.user_id with open('ATRI/plugins/noobList/noobList.json', 'r') as f: data = json.load(f) @@ -479,23 +501,27 @@ async def _(session: CommandSession): 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: + print(noobList) + print(countX(noobList, user)) + if countX(noobList, user) == 5: if user == master: - await session.send('是主人的话...那算了...呜呜') + await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......') + noobList = list(set(noobList)) pass else: - await session.send('哼!接下来10分钟别想让我理你!') + await session.send(f'[CQ:at,qq={user}]哼!接下来10分钟别想让我理你!') bL[f"{user}"] = f"{user}" file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' f = open(file, 'w') f.write(json.dumps(bL)) f.close() + noobList = list(set(noobList)) + print(noobList) delta = timedelta(minutes = 10) trigger = DateTrigger( run_date = datetime.now() + delta @@ -509,20 +535,4 @@ async def _(session: CommandSession): ) else: - pass - -async def countX(lst, x): - count = 0 - for ele in lst: - if (ele == x): - count = count + 1 - return count - -async 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() \ No newline at end of file + pass \ No newline at end of file -- cgit v1.2.3