Merge pull request #15 from gooberinc/dev

Dev
This commit is contained in:
WhatDidYouExpect 2025-07-11 15:38:59 +02:00 committed by GitHub
commit 06df9e0ada
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 130 deletions

3
bot.py
View file

@ -45,7 +45,6 @@ from discord.abc import Messageable
from better_profanity import profanity from better_profanity import profanity
from discord.ext import commands from discord.ext import commands
from modules.central import ping_server
from modules.volta.main import _, set_language from modules.volta.main import _, set_language
from modules.markovmemory import * from modules.markovmemory import *
from modules.version import * from modules.version import *
@ -135,7 +134,6 @@ async def on_ready() -> None:
synced: List[discord.app_commands.AppCommand] = await bot.tree.sync() synced: List[discord.app_commands.AppCommand] = await bot.tree.sync()
logger.info(f"{_('synced_commands')} {len(synced)} {(_('synced_commands2'))}") logger.info(f"{_('synced_commands')} {len(synced)} {(_('synced_commands2'))}")
slash_commands_enabled = True slash_commands_enabled = True
ping_server() # ping_server from modules/central.py
active_users: str = await fetch_active_users() active_users: str = await fetch_active_users()
logger.info(f"{(_('active_users:'))} {active_users}") logger.info(f"{(_('active_users:'))} {active_users}")
@ -468,6 +466,7 @@ async def about(ctx: commands.Context) -> None:
embed: discord.Embed = discord.Embed(title=f"{(_('command_about_embed_title'))}", description="", color=Colour(0x000000)) 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_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"{(_('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) await send_message(ctx, embed=embed)

View file

@ -1,18 +1,21 @@
DISCORD_BOT_TOKEN=token DISCORDBOTTOKEN=
BOT_PREFIX="g." BOTPREFIX="g."
PING_LINE="The Beretta fires fast and won't make you feel any better!" PINGLINE="The Beretta fires fast and won't make you feel any better!"
BLACKLISTED_USERS= BLACKLISTEDUSERS=
USERTRAIN_ENABLED="true" OWNERID=
showmemenabled="true" USERTRAINENABLED="true"
NAME="an instance of goober" SHOWMEMENABLED="true"
locale=fi NAME="gooberino goobs"
ALIVEPING="true" LOCALE=fi
ALIVEPING="True"
AUTOUPDATE="True" AUTOUPDATE="True"
gooberTOKEN= GOOBERTOKEN=
song="A Heart of Cold - Heaven Pierce Her" SONG="Basket Case - Green Day"
CHECKSDISABLED="Frue"
REACT="True" 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" 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=" SPLASHTEXT="
SS\ SS\
SS | SS |
SSSSSS\ SSSSSS\ SSSSSS\ SSSSSSS\ SSSSSS\ SSSSSS\ SSSSSS\ SSSSSS\ SSSSSS\ SSSSSSS\ SSSSSS\ SSSSSS\

View file

@ -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=<token>.")
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)

View file

@ -16,17 +16,17 @@ RESET = f"{ANSI}0m"
VERSION_URL = "https://goober.expect.ovh" VERSION_URL = "https://goober.expect.ovh"
UPDATE_URL = VERSION_URL+"/latest_version.json" UPDATE_URL = VERSION_URL+"/latest_version.json"
LOCAL_VERSION_FILE = "current_version.txt" LOCAL_VERSION_FILE = "current_version.txt"
TOKEN = os.getenv("DISCORD_BOT_TOKEN", "0") TOKEN = os.getenv("DISCORDBOTTOKEN", "0")
PREFIX = os.getenv("BOT_PREFIX", "g.") PREFIX = os.getenv("BOTPREFIX", "g.")
PING_LINE = os.getenv("PING_LINE") PING_LINE = os.getenv("PINGLINE")
CHECKS_DISABLED = os.getenv("CHECKS_DISABLED") CHECKS_DISABLED = os.getenv("CHECKSDISABLED")
LOCALE = os.getenv("locale", "en") LOCALE = os.getenv("LOCALE", "en")
gooberTOKEN = os.getenv("gooberTOKEN") gooberTOKEN = os.getenv("GOOBERTOKEN")
splashtext = os.getenv("splashtext") splashtext = os.getenv("SPLASHTEXT")
ownerid = int(os.getenv("ownerid", "0")) ownerid = int(os.getenv("OWNERID", "0"))
showmemenabled = os.getenv("showmemenabled") showmemenabled = os.getenv("SHOWMEMENABLED")
BLACKLISTED_USERS = os.getenv("BLACKLISTED_USERS", "").split(",") BLACKLISTED_USERS = os.getenv("BLACKLISTEDUSERS", "").split(",")
USERTRAIN_ENABLED = os.getenv("USERTRAIN_ENABLED", "true").lower() == "true" USERTRAIN_ENABLED = os.getenv("USERTRAINENABLED", "true").lower() == "true"
NAME = os.getenv("NAME") NAME = os.getenv("NAME")
MEMORY_FILE = "memory.json" MEMORY_FILE = "memory.json"
MEMORY_LOADED_FILE = "MEMORY_LOADED" # is this still even used?? okay just checked its used in the markov module 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 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 launched = False
latest_version = "0.0.0" latest_version = "0.0.0"
local_version = "2.1.3" local_version = "2.1.4"
os.environ['gooberlocal_version'] = local_version os.environ['gooberlocal_version'] = local_version
REACT = os.getenv("REACT") 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 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

View file

@ -18,7 +18,7 @@ RESET = f"{ANSI}0m"
load_dotenv() load_dotenv()
LOCALE = os.getenv("locale") LOCALE = os.getenv("LOCALE")
module_dir = pathlib.Path(__file__).parent.parent module_dir = pathlib.Path(__file__).parent.parent
working_dir = pathlib.Path.cwd() working_dir = pathlib.Path.cwd()
EXCLUDE_DIRS = {'.git', '__pycache__'} EXCLUDE_DIRS = {'.git', '__pycache__'}