52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
|
""" The system module. """
|
||
|
|
||
|
import sys
|
||
|
from platform import uname
|
||
|
import discord
|
||
|
from discord.ext import commands
|
||
|
from subprocess import run, PIPE
|
||
|
from pagermaid import color, des_handler, par_handler, redis_status
|
||
|
|
||
|
|
||
|
class Info(commands.Cog):
|
||
|
def __init__(self, bot):
|
||
|
self.bot = bot
|
||
|
|
||
|
@commands.command()
|
||
|
async def info(self, ctx):
|
||
|
git_hash = run("git rev-parse --short HEAD", stdout=PIPE, shell=True).stdout.decode().strip()
|
||
|
get_hash_link = f"https://github.com/Xtao-Labs/PagerMaid-Discord/commit/{git_hash}"
|
||
|
dpy_repo = "https://github.com/Rapptz/discord.py"
|
||
|
python_url = "https://www.python.org/"
|
||
|
|
||
|
app_info = await self.bot.application_info()
|
||
|
if app_info.team:
|
||
|
owner = app_info.team.name
|
||
|
else:
|
||
|
owner = app_info.owner
|
||
|
|
||
|
dpy_version = "[{}]({})".format(discord.__version__, dpy_repo)
|
||
|
python_version = "[{}.{}.{}]({})".format(*sys.version_info[:3], python_url)
|
||
|
git_version = "[{}]({})".format(git_hash, get_hash_link)
|
||
|
database = '在线' if redis_status() else '离线'
|
||
|
|
||
|
embed = discord.Embed(title="PagerMaid-Discord 运行状态", color=color)
|
||
|
embed.add_field(name="实例创建者", value=str(owner))
|
||
|
embed.add_field(name="Python", value=python_version)
|
||
|
embed.add_field(name="discord.py", value=dpy_version)
|
||
|
embed.add_field(name="Git commit", value=git_version)
|
||
|
embed.add_field(name="主机名", value=uname().node)
|
||
|
embed.add_field(name="主机平台", value=sys.platform)
|
||
|
embed.add_field(name="Kernel", value=uname().release)
|
||
|
embed.add_field(name="数据库", value=database)
|
||
|
embed.add_field(name="交流群", value='[点击加入](https://discord.gg/A4mWpa83e6)')
|
||
|
await ctx.send(embed=embed)
|
||
|
|
||
|
|
||
|
des_handler('info', '查看程序信息。')
|
||
|
par_handler('info', '')
|
||
|
|
||
|
|
||
|
def setup(bot):
|
||
|
bot.add_cog(Info(bot))
|