2021-02-01 15:13:11 +00:00
|
|
|
|
import asyncio
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
import psutil
|
|
|
|
|
from graia.application import Group, Friend
|
|
|
|
|
|
|
|
|
|
from core.template import sendMessage, revokeMessage
|
2021-07-10 17:05:07 +00:00
|
|
|
|
from database_old import BotDB as database
|
2021-04-28 13:39:15 +00:00
|
|
|
|
from core.broadcast import app
|
2021-07-06 18:00:26 +00:00
|
|
|
|
from modules_o.utils.ab import ab
|
|
|
|
|
from modules_o.utils.newbie import newbie
|
|
|
|
|
from modules_o.utils.rc import rc
|
2021-02-01 15:13:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def rc_loader(kwargs: dict):
|
|
|
|
|
if Group in kwargs:
|
|
|
|
|
table = 'start_wiki_link_group'
|
|
|
|
|
id = kwargs[Group].id
|
|
|
|
|
if Friend in kwargs:
|
|
|
|
|
table = 'start_wiki_link_self'
|
|
|
|
|
id = kwargs[Friend].id
|
|
|
|
|
msg = await rc(table, id)
|
|
|
|
|
await sendMessage(kwargs, msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def ab_loader(kwargs: dict):
|
|
|
|
|
if Group in kwargs:
|
|
|
|
|
table = 'start_wiki_link_group'
|
|
|
|
|
id = kwargs[Group].id
|
|
|
|
|
if Friend in kwargs:
|
|
|
|
|
table = 'start_wiki_link_self'
|
|
|
|
|
id = kwargs[Friend].id
|
|
|
|
|
msg = await ab(table, id)
|
|
|
|
|
send = await sendMessage(kwargs, msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def newbie_loader(kwargs: dict):
|
|
|
|
|
if Group in kwargs:
|
|
|
|
|
table = 'start_wiki_link_group'
|
|
|
|
|
id = kwargs[Group].id
|
|
|
|
|
if Friend in kwargs:
|
|
|
|
|
table = 'start_wiki_link_self'
|
|
|
|
|
id = kwargs[Friend].id
|
|
|
|
|
msg = await newbie(table, id)
|
|
|
|
|
await sendMessage(kwargs, msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def ping(kwargs: dict):
|
2021-05-22 08:45:39 +00:00
|
|
|
|
checkpermisson = database.check_superuser(kwargs)
|
|
|
|
|
result = "Pong!"
|
|
|
|
|
if checkpermisson:
|
|
|
|
|
Boot_Start = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(psutil.boot_time()))
|
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
Cpu_usage = psutil.cpu_percent()
|
|
|
|
|
RAM = int(psutil.virtual_memory().total / (1024 * 1024))
|
|
|
|
|
RAM_percent = psutil.virtual_memory().percent
|
|
|
|
|
Swap = int(psutil.swap_memory().total / (1024 * 1024))
|
|
|
|
|
Swap_percent = psutil.swap_memory().percent
|
|
|
|
|
Disk = int(psutil.disk_usage('.').used / (1024 * 1024 * 1024))
|
|
|
|
|
DiskTotal = int(psutil.disk_usage('.').total / (1024 * 1024 * 1024))
|
|
|
|
|
try:
|
|
|
|
|
GroupList = len(await app.groupList())
|
|
|
|
|
except Exception:
|
|
|
|
|
GroupList = '无法获取'
|
|
|
|
|
try:
|
|
|
|
|
FriendList = len(await app.friendList())
|
|
|
|
|
except Exception:
|
|
|
|
|
FriendList = '无法获取'
|
|
|
|
|
BFH = r'%'
|
|
|
|
|
result += (f"\n系统运行时间:{Boot_Start}"
|
|
|
|
|
+ f"\n当前CPU使用率:{Cpu_usage}{BFH}"
|
|
|
|
|
+ f"\n物理内存:{RAM}M 使用率:{RAM_percent}{BFH}"
|
|
|
|
|
+ f"\nSwap内存:{Swap}M 使用率:{Swap_percent}{BFH}"
|
|
|
|
|
+ f"\n磁盘容量:{Disk}G/{DiskTotal}G"
|
|
|
|
|
+ f"\n已加入群聊:{GroupList}"
|
|
|
|
|
+ f" | 已添加好友:{FriendList}")
|
2021-02-01 15:13:11 +00:00
|
|
|
|
await sendMessage(kwargs, result)
|
|
|
|
|
|
2021-02-01 15:25:57 +00:00
|
|
|
|
|
2021-02-01 15:13:11 +00:00
|
|
|
|
command = {'rc': rc_loader, 'ab': ab_loader, 'newbie': newbie_loader}
|
|
|
|
|
essential = {'ping': ping}
|
2021-06-05 10:25:21 +00:00
|
|
|
|
alias = {'p': 'ping'}
|
2021-02-09 13:05:19 +00:00
|
|
|
|
help = {'rc': {'help': '~rc - 查询Wiki最近更改。'},
|
|
|
|
|
'ab': {'help': '~ab - 查询Wiki滥用过滤器日志。'},
|
|
|
|
|
'newbie': {'help': '~newbie - 查询Wiki用户注册日志。'},
|
|
|
|
|
'ping': {'help': '~ping - PongPongPong', 'essential': True}}
|