This commit is contained in:
expect 2025-06-23 13:56:23 +02:00
parent 9a8d9bc3e2
commit 23774d3199
5 changed files with 41 additions and 19 deletions

10
bot.py
View file

@ -350,10 +350,7 @@ async def ping(ctx):
@bot.hybrid_command(description=f"{get_translation(LOCALE, 'command_about_desc')}") @bot.hybrid_command(description=f"{get_translation(LOCALE, 'command_about_desc')}")
async def about(ctx): async def about(ctx):
print("-----------------------------------\n\n") print("-----------------------------------\n\n")
try: latest_version = check_for_update() # check_for_update from modules/version.py
check_for_update() # check_for_update from modules/version.py
except Exception as e:
pass
print("-----------------------------------") print("-----------------------------------")
embed = discord.Embed(title=f"{get_translation(LOCALE, 'command_about_embed_title')}", description="", color=discord.Color.blue()) embed = discord.Embed(title=f"{get_translation(LOCALE, 'command_about_embed_title')}", description="", color=discord.Color.blue())
embed.add_field(name=f"{get_translation(LOCALE, 'command_about_embed_field1')}", value=f"{NAME}", inline=False) embed.add_field(name=f"{get_translation(LOCALE, 'command_about_embed_field1')}", value=f"{NAME}", inline=False)
@ -367,10 +364,7 @@ async def stats(ctx):
if ctx.author.id != ownerid: if ctx.author.id != ownerid:
return return
print("-----------------------------------\n\n") print("-----------------------------------\n\n")
try: latest_version = check_for_update() # check_for_update from modules/version.py
check_for_update() # check_for_update from modules/version.py
except Exception as e:
pass
print("-----------------------------------") print("-----------------------------------")
memory_file = 'memory.json' memory_file = 'memory.json'
file_size = os.path.getsize(memory_file) file_size = os.path.getsize(memory_file)

View file

@ -40,5 +40,5 @@ song = os.getenv("song")
arch = platform.machine() arch = platform.machine()
slash_commands_enabled = False slash_commands_enabled = False
latest_version = "0.0.0" latest_version = "0.0.0"
local_version = "0.15.6" local_version = "0.15.7"
os.environ['gooberlocal_version'] = local_version os.environ['gooberlocal_version'] = local_version

View file

@ -5,10 +5,11 @@ import sys
import subprocess import subprocess
import ast import ast
import requests import requests
import re
import importlib.metadata import importlib.metadata
from modules.globalvars import * from modules.globalvars import *
from ping3 import ping
def check_requirements(): def check_requirements():
STD_LIB_MODULES = { STD_LIB_MODULES = {
@ -101,16 +102,43 @@ def check_requirements():
print("\nAll requirements are satisfied.") print("\nAll requirements are satisfied.")
def check_latency(): def check_latency():
host = "1.1.1.1"
host = "1.1.1.1" # change this to google later system = platform.system()
latency = ping(host) if system == "Windows":
cmd = ["ping", "-n", "1", "-w", "1000", host]
if latency is not None: latency_pattern = r"Average = (\d+)ms"
print(f"Ping to {host}: {latency * 1000:.2f} ms")
if latency * 1000 > 300:
print(f"{YELLOW}High latency detected! You may experience delays in response times.{RESET}")
else: else:
print("Ping failed.") cmd = ["ping", "-c", "1", "-W", "1", host]
latency_pattern = r"time[=<]\s*([\d\.]+)\s*ms"
try:
result = subprocess.run(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
if result.returncode == 0:
print(result.stdout)
# Try to extract latency
match = re.search(latency_pattern, result.stdout)
if match:
latency_ms = float(match.group(1))
print(f"Ping to {host}: {latency_ms:.2f} ms")
if latency_ms > 300:
print(f"{YELLOW}High latency detected! You may experience delays in response times.{RESET}")
else:
print(f"{YELLOW}Could not parse latency.{RESET}")
else:
print(result.stderr)
print(f"{RED}Ping to {host} failed.{RESET}")
except Exception as e:
print(f"{RED}Error running ping: {e}{RESET}")
def check_memory(): def check_memory():
try: try:

View file

@ -75,3 +75,4 @@ def check_for_update():
elif local_version == latest_version: elif local_version == latest_version:
print(f"{GREEN}{get_translation(LOCALE, 'latest_version')} {local_version}{RESET}") print(f"{GREEN}{get_translation(LOCALE, 'latest_version')} {local_version}{RESET}")
print(f"{get_translation(LOCALE, 'latest_version2').format(VERSION_URL=VERSION_URL)}\n\n") print(f"{get_translation(LOCALE, 'latest_version2').format(VERSION_URL=VERSION_URL)}\n\n")
return latest_version

View file

@ -5,4 +5,3 @@ requests
psutil psutil
better_profanity better_profanity
python-dotenv python-dotenv
ping3