commit before utter laptop death

This commit is contained in:
WhatDidYouExpect 2025-07-23 16:58:21 +02:00
parent 4e111b410d
commit d6b51c787a
11 changed files with 163 additions and 221 deletions

View file

@ -1,20 +1,17 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from modules.globalvars import ownerid from modules.permission import requires_admin
class FileSync(commands.Cog): class FileSync(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
self.mode = None self.mode = None
self.peer_id = None self.peer_id = None
self.awaiting_file = False self.awaiting_file = False
@requires_admin()
@commands.command() @commands.command()
async def syncfile(self, ctx, mode: str, peer: discord.User): async def syncfile(self, ctx, mode: str, peer: discord.User):
self.mode = mode.lower() self.mode = mode.lower()
self.peer_id = peer.id self.peer_id = peer.id
if ctx.author.id != ownerid:
await ctx.send("You don't have permission to execute this command.")
return
if self.mode == "s": if self.mode == "s":
await ctx.send(f"<@{self.peer_id}> FILE_TRANSFER_REQUEST") await ctx.send(f"<@{self.peer_id}> FILE_TRANSFER_REQUEST")
await ctx.send(file=discord.File("memory.json")) await ctx.send(file=discord.File("memory.json"))

View file

@ -1,14 +1,19 @@
import os import os
import platform
import subprocess import subprocess
from typing import Dict, List from typing import Dict, List
import discord import discord
from discord import Colour
from discord.ext import commands from discord.ext import commands
import discord.ext import discord.ext
import discord.ext.commands import discord.ext.commands
from modules.globalvars import local_version
from modules.volta.main import _ , set_language from modules.volta.main import _ , set_language
from modules.permission import requires_admin from modules.permission import requires_admin
from modules.sentenceprocessing import send_message from modules.sentenceprocessing import send_message
from modules.settings import instance as settings_manager from modules.settings import instance as settings_manager
from modules.version import check_for_update
import requests import requests
settings = settings_manager.settings settings = settings_manager.settings
@ -21,13 +26,21 @@ def get_git_origin_raw():
) )
return result.stdout.strip() return result.stdout.strip()
except Exception: except Exception:
return "http://forgejo.expect.ovh/gooberinc/goober" return "Failed to get git origin"
class BaseCommands(commands.Cog): class BaseCommands(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot: discord.ext.commands.Bot = bot self.bot: discord.ext.commands.Bot = bot
def get_git_origin_raw():
try:
result = subprocess.run(
["git", "config", "--get", "remote.origin.url"],
capture_output=True, text=True, check=True
)
return result.stdout.strip()
except Exception:
return "https://forgejo.expect.ovh/gooberinc/goober" # fallback if git fails
@commands.command() @commands.command()
async def help(self, ctx: commands.Context) -> None: async def help(self, ctx: commands.Context) -> None:
@ -111,19 +124,13 @@ class BaseCommands(commands.Cog):
@commands.command() @commands.command()
async def about(self, ctx: commands.Context) -> None: async def about(self, ctx: commands.Context) -> None:
embed: discord.Embed = discord.Embed( latest_version: str = check_for_update(slient=True)
title=f"{_('command_about_embed_title')}", embed: discord.Embed = discord.Embed(title=f"{(_('command_about_embed_title'))}", description="", color=Colour(0x000000))
description="", embed.add_field(name=f"{(_('command_about_embed_field1'))}", value=f"{settings['name']}", inline=False)
color=discord.Colour(0x000000), 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"Git", value=get_git_origin_raw())
embed.add_field(name=f"OS", value=platform.platform())
embed.add_field(
name=_('command_about_embed_field1'),
value=settings['name'],
inline=False,
)
embed.add_field(name="Git", value=get_git_origin_raw())
await send_message(ctx, embed=embed) await send_message(ctx, embed=embed)
@commands.command() @commands.command()

View file

@ -1,18 +1,15 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from modules.globalvars import ownerid from modules.permission import requires_admin
COG_PREFIX = "assets.cogs." COG_PREFIX = "assets.cogs."
class CogManager(commands.Cog): class CogManager(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@requires_admin()
@commands.command() @commands.command()
async def load(self, ctx, cog_name: str = None): async def load(self, ctx, cog_name: str = None):
if ctx.author.id != ownerid:
await ctx.send("You do not have permission to use this command.")
return
if cog_name is None: if cog_name is None:
await ctx.send("Please provide the cog name to load.") await ctx.send("Please provide the cog name to load.")
return return
@ -21,12 +18,9 @@ class CogManager(commands.Cog):
await ctx.send(f"Loaded cog `{cog_name}` successfully.") await ctx.send(f"Loaded cog `{cog_name}` successfully.")
except Exception as e: except Exception as e:
await ctx.send(f"Error loading cog `{cog_name}`: {e}") await ctx.send(f"Error loading cog `{cog_name}`: {e}")
@requires_admin()
@commands.command() @commands.command()
async def unload(self, ctx, cog_name: str = None): async def unload(self, ctx, cog_name: str = None):
if ctx.author.id != ownerid:
await ctx.send("You do not have permission to use this command.")
return
if cog_name is None: if cog_name is None:
await ctx.send("Please provide the cog name to unload.") await ctx.send("Please provide the cog name to unload.")
return return
@ -35,12 +29,9 @@ class CogManager(commands.Cog):
await ctx.send(f"Unloaded cog `{cog_name}` successfully.") await ctx.send(f"Unloaded cog `{cog_name}` successfully.")
except Exception as e: except Exception as e:
await ctx.send(f"Error unloading cog `{cog_name}`: {e}") await ctx.send(f"Error unloading cog `{cog_name}`: {e}")
@requires_admin()
@commands.command() @commands.command()
async def reload(self, ctx, cog_name: str = None): async def reload(self, ctx, cog_name: str = None):
if ctx.author.id != ownerid:
await ctx.send("You do not have permission to use this command.")
return
if cog_name is None: if cog_name is None:
await ctx.send("Please provide the cog name to reload.") await ctx.send("Please provide the cog name to reload.")
return return

View file

@ -32,11 +32,12 @@ settings = settings_manager.settings
class Markov(commands.Cog): class Markov(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot: discord.ext.commands.Bot = bot self.bot: discord.ext.commands.Bot = bot
self.model: markovify.NewlineText
@requires_admin() @requires_admin()
@commands.command() @commands.command()
async def retrain(self, ctx: discord.ext.commands.Context): async def retrain(self, ctx: discord.ext.commands.Context):
markov_model: Optional[markovify.Text] = load_markov_model()
message_ref: discord.Message | None = await send_message( message_ref: discord.Message | None = await send_message(
ctx, f"{_('command_markov_retrain')}" ctx, f"{_('command_markov_retrain')}"
) )
@ -71,8 +72,8 @@ class Markov(commands.Cog):
await ctx.send("Failed to retrain!") await ctx.send("Failed to retrain!")
return False return False
self.model = model markov_model = model
save_markov_model(self.model) save_markov_model(markov_model)
logger.debug(f"Completed retraining in {round(time.time() - start_time,3)}s") logger.debug(f"Completed retraining in {round(time.time() - start_time,3)}s")
@ -86,33 +87,25 @@ class Markov(commands.Cog):
@commands.command() @commands.command()
async def talk(self, ctx: commands.Context, sentence_size: int = 5) -> None: async def talk(self, ctx: commands.Context, sentence_size: int = 5) -> None:
if not self.model: markov_model: Optional[markovify.Text] = load_markov_model()
await send_message(ctx, f"{_('command_markovcommand_talk_insufficent_text')}") if markov_model is None:
await send_message(ctx, _("command_markovcommand_talk_insufficent_text"))
return return
response: str = "" raw_sentence = None
if sentence_size == 1: if sentence_size == 1:
response = ( raw_sentence = markov_model.make_short_sentence(max_chars=100, tries=100)
self.model.make_short_sentence(max_chars=100, tries=100)
or _('command_markovcommand_talk_generation_fail')
)
else: else:
response = improve_sentence_coherence( raw_sentence = markov_model.make_sentence(tries=100, max_words=sentence_size)
self.model.make_sentence(tries=100, max_words=sentence_size) print(raw_sentence)
or _('command_talk_generation_fail')
)
cleaned_response: str = re.sub(r"[^\w\s]", "", response).lower() if random.random() < 0.9 and is_positive(raw_sentence):
coherent_response: str = rephrase_for_coherence(cleaned_response) gif_url = random.choice(settings["bot"]["misc"]["positive_gifs"])
raw_sentence = f"{raw_sentence}\n[jif]({gif_url})"
if random.random() < 0.9 and is_positive(coherent_response): os.environ["gooberlatestgen"] = raw_sentence
gif_url: str = random.choice(settings["bot"]["misc"]["positive_gifs"]) await send_message(ctx, raw_sentence)
coherent_response = f"{coherent_response}\n[jif]({gif_url})"
os.environ["gooberlatestgen"] = coherent_response
await send_message(ctx, coherent_response)
async def setup(bot): async def setup(bot):

View file

@ -15,18 +15,7 @@ class PermissionManager(commands.Cog):
@commands.command() @commands.command()
async def add_owner(self, ctx: commands.Context, member: discord.Member): async def add_owner(self, ctx: commands.Context, member: discord.Member):
settings["bot"]["owner_ids"].append(member.id) settings["bot"]["owner_ids"].append(member.id)
settings_manager.add_admin_log_event(
{
"action": "add",
"author": ctx.author.id,
"change": "owner_ids",
"messageId": ctx.message.id,
"target": member.id,
}
)
settings_manager.commit() settings_manager.commit()
embed = discord.Embed( embed = discord.Embed(
title="Permissions", title="Permissions",
description=f"Set {member.name} as an owner", description=f"Set {member.name} as an owner",
@ -40,15 +29,6 @@ class PermissionManager(commands.Cog):
async def remove_owner(self, ctx: commands.Context, member: discord.Member): async def remove_owner(self, ctx: commands.Context, member: discord.Member):
try: try:
settings["bot"]["owner_ids"].remove(member.id) settings["bot"]["owner_ids"].remove(member.id)
settings_manager.add_admin_log_event(
{
"action": "del",
"author": ctx.author.id,
"change": "owner_ids",
"messageId": ctx.message.id,
"target": member.id,
}
)
settings_manager.commit() settings_manager.commit()
except ValueError: except ValueError:
await ctx.send("User is not an owner!") await ctx.send("User is not an owner!")
@ -90,15 +70,6 @@ class PermissionManager(commands.Cog):
async def unblacklist_user(self, ctx: commands.Context, member: discord.Member): async def unblacklist_user(self, ctx: commands.Context, member: discord.Member):
try: try:
settings["bot"]["blacklisted_users"].remove(member.id) settings["bot"]["blacklisted_users"].remove(member.id)
settings_manager.add_admin_log_event(
{
"action": "del",
"author": ctx.author.id,
"change": "blacklisted_users",
"messageId": ctx.message.id,
"target": member.id,
}
)
settings_manager.commit() settings_manager.commit()
except ValueError: except ValueError:

51
main.py
View file

@ -31,7 +31,8 @@ import logging
from modules.settings import Settings as SettingsManager from modules.settings import Settings as SettingsManager
from modules.permission import requires_admin from modules.permission import requires_admin
from modules.volta.main import _ from modules.volta.main import _
from modules.version import check_for_update
check_for_update()
logger = logging.getLogger("goober") logger = logging.getLogger("goober")
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
@ -85,15 +86,18 @@ class MessageMetadata(TypedDict):
# Constants with type hints # Constants with type hints
positive_gifs: List[str] = settings["bot"]["misc"]["positive_gifs"] positive_gifs: List[str] = settings["bot"]["misc"]["positive_gifs"]
name = settings["name"]
currenthash: str = "" currenthash: str = ""
launched: bool = False launched: bool = False
slash_commands_enabled: bool = False slash_commands_enabled: bool = False
# Set up Discord bot intents and create bot instance # Set up Discord bot intents and create bot instance
intents: discord.Intents = discord.Intents.default() intents: discord.Intents = discord.Intents.default()
intents.messages = True intents.messages = True
intents.presences = True
intents.members = True
intents.message_content = True intents.message_content = True
bot: commands.Bot = commands.Bot( bot: commands.Bot = commands.Bot(
command_prefix=settings["bot"]["prefix"], command_prefix=settings["bot"]["prefix"],
intents=intents, intents=intents,
@ -104,11 +108,6 @@ bot: commands.Bot = commands.Bot(
# Load memory and Markov model for text generation # Load memory and Markov model for text generation
memory: List[str | Dict[Literal["_meta"], MessageMetadata]] = load_memory() memory: List[str | Dict[Literal["_meta"], MessageMetadata]] = load_memory()
markov_model: Optional[markovify.Text] = load_markov_model()
if not markov_model:
logger.error(_('markov_model_not_found'))
memory = load_memory()
markov_model = train_markov_model(memory)
generated_sentences: Set[str] = set() generated_sentences: Set[str] = set()
used_words: Set[str] = set() used_words: Set[str] = set()
@ -150,7 +149,7 @@ 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')}")
logger.info(_('started')) logger.info(_('started').format(name=name))
except discord.errors.Forbidden as perm_error: except discord.errors.Forbidden as perm_error:
logger.error(f"Permission error while syncing commands: {perm_error}") logger.error(f"Permission error while syncing commands: {perm_error}")
@ -174,34 +173,6 @@ async def on_ready() -> None:
launched = True launched = True
bot.remove_command('help') bot.remove_command('help')
# Command: Show help information
@bot.hybrid_command(description=f"{(_('command_desc_help'))}")
async def help(ctx: commands.Context) -> None:
embed: discord.Embed = discord.Embed(
title=f"{(_('command_help_embed_title'))}",
description=f"{(_('command_help_embed_desc'))}",
color=Colour(0x000000)
)
command_categories: Dict[str, List[str]] = {
f"{(_('command_help_categories_general'))}": ["mem", "talk", "about", "ping", "impact", "demotivator", "help"],
f"{(_('command_help_categories_admin'))}": ["stats", "retrain", "setlanguage"]
}
custom_commands: List[str] = []
for cog_name, cog in bot.cogs.items():
for command in cog.get_commands():
if command.name not in command_categories[f"{(_('command_help_categories_general'))}"] and command.name not in command_categories[f"{(_('command_help_categories_admin'))}"]:
custom_commands.append(command.name)
if custom_commands:
embed.add_field(name=f"{(_('command_help_categories_custom'))}", value="\n".join([f"{PREFIX}{command}" for command in custom_commands]), inline=False)
for category, commands_list in command_categories.items():
commands_in_category: str = "\n".join([f"{PREFIX}{command}" for command in commands_list])
embed.add_field(name=category, value=commands_in_category, inline=False)
await send_message(ctx, embed=embed)
@bot.event @bot.event
async def on_command_error(ctx: commands.Context, error: commands.CommandError) -> None: async def on_command_error(ctx: commands.Context, error: commands.CommandError) -> None:
@ -226,7 +197,7 @@ async def on_command_error(ctx: commands.Context, error: commands.CommandError)
# Event: Called on every message # Event: Called on every message
@bot.event @bot.event
async def on_message(message: discord.Message) -> None: async def on_message(message: discord.Message) -> None:
global memory, markov_model global memory
EMOJIS = [ EMOJIS = [
"\U0001f604", "\U0001f604",
"\U0001f44d", "\U0001f44d",
@ -250,12 +221,6 @@ async def on_message(message: discord.Message) -> None:
await bot.process_commands(message) await bot.process_commands(message)
return return
if (
profanity.contains_profanity(message.content)
and settings["bot"]["misc"]["block_profanity"]
):
return
if message.content: if message.content:
if not settings["bot"]["user_training"]: if not settings["bot"]["user_training"]:
return return

View file

@ -1,80 +1,71 @@
import os import os
import platform import platform
from typing import Callable, List
from dotenv import load_dotenv
import pathlib import pathlib
import subprocess import subprocess
from dotenv import load_dotenv
import discord
from discord import Colour, Embed, File, Interaction, Message
from discord.ext import commands
from discord import app_commands
from discord.abc import Messageable
env_path = pathlib.Path(__file__).parent.parent / '.env' def get_git_branch():
try:
branch = (
subprocess.check_output(
["git", "rev-parse", "--abbrev-ref", "HEAD"], stderr=subprocess.DEVNULL
)
.decode("utf-8")
.strip()
)
return branch
except subprocess.CalledProcessError:
return None
env_path = pathlib.Path(__file__).parent.parent / ".env"
load_dotenv(dotenv_path=env_path) load_dotenv(dotenv_path=env_path)
# ANSI colors available_cogs: Callable[[], List[str]] = lambda: [
file[:-3] for file in os.listdir("assets/cogs") if file.endswith(".py")
]
ANSI = "\033[" ANSI = "\033["
RED = f"{ANSI}31m" RED = f"{ANSI}31m"
GREEN = f"{ANSI}32m" GREEN = f"{ANSI}32m"
YELLOW = f"{ANSI}33m" YELLOW = f"{ANSI}33m"
PURPLE = f"{ANSI}35m" PURPLE = f"{ANSI}35m"
DEBUG = f"{ANSI}1;30m" DEBUG = f"{ANSI}90m"
RESET = f"{ANSI}0m" RESET = f"{ANSI}0m"
VERSION_URL = "https://raw.githubusercontent.com/gooberinc/version/main" VERSION_URL = "https://raw.githubusercontent.com/gooberinc/version/main"
UPDATE_URL = f"{VERSION_URL}/latest_version.json" UPDATE_URL = VERSION_URL + "/latest_version.json"
print(UPDATE_URL) print(UPDATE_URL)
LOCAL_VERSION_FILE = "current_version.txt" LOCAL_VERSION_FILE = "current_version.txt"
MEMORY_FILE = "memory.json"
MEMORY_LOADED_FILE = "MEMORY_LOADED" # used in markov module
local_version = "3.0.0"
latest_version = "0.0.0"
os.environ['gooberlocal_version'] = local_version
def get_git_branch() -> str | None: # TOKEN = os.getenv("DISCORDBOTTOKEN", "0")
try: # PREFIX = os.getenv("BOTPREFIX", "g.")
return subprocess.check_output( # PING_LINE = os.getenv("PINGLINE")
["git", "rev-parse", "--abbrev-ref", "HEAD"], # CHECKS_DISABLED = os.getenv("CHECKSDISABLED")
stderr=subprocess.DEVNULL # LOCALE = os.getenv("LOCALE", "en")
).decode().strip() # BLACKLISTED_USERS = os.getenv("BLACKLISTEDUSERS", "").split(",")
except subprocess.CalledProcessError: # USERTRAIN_ENABLED = os.getenv("USERTRAINENABLED", "true").lower() == "true"
return None # 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
# ALIVEPING = os.getenv("ALIVEPING")
# AUTOUPDATE = os.getenv("AUTOUPDATE")
# REACT = os.getenv("REACT")
branch = get_git_branch() # gooberTOKEN = os.getenv("GOOBERTOKEN")
beta = branch != "main" if branch else True # splashtext = os.getenv("SPLASHTEXT")
# ownerid = int(os.getenv("OWNERID", "0"))
# showmemenabled = os.getenv("SHOWMEMENABLED")
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"))
status = os.getenv("STATUS")
showmemenabled = os.getenv("SHOWMEMENABLED")
BLACKLISTED_USERS = os.getenv("BLACKLISTEDUSERS", "").split(",")
USERTRAIN_ENABLED = os.getenv("USERTRAINENABLED", "true").lower() == "true"
NAME = os.getenv("NAME")
ALIVEPING = os.getenv("ALIVEPING")
AUTOUPDATE = os.getenv("AUTOUPDATE")
song = os.getenv("SONG")
REACT = os.getenv("REACT")
intents = discord.Intents.default()
intents.messages = True
intents.presences = True
intents.members = True
intents.message_content = True
bot = commands.Bot(
command_prefix=PREFIX,
intents=intents,
allowed_mentions=discord.AllowedMentions(
everyone=False, roles=False, users=False, replied_user=True
)
)
# IGNOREWARNING = False # is this either??? i don't think so?
# song = os.getenv("song")
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 launched = False
latest_version = "0.0.0"
local_version = "3.0.0"
os.environ["gooberlocal_version"] = local_version
beta = get_git_branch() == "dev"

View file

@ -3,55 +3,75 @@ import json
import markovify import markovify
import pickle import pickle
from modules.globalvars import * from modules.globalvars import *
from modules.volta.main import _
import logging import logging
from modules.volta.main import _
from modules.settings import instance as settings_manager
settings = settings_manager.settings
logger = logging.getLogger("goober") logger = logging.getLogger("goober")
def get_file_info(file_path: str) -> dict:
# Get file size and line count for a given file path
def get_file_info(file_path):
try: try:
file_size = os.path.getsize(file_path) file_size = os.path.getsize(file_path)
with open(file_path, "r") as f: with open(file_path, "r") as f:
lines = f.readlines() lines = f.readlines()
return { return {"file_size_bytes": file_size, "line_count": len(lines)}
"file_size_bytes": file_size,
"line_count": len(lines)
}
except Exception as e: except Exception as e:
return {"error": str(e)} return {"error": str(e)}
def load_memory() -> list:
try:
with open(MEMORY_FILE, "r") as f:
return json.load(f)
except FileNotFoundError:
return []
def save_memory(memory: list) -> None: # Load memory data from file, or use default dataset if not loaded yet
with open(MEMORY_FILE, "w") as f: def load_memory():
data = []
# Try to load data from MEMORY_FILE
try:
with open(settings["bot"]["active_memory"], "r") as f:
data = json.load(f)
except FileNotFoundError:
pass
return data
# Save memory data to MEMORY_FILE
def save_memory(memory):
with open(settings["bot"]["active_memory"], "w") as f:
json.dump(memory, f, indent=4) json.dump(memory, f, indent=4)
def train_markov_model(memory: list, additional_data: list = None):
lines = [line for line in (memory or []) if isinstance(line, str)]
if additional_data: def train_markov_model(memory, additional_data=None) -> markovify.NewlineText | None:
lines.extend(line for line in additional_data if isinstance(line, str)) if not memory:
if not lines:
return None return None
text = "\n".join(lines) filtered_memory = [line for line in memory if isinstance(line, str)]
return markovify.NewlineText(text, state_size=2) if additional_data:
filtered_memory.extend(
line for line in additional_data if isinstance(line, str)
)
def save_markov_model(model, filename: str = 'markov_model.pkl') -> None: if not filtered_memory:
with open(filename, 'wb') as f: return None
text = "\n".join(filtered_memory)
model = markovify.NewlineText(text, state_size=2)
return model
def save_markov_model(model, filename="markov_model.pkl"):
with open(filename, "wb") as f:
pickle.dump(model, f) pickle.dump(model, f)
logger.info(f"Markov model saved to {filename}.")
def load_markov_model(filename: str = 'markov_model.pkl'): def load_markov_model(filename="markov_model.pkl"):
try: try:
with open(filename, 'rb') as f: with open(filename, "rb") as f:
model = pickle.load(f) model = pickle.load(f)
logger.info(f"{_('model_loaded')} {filename}.{RESET}") logger.info(f"{_('model_loaded')} {filename}.{RESET}")
return model return model
except FileNotFoundError: except FileNotFoundError:
logger.error(f"{filename} {_('not_found')}{RESET}") logger.error(f"{filename} {_('not_found')}{RESET}")
return None return None

View file

@ -19,11 +19,11 @@ class PermissionError(Exception):
def requires_admin(): def requires_admin():
async def wrapper(ctx: discord.ext.commands.Context): async def wrapper(ctx: discord.ext.commands.Context):
print(ctx.author.id)
if ctx.author.id not in settings["bot"]["owner_ids"]: if ctx.author.id not in settings["bot"]["owner_ids"]:
await ctx.send( await ctx.send("You don't have the necessary permissions to run this command!")
"You don't have the necessary permissions to run this command!" return
)
return False
command = ctx.command command = ctx.command
if not command: if not command:

View file

@ -1,4 +1,5 @@
from modules.globalvars import * from modules.globalvars import *
from modules.settings import Settings as SettingsManager
from modules.volta.main import _, check_missing_translations from modules.volta.main import _, check_missing_translations
import time import time
import os import os
@ -14,6 +15,13 @@ import logging
logger = logging.getLogger("goober") logger = logging.getLogger("goober")
settings_manager = SettingsManager()
settings = settings_manager.settings
MEMORY_FILE = settings["bot"]["active_memory"]
with open(settings["splash_text_loc"], "r", encoding="UTF-8") as f:
splash_text = "".join(f.readlines())
# import shutil # import shutil
psutilavaliable = True psutilavaliable = True
try: try:
@ -210,8 +218,8 @@ def presskey2skip(timeout):
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
beta = beta beta = beta
def start_checks(): def start_checks():
if CHECKS_DISABLED == "True": if settings["disable_checks"]:
logger.warning(f"{(_('checks_disabled'))}") logger.warning(f"{_('checks_disabled')}")
return return
logger.info(_('running_prestart_checks')) logger.info(_('running_prestart_checks'))
check_for_model() check_for_model()
@ -233,5 +241,4 @@ def start_checks():
pass pass
logger.info(_('continuing_in_seconds').format(seconds=5)) logger.info(_('continuing_in_seconds').format(seconds=5))
presskey2skip(timeout=5) presskey2skip(timeout=5)
os.system('cls' if os.name == 'nt' else 'clear') os.system('cls' if os.name == 'nt' else 'clear')
print(splashtext)

View file

@ -1,6 +1,6 @@
import sys import sys
import traceback import traceback
from modules.globalvars import RED, RESET, splashtext from modules.globalvars import RED, RESET
from modules.volta.main import _ from modules.volta.main import _
def handle_exception(exc_type, exc_value, exc_traceback, *, context=None): def handle_exception(exc_type, exc_value, exc_traceback, *, context=None):