summaryrefslogtreecommitdiff
path: root/ATRI/plugins/other.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/other.py')
-rw-r--r--ATRI/plugins/other.py246
1 files changed, 94 insertions, 152 deletions
diff --git a/ATRI/plugins/other.py b/ATRI/plugins/other.py
index 5946905..c67204f 100644
--- a/ATRI/plugins/other.py
+++ b/ATRI/plugins/other.py
@@ -1,13 +1,13 @@
-import json
import random
import nonebot
+import warnings
from datetime import datetime
from random import choice
-from pathlib import Path
from nonebot import on_command, CommandSession
from nonebot.helpers import render_expression
import config # type: ignore
+from ATRI.modules.funcControl import checkNoob # type: ignore
bot = nonebot.get_bot()
@@ -21,6 +21,14 @@ 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
+
HELP_REPLY = (
'ええと...让我想想...',
@@ -34,181 +42,93 @@ HELP_REPLY = (
async def _(session: CommandSession):
user = session.event.user_id
group = session.event.group_id
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f:
- data1 = json.load(f)
- except:
- data1 = {}
-
- if str(group) in data.keys():
- pass
- else:
- if str(user) in data1.keys():
- pass
+ if checkNoob(user, group):
+ if 0 <= now_time() < 5.5:
+ await session.send(
+ choice(
+ [
+ 'zzzz......',
+ 'zzzzzzzz......',
+ 'zzz...好涩哦..zzz....',
+ '别...不要..zzz..那..zzz..',
+ '嘻嘻..zzz..呐~..zzzz..'
+ ]
+ )
+ )
else:
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
+ await session.send(
+ str(
+ random.choice(
[
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
+ '大凶',
+ '大胸',
+ '小凶',
+ '小胸',
+ '凶',
+ '吉',
+ '中吉',
+ '大吉',
+ '特大吉',
+ '超特大吉'
]
)
)
- 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
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', '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:
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
+ if checkNoob(user, group):
+ if 0 <= now_time() < 5.5:
+ await session.send(
+ choice(
+ [
+ 'zzzz......',
+ 'zzzzzzzz......',
+ 'zzz...好涩哦..zzz....',
+ '别...不要..zzz..那..zzz..',
+ '嘻嘻..zzz..呐~..zzzz..'
+ ]
)
- else:
- await session.send(
- str(
- random.randint(
- 1,6
- )
+ )
+ else:
+ await session.send(
+ str(
+ random.randint(
+ 1,6
)
)
+ )
@on_command('关于', aliases = ['关于机器人'], only_to_me = False)
async def _(session: CommandSession):
user = session.event.user_id
group = session.event.group_id
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', '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:
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
- )
- else:
- await session.send(
- """想了解ATRI嘛
- 写出咱的是Kyomotoi
- 他的主页:https://blog.lolihub.icu/
- 项目地址:https://github.com/Kyomotoi/ATRI
- 欢迎star~w!"""
- )
+ 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
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f:
- data = json.load(f)
- except:
- data = {}
- try:
- with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', '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:
- if 0 <= now_time() < 5.5:
- await session.send(
- choice(
- [
- 'zzzz......',
- 'zzzzzzzz......',
- 'zzz...好涩哦..zzz....',
- '别...不要..zzz..那..zzz..',
- '嘻嘻..zzz..呐~..zzzz..'
- ]
- )
- )
- else:
- await session.send(
- f"""{render_expression(HELP_REPLY)}
- 请仔细阅读文档哦~~https://blog.lolihub.icu/#/ATRI/user"""
- )
+ 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 _(session: CommandSession):
+async def EMMAAAA(session: CommandSession):
+ global RepoList
h_type = session.event.detail_type
msg = session.current_arg.strip()
user = session.event.user_id
@@ -217,6 +137,11 @@ async def _(session: CommandSession):
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,
@@ -227,4 +152,21 @@ async def _(session: CommandSession):
await bot.send_private_msg(
user_id = master,
message = f"来自用户[{user}]的反馈:\n{msg}"
- ) # type: ignore \ No newline at end of file
+ ) # 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 = 24,
+ misfire_grace_time = 10
+)
+async def _():
+ global RepoList
+ try:
+ RepoList = []
+ except:
+ await bot.send_private_msg(user_id = master, message = f'红茶重置失败...请手动重启ATRI以重置红茶...') # type: ignore \ No newline at end of file