diff --git a/bot.py b/bot.py index dc5f725..5ea6cb9 100644 --- a/bot.py +++ b/bot.py @@ -22,10 +22,7 @@ import discord from discord.ext import commands from discord import Colour -import nltk -import nltk.data from better_profanity import profanity - from discord.ext import commands from modules.central import ping_server @@ -39,43 +36,7 @@ from modules.image import gen_image sys.excepthook = handle_exception check_for_update() # Check for updates (from modules/version.py) -# Ensure required NLTK resources are available -def check_resources(): - # Check for required NLTK resources and download if missing - resources = { - 'vader_lexicon': 'sentiment/vader_lexicon', - 'punkt_tab': 'tokenizers/punkt', - } - for resource, path in resources.items(): - try: - nltk.data.find(path) - print(f"{resource} is already installed.") - except Exception: - nltk.download(str(resource)) - -check_resources() - -# Download locale JSON files if not present -def download_json(): - # Download the locale JSON file from GitHub if not present - locales_dir = "locales" - response = requests.get(f"https://raw.githubusercontent.com/gooberinc/goober/refs/heads/main/locales/{LOCALE}.json") - if response.status_code == 200: - if not os.path.exists(locales_dir): - os.makedirs(locales_dir) - file_path = os.path.join(locales_dir, f"{LOCALE}.json") - if os.path.exists(file_path): - return - else: - with open(file_path, "w", encoding="utf-8") as file: - file.write(response.text) - if not os.path.exists(os.path.join(locales_dir, "en.json")): - response = requests.get(f"https://raw.githubusercontent.com/gooberinc/goober/refs/heads/main/locales/en.json") - if response.status_code == 200: - with open(os.path.join(locales_dir, "en.json"), "w", encoding="utf-8") as file: - file.write(response.text) - -download_json() +# removed since all locales come with goober now # Dynamically load all cogs (extensions) from the cogs folder async def load_cogs_from_folder(bot, folder_name="assets/cogs"): @@ -122,11 +83,7 @@ async def on_ready(): folder_name = "cogs" if launched == True: return - if not os.path.exists(folder_name): - os.makedirs(folder_name) - print(f"{GREEN}{get_translation(LOCALE, 'folder_created').format(folder_name=folder_name)}{RESET}") - else: - print(f"{DEBUG}{get_translation(LOCALE, 'folder_exists').format(folder_name=folder_name)}{RESET}") + # create folder logic only existed to prevent errors from upgrading from older versions of goober, now got nuked because its been like a billion versions since then await load_cogs_from_folder(bot) try: synced = await bot.tree.sync() diff --git a/locales/en.json b/locales/en.json deleted file mode 100644 index 354f2c7..0000000 --- a/locales/en.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "modification_warning": "Goober has been modified! Any changes will be lost in an update!", - "reported_version": "Reported Version:", - "current_hash": "Current Hash:", - "not_found": "is not found!", - "version_error": "Unable to fetch version info. Status code", - "loaded_cog": "Loaded cog:", - "loaded_cog2": "Loaded module:", - "cog_fail": "Failed to load cog:", - "cog_fail2": "Failed to load module:", - "no_model": "No saved Markov model found. Starting from scratch.", - "folder_created": "Folder '{folder_name}' created.", - "folder_exists": "Folder '{folder_name}' already exists. skipping...", - "logged_in": "Logged in as", - "synced_commands": "Synced", - "synced_commands2": "commands!", - "fail_commands_sync": "Failed to sync commands:", - "started": "{name} has started!", - "name_check": "Error checking name availability:", - "name_taken": "Name is already taken. Please choose a different name.", - "name_check2": "Error during name availability check:", - "add_token": "Token: {token}\nPlease add this token to your .env file as", - "token_exists": "Token already exists in .env. Continuing with the existing token.", - "registration_error": "Error during registration:", - "version_backup": "Backup created:", - "backup_error": "Error: {LOCAL_VERSION_FILE} not found for backup.", - "model_loaded": "Markov model loaded from", - "fetch_update_fail": "Could not fetch update information.", - "invalid_server": "Error: Invalid version information received from server.", - "goober_server_alert": "Alert from goober central!\n", - "new_version": "New version available: {latest_version} (Current: {local_version})", - "changelog": "Check {VERSION_URL}/goob/changes.txt to check out the changelog\n\n", - "invalid_version": "The version: {local_version} isnt valid!", - "invalid_version2": "If this is intended then ignore this message, else press Y to pull a valid version from the server regardless of the version of goober currently running", - "invalid_version3": "The current version will be backed up to current_version.bak..", - "input": "(Y or any other key to ignore....)", - "modification_ignored": "You've modified", - "modification_ignored2": "IGNOREWARNING is set to false..", - "latest_version": "You're using the latest version:", - "latest_version2": "Check {VERSION_URL}/goob/changes.txt to check out the changelog", - "pinging_disabled": "Pinging is disabled! Not telling the server im on...", - "goober_ping_success": "Logged into goober central as {NAME}", - "goober_ping_fail": "Failed to send data. Server returned status code:", - "goober_ping_fail2": "An error occurred while sending data:", - "sentence_positivity": "Positivity of sentence is:", - "command_edit_fail": "Failed to edit message:", - "command_desc_retrain": "Retrains the Markov model manually.", - "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_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.", - "command_talk_generation_fail": "I have nothing to say right now!", - "command_desc_help": "help", - "command_help_embed_title": "Bot Help", - "command_help_embed_desc": "List of commands grouped by category.", - "command_help_categories_general": "General", - "command_help_categories_admin": "Administration", - "command_help_categories_custom": "Custom Commands", - "command_ran": "Info: {message.author.name} ran {message.content}", - "command_ran_s": "Info: {interaction.user} ran ", - "command_desc_ping": "ping", - "command_ping_embed_desc": "Bot Latency:", - "command_ping_footer": "Requested by", - "command_about_desc": "about", - "command_about_embed_title": "About me", - "command_about_embed_field1": "Name", - "command_about_embed_field2name": "Version", - "command_about_embed_field2value": "Local: {local_version} \nLatest: {latest_version}", - "command_desc_stats": "stats", - "command_stats_embed_title": "Bot stats", - "command_stats_embed_desc": "Data about the the bot's memory.", - "command_stats_embed_field1name": "File Stats", - "command_stats_embed_field1value": "Size: {file_size} bytes\nLines: {line_count}", - "command_stats_embed_field2name": "Version", - "command_stats_embed_field2value": "Local: {local_version} \nLatest: {latest_version}", - "command_stats_embed_field3name": "Variable Info", - "command_stats_embed_field3value": "Name: {NAME} \nPrefix: {PREFIX} \nOwner ID: {ownerid} \nCooldown: {cooldown_time} \nPing line: {PING_LINE} \nMemory Sharing Enabled: {showmemenabled} \nUser Training Enabled: {USERTRAIN_ENABLED}\nSong: {song} \nSplashtext: ```{splashtext}```" -} - diff --git a/locales/it.json b/locales/it.json deleted file mode 100644 index 8a88b29..0000000 --- a/locales/it.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "modification_warning": "Goober è stato modificato! Verifiche del server saltate completamente...", - "reported_version": "Versione segnalata:", - "current_hash": "Hash attuale:", - "not_found": "non trovato!", - "version_error": "Impossibile recuperare le informazioni sulla versione. Codice di stato", - "loaded_cog": "Cog caricato:", - "cog_fail": "Impossibile caricare il cog:", - "loaded_cog2": "Module caricato:", - "cog_fail2": "Impossibile caricare il module:", - "no_model": "Nessun modello Markov salvato trovato. Iniziamo da zero.", - "folder_created": "Cartella '{folder_name}' creata.", - "folder_exists": "La cartella '{folder_name}' esiste già. Saltando...", - "logged_in": "Accesso effettuato come", - "synced_commands": "Sincronizzati", - "synced_commands2": "comandi!", - "fail_commands_sync": "Impossibile sincronizzare i comandi:", - "started": "{name} è stato avviato!", - "name_check": "Errore nel controllo disponibilità del nome:", - "name_taken": "Il nome è già preso. Scegli un nome diverso.", - "name_check2": "Errore durante il controllo della disponibilità del nome:", - "add_token": "Token: {token}\nAggiungi questo token al tuo file .env come", - "token_exists": "Il token esiste già in .env. Continuando con il token esistente.", - "goober_server_alert": "Avviso da goober central!\n", - "registration_error": "Errore durante la registrazione:", - "version_backup": "Backup creato:", - "backup_error": "Errore: {LOCAL_VERSION_FILE} non trovato per il backup.", - "model_loaded": "Modello Markov caricato da", - "fetch_update_fail": "Impossibile recuperare le informazioni sull'aggiornamento.", - "invalid_server": "Errore: informazioni sulla versione non valide ricevute dal server.", - "new_version": "Nuova versione disponibile: {latest_version} (Attuale: {local_version})", - "changelog": "Controlla {VERSION_URL}/goob/changes.txt per vedere il changelog\n\n", - "invalid_version": "La versione: {local_version} non è valida!", - "invalid_version2": "Se è intenzionale ignora questo messaggio, altrimenti premi Y per scaricare una versione valida dal server indipendentemente dalla versione attuale di goober", - "invalid_version3": "La versione attuale sarà salvata come current_version.bak..", - "input": "(Y o qualsiasi altro tasto per ignorare....)", - "modification_ignored": "Hai modificato", - "modification_ignored2": "IGNOREWARNING è impostato su false..", - "latest_version": "Stai utilizzando l'ultima versione:", - "latest_version2": "Controlla {VERSION_URL}/goob/changes.txt per vedere il changelog", - "pinging_disabled": "Il ping è disabilitato! Non dico al server che sono online...", - "goober_ping_success": "Accesso a goober central come {NAME}", - "goober_ping_fail": "Impossibile inviare i dati. Il server ha restituito il codice di stato:", - "goober_ping_fail2": "Si è verificato un errore durante l'invio dei dati:", - "sentence_positivity": "La positività della frase è:", - "command_edit_fail": "Impossibile modificare il messaggio:", - "command_desc_retrain": "Rafforza manualmente il modello Markov.", - "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_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.", - "command_talk_generation_fail": "Non ho nulla da dire in questo momento!", - "command_desc_help": "aiuto", - "command_help_embed_title": "Aiuto Bot", - "command_help_embed_desc": "Elenco dei comandi raggruppati per categoria.", - "command_help_categories_general": "Generale", - "command_help_categories_admin": "Amministrazione", - "command_help_categories_custom": "Comandi personalizzati", - "command_ran": "Info: {message.author.name} ha eseguito {message.content}", - "command_desc_ping": "ping", - "command_ping_embed_desc": "Latenza del bot:", - "command_ping_footer": "Richiesto da", - "command_about_desc": "informazioni", - "command_about_embed_title": "Informazioni su di me", - "command_about_embed_field1": "Nome", - "command_about_embed_field2name": "Versione", - "command_about_embed_field2value": "Locale: {local_version} \nUltima: {latest_version}", - "command_desc_stats": "statistiche", - "command_stats_embed_title": "Statistiche del bot", - "command_stats_embed_desc": "Dati sulla memoria del bot.", - "command_stats_embed_field1name": "Statistiche del file", - "command_stats_embed_field1value": "Dimensione: {file_size} byte\nLinee: {line_count}", - "command_stats_embed_field2name": "Versione", - "command_stats_embed_field2value": "Locale: {local_version} \nUltima: {latest_version}", - "command_stats_embed_field3name": "Informazioni sulle variabili", - "command_stats_embed_field3value": "Nome: {NAME} \nPrefisso: {PREFIX} \nID Proprietario: {ownerid} \nCooldown: {cooldown_time} \nLinea ping: {PING_LINE} \nMemoria Condivisa Abilitata: {showmemenabled} \nAddestramento Utente Abilitato: {USERTRAIN_ENABLED}\nCanzone: {song} \nSplashtext: ```{splashtext}```" - } - diff --git a/modules/sentenceprocessing.py b/modules/sentenceprocessing.py index 8bd7ec9..2394a6c 100644 --- a/modules/sentenceprocessing.py +++ b/modules/sentenceprocessing.py @@ -1,6 +1,26 @@ import re from modules.globalvars import * from modules.translations import * + +import nltk +import nltk.data + +# Ensure required NLTK resources are available +def check_resources(): + # Check for required NLTK resources and download if missing + resources = { + 'vader_lexicon': 'sentiment/vader_lexicon', + 'punkt_tab': 'tokenizers/punkt', + } + for resource, path in resources.items(): + try: + nltk.data.find(path) + print(f"{resource} is already installed.") + except Exception: + nltk.download(str(resource)) + +check_resources() + from nltk.sentiment.vader import SentimentIntensityAnalyzer from nltk.tokenize import word_tokenize