diff options
Diffstat (limited to 'ATRI/plugins/Check.py')
-rw-r--r-- | ATRI/plugins/Check.py | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/ATRI/plugins/Check.py b/ATRI/plugins/Check.py index 1dc64a0..ab92310 100644 --- a/ATRI/plugins/Check.py +++ b/ATRI/plugins/Check.py @@ -6,11 +6,12 @@ from pathlib import Path import nonebot from nonebot import on_command, CommandSession -import config # type: ignore +import config +from ATRI.modules.error import errorBack bot = nonebot.get_bot() -master = config.MASTER() +master = config.SUPERUSERS file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json' file1 = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json' @@ -153,7 +154,7 @@ async def _(session: CommandSession): -@on_command('check_status', patterns = [r"检查状态|检查运行|检查身体"]) +@on_command('check_status', patterns = [r"检查状态|检查运行|检查身体|查看状态"]) async def _(session: CommandSession): user = session.event.user_id group = session.event.group_id @@ -175,11 +176,14 @@ async def _(session: CommandSession): if str(user) in data1.keys(): pass else: - 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 + 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 = 'アトリは、高性能ですから!' @@ -199,8 +203,20 @@ async def _(session: CommandSession): * 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 = ['追踪'], only_to_me = False) +@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() |