diff --git a/bot.py b/bot.py index 8cb283d..437d777 100644 --- a/bot.py +++ b/bot.py @@ -45,7 +45,6 @@ from discord.abc import Messageable from better_profanity import profanity from discord.ext import commands -from modules.central import ping_server from modules.volta.main import _, set_language from modules.markovmemory import * from modules.version import * @@ -135,7 +134,6 @@ async def on_ready() -> None: synced: List[discord.app_commands.AppCommand] = await bot.tree.sync() logger.info(f"{_('synced_commands')} {len(synced)} {(_('synced_commands2'))}") slash_commands_enabled = True - ping_server() # ping_server from modules/central.py active_users: str = await fetch_active_users() logger.info(f"{(_('active_users:'))} {active_users}") @@ -468,7 +466,8 @@ async def about(ctx: commands.Context) -> None: embed: discord.Embed = discord.Embed(title=f"{(_('command_about_embed_title'))}", description="", color=Colour(0x000000)) embed.add_field(name=f"{(_('command_about_embed_field1'))}", value=f"{NAME}", inline=False) embed.add_field(name=f"{(_('command_about_embed_field2name'))}", value=f"{(_('command_about_embed_field2value')).format(local_version=local_version, latest_version=latest_version)}", inline=False) - + embed.add_field(name=f"Github", value=f"https://github.com/gooberinc/goober") + await send_message(ctx, embed=embed) # Command: Show bot statistics (admin only) diff --git a/example.env b/example.env index 50d672d..03c30c6 100644 --- a/example.env +++ b/example.env @@ -1,18 +1,21 @@ -DISCORD_BOT_TOKEN=token -BOT_PREFIX="g." -PING_LINE="The Beretta fires fast and won't make you feel any better!" -BLACKLISTED_USERS= -USERTRAIN_ENABLED="true" -showmemenabled="true" -NAME="an instance of goober" -locale=fi -ALIVEPING="true" +DISCORDBOTTOKEN= +BOTPREFIX="g." +PINGLINE="The Beretta fires fast and won't make you feel any better!" +BLACKLISTEDUSERS= +OWNERID= +USERTRAINENABLED="true" +SHOWMEMENABLED="true" +NAME="gooberino goobs" +LOCALE=fi +ALIVEPING="True" AUTOUPDATE="True" -gooberTOKEN= -song="A Heart of Cold - Heaven Pierce Her" +GOOBERTOKEN= +SONG="Basket Case - Green Day" +CHECKSDISABLED="Frue" REACT="True" -POSITIVE_GIFS="https://tenor.com/view/chill-guy-my-new-character-gif-2777893510283028272, https://tenor.com/view/goodnight-goodnight-friends-weezer-weezer-goodnight-gif-7322052181075806988" -splashtext=" +POSITIVEGIFS="https://media.discordapp.net/attachments/821047460151427135/1181371808566493184/jjpQGeno.gif, https://tenor.com/view/chill-guy-my-new-character-gif-2777893510283028272,https://tenor.com/view/goodnight-goodnight-friends-weezer-weezer-goodnight-gif-7322052181075806988" +SPLASHTEXT=" + SS\ SS | SSSSSS\ SSSSSS\ SSSSSS\ SSSSSSS\ SSSSSS\ SSSSSS\ @@ -23,5 +26,5 @@ SS | SS |SS | SS |SS | SS |SS | SS |SS ____|SS | \____SS | \______/ \______/ \_______/ \_______|\__| SS\ SS | \SSSSSS | - \______/ -" + \______/ +" \ No newline at end of file diff --git a/modules/central.py b/modules/central.py deleted file mode 100644 index 6293bbb..0000000 --- a/modules/central.py +++ /dev/null @@ -1,99 +0,0 @@ -import requests -import os -import modules.globalvars as gv -from modules.volta.main import _ -from modules.markovmemory import get_file_info -import logging -logger = logging.getLogger("goober") - -# Ping the server to check if it's alive and send some info -def ping_server(): - if gv.ALIVEPING == "false": - # If pinging is disabled, print message and set environment variable - print(f"{gv.YELLOW}{(_('pinging_disabled'))}") - os.environ['gooberauthenticated'] = 'No' - return - # Get server alert message - goobres = requests.get(f"{gv.VERSION_URL}/alert") - logger.info(f"{(_('goober_server_alert'))}{goobres.text}") - # Gather file info for payload - file_info = get_file_info(gv.MEMORY_FILE) - payload = { - "name": gv.NAME, - "memory_file_info": file_info, - "version": gv.local_version, - "slash_commands": gv.slash_commands_enabled, - "token": gv.gooberTOKEN - } - try: - # Send ping to server - response = requests.post(gv.VERSION_URL+"/ping", json=payload) - if response.status_code == 200: - # Success: print message and set environment variable - logger.info(f"{(_('goober_ping_success')).format(NAME=gv.NAME)}") - os.environ['gooberauthenticated'] = 'Yes' - else: - # Failure: print error and set environment variable - logger.error(f"{(_('goober_ping_fail'))} {response.status_code}") - os.environ['gooberauthenticated'] = 'No' - except Exception as e: - # Exception: print error and set environment variable - logger.error(f"{(_('goober_ping_fail2'))} {str(e)}") - os.environ['gooberauthenticated'] = 'No' - -# Check if a given name is available for registration -def is_name_available(NAME): - if os.getenv("gooberTOKEN"): - # If token is already set, skip check - return - try: - # Send request to check name availability - response = requests.post(f"{gv.VERSION_URL}/check-if-available", json={"name": NAME}, headers={"Content-Type": "application/json"}) - if response.status_code == 200: - data = response.json() - return data.get("available", False) - else: - # Print error if request failed - logger.e(f"{(_('name_check'))}", response.json()) - return False - except Exception as e: - # Print exception if request failed - logger.error(f"{(_('name_check2'))}", e) - return False - -# Register a new name with the server -def register_name(NAME): - try: - if gv.ALIVEPING == False: - # If pinging is disabled, do nothing - return - # Check if the name is available - if not is_name_available(NAME): - if os.getenv("gooberTOKEN"): - return - # Name taken: print error and exit - logger.critical(f"{(_('name_taken'))}") - quit() - # Register the name - response = requests.post(f"{gv.VERSION_URL}/register", json={"name": NAME}, headers={"Content-Type": "application/json"}) - if response.status_code == 200: - data = response.json() - token = data.get("token") - if not os.getenv("gooberTOKEN"): - # Print instructions to add token and exit - logger.info(f"{(_('add_token')).format(token=token)} gooberTOKEN=.") - quit() - else: - print(f"{gv.GREEN}{gv.gv.RESET}") - return token - else: - # Print error if registration failed - logger.critical(f"{gv.RED}{(_('token_exists')).format()}", response.json()) - return None - except Exception as e: - # Print exception if registration failed - logger.critical(f"{gv.RED}{(_('registration_error')).format()}", e) - return None - -# Attempt to register the name at module load -register_name(gv.NAME) \ No newline at end of file diff --git a/modules/globalvars.py b/modules/globalvars.py index 3c76bc7..5c2e2e3 100644 --- a/modules/globalvars.py +++ b/modules/globalvars.py @@ -16,17 +16,17 @@ RESET = f"{ANSI}0m" VERSION_URL = "https://goober.expect.ovh" UPDATE_URL = VERSION_URL+"/latest_version.json" LOCAL_VERSION_FILE = "current_version.txt" -TOKEN = os.getenv("DISCORD_BOT_TOKEN", "0") -PREFIX = os.getenv("BOT_PREFIX", "g.") -PING_LINE = os.getenv("PING_LINE") -CHECKS_DISABLED = os.getenv("CHECKS_DISABLED") -LOCALE = os.getenv("locale", "en") -gooberTOKEN = os.getenv("gooberTOKEN") -splashtext = os.getenv("splashtext") -ownerid = int(os.getenv("ownerid", "0")) -showmemenabled = os.getenv("showmemenabled") -BLACKLISTED_USERS = os.getenv("BLACKLISTED_USERS", "").split(",") -USERTRAIN_ENABLED = os.getenv("USERTRAIN_ENABLED", "true").lower() == "true" +TOKEN = os.getenv("DISCORDBOTTOKEN", "0") +PREFIX = os.getenv("BOTPREFIX", "g.") +PING_LINE = os.getenv("PINGLINE") +CHECKS_DISABLED = os.getenv("CHECKSDISABLED") +LOCALE = os.getenv("LOCALE", "en") +gooberTOKEN = os.getenv("GOOBERTOKEN") +splashtext = os.getenv("SPLASHTEXT") +ownerid = int(os.getenv("OWNERID", "0")) +showmemenabled = os.getenv("SHOWMEMENABLED") +BLACKLISTED_USERS = os.getenv("BLACKLISTEDUSERS", "").split(",") +USERTRAIN_ENABLED = os.getenv("USERTRAINENABLED", "true").lower() == "true" NAME = os.getenv("NAME") MEMORY_FILE = "memory.json" MEMORY_LOADED_FILE = "MEMORY_LOADED" # is this still even used?? okay just checked its used in the markov module @@ -38,7 +38,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.1.3" +local_version = "2.1.4" os.environ['gooberlocal_version'] = local_version REACT = os.getenv("REACT") beta = False # this makes goober think its a beta version, so it will not update to the latest stable version or run any version checks diff --git a/modules/volta/main.py b/modules/volta/main.py index b8e88ea..03f5d4f 100644 --- a/modules/volta/main.py +++ b/modules/volta/main.py @@ -18,7 +18,7 @@ RESET = f"{ANSI}0m" load_dotenv() -LOCALE = os.getenv("locale") +LOCALE = os.getenv("LOCALE") module_dir = pathlib.Path(__file__).parent.parent working_dir = pathlib.Path.cwd() EXCLUDE_DIRS = {'.git', '__pycache__'}