mirror of
https://github.com/GaMeNu/HFCNotificator.git
synced 2024-11-16 15:24:51 +02:00
v2.2.4
Added info command, along with organized way to save client data
This commit is contained in:
parent
d00eb57250
commit
005678640f
@ -15,14 +15,16 @@ Alternatively, you can DM the bot to receive alerts directly to your DMs!
|
|||||||
Please do note that the bot instance listed here is hosted on a private machine, and may be a bit slow.
|
Please do note that the bot instance listed here is hosted on a private machine, and may be a bit slow.
|
||||||
|
|
||||||
## Command documentation
|
## Command documentation
|
||||||
#### /about
|
|
||||||
Get some info about the bot
|
|
||||||
#### /register
|
#### /register
|
||||||
Run in a channel to register it to receive alerts
|
Run in a channel to register it to receive alerts
|
||||||
#### /unregister
|
#### /unregister
|
||||||
Run in a registered channel to stop it from receiving alerts
|
Run in a registered channel to stop it from receiving alerts
|
||||||
#### /latest \<time\> \<unit\> \[page\]
|
#### /latest \<time\> \<unit\> \[page\]
|
||||||
Get the latest alerts from up to a certain time back.
|
Get the latest alerts from up to a certain time back.
|
||||||
|
#### /about
|
||||||
|
Get some info about the bot itself
|
||||||
|
#### /info
|
||||||
|
Get info about the system and client
|
||||||
|
|
||||||
### Location commands
|
### Location commands
|
||||||
#### /locations add \<id\>
|
#### /locations add \<id\>
|
||||||
|
4
botinfo.json
Normal file
4
botinfo.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"version": "2.2.4",
|
||||||
|
"maintainer": "GaMeNu (@gamenu)"
|
||||||
|
}
|
7
botinfo.py
Normal file
7
botinfo.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
with open('botinfo.json', 'r') as f:
|
||||||
|
botinfo_dict = json.loads(f.read())
|
||||||
|
|
||||||
|
version = botinfo_dict["version"]
|
||||||
|
maintainer = botinfo_dict["maintainer"]
|
@ -1,13 +1,18 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import psutil
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands, tasks
|
from discord.ext import commands, tasks
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
|
|
||||||
|
import cpuinfo
|
||||||
|
import botinfo
|
||||||
import db_access
|
import db_access
|
||||||
import errlogging
|
import errlogging
|
||||||
from db_access import *
|
from db_access import *
|
||||||
@ -101,6 +106,8 @@ class Notificator(commands.Cog):
|
|||||||
if not self.check_for_updates.is_running():
|
if not self.check_for_updates.is_running():
|
||||||
self.check_for_updates.start()
|
self.check_for_updates.start()
|
||||||
|
|
||||||
|
self.start_time = time.time()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def setup(bot: commands.Bot, handler: logging.Handler):
|
async def setup(bot: commands.Bot, handler: logging.Handler):
|
||||||
"""
|
"""
|
||||||
@ -523,7 +530,52 @@ class Notificator(commands.Cog):
|
|||||||
|
|
||||||
return ret_str
|
return ret_str
|
||||||
|
|
||||||
@app_commands.command(name='about', description='Info about the bot')
|
@app_commands.command(name='info', description='Get client and system info')
|
||||||
|
async def botinfo(self, intr: discord.Interaction):
|
||||||
|
|
||||||
|
def format_timedelta(timedelta: datetime.timedelta):
|
||||||
|
return f'{timedelta.days} days, {((timedelta.seconds // 3600) % 24)}:{((timedelta.seconds // 60) % 60)}:{(timedelta.seconds % 60)}'
|
||||||
|
|
||||||
|
curtime = time.time()
|
||||||
|
client_uptime = datetime.timedelta(seconds=int(round(curtime - self.start_time)))
|
||||||
|
client_uptime_format = format_timedelta(client_uptime)
|
||||||
|
|
||||||
|
print(curtime)
|
||||||
|
print(psutil.boot_time())
|
||||||
|
print(curtime - psutil.boot_time())
|
||||||
|
|
||||||
|
system_uptime = datetime.timedelta(seconds=int(round(curtime - psutil.boot_time())))
|
||||||
|
system_uptime_format = format_timedelta(system_uptime)
|
||||||
|
|
||||||
|
uname = platform.uname()
|
||||||
|
|
||||||
|
b_to_mb = 1000000
|
||||||
|
|
||||||
|
e = discord.Embed(color=discord.Color.orange())
|
||||||
|
e.title = 'Home Front Command Notificator'
|
||||||
|
e.description = 'Info about this bot instance'
|
||||||
|
|
||||||
|
e.add_field(name='', value=f'''```asciidoc
|
||||||
|
==== Instance and Client Information ====
|
||||||
|
Version :: {botinfo.version}
|
||||||
|
Uptime :: {client_uptime_format}
|
||||||
|
Instance Maintainer(s) :: {botinfo.maintainer}
|
||||||
|
|
||||||
|
Guilds Joined :: {len(self.bot.guilds)}
|
||||||
|
Registered channels :: {len(self.db.get_all_channels())}
|
||||||
|
|
||||||
|
==== System Information ====
|
||||||
|
OS :: {uname.system} {uname.release}
|
||||||
|
Uptime :: {system_uptime_format}
|
||||||
|
|
||||||
|
Processor :: {cpuinfo.get_cpu_info()["brand_raw"]}
|
||||||
|
Proc.Usage :: {psutil.cpu_percent()}%
|
||||||
|
|
||||||
|
RAM Usage :: {(psutil.virtual_memory().used / b_to_mb):.2f} MB / {(psutil.virtual_memory().total / b_to_mb):.2f} MB ({psutil.virtual_memory().percent}%)
|
||||||
|
```''', inline=False)
|
||||||
|
await intr.response.send_message(embed=e)
|
||||||
|
|
||||||
|
@app_commands.command(name='about', description='About the bot')
|
||||||
async def about_bot(self, intr: discord.Interaction):
|
async def about_bot(self, intr: discord.Interaction):
|
||||||
e = discord.Embed(color=discord.Color.orange())
|
e = discord.Embed(color=discord.Color.orange())
|
||||||
e.title = 'Home Front Command Notificator'
|
e.title = 'Home Front Command Notificator'
|
||||||
|
@ -2,4 +2,6 @@ aiohttp==3.9.0b0
|
|||||||
discord.py
|
discord.py
|
||||||
mysql-connector-python
|
mysql-connector-python
|
||||||
requests
|
requests
|
||||||
python-dotenv
|
python-dotenv
|
||||||
|
py-cpuinfo
|
||||||
|
psutil~=5.9.6
|
@ -1,4 +1,6 @@
|
|||||||
discord.py
|
discord.py
|
||||||
mysql-connector-python
|
mysql-connector-python~=8.2.0
|
||||||
requests
|
requests~=2.31.0
|
||||||
python-dotenv
|
python-dotenv~=1.0.0
|
||||||
|
py-cpuinfo~=9.0.0
|
||||||
|
psutil~=5.9.6
|
Loading…
Reference in New Issue
Block a user