idiot
This commit is contained in:
parent
9a8d9bc3e2
commit
23774d3199
5 changed files with 41 additions and 19 deletions
10
bot.py
10
bot.py
|
@ -350,10 +350,7 @@ async def ping(ctx):
|
|||
@bot.hybrid_command(description=f"{get_translation(LOCALE, 'command_about_desc')}")
|
||||
async def about(ctx):
|
||||
print("-----------------------------------\n\n")
|
||||
try:
|
||||
check_for_update() # check_for_update from modules/version.py
|
||||
except Exception as e:
|
||||
pass
|
||||
latest_version = check_for_update() # check_for_update from modules/version.py
|
||||
print("-----------------------------------")
|
||||
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)
|
||||
|
@ -367,10 +364,7 @@ async def stats(ctx):
|
|||
if ctx.author.id != ownerid:
|
||||
return
|
||||
print("-----------------------------------\n\n")
|
||||
try:
|
||||
check_for_update() # check_for_update from modules/version.py
|
||||
except Exception as e:
|
||||
pass
|
||||
latest_version = check_for_update() # check_for_update from modules/version.py
|
||||
print("-----------------------------------")
|
||||
memory_file = 'memory.json'
|
||||
file_size = os.path.getsize(memory_file)
|
||||
|
|
|
@ -40,5 +40,5 @@ song = os.getenv("song")
|
|||
arch = platform.machine()
|
||||
slash_commands_enabled = False
|
||||
latest_version = "0.0.0"
|
||||
local_version = "0.15.6"
|
||||
local_version = "0.15.7"
|
||||
os.environ['gooberlocal_version'] = local_version
|
||||
|
|
|
@ -5,10 +5,11 @@ import sys
|
|||
import subprocess
|
||||
import ast
|
||||
import requests
|
||||
import re
|
||||
import importlib.metadata
|
||||
|
||||
from modules.globalvars import *
|
||||
from ping3 import ping
|
||||
|
||||
|
||||
def check_requirements():
|
||||
STD_LIB_MODULES = {
|
||||
|
@ -101,16 +102,43 @@ def check_requirements():
|
|||
print("\nAll requirements are satisfied.")
|
||||
|
||||
def check_latency():
|
||||
|
||||
host = "1.1.1.1" # change this to google later
|
||||
latency = ping(host)
|
||||
host = "1.1.1.1"
|
||||
|
||||
if latency is not None:
|
||||
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}")
|
||||
system = platform.system()
|
||||
if system == "Windows":
|
||||
cmd = ["ping", "-n", "1", "-w", "1000", host]
|
||||
latency_pattern = r"Average = (\d+)ms"
|
||||
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():
|
||||
try:
|
||||
|
|
|
@ -75,3 +75,4 @@ def check_for_update():
|
|||
elif local_version == latest_version:
|
||||
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")
|
||||
return latest_version
|
|
@ -5,4 +5,3 @@ requests
|
|||
psutil
|
||||
better_profanity
|
||||
python-dotenv
|
||||
ping3
|
Loading…
Add table
Add a link
Reference in a new issue