commit
6a04ada599
16 changed files with 118 additions and 502 deletions
66
assets/cogs/pulse.py
Normal file
66
assets/cogs/pulse.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
from discord.ext import commands
|
||||
import discord
|
||||
from collections import defaultdict, Counter
|
||||
import datetime
|
||||
from modules.globalvars import ownerid
|
||||
class StatsCog(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.start_time = datetime.datetime.utcnow()
|
||||
self.active_users = set()
|
||||
self.total_messages = 0
|
||||
self.command_usage = Counter()
|
||||
self.user_message_counts = Counter()
|
||||
self.messages_per_hour = defaultdict(int)
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message):
|
||||
if message.author.bot:
|
||||
return
|
||||
self.active_users.add(message.author.id)
|
||||
self.total_messages += 1
|
||||
self.user_message_counts[message.author.id] += 1
|
||||
|
||||
now = datetime.datetime.utcnow()
|
||||
hour_key = now.strftime("%Y-%m-%d %H")
|
||||
self.messages_per_hour[hour_key] += 1
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_command(self, ctx):
|
||||
self.command_usage[ctx.command.qualified_name] += 1
|
||||
|
||||
@commands.command()
|
||||
async def spyware(self, ctx):
|
||||
if ctx.author.id != ownerid:
|
||||
return
|
||||
uptime = datetime.datetime.utcnow() - self.start_time
|
||||
hours_elapsed = max((uptime.total_seconds() / 3600), 1)
|
||||
avg_per_hour = self.total_messages / hours_elapsed
|
||||
if self.messages_per_hour:
|
||||
peak_hour, peak_count = max(self.messages_per_hour.items(), key=lambda x: x[1])
|
||||
else:
|
||||
peak_hour, peak_count = "N/A", 0
|
||||
|
||||
top_users = self.user_message_counts.most_common(5)
|
||||
|
||||
embed = discord.Embed(title="Community Stats", color=discord.Color.blue())
|
||||
embed.add_field(name="Uptime", value=str(uptime).split('.')[0], inline=False)
|
||||
embed.add_field(name="Total Messages", value=str(self.total_messages), inline=True)
|
||||
embed.add_field(name="Active Users", value=str(len(self.active_users)), inline=True)
|
||||
embed.add_field(name="Avg Messages/Hour", value=f"{avg_per_hour:.2f}", inline=True)
|
||||
embed.add_field(name="Peak Hour (UTC)", value=f"{peak_hour}: {peak_count} messages", inline=True)
|
||||
|
||||
top_str = "\n".join(
|
||||
f"<@{user_id}>: {count} messages" for user_id, count in top_users
|
||||
) or "No data"
|
||||
embed.add_field(name="Top Chatters", value=top_str, inline=False)
|
||||
|
||||
cmd_str = "\n".join(
|
||||
f"{cmd}: {count}" for cmd, count in self.command_usage.most_common(5)
|
||||
) or "No commands used yet"
|
||||
embed.add_field(name="Top Commands", value=cmd_str, inline=False)
|
||||
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
async def setup(bot):
|
||||
await bot.add_cog(StatsCog(bot))
|
|
@ -3,6 +3,6 @@
|
|||
This folder contains localization files for the project.
|
||||
|
||||
**Notice:**
|
||||
The Maltese, Frisian, Estonian, Spanish, and French locales currently do not have maintainers. If you are interested in helping maintain or improve these translations, please consider contributing!
|
||||
The Spanish and French locales currently do not have maintainers. If you are interested in helping maintain or improve these translations, please consider contributing!
|
||||
|
||||
Thank you for supporting localization efforts!
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"memory_file_valid": "The memory.json file is valid!",
|
||||
"file_aint_uft8": "File is not valid UTF-8 text. Might be binary or corrupted.",
|
||||
"psutil_not_installed": "Memory check skipped.",
|
||||
"not_cloned": "Goober is not cloned! Please clone it from GitHub.",
|
||||
"checks_disabled": "Checks are disabled!",
|
||||
|
@ -99,7 +101,7 @@
|
|||
"command_markov_retrain": "Retraining the Markov model... Please wait.",
|
||||
"command_markov_memory_not_found": "Error: memory file not found!",
|
||||
"command_markov_memory_is_corrupt": "Error: memory file is corrupt!",
|
||||
"command_markov_retraining": "Processing {processed_data}/{data_size} data points...",
|
||||
"command_markov_retraining": "Processing {data_size} data points...",
|
||||
"command_markov_retrain_successful": "Markov model retrained successfully using {data_size} data points!",
|
||||
"command_desc_talk":"talks n like stuf",
|
||||
"command_talk_insufficent_text": "I need to learn more from messages before I can talk.",
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
{
|
||||
"checks_disabled": "Tarkistukset on poistettu käytöstä!",
|
||||
"active_users:": "Aktiiviset käyttäjät:",
|
||||
"spacy_initialized": "spaCy ja spacytextblob ovat valmiita.",
|
||||
"spacy_model_not_found": "spaCy mallia ei löytynyt! Ladataan se....`",
|
||||
"unhandled_exception": "Käsittelemätön virhe tapahtui. Ilmoita tästä GitHubiin.",
|
||||
"env_file_not_found": ".env faili ei leitud! Palun loo see vajalike muutujatega.",
|
||||
"error_fetching_active_users": "Aktiivsete kasutajate hankimisel tekkis viga: {error}",
|
||||
"error_sending_alive_ping": "Elusoleku ping'i saatmisel tekkis viga: {error}",
|
||||
"already_started": "Olen juba käivitatud! Ei uuenda...",
|
||||
"please_restart": "Palun taaskäivita goober!",
|
||||
"local_ahead": "Kohalik {remote}/{branch} on ees või ajakohane. Ei uuenda...",
|
||||
"remote_ahead": "Kaug-{remote}/{branch} on ees. Uuendan...",
|
||||
"cant_find_local_version": "Ma ei leia local_version muutujat! Või on seda muudetud ja see pole täisarv!",
|
||||
"running_prestart_checks": "Käivitamiseelsed kontrollid käivad...",
|
||||
"continuing_in_seconds": "Jätkan {seconds} sekundi pärast... Vajuta suvalist klahvi, et vahele jätta.",
|
||||
"missing_requests_psutil": "Puuduvad requests ja psutil! Palun paigalda need käsuga: `pip install requests psutil`",
|
||||
"requirements_not_found": "requirements.txt faili ei leitud asukohast {path}, kas seda on muudetud?",
|
||||
"warning_failed_parse_imports": "Hoiatus: Importide parsimine ebaõnnestus failist {filename}: {error}",
|
||||
"cogs_dir_not_found": "Cogs kataloogi ei leitud asukohast {path}, jätan vahele.",
|
||||
"std_lib_local_skipped": "STD LIB / KOHALIK {package} (kontroll vahele jäetud)",
|
||||
"ok_installed": "OK",
|
||||
"missing_package": "PUUDUB",
|
||||
"missing_package2": "ei ole paigaldatud",
|
||||
"missing_packages_detected": "Tuvastati puuduvad paketid:",
|
||||
"telling_goober_central": "Teavitan goober central aadressil {url}",
|
||||
"failed_to_contact": "Ei õnnestunud ühendust saada {url}: {error}",
|
||||
"all_requirements_satisfied": "Kõik nõuded on täidetud.",
|
||||
"ping_to": "Ping aadressile {host}: {latency} ms",
|
||||
"high_latency": "Tuvastatud kõrge latentsus! Võid kogeda viivitusi vastustes.",
|
||||
"could_not_parse_latency": "Latentsust ei õnnestunud parsida.",
|
||||
"ping_failed": "Ping aadressile {host} ebaõnnestus.",
|
||||
"error_running_ping": "Ping'i käivitamisel tekkis viga: {error}",
|
||||
"memory_usage": "Mälu kasutus: {used} GB / {total} GB ({percent}%)",
|
||||
"memory_above_90": "Mälu kasutus on üle 90% ({percent}%). Kaalu mälu vabastamist.",
|
||||
"total_memory": "Kogu mälu: {total} GB",
|
||||
"used_memory": "Kasutatud mälu: {used} GB",
|
||||
"low_free_memory": "Tuvastatud vähe vaba mälu! Ainult {free} GB saadaval.",
|
||||
"measuring_cpu": "Mõõdan protsessori kasutust tuuma kohta...",
|
||||
"core_usage": "Tuuma {idx}: [{bar}] {usage}%",
|
||||
"total_cpu_usage": "Kogu protsessori kasutus: {usage}%",
|
||||
"high_avg_cpu": "Kõrge keskmine protsessori kasutus: {usage}%",
|
||||
"really_high_cpu": "Väga kõrge protsessori koormus! Süsteem võib hakata tõrkuma.",
|
||||
"memory_file": "Mälufail: {size} MB",
|
||||
"memory_file_large": "Mälufail on 1GB või suurem, kaalu selle kustutamist ruumi vabastamiseks.",
|
||||
"memory_file_corrupted": "Mälufail on rikutud! JSON dekodeerimise viga: {error}",
|
||||
"consider_backup_memory": "Kaalu mälufaili varundamist ja uuesti loomist.",
|
||||
"memory_file_encoding": "Mälufailil on kodeeringu probleemid: {error}",
|
||||
"error_reading_memory": "Viga mälufaili lugemisel: {error}",
|
||||
"memory_file_not_found": "Mälufaili ei leitud.",
|
||||
"modification_warning": "Gooberit on muudetud! Kõik muudatused lähevad uuendamisel kaotsi!",
|
||||
"reported_version": "Teatatud versioon:",
|
||||
"current_hash": "Praegune räsi:",
|
||||
"not_found": "ei leitud!",
|
||||
"version_error": "Versiooni infot ei õnnestunud hankida. Staatuskood",
|
||||
"loaded_cog": "Laaditud cog:",
|
||||
"loaded_cog2": "Laaditud moodul:",
|
||||
"cog_fail": "Cog'i laadimine ebaõnnestus:",
|
||||
"cog_fail2": "Mooduli laadimine ebaõnnestus:",
|
||||
"no_model": "Salvestatud Markovi mudelit ei leitud. Alustan nullist.",
|
||||
"folder_created": "Kaust '{folder_name}' loodud.",
|
||||
"folder_exists": "Kaust '{folder_name}' on juba olemas. Jätan vahele...",
|
||||
"logged_in": "Sisse logitud kui",
|
||||
"synced_commands": "Sünkroonitud",
|
||||
"synced_commands2": "käsku!",
|
||||
"fail_commands_sync": "Käskude sünkroonimine ebaõnnestus:",
|
||||
"started": "{name} on käivitatud!",
|
||||
"name_check": "Viga nime saadavuse kontrollimisel:",
|
||||
"name_taken": "Nimi on juba võetud. Palun vali teine nimi.",
|
||||
"name_check2": "Viga nime saadavuse kontrolli ajal:",
|
||||
"add_token": "Token: {token}\nPalun lisa see token oma .env faili kui",
|
||||
"token_exists": "Token on juba .env failis olemas. Kasutan olemasolevat tokenit.",
|
||||
"registration_error": "Registreerimisel tekkis viga:",
|
||||
"version_backup": "Varukoopia loodud:",
|
||||
"backup_error": "Viga: {LOCAL_VERSION_FILE} ei leitud varundamiseks.",
|
||||
"model_loaded": "Markovi mudel laaditud asukohast",
|
||||
"fetch_update_fail": "Uuenduse infot ei õnnestunud hankida.",
|
||||
"invalid_server": "Viga: Serverilt saadud versiooni info on vigane.",
|
||||
"goober_server_alert": "Hoiatus goober centralilt!\n",
|
||||
"new_version": "Uus versioon saadaval: {latest_version} (Praegune: {local_version})",
|
||||
"changelog": "Vaata {VERSION_URL}/goob/changes.txt, et näha muudatuste logi\n\n",
|
||||
"invalid_version": "Versioon: {local_version} ei ole kehtiv!",
|
||||
"invalid_version2": "Kui see on tahtlik, siis ignoreeri seda teadet, muidu vajuta Y, et tõmmata serverist kehtiv versioon sõltumata praegu töötavast gooberi versioonist",
|
||||
"invalid_version3": "Praegune versioon varundatakse faili current_version.bak..",
|
||||
"input": "(Y või mõni muu klahv, et ignoreerida....)",
|
||||
"modification_ignored": "Oled muutnud",
|
||||
"modification_ignored2": "IGNOREWARNING on seatud väärtusele false..",
|
||||
"latest_version": "Kasutad uusimat versiooni:",
|
||||
"latest_version2": "Vaata {VERSION_URL}/goob/changes.txt, et näha muudatuste logi",
|
||||
"pinging_disabled": "Pingimine on keelatud! Ei teavita serverit...",
|
||||
"goober_ping_success": "Sisse logitud goober centralisse kui {NAME}",
|
||||
"goober_ping_fail": "Andmete saatmine ebaõnnestus. Server tagastas staatuse:",
|
||||
"goober_ping_fail2": "Andmete saatmisel tekkis viga:",
|
||||
"sentence_positivity": "Lause positiivsus on:",
|
||||
"command_edit_fail": "Sõnumi muutmine ebaõnnestus:",
|
||||
"command_desc_retrain": "Treeni Markovi mudelit käsitsi uuesti.",
|
||||
"command_markov_retrain": "Markovi mudelit treenitakse uuesti... Palun oota.",
|
||||
"command_markov_memory_not_found": "Viga: mälufaili ei leitud!",
|
||||
"command_markov_memory_is_corrupt": "Viga: mälufail on rikutud!",
|
||||
"command_markov_retraining": "Töötlen {processed_data}/{data_size} andmepunkti...",
|
||||
"command_markov_retrain_successful": "Markovi mudel treeniti edukalt uuesti, kasutades {data_size} andmepunkti!",
|
||||
"command_desc_talk": "räägib ja muud sellist",
|
||||
"command_talk_insufficent_text": "Mul on vaja rohkem sõnumeid õppimiseks, enne kui saan rääkida.",
|
||||
"command_talk_generation_fail": "Mul pole hetkel midagi öelda!",
|
||||
"command_desc_help": "abi",
|
||||
"command_help_embed_title": "Boti abi",
|
||||
"command_help_embed_desc": "Käskude loetelu kategooriate kaupa.",
|
||||
"command_help_categories_general": "Üldine",
|
||||
"command_help_categories_admin": "Administreerimine",
|
||||
"command_help_categories_custom": "Kohandatud käsud",
|
||||
"command_ran": "Info: {message.author.name} käivitas {message.content}",
|
||||
"command_ran_s": "Info: {interaction.user} käivitas ",
|
||||
"command_desc_ping": "ping",
|
||||
"command_ping_embed_desc": "Boti latentsus:",
|
||||
"command_ping_footer": "Soovis",
|
||||
"command_about_desc": "teave",
|
||||
"command_about_embed_title": "Minust",
|
||||
"command_about_embed_field1": "Nimi",
|
||||
"command_about_embed_field2name": "Versioon",
|
||||
"command_about_embed_field2value": "Kohalik: {local_version} \nViimane: {latest_version}",
|
||||
"command_desc_stats": "statistika",
|
||||
"command_stats_embed_title": "Boti statistika",
|
||||
"command_stats_embed_desc": "Andmed boti mälu kohta.",
|
||||
"command_stats_embed_field1name": "Faili statistika",
|
||||
"command_stats_embed_field1value": "Suurus: {file_size} baiti\nRead: {line_count}",
|
||||
"command_stats_embed_field2name": "Versioon",
|
||||
"command_stats_embed_field2value": "Kohalik: {local_version} \nViimane: {latest_version}",
|
||||
"command_stats_embed_field3name": "Muutuja info",
|
||||
"command_stats_embed_field3value": "Nimi: {NAME} \nPrefiks: {PREFIX} \nOmaniku ID: {ownerid}\nPingirida: {PING_LINE} \nMälu jagamine lubatud: {showmemenabled} \nKasutajaõpe lubatud: {USERTRAIN_ENABLED}\nLaul: {song} \nSplashtekst: ```{splashtext}```"
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"memory_file_valid": "memory.json on toimiva!",
|
||||
"file_aint_uft8": "Tiedosto ei ole UTF-8 tekstiä. Saattaa olla binääriä tai korruptoitunut.",
|
||||
"active_users:": "Aktiiviset käyttäjät:",
|
||||
"cog_fail2": "Moduulin lataaminen epäonnistui:",
|
||||
"command_ran_s": "Info: {interaction.user} suoritti",
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
{
|
||||
"env_file_not_found": "It .env-bestân is net fûn! Meitsje ien mei de fereaske fariabelen.",
|
||||
"error_fetching_active_users": "Flater by it opheljen fan aktive brûkers: {error}",
|
||||
"error_sending_alive_ping": "Flater by it ferstjoeren fan alive ping: {error}",
|
||||
"already_started": "Ik bin al start! Gjin update...",
|
||||
"please_restart": "Start opnij, goober!",
|
||||
"local_ahead": "Lokaal {remote}/{branch} is foarút of by de tiid. Gjin update...",
|
||||
"remote_ahead": "Remote {remote}/{branch} is foarút. Update wurdt útfierd...",
|
||||
"cant_find_local_version": "Kin de local_version-fariabele net fine! Of it is ferboud en gjin integer mear!",
|
||||
"running_prestart_checks": "Pre-start kontrôles wurde útfierd...",
|
||||
"continuing_in_seconds": "Trochgean oer {seconds} sekonden... Druk op in toets om oer te slaan.",
|
||||
"missing_requests_psutil": "Requests en psutil ûntbrekke! Ynstallearje se mei pip: `pip install requests psutil`",
|
||||
"requirements_not_found": "requirements.txt net fûn op {path}, is it ferboud?",
|
||||
"warning_failed_parse_imports": "Warskôging: Ynlêzen fan imports út {filename} mislearre: {error}",
|
||||
"cogs_dir_not_found": "Cogs-map net fûn op {path}, oerslein.",
|
||||
"std_lib_local_skipped": "STD LIB / LOKAAL {package} (kontrôle oerslein)",
|
||||
"ok_installed": "OK",
|
||||
"missing_package": "NET FÛN",
|
||||
"missing_package2": "is net ynstallearre",
|
||||
"missing_packages_detected": "Untbrekkende pakketten fûn:",
|
||||
"telling_goober_central": "Ynformaasje ferstjoerd nei goober central op {url}",
|
||||
"failed_to_contact": "Kontakt mei {url} mislearre: {error}",
|
||||
"all_requirements_satisfied": "Alle easken binne foldien.",
|
||||
"ping_to": "Ping nei {host}: {latency} ms",
|
||||
"high_latency": "Hege latency ûntdutsen! Jo kinne fertraging ûnderfine.",
|
||||
"could_not_parse_latency": "Latency koe net lêzen wurde.",
|
||||
"ping_failed": "Ping nei {host} mislearre.",
|
||||
"error_running_ping": "Flater by it útfieren fan ping: {error}",
|
||||
"memory_usage": "Unthâldbrûk: {used} GB / {total} GB ({percent}%)",
|
||||
"memory_above_90": "Unthâldbrûk is boppe 90% ({percent}%). Frij wat ûnthâld op.",
|
||||
"total_memory": "Totaal Unthâld: {total} GB",
|
||||
"used_memory": "Brûkt Unthâld: {used} GB",
|
||||
"low_free_memory": "Leech frij ûnthâld ûntdutsen! Mar {free} GB beskikber.",
|
||||
"measuring_cpu": "CPU-brûk per kearn wurdt metten...",
|
||||
"core_usage": "Kearn {idx}: [{bar}] {usage}%",
|
||||
"total_cpu_usage": "Totale CPU-brûk: {usage}%",
|
||||
"high_avg_cpu": "Heech gemiddeld CPU-brûk: {usage}%",
|
||||
"really_high_cpu": "Tige hege CPU-lêst! It systeem kin traach wurde of hingje.",
|
||||
"memory_file": "Unthâld-bestân: {size} MB",
|
||||
"memory_file_large": "Unthâld-bestân is 1GB of mear, wiskje om romte frij te meitsjen.",
|
||||
"memory_file_corrupted": "Unthâld-bestân is skansearre! JSON decode-flater: {error}",
|
||||
"consider_backup_memory": "Tink derom om in reservekopy fan it ûnthâld-bestân te meitsjen en opnij oan te meitsjen.",
|
||||
"memory_file_encoding": "Unthâld-bestân hat enkodearingsproblemen: {error}",
|
||||
"error_reading_memory": "Flater by it lêzen fan ûnthâld-bestân: {error}",
|
||||
"memory_file_not_found": "Unthâld-bestân net fûn.",
|
||||
"modification_warning": "Goober is oanpast! Wizigingen sille ferlern gean by in update!",
|
||||
"reported_version": "Melde ferzje:",
|
||||
"current_hash": "Aktuele Hash:",
|
||||
"not_found": "net fûn!",
|
||||
"version_error": "Koe ferzje-ynfo net ophelje. Statuskoade",
|
||||
"loaded_cog": "Cog laden:",
|
||||
"loaded_cog2": "Module laden:",
|
||||
"cog_fail": "Cog laden mislearre:",
|
||||
"cog_fail2": "Module laden mislearre:",
|
||||
"no_model": "Gjin bewarre Markov-model fûn. Fanôf nij begjinne.",
|
||||
"folder_created": "Map '{folder_name}' oanmakke.",
|
||||
"folder_exists": "Map '{folder_name}' bestiet al. oerslein...",
|
||||
"logged_in": "Ynlogd as",
|
||||
"synced_commands": "Kommando's syngronisearre",
|
||||
"synced_commands2": "kommando's!",
|
||||
"fail_commands_sync": "Syngronisaasje fan kommando's mislearre:",
|
||||
"started": "{name} is begûn!",
|
||||
"name_check": "Flater by it kontrolearjen fan namme beskikberens:",
|
||||
"name_taken": "Namme is al yn gebrûk. Kies in oare.",
|
||||
"name_check2": "Flater by nammekontrôle:",
|
||||
"add_token": "Token: {token}\nFoegje dizze token ta oan jo .env-bestân as",
|
||||
"token_exists": "Token bestiet al yn .env. Fierder mei besteande token.",
|
||||
"registration_error": "Flater by registraasje:",
|
||||
"version_backup": "Reservekopy makke:",
|
||||
"backup_error": "Flater: {LOCAL_VERSION_FILE} net fûn foar reservekopy.",
|
||||
"model_loaded": "Markov-model laden fan",
|
||||
"fetch_update_fail": "Koe update-ynformaasje net ophelje.",
|
||||
"invalid_server": "Flater: Unjildige ferzje ynformaasje ûntfongen fan server.",
|
||||
"goober_server_alert": "Warskôging fan goober central!\n",
|
||||
"new_version": "Nije ferzje beskikber: {latest_version} (Aktueel: {local_version})",
|
||||
"changelog": "Sjoch {VERSION_URL}/goob/changes.txt foar de wizigingslog\n\n",
|
||||
"invalid_version": "De ferzje: {local_version} is net jildich!",
|
||||
"invalid_version2": "As dit bewust is, negearje dit dan. Oars druk op Y om in jildige ferzje fan 'e server te heljen.",
|
||||
"invalid_version3": "De aktuele ferzje wurdt bewarre as current_version.bak..",
|
||||
"input": "(Y of in oare toets om te negearjen....)",
|
||||
"modification_ignored": "Jo hawwe oanpassingen dien oan",
|
||||
"modification_ignored2": "IGNOREWARNING is ynsteld op false..",
|
||||
"latest_version": "Jo brûke de lêste ferzje:",
|
||||
"latest_version2": "Sjoch {VERSION_URL}/goob/changes.txt foar de wizigingslog",
|
||||
"pinging_disabled": "Pingjen is útskeakele! Gjin melding oan de server...",
|
||||
"goober_ping_success": "Ynlogd op goober central as {NAME}",
|
||||
"goober_ping_fail": "Ferstjoeren fan gegevens mislearre. Server joech statuskoade:",
|
||||
"goober_ping_fail2": "Flater by it ferstjoeren fan gegevens:",
|
||||
"sentence_positivity": "Positiviteit fan sin is:",
|
||||
"command_edit_fail": "Flater by it bewurkjen fan berjocht:",
|
||||
"command_desc_retrain": "Traind it Markov-model opnij.",
|
||||
"command_markov_retrain": "Markov-model wurdt opnij traind... Wachtsje efkes.",
|
||||
"command_markov_memory_not_found": "Flater: ûnthâld-bestân net fûn!",
|
||||
"command_markov_memory_is_corrupt": "Flater: ûnthâld-bestân is skansearre!",
|
||||
"command_markov_retraining": "Ferwurket {processed_data}/{data_size} gegevenspunten...",
|
||||
"command_markov_retrain_successful": "Markov-model mei sukses opnij traind mei {data_size} gegevenspunten!",
|
||||
"command_desc_talk": "praat en sa",
|
||||
"command_talk_insufficent_text": "Ik moat mear leare fan berjochten foardat ik prate kin.",
|
||||
"command_talk_generation_fail": "Ik ha no neat te sizzen!",
|
||||
"command_desc_help": "help",
|
||||
"command_help_embed_title": "Bot Help",
|
||||
"command_help_embed_desc": "List mei kommando's groepearre op kategory.",
|
||||
"command_help_categories_general": "Algemien",
|
||||
"command_help_categories_admin": "Behear",
|
||||
"command_help_categories_custom": "Oanpaste Kommando's",
|
||||
"command_ran": "Info: {message.author.name} hat {message.content} útfierd",
|
||||
"command_ran_s": "Info: {interaction.user} hat útfierd ",
|
||||
"command_desc_ping": "ping",
|
||||
"command_ping_embed_desc": "Bot Latency:",
|
||||
"command_ping_footer": "Frege troch",
|
||||
"command_about_desc": "oer",
|
||||
"command_about_embed_title": "Oer my",
|
||||
"command_about_embed_field1": "Namme",
|
||||
"command_about_embed_field2name": "Ferzje",
|
||||
"command_about_embed_field2value": "Lokaal: {local_version} \nLêste: {latest_version}",
|
||||
"command_desc_stats": "stats",
|
||||
"command_stats_embed_title": "Bot Statistyk",
|
||||
"command_stats_embed_desc": "Gegevens oer it ûnthâld fan de bot.",
|
||||
"command_stats_embed_field1name": "Bestân Statistyk",
|
||||
"command_stats_embed_field1value": "Grutte: {file_size} bytes\nRigels: {line_count}",
|
||||
"command_stats_embed_field2name": "Ferzje",
|
||||
"command_stats_embed_field2value": "Lokaal: {local_version} \nLêste: {latest_version}",
|
||||
"command_stats_embed_field3name": "Fariabel Info",
|
||||
"command_stats_embed_field3value": "Namme: {NAME} \nFoarheaksel: {PREFIX} \nEigner ID: {ownerid}\nPingrigel: {PING_LINE} \nUnthâld Dielen Ynskeakele: {showmemenabled} \nBrûkerstraining Ynskeakele: {USERTRAIN_ENABLED}\nLiet: {song} \nSplashtekst: ```{splashtext}```"
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"memory_file_valid": "Il file JSON è valido!",
|
||||
"file_aint_utf8": "Il file non è un UTF-8 valido. Forse è binario?",
|
||||
"psutil_not_installed": "Controllo memoria saltato.",
|
||||
"not_cloned": "Goober non è stato clonato! Clonalo da GitHub.",
|
||||
"checks_disabled": "I controlli sono disabilitati!",
|
||||
|
@ -100,7 +102,7 @@
|
|||
"command_markov_retrain": "Rafforzamento del modello Markov in corso... Attendere.",
|
||||
"command_markov_memory_not_found": "Errore: file di memoria non trovato!",
|
||||
"command_markov_memory_is_corrupt": "Errore: file di memoria corrotto!",
|
||||
"command_markov_retraining": "Elaborazione di {processed_data}/{data_size} punti dati...",
|
||||
"command_markov_retraining": "Elaborazione di {data_size} punti dati...",
|
||||
"command_markov_retrain_successful": "Modello Markov rafforzato con successo utilizzando {data_size} punti dati!",
|
||||
"command_desc_talk": "parla n come stuf",
|
||||
"command_talk_insufficent_text": "Ho bisogno di imparare di più dai messaggi prima di poter parlare.",
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
{
|
||||
"env_file_not_found": "Ma nstab l‑file .env! Oħloq wieħed bil‑varjabbli meħtieġa.",
|
||||
"error_fetching_active_users": "Żball waqt il‑ġbir tal‑utenti attivi: {error}",
|
||||
"error_sending_alive_ping": "Żball biex jintbagħat l‑alive ping: {error}",
|
||||
"already_started": "Illum diġà bdejt! Ma sejħinx l‑aġġornament…",
|
||||
"please_restart": "Irristartja jekk jogħġbok, goober!",
|
||||
"local_ahead": "L‑lokali {remote}/{branch} qiegħed qabel jew parallelament. Ma qed naġġornax…",
|
||||
"remote_ahead": "Il‑remote {remote}/{branch} hu 'l quddiem. Qed naġġorna…",
|
||||
"cant_find_local_version": "Ma nistax insib il‑varjabbli local_version! Jew ġie ħassar u mhux intier!",
|
||||
"running_prestart_checks": "Qed inħadmu ċ‑ċekkjijiet tal‑pre‑start…",
|
||||
"continuing_in_seconds": "Se nkunu qed inkomplu fi żmien {seconds} sekondi… Agħfas kwalunkwe buttuna biex tiċċekkja.",
|
||||
"missing_requests_psutil": "M’hemmx requests u psutil! Poġġihom b’pip: `pip install requests psutil`",
|
||||
"requirements_not_found": "requirements.txt mhux instab f’{path}, ġie modifikat?",
|
||||
"warning_failed_parse_imports": "Twissija: Parse tal‑imports f’{filename} fallita: {error}",
|
||||
"cogs_dir_not_found": "Direttorju “cogs” mhux instab f’{path}, qed niskippjaw l‑iskan.",
|
||||
"std_lib_local_skipped": "STD LIB / LOKALI {package} (ċekk skippjat)",
|
||||
"ok_installed": "OK",
|
||||
"missing_package": "NINNEŻER",
|
||||
"missing_package2": "mhux installat",
|
||||
"missing_packages_detected": "Parzijiet nieqsa ġew skoperti:",
|
||||
"telling_goober_central": "Qed ninfurmaw lill‑goober central f’{url}",
|
||||
"failed_to_contact": "Falliment fil‑kuntatt ma’ {url}: {error}",
|
||||
"all_requirements_satisfied": "Il‑ħtiġijiet kollha laqgħu.",
|
||||
"ping_to": "Ping lejn {host}: {latency} ms",
|
||||
"high_latency": "Latentizza għolja skoperta! Possibbli dewmien fir‑rispons.",
|
||||
"could_not_parse_latency": "Ma nistax ninterpreta l‑latentizza.",
|
||||
"ping_failed": "Ping lejn {host} falla.",
|
||||
"error_running_ping": "Żball fl‑eżekuzzjoni tal‑ping: {error}",
|
||||
"memory_usage": "Użu ta' memorja: {used} GB / {total} GB ({percent}%)",
|
||||
"memory_above_90": "Użu ta’ memorja fuq 90% ({percent}%). Ħsieb li tnaddaf xi ħaġa.",
|
||||
"total_memory": "Memorja totali: {total} GB",
|
||||
"used_memory": "Memorja użata: {used} GB",
|
||||
"low_free_memory": "Memorja ħielsa baxxa! Biss {free} GB disponibbli.",
|
||||
"measuring_cpu": "Qed nkejlu l‑CPU għal kull core…",
|
||||
"core_usage": "Core {idx}: [{bar}] {usage}%",
|
||||
"total_cpu_usage": "Użu totali tal‑CPU: {usage}%",
|
||||
"high_avg_cpu": "Użu medju għoli tal‑CPU: {usage}%",
|
||||
"really_high_cpu": "Użu eċċessiv tal‑CPU! Is‑sistema tista’ tieħu throttle jew tieqaf.",
|
||||
"memory_file": "Fajl tal‑memorja: {size} MB",
|
||||
"memory_file_large": "Il‑fajl tal‑memorja hu 1 GB jew aktar, ħsieb biex tiċċara għandu tagħmel sens.",
|
||||
"memory_file_corrupted": "Il‑fajl tal‑memorja hu korrott! Żball JSON decode: {error}",
|
||||
"consider_backup_memory": "Inħeġġuk biex tagħmel backup u terġa’ toħloq il‑fajl tal‑memorja.",
|
||||
"memory_file_encoding": "Il‑fajl tal‑memorja għandu issues ta’ kodifika: {error}",
|
||||
"error_reading_memory": "Żball fil‑qari tal‑fajl tal‑memorja: {error}",
|
||||
"memory_file_not_found": "Fajl tal‑memorja mhux instab.",
|
||||
"modification_warning": "Il‑Goober ġie mmodifikat! Kull tibdil jintilef fl‑aġġornament!",
|
||||
"reported_version": "Verżjoni rrappurtata:",
|
||||
"current_hash": "Hash attwali:",
|
||||
"not_found": "mhux instab!",
|
||||
"version_error": "Ma nistax niġbor informazzjoni dwar il‑verżjoni. Kodiċi ta’ stat",
|
||||
"loaded_cog": "Cog imlaħħaq:",
|
||||
"loaded_cog2": "Modulu imlaħħaq:",
|
||||
"cog_fail": "Falliment fit‑tagħbija tal‑cog:",
|
||||
"cog_fail2": "Falliment fit‑tagħbija tal‑modulu:",
|
||||
"no_model": "Ma nstab l-ebda Markov model maħżun. Bdejt minn null.",
|
||||
"folder_created": "Folder ‘{folder_name}’ ġie maħluq.",
|
||||
"folder_exists": "Folder ‘{folder_name}’ diġà teżisti. qed niskippja…",
|
||||
"logged_in": "Id‑depożitu bħala",
|
||||
"synced_commands": "Sync sseħħ",
|
||||
"synced_commands2": "kmandi!",
|
||||
"fail_commands_sync": "Falliment tas‑sync tal‑kmandi:",
|
||||
"started": "{name} beda!",
|
||||
"name_check": "Żball fil‑ċekk tal‑isem:",
|
||||
"name_taken": "L‑isem diġà jieħu. Sib ieħor, jekk jogħġbok.",
|
||||
"name_check2": "Żball waqt iċ‑ċekk tal‑availabbiltà ta’ l‑isem:",
|
||||
"add_token": "Token: {token}\nŻid dan fil‑.env bħala",
|
||||
"token_exists": "Token diġà jeżisti fil‑.env. Qed inkomplu bil‑token attwali.",
|
||||
"registration_error": "Żball fir‑reġistrazzjoni:",
|
||||
"version_backup": "Backup maħluq:",
|
||||
"backup_error": "Żball: {LOCAL_VERSION_FILE} mhux instab għaż‑backup.",
|
||||
"model_loaded": "Markov model imlaħħaq minn",
|
||||
"fetch_update_fail": "Ma setgħux jiġbdu informazzjoni dwar l‑aġġornament.",
|
||||
"invalid_server": "Żball: Informazzjoni dwar il‑verżjoni misjuba mis‑server mhix valida.",
|
||||
"goober_server_alert": "Allarm minn goober central!\n",
|
||||
"new_version": "Verżjoni ġdida disponibbli: {latest_version} (Attwali: {local_version})",
|
||||
"changelog": "Eżamina {VERSION_URL}/goob/changes.txt biex tara l‑modifiki\n\n",
|
||||
"invalid_version": "Il‑verżjoni: {local_version} mhix valida!",
|
||||
"invalid_version2": "Jekk intenzjonata, ignora; inkella agħfas Y biex tittrasferixxi verżjoni valida mill‑server minkejja l‑verżjoni ta’ goober attwali",
|
||||
"invalid_version3": "Il‑verżjoni attwali tkun backuppjata għal current_version.bak..",
|
||||
"input": "(Y jew kwalunkwe buttuna oħra biex tinjoraha…)",
|
||||
"modification_ignored": "Int immodifikajt",
|
||||
"modification_ignored2": "IGNOREWARNING hija false..",
|
||||
"latest_version": "Int qed tuża l‑verżjoni l‑iktar ġdida:",
|
||||
"latest_version2": "Ara {VERSION_URL}/goob/changes.txt biex tara l‑log tal‑modifiki",
|
||||
"pinging_disabled": "Pinging imblukkat! Ma qed ninfurmakx li għadek online…",
|
||||
"goober_ping_success": "Logged fil‑goober central bħala {NAME}",
|
||||
"goober_ping_fail": "Falliment fl‑invjaġġ tal‑data. Il‑server irrisponda b’kodiċi stat:",
|
||||
"goober_ping_fail2": "Żball seħħ waqt li bagħta data:",
|
||||
"sentence_positivity": "Posittività ta’ sentenza hi:",
|
||||
"command_edit_fail": "Falliment fit‑tbiddel tal‑messaġġ:",
|
||||
"command_desc_retrain": "Retrain il‑Markov model b’manu.",
|
||||
"command_markov_retrain": "Qed inretrain il‑Markov model… Awżilja, jekk jogħġbok.",
|
||||
"command_markov_memory_not_found": "Żball: fajl tal‑memorja maħżun mhux instab!",
|
||||
"command_markov_memory_is_corrupt": "Żball: fajl tal‑memorja hu korrott!",
|
||||
"command_markov_retraining": "Qed nipproċessa {processed_data}/{data_size} punti tad‑data…",
|
||||
"command_markov_retrain_successful": "Markov model retrained b’suċċess bl‑użu ta’ {data_size} punti tad‑data!",
|
||||
"command_desc_talk": "jitkellem bħal affarijiet",
|
||||
"command_talk_insufficent_text": "Għandi bżonn nitgħallem iktar mill‑messaġġi qabel nista’ nitkellem.",
|
||||
"command_talk_generation_fail": "M’għandi xejn x’ngħid bħalissa!",
|
||||
"command_desc_help": "għin",
|
||||
"command_help_embed_title": "Għajnuna tal‑Bot",
|
||||
"command_help_embed_desc": "Lista ta’ kmandi maqsuma b’kategoriji.",
|
||||
"command_help_categories_general": "Ġenerali",
|
||||
"command_help_categories_admin": "Amministrazzjoni",
|
||||
"command_help_categories_custom": "Kmandi Personalizzati",
|
||||
"command_ran": "Info: {message.author.name} użani {message.content}",
|
||||
"command_ran_s": "Info: {interaction.user} użani ",
|
||||
"command_desc_ping": "ping",
|
||||
"command_ping_embed_desc": "Latentizza tal‑Bot:",
|
||||
"command_ping_footer": "Mtitlub minn",
|
||||
"command_about_desc": "dwar",
|
||||
"command_about_embed_title": "Dwar jien",
|
||||
"command_about_embed_field1": "Isem",
|
||||
"command_about_embed_field2name": "Verżjoni",
|
||||
"command_about_embed_field2value": "Lokali: {local_version} \nĠdida: {latest_version}",
|
||||
"command_desc_stats": "stats",
|
||||
"command_stats_embed_title": "Stati tal‑Bot",
|
||||
"command_stats_embed_desc": "Informazzjoni dwar il‑memorja tal‑bot.",
|
||||
"command_stats_embed_field1name": "Statistika tal‑Fajl",
|
||||
"command_stats_embed_field1value": "Daqs: {file_size} bytes\nLinji: {line_count}",
|
||||
"command_stats_embed_field2name": "Verżjoni",
|
||||
"command_stats_embed_field2value": "Lokali: {local_version} \nĠdida: {latest_version}",
|
||||
"command_stats_embed_field3name": "Informazzjoni Varjabbli",
|
||||
"command_stats_embed_field3value": "Isem: {NAME} \nPrefiss: {PREFIX} \nID ta’ Sid: {ownerid}\nPing line: {PING_LINE} \nImoħħar Memenja: {showmemenabled} \nUser Training Attiva: {USERTRAIN_ENABLED}\nKan ta’: {song} \nSplashtext: ```{splashtext}```"
|
||||
}
|
20
bot.py
20
bot.py
|
@ -180,8 +180,6 @@ async def retrain(ctx: commands.Context) -> None:
|
|||
|
||||
for i, data in enumerate(memory):
|
||||
processed_data += 1
|
||||
if processed_data % 1000 == 0 or processed_data == data_size:
|
||||
await send_message(ctx, f"{_('command_markov_retraining').format(processed_data=processed_data, data_size=data_size)}", edit=True, message_reference=processing_message_ref)
|
||||
|
||||
global markov_model
|
||||
markov_model = train_markov_model(memory)
|
||||
|
@ -389,6 +387,24 @@ async def on_message(message: discord.Message) -> None:
|
|||
cleaned_message: str = preprocess_message(formatted_message)
|
||||
if cleaned_message:
|
||||
memory.append(cleaned_message)
|
||||
message_metadata = {
|
||||
"user_id": str(message.author.id),
|
||||
"user_name": str(message.author),
|
||||
"guild_id": str(message.guild.id) if message.guild else "DM",
|
||||
"guild_name": str(message.guild.name) if message.guild else "DM",
|
||||
"channel_id": str(message.channel.id),
|
||||
"channel_name": str(message.channel),
|
||||
"message": message.content,
|
||||
"timestamp": time.time()
|
||||
}
|
||||
try:
|
||||
if isinstance(memory, list):
|
||||
memory.append({"_meta": message_metadata})
|
||||
else:
|
||||
logger.warning("Memory is not a list; can't append metadata")
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to append metadata to memory: {e}")
|
||||
|
||||
save_memory(memory)
|
||||
|
||||
sentiment_score = is_positive(message.content) # doesnt work but im scared to change the logic now please ignore
|
||||
|
|
|
@ -6,6 +6,7 @@ OWNERID=
|
|||
USERTRAINENABLED="true"
|
||||
SHOWMEMENABLED="true"
|
||||
LOCALE=fi
|
||||
NAME=goober
|
||||
AUTOUPDATE="True"
|
||||
SONG="Basket Case - Green Day"
|
||||
CHECKSDISABLED="Frue"
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
import os
|
||||
import importlib
|
||||
import inspect
|
||||
import sys
|
||||
|
||||
_hooks = {}
|
||||
|
||||
def register_hook(name, func):
|
||||
if name not in _hooks:
|
||||
_hooks[name] = []
|
||||
_hooks[name].append(func)
|
||||
|
||||
async def call_hook(name, *args, **kwargs):
|
||||
if name not in _hooks:
|
||||
return
|
||||
for func in _hooks[name]:
|
||||
if callable(func):
|
||||
if inspect.iscoroutinefunction(func):
|
||||
await func(*args, **kwargs)
|
||||
else:
|
||||
func(*args, **kwargs)
|
||||
|
||||
def register_all_functions_as_hooks(module):
|
||||
"""Register every function/coroutine function in the given module as a hook under its function name."""
|
||||
for name, obj in inspect.getmembers(module):
|
||||
if inspect.isfunction(obj) or inspect.iscoroutinefunction(obj):
|
||||
register_hook(name, obj)
|
||||
|
||||
def _register_all_modules_functions():
|
||||
"""Scan all python modules in this 'modules' folder (excluding this file) and register their functions."""
|
||||
# Calculate the path to the modules directory relative to this file
|
||||
modules_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Current file name so we skip it
|
||||
current_file = os.path.basename(__file__)
|
||||
|
||||
# Ensure 'modules' is in sys.path for importlib to work
|
||||
if modules_dir not in sys.path:
|
||||
sys.path.insert(0, modules_dir)
|
||||
|
||||
# List all python files except dunder files and this file
|
||||
for filename in os.listdir(modules_dir):
|
||||
if filename.endswith(".py") and not filename.startswith("__") and filename != current_file:
|
||||
module_name = filename[:-3] # strip .py extension
|
||||
try:
|
||||
module = importlib.import_module(module_name)
|
||||
register_all_functions_as_hooks(module)
|
||||
except Exception as e:
|
||||
print(f"[hooks] Failed to import {module_name}: {e}")
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ arch = platform.machine()
|
|||
slash_commands_enabled = True # 100% broken, its a newer enough version so its probably enabled by default.... fix this at somepoint or hard code it in goober central code
|
||||
launched = False
|
||||
latest_version = "0.0.0"
|
||||
local_version = "2.3.2"
|
||||
local_version = "2.3.3"
|
||||
os.environ['gooberlocal_version'] = local_version
|
||||
REACT = os.getenv("REACT")
|
||||
if get_git_branch() == "dev":
|
||||
|
|
|
@ -34,13 +34,15 @@ def save_memory(memory):
|
|||
with open(MEMORY_FILE, "w") as f:
|
||||
json.dump(memory, f, indent=4)
|
||||
|
||||
# Train a Markov model using memory and optional additional data
|
||||
def train_markov_model(memory, additional_data=None):
|
||||
if not memory:
|
||||
return None
|
||||
text = "\n".join(memory)
|
||||
filtered_memory = [line for line in memory if isinstance(line, str)]
|
||||
if additional_data:
|
||||
text += "\n" + "\n".join(additional_data)
|
||||
filtered_memory.extend(line for line in additional_data if isinstance(line, str))
|
||||
if not filtered_memory:
|
||||
return None
|
||||
text = "\n".join(filtered_memory)
|
||||
model = markovify.NewlineText(text, state_size=2)
|
||||
return model
|
||||
|
||||
|
|
|
@ -59,7 +59,8 @@ def check_requirements():
|
|||
PACKAGE_ALIASES = {
|
||||
"discord": "discord.py",
|
||||
"better_profanity": "better-profanity",
|
||||
"dotenv": "python-dotenv"
|
||||
"dotenv": "python-dotenv",
|
||||
"pil": "pillow"
|
||||
}
|
||||
|
||||
parent_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -71,36 +72,13 @@ def check_requirements():
|
|||
|
||||
with open(requirements_path, 'r') as f:
|
||||
lines = f.readlines()
|
||||
requirements = {
|
||||
line.strip() for line in lines
|
||||
if line.strip() and not line.startswith('#')
|
||||
}
|
||||
|
||||
cogs_dir = os.path.abspath(os.path.join(parent_dir, '..', 'assets', 'cogs'))
|
||||
if os.path.isdir(cogs_dir):
|
||||
for filename in os.listdir(cogs_dir):
|
||||
if filename.endswith('.py'):
|
||||
filepath = os.path.join(cogs_dir, filename)
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
try:
|
||||
tree = ast.parse(f.read(), filename=filename)
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Import):
|
||||
for alias in node.names:
|
||||
pkg = alias.name.split('.')[0]
|
||||
if pkg in STD_LIB_MODULES or pkg == 'modules':
|
||||
continue
|
||||
requirements.add(pkg)
|
||||
elif isinstance(node, ast.ImportFrom):
|
||||
if node.module:
|
||||
pkg = node.module.split('.')[0]
|
||||
if pkg in STD_LIB_MODULES or pkg == 'modules':
|
||||
continue
|
||||
requirements.add(pkg)
|
||||
except Exception as e:
|
||||
logger.warning(f"{(_('warning_failed_parse_imports')).format(filename=filename, error=e)}")
|
||||
else:
|
||||
logger.warning(f"{(_('cogs_dir_not_found')).format(path=cogs_dir)}")
|
||||
requirements = set()
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
base_pkg = line.split('==')[0].lower()
|
||||
aliased_pkg = PACKAGE_ALIASES.get(base_pkg, base_pkg)
|
||||
requirements.add(aliased_pkg)
|
||||
|
||||
installed_packages = {dist.metadata['Name'].lower() for dist in importlib.metadata.distributions()}
|
||||
missing = []
|
||||
|
@ -110,7 +88,7 @@ def check_requirements():
|
|||
print((_('std_lib_local_skipped')).format(package=req))
|
||||
continue
|
||||
|
||||
check_name = PACKAGE_ALIASES.get(req, req).lower()
|
||||
check_name = req.lower()
|
||||
|
||||
if check_name in installed_packages:
|
||||
logger.info(f"{_('ok_installed').format(package=check_name)} {check_name}")
|
||||
|
@ -122,31 +100,25 @@ def check_requirements():
|
|||
logger.error(_('missing_packages_detected'))
|
||||
for pkg in missing:
|
||||
print(f" - {pkg}")
|
||||
logger.info((_('telling_goober_central')).format(url=VERSION_URL))
|
||||
payload = {
|
||||
"name": NAME,
|
||||
"version": local_version,
|
||||
"slash_commands": f"{slash_commands_enabled}\n\n**Error**\nMissing packages have been detected, Failed to start",
|
||||
"token": gooberTOKEN
|
||||
}
|
||||
try:
|
||||
requests.post(VERSION_URL + "/ping", json=payload) # type: ignore
|
||||
except Exception as e:
|
||||
logger.error(f"{(_('failed_to_contact')).format(url=VERSION_URL, error=e)}")
|
||||
sys.exit(1)
|
||||
else:
|
||||
logger.info(_('all_requirements_satisfied'))
|
||||
|
||||
def check_latency():
|
||||
host = "1.1.1.1"
|
||||
|
||||
system = platform.system()
|
||||
|
||||
if system == "Windows":
|
||||
cmd = ["ping", "-n", "1", "-w", "1000", host]
|
||||
latency_pattern = r"Average = (\d+)ms"
|
||||
|
||||
elif system == "Darwin":
|
||||
cmd = ["ping", "-c", "1", host]
|
||||
latency_pattern = r"time=([\d\.]+) ms"
|
||||
|
||||
else:
|
||||
cmd = ["ping", "-c", "1", "-W", "1", host]
|
||||
latency_pattern = r"time[=<]\s*([\d\.]+)\s*ms"
|
||||
latency_pattern = r"time=([\d\.]+) ms"
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
|
@ -157,7 +129,6 @@ def check_latency():
|
|||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(result.stdout)
|
||||
match = re.search(latency_pattern, result.stdout)
|
||||
if match:
|
||||
latency_ms = float(match.group(1))
|
||||
|
@ -197,16 +168,6 @@ def check_cpu():
|
|||
return
|
||||
logger.info((_('measuring_cpu')))
|
||||
cpu_per_core = psutil.cpu_percent(interval=1, percpu=True) # type: ignore
|
||||
for idx, core_usage in enumerate(cpu_per_core):
|
||||
bar_length = int(core_usage / 5)
|
||||
bar = '█' * bar_length + '-' * (20 - bar_length)
|
||||
if core_usage > 85:
|
||||
color = RED
|
||||
elif core_usage > 60:
|
||||
color = YELLOW
|
||||
else:
|
||||
color = GREEN
|
||||
logger.info((_('core_usage')).format(idx=idx, bar=bar, usage=core_usage))
|
||||
total_cpu = sum(cpu_per_core) / len(cpu_per_core)
|
||||
logger.info((_('total_cpu_usage')).format(usage=total_cpu))
|
||||
if total_cpu > 85:
|
||||
|
|
|
@ -70,9 +70,7 @@ def get_latest_version_info():
|
|||
return None
|
||||
|
||||
# Check if an update is available and perform update if needed
|
||||
def check_for_update():
|
||||
if ALIVEPING != "True":
|
||||
return
|
||||
def check_for_update():
|
||||
global latest_version, local_version, launched
|
||||
|
||||
latest_version_info = get_latest_version_info()
|
||||
|
@ -87,12 +85,10 @@ def check_for_update():
|
|||
if not latest_version or not download_url:
|
||||
logger.error(f"{RED}{_('invalid_server')}{RESET}")
|
||||
return None, None
|
||||
|
||||
# Check if local_version is valid
|
||||
if local_version == "0.0.0" or None:
|
||||
logger.error(f"{RED}{_('cant_find_local_version')}{RESET}")
|
||||
return
|
||||
|
||||
# Compare local and latest versions
|
||||
if local_version < latest_version:
|
||||
logger.info(f"{YELLOW}{_('new_version').format(latest_version=latest_version, local_version=local_version)}{RESET}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue