added cpu info to stats

This commit is contained in:
ctih1 2025-07-26 14:27:47 +03:00
parent 6acb1f68d3
commit e8779f16df
4 changed files with 41 additions and 16 deletions

View file

@ -9,6 +9,8 @@ from modules.permission import requires_admin
from modules.sentenceprocessing import send_message
from modules.settings import instance as settings_manager
import requests
import psutil
import cpuinfo
settings = settings_manager.settings
@ -125,7 +127,9 @@ class BaseCommands(commands.Cog):
memory_info = psutil.virtual_memory() # type: ignore
total_memory = memory_info.total / (1024**3)
used_memory = memory_info.used / (1024**3)
free_memory = memory_info.available / (1024**3)
cpu_name = cpuinfo.get_cpu_info()["brand"]
with open(memory_file, "r") as file:
@ -143,8 +147,11 @@ class BaseCommands(commands.Cog):
)
embed.add_field(
name=k.memory_embed_field(),
value=k.memory_usage(used=used_memory, total=total_memory, percent=round(used_memory/total_memory * 100))
name=k.system_info(),
value=f"""
{k.memory_usage(used=used_memory, total=total_memory, percent=round(used_memory/total_memory * 100))}
{k.cpu_info(cpu_name)}
"""
)
with open(settings["splash_text_loc"], "r") as f:

View file

@ -138,6 +138,7 @@
"blacklisted": "blacklisted",
"blacklisted_user": "Blacklisted user",
"edit_fail": "Failed to edit message",
"memory_embed_field": "RAM details"
"system_info": "System information",
"cpu_info": "CPU: {cpu}"
}

View file

@ -2306,19 +2306,35 @@ def edit_fail(lang:str|None=None):
if lang == 'fr': return "Failed to edit message"
if lang == 'it': return "Failed to edit message"
else: raise ValueError(f'Invalid language {lang}')
def memory_embed_field(lang:str|None=None):
def system_info(lang:str|None=None):
"""
### Locales
- En: **RAM details**
- Es: **RAM details**
- Fi: **RAM details**
- Fr: **RAM details**
- It: **RAM details**
- En: **System information**
- Es: **System information**
- Fi: **System information**
- Fr: **System information**
- It: **System information**
"""
if not lang: lang=default_lang
if lang == 'en': return "RAM details"
if lang == 'es': return "RAM details"
if lang == 'fi': return "RAM details"
if lang == 'fr': return "RAM details"
if lang == 'it': return "RAM details"
if lang == 'en': return "System information"
if lang == 'es': return "System information"
if lang == 'fi': return "System information"
if lang == 'fr': return "System information"
if lang == 'it': return "System information"
else: raise ValueError(f'Invalid language {lang}')
def cpu_info(cpu,lang:str|None=None):
"""
### Locales
- En: **CPU: {cpu}**
- Es: **CPU: {cpu}**
- Fi: **CPU: {cpu}**
- Fr: **CPU: {cpu}**
- It: **CPU: {cpu}**
"""
if not lang: lang=default_lang
if lang == 'en': return "CPU: {cpu}".format_map({"cpu": cpu})
if lang == 'es': return "CPU: {cpu}".format_map({"cpu": cpu})
if lang == 'fi': return "CPU: {cpu}".format_map({"cpu": cpu})
if lang == 'fr': return "CPU: {cpu}".format_map({"cpu": cpu})
if lang == 'it': return "CPU: {cpu}".format_map({"cpu": cpu})
else: raise ValueError(f'Invalid language {lang}')

View file

@ -8,4 +8,5 @@ better_profanity
python-dotenv
dotenv
pillow
watchdog
watchdog
py-cpuinfo