fuckass git
This commit is contained in:
parent
d3f3e64a96
commit
ee4f294b36
7 changed files with 52 additions and 89 deletions
27
bot.py
27
bot.py
|
@ -31,13 +31,6 @@ file_handler.setFormatter(GooberFormatter(colors=False))
|
||||||
logger.addHandler(console_handler)
|
logger.addHandler(console_handler)
|
||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
logger.debug("Testing logging")
|
|
||||||
logger.info("Testing logging")
|
|
||||||
logger.warning("Testing logging")
|
|
||||||
logger.error("Testing logging")
|
|
||||||
logger.critical("Testing logging")
|
|
||||||
|
|
||||||
|
|
||||||
# Print splash text and check for updates
|
# Print splash text and check for updates
|
||||||
print(splashtext) # Print splash text (from modules/globalvars.py)
|
print(splashtext) # Print splash text (from modules/globalvars.py)
|
||||||
start_checks()
|
start_checks()
|
||||||
|
@ -204,13 +197,13 @@ async def retrain(ctx: commands.Context) -> None:
|
||||||
for i, data in enumerate(memory):
|
for i, data in enumerate(memory):
|
||||||
processed_data += 1
|
processed_data += 1
|
||||||
if processed_data % 1000 == 0 or processed_data == data_size:
|
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)
|
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
|
global markov_model
|
||||||
markov_model = train_markov_model(memory)
|
markov_model = train_markov_model(memory)
|
||||||
save_markov_model(markov_model)
|
save_markov_model(markov_model)
|
||||||
|
|
||||||
await send_message(ctx, f"{(_('command_markov_retrain_successful')).format(data_size=data_size)}", edit=True, message_reference=processing_message_ref)
|
await send_message(ctx, f"{_('command_markov_retrain_successful').format(data_size=data_size)}", edit=True, message_reference=processing_message_ref)
|
||||||
|
|
||||||
# Command: Generate a sentence using the Markov model
|
# Command: Generate a sentence using the Markov model
|
||||||
@bot.hybrid_command(description=f"{(_('command_desc_talk'))}")
|
@bot.hybrid_command(description=f"{(_('command_desc_talk'))}")
|
||||||
|
@ -270,7 +263,7 @@ async def impact(ctx: commands.Context) -> None:
|
||||||
else:
|
else:
|
||||||
fallback_image: Optional[str] = get_random_asset_image()
|
fallback_image: Optional[str] = get_random_asset_image()
|
||||||
if fallback_image is None:
|
if fallback_image is None:
|
||||||
await ctx.reply((_('no_image_available')))
|
await ctx.reply(_('no_image_available'))
|
||||||
return
|
return
|
||||||
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
||||||
shutil.copy(fallback_image, temp_input)
|
shutil.copy(fallback_image, temp_input)
|
||||||
|
@ -278,7 +271,7 @@ async def impact(ctx: commands.Context) -> None:
|
||||||
else:
|
else:
|
||||||
fallback_image = get_random_asset_image()
|
fallback_image = get_random_asset_image()
|
||||||
if fallback_image is None:
|
if fallback_image is None:
|
||||||
await ctx.reply((_('no_image_available')))
|
await ctx.reply(_('no_image_available'))
|
||||||
return
|
return
|
||||||
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
||||||
shutil.copy(fallback_image, temp_input)
|
shutil.copy(fallback_image, temp_input)
|
||||||
|
@ -289,7 +282,7 @@ async def impact(ctx: commands.Context) -> None:
|
||||||
if output_path is None or not os.path.isfile(output_path):
|
if output_path is None or not os.path.isfile(output_path):
|
||||||
if temp_input and os.path.exists(temp_input):
|
if temp_input and os.path.exists(temp_input):
|
||||||
os.remove(temp_input)
|
os.remove(temp_input)
|
||||||
await ctx.reply((_('failed_generate_image')))
|
await ctx.reply(_('failed_generate_image'))
|
||||||
return
|
return
|
||||||
|
|
||||||
await ctx.send(file=discord.File(output_path))
|
await ctx.send(file=discord.File(output_path))
|
||||||
|
@ -319,7 +312,7 @@ async def demotivator(ctx: commands.Context) -> None:
|
||||||
else:
|
else:
|
||||||
fallback_image: Optional[str] = get_random_asset_image()
|
fallback_image: Optional[str] = get_random_asset_image()
|
||||||
if fallback_image is None:
|
if fallback_image is None:
|
||||||
await ctx.reply((_('no_image_available')))
|
await ctx.reply(_('no_image_available'))
|
||||||
return
|
return
|
||||||
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
||||||
shutil.copy(fallback_image, temp_input)
|
shutil.copy(fallback_image, temp_input)
|
||||||
|
@ -327,7 +320,7 @@ async def demotivator(ctx: commands.Context) -> None:
|
||||||
else:
|
else:
|
||||||
fallback_image = get_random_asset_image()
|
fallback_image = get_random_asset_image()
|
||||||
if fallback_image is None:
|
if fallback_image is None:
|
||||||
await ctx.reply((_('no_image_available')))
|
await ctx.reply(_('no_image_available'))
|
||||||
return
|
return
|
||||||
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
temp_input = tempfile.mktemp(suffix=os.path.splitext(fallback_image)[1])
|
||||||
shutil.copy(fallback_image, temp_input)
|
shutil.copy(fallback_image, temp_input)
|
||||||
|
@ -438,11 +431,11 @@ async def block_blacklisted(ctx: commands.Context) -> bool:
|
||||||
try:
|
try:
|
||||||
if isinstance(ctx, discord.Interaction):
|
if isinstance(ctx, discord.Interaction):
|
||||||
if not ctx.response.is_done():
|
if not ctx.response.is_done():
|
||||||
await ctx.response.send_message((_('blacklisted')), ephemeral=True)
|
await ctx.response.send_message(_('blacklisted'), ephemeral=True)
|
||||||
else:
|
else:
|
||||||
await ctx.followup.send((_('blacklisted')), ephemeral=True)
|
await ctx.followup.send(_('blacklisted'), ephemeral=True)
|
||||||
else:
|
else:
|
||||||
await ctx.send((_('blacklisted_user')), ephemeral=True)
|
await ctx.send(_('blacklisted_user'), ephemeral=True)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
37
log.txt
37
log.txt
|
@ -1,37 +0,0 @@
|
||||||
[ DEBUG ]: Testing logging [1;30m [07/08/25 17:01:45.827] (bot.py:<module>) [0m
|
|
||||||
[ INFO ]: Testing logging [1;30m [07/08/25 17:01:45.828] (bot.py:<module>) [0m
|
|
||||||
[ WARNING ]: Testing logging [1;30m [07/08/25 17:01:45.828] (bot.py:<module>) [0m
|
|
||||||
[ ERROR ]: Testing logging [1;30m [07/08/25 17:01:45.829] (bot.py:<module>) [0m
|
|
||||||
[ CRITICAL ]: Testing logging [1;30m [07/08/25 17:01:45.829] (bot.py:<module>) [0m
|
|
||||||
[ INFO ]: Suoritetaan esikäynnistystarkistuksia... [1;30m [07/08/25 17:01:45.830] (prestartchecks.py:start_checks) [0m
|
|
||||||
[ INFO ]: Model is installed. [1;30m [07/08/25 17:01:45.832] (prestartchecks.py:check_for_model) [0m
|
|
||||||
[ INFO ]: OK aiohttp [1;30m [07/08/25 17:01:48.091] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK better-profanity [1;30m [07/08/25 17:01:48.091] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK discord.py [1;30m [07/08/25 17:01:48.092] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK discord.py [1;30m [07/08/25 17:01:48.092] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK python-dotenv [1;30m [07/08/25 17:01:48.093] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK markovify [1;30m [07/08/25 17:01:48.093] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK pillow [1;30m [07/08/25 17:01:48.093] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK psutil [1;30m [07/08/25 17:01:48.094] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK python-dotenv [1;30m [07/08/25 17:01:48.094] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK requests [1;30m [07/08/25 17:01:48.095] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK spacy [1;30m [07/08/25 17:01:48.095] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: OK spacytextblob [1;30m [07/08/25 17:01:48.095] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: Kaikki vaatimukset täyttyvät. [1;30m [07/08/25 17:01:48.096] (prestartchecks.py:check_requirements) [0m
|
|
||||||
[ INFO ]: Ping osoitteeseen 1.1.1.1: 117.0 ms [1;30m [07/08/25 17:01:48.240] (prestartchecks.py:check_latency) [0m
|
|
||||||
[ INFO ]: Muistin käyttö: 12.796562194824219 Gt / 15.846412658691406 Gt (80.753685205879%) [1;30m [07/08/25 17:01:48.248] (prestartchecks.py:check_memory) [0m
|
|
||||||
[ INFO ]: Kokonaismuisti: 15.846412658691406 Gt [1;30m [07/08/25 17:01:48.249] (prestartchecks.py:check_memory) [0m
|
|
||||||
[ INFO ]: Käytetty muisti: 12.796562194824219 Gt [1;30m [07/08/25 17:01:48.249] (prestartchecks.py:check_memory) [0m
|
|
||||||
[ INFO ]: Muistitiedosto: 0.00022029876708984375 Mt [1;30m [07/08/25 17:01:48.250] (prestartchecks.py:check_memoryjson) [0m
|
|
||||||
[ INFO ]: Mitataan suorittimen käyttöä ytimittäin... [1;30m [07/08/25 17:01:48.250] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 0: [██------------------] 14.1% [1;30m [07/08/25 17:01:49.251] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 1: [█-------------------] 9.4% [1;30m [07/08/25 17:01:49.252] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 2: [███-----------------] 17.2% [1;30m [07/08/25 17:01:49.252] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 3: [███-----------------] 18.8% [1;30m [07/08/25 17:01:49.253] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 4: [███████-------------] 35.4% [1;30m [07/08/25 17:01:49.253] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 5: [██████--------------] 31.8% [1;30m [07/08/25 17:01:49.253] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 6: [██████████----------] 54.4% [1;30m [07/08/25 17:01:49.254] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Ydin 7: [███████-------------] 39.1% [1;30m [07/08/25 17:01:49.254] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Kokonaisprosessorin käyttö: 27.525% [1;30m [07/08/25 17:01:49.255] (prestartchecks.py:check_cpu) [0m
|
|
||||||
[ INFO ]: Jatketaan 5 sekunnin kuluttua... Paina mitä tahansa näppäintä ohittaaksesi. [1;30m [07/08/25 17:01:49.255] (prestartchecks.py:start_checks) [0m
|
|
||||||
[ ERROR ]: [VOLTA] [33mMissing key: 'markov_model_not_found' in en.json![0m [1;30m [07/08/25 17:01:59.630] (bot.py:<module>) [0m
|
|
|
@ -3,17 +3,19 @@ import os
|
||||||
import modules.globalvars as gv
|
import modules.globalvars as gv
|
||||||
from modules.volta.main import _
|
from modules.volta.main import _
|
||||||
from modules.markovmemory import get_file_info
|
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
|
# Ping the server to check if it's alive and send some info
|
||||||
def ping_server():
|
def ping_server():
|
||||||
if gv.ALIVEPING == "false":
|
if gv.ALIVEPING == "false":
|
||||||
# If pinging is disabled, print message and set environment variable
|
# If pinging is disabled, print message and set environment variable
|
||||||
print(f"{gv.YELLOW}{(_('pinging_disabled'))}{gv.RESET}")
|
print(f"{gv.YELLOW}{(_('pinging_disabled'))}")
|
||||||
os.environ['gooberauthenticated'] = 'No'
|
os.environ['gooberauthenticated'] = 'No'
|
||||||
return
|
return
|
||||||
# Get server alert message
|
# Get server alert message
|
||||||
goobres = requests.get(f"{gv.VERSION_URL}/alert")
|
goobres = requests.get(f"{gv.VERSION_URL}/alert")
|
||||||
print(f"{(_('goober_server_alert'))}{goobres.text}")
|
logger.info(f"{(_('goober_server_alert'))}{goobres.text}")
|
||||||
# Gather file info for payload
|
# Gather file info for payload
|
||||||
file_info = get_file_info(gv.MEMORY_FILE)
|
file_info = get_file_info(gv.MEMORY_FILE)
|
||||||
payload = {
|
payload = {
|
||||||
|
@ -28,15 +30,15 @@ def ping_server():
|
||||||
response = requests.post(gv.VERSION_URL+"/ping", json=payload)
|
response = requests.post(gv.VERSION_URL+"/ping", json=payload)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
# Success: print message and set environment variable
|
# Success: print message and set environment variable
|
||||||
print(f"{gv.GREEN}{(_('goober_ping_success')).format(NAME=gv.NAME)}{gv.RESET}")
|
logger.info(f"{(_('goober_ping_success')).format(NAME=gv.NAME)}")
|
||||||
os.environ['gooberauthenticated'] = 'Yes'
|
os.environ['gooberauthenticated'] = 'Yes'
|
||||||
else:
|
else:
|
||||||
# Failure: print error and set environment variable
|
# Failure: print error and set environment variable
|
||||||
print(f"{gv.RED}{(_('goober_ping_fail'))} {response.status_code}{gv.RESET}")
|
logger.error(f"{(_('goober_ping_fail'))} {response.status_code}")
|
||||||
os.environ['gooberauthenticated'] = 'No'
|
os.environ['gooberauthenticated'] = 'No'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Exception: print error and set environment variable
|
# Exception: print error and set environment variable
|
||||||
print(f"{gv.RED}{(_('goober_ping_fail2'))} {str(e)}{gv.RESET}")
|
logger.error(f"{(_('goober_ping_fail2'))} {str(e)}")
|
||||||
os.environ['gooberauthenticated'] = 'No'
|
os.environ['gooberauthenticated'] = 'No'
|
||||||
|
|
||||||
# Check if a given name is available for registration
|
# Check if a given name is available for registration
|
||||||
|
@ -52,11 +54,11 @@ def is_name_available(NAME):
|
||||||
return data.get("available", False)
|
return data.get("available", False)
|
||||||
else:
|
else:
|
||||||
# Print error if request failed
|
# Print error if request failed
|
||||||
print(f"{(_('name_check'))}", response.json())
|
logger.e(f"{(_('name_check'))}", response.json())
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Print exception if request failed
|
# Print exception if request failed
|
||||||
print(f"{(_('name_check2'))}", e)
|
logger.error(f"{(_('name_check2'))}", e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Register a new name with the server
|
# Register a new name with the server
|
||||||
|
@ -70,7 +72,7 @@ def register_name(NAME):
|
||||||
if os.getenv("gooberTOKEN"):
|
if os.getenv("gooberTOKEN"):
|
||||||
return
|
return
|
||||||
# Name taken: print error and exit
|
# Name taken: print error and exit
|
||||||
print(f"{gv.RED}{(_('name_taken'))}{gv.RESET}")
|
logger.critical(f"{(_('name_taken'))}")
|
||||||
quit()
|
quit()
|
||||||
# Register the name
|
# Register the name
|
||||||
response = requests.post(f"{gv.VERSION_URL}/register", json={"name": NAME}, headers={"Content-Type": "application/json"})
|
response = requests.post(f"{gv.VERSION_URL}/register", json={"name": NAME}, headers={"Content-Type": "application/json"})
|
||||||
|
@ -79,18 +81,18 @@ def register_name(NAME):
|
||||||
token = data.get("token")
|
token = data.get("token")
|
||||||
if not os.getenv("gooberTOKEN"):
|
if not os.getenv("gooberTOKEN"):
|
||||||
# Print instructions to add token and exit
|
# Print instructions to add token and exit
|
||||||
print(f"{gv.GREEN}{(_('add_token')).format(token=token)} gooberTOKEN=<token>.{gv.gv.RESET}")
|
logger.info(f"{(_('add_token')).format(token=token)} gooberTOKEN=<token>.")
|
||||||
quit()
|
quit()
|
||||||
else:
|
else:
|
||||||
print(f"{gv.GREEN}{gv.gv.RESET}")
|
print(f"{gv.GREEN}{gv.gv.RESET}")
|
||||||
return token
|
return token
|
||||||
else:
|
else:
|
||||||
# Print error if registration failed
|
# Print error if registration failed
|
||||||
print(f"{gv.RED}{(_('token_exists')).format()}{gv.RESET}", response.json())
|
logger.critical(f"{gv.RED}{(_('token_exists')).format()}", response.json())
|
||||||
return None
|
return None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Print exception if registration failed
|
# Print exception if registration failed
|
||||||
print(f"{gv.RED}{(_('registration_error')).format()}{gv.RESET}", e)
|
logger.critical(f"{gv.RED}{(_('registration_error')).format()}", e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Attempt to register the name at module load
|
# Attempt to register the name at module load
|
||||||
|
|
|
@ -41,5 +41,5 @@ latest_version = "0.0.0"
|
||||||
local_version = "2.1.3"
|
local_version = "2.1.3"
|
||||||
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 = True # this makes goober think its a beta version, so it will not update to the latest stable version or run any version checks
|
||||||
|
|
|
@ -4,7 +4,8 @@ import markovify
|
||||||
import pickle
|
import pickle
|
||||||
from modules.globalvars import *
|
from modules.globalvars import *
|
||||||
from modules.volta.main import _
|
from modules.volta.main import _
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger("goober")
|
||||||
# Get file size and line count for a given file path
|
# Get file size and line count for a given file path
|
||||||
def get_file_info(file_path):
|
def get_file_info(file_path):
|
||||||
try:
|
try:
|
||||||
|
@ -47,15 +48,15 @@ def train_markov_model(memory, additional_data=None):
|
||||||
def save_markov_model(model, filename='markov_model.pkl'):
|
def save_markov_model(model, filename='markov_model.pkl'):
|
||||||
with open(filename, 'wb') as f:
|
with open(filename, 'wb') as f:
|
||||||
pickle.dump(model, f)
|
pickle.dump(model, f)
|
||||||
print(f"Markov model saved to {filename}.")
|
logger.info(f"Markov model saved to {filename}.")
|
||||||
|
|
||||||
# Load the Markov model from a pickle file
|
# Load the Markov model from a pickle file
|
||||||
def load_markov_model(filename='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)
|
||||||
print(f"{GREEN}{_('model_loaded')} {filename}.{RESET}")
|
logger.info(f"{_('model_loaded')} {filename}.{RESET}")
|
||||||
return model
|
return model
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f"{RED}{filename} {_('not_found')}{RESET}")
|
logger.error(f"{filename} {_('not_found')}{RESET}")
|
||||||
return None
|
return None
|
|
@ -6,17 +6,20 @@ import spacy
|
||||||
from spacy.tokens import Doc
|
from spacy.tokens import Doc
|
||||||
from spacytextblob.spacytextblob import SpacyTextBlob
|
from spacytextblob.spacytextblob import SpacyTextBlob
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger("goober")
|
||||||
|
|
||||||
|
|
||||||
def check_resources():
|
def check_resources():
|
||||||
try:
|
try:
|
||||||
nlp = spacy.load("en_core_web_sm")
|
nlp = spacy.load("en_core_web_sm")
|
||||||
except OSError:
|
except OSError:
|
||||||
print((_('spacy_model_not_found')))
|
logging.critical((_('spacy_model_not_found')))
|
||||||
spacy.cli.download("en_core_web_sm")
|
spacy.cli.download("en_core_web_sm")
|
||||||
nlp = spacy.load("en_core_web_sm")
|
nlp = spacy.load("en_core_web_sm")
|
||||||
if "spacytextblob" not in nlp.pipe_names:
|
if "spacytextblob" not in nlp.pipe_names:
|
||||||
nlp.add_pipe("spacytextblob")
|
nlp.add_pipe("spacytextblob")
|
||||||
print((_('spacy_initialized')))
|
logger.info((_('spacy_initialized')))
|
||||||
|
|
||||||
check_resources()
|
check_resources()
|
||||||
|
|
||||||
|
@ -28,8 +31,8 @@ def is_positive(sentence):
|
||||||
doc = nlp(sentence)
|
doc = nlp(sentence)
|
||||||
sentiment_score = doc._.polarity # from spacytextblob
|
sentiment_score = doc._.polarity # from spacytextblob
|
||||||
|
|
||||||
debug_message = f"{DEBUG}{(_('sentence_positivity'))} {sentiment_score}{RESET}"
|
debug_message = f"{(_('sentence_positivity'))} {sentiment_score}{RESET}"
|
||||||
print(debug_message)
|
logger.debug(debug_message)
|
||||||
|
|
||||||
return sentiment_score > 0.6 # had to raise the bar because it kept saying "death to jews" was fine and it kept reacting to them
|
return sentiment_score > 0.6 # had to raise the bar because it kept saying "death to jews" was fine and it kept reacting to them
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@ from modules.globalvars import *
|
||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger("goober")
|
||||||
launched = False
|
launched = False
|
||||||
|
|
||||||
# Run a shell command and return its output
|
# Run a shell command and return its output
|
||||||
|
@ -27,11 +28,11 @@ def auto_update(branch='main', remote='origin'):
|
||||||
if is_remote_ahead(branch, remote):
|
if is_remote_ahead(branch, remote):
|
||||||
print(_( "remote_ahead").format(remote=remote, branch=branch))
|
print(_( "remote_ahead").format(remote=remote, branch=branch))
|
||||||
pull_result = run_cmd(f'git pull {remote} {branch}')
|
pull_result = run_cmd(f'git pull {remote} {branch}')
|
||||||
print(pull_result)
|
logger.info(pull_result)
|
||||||
print(_( "please_restart"))
|
logger.info(_( "please_restart"))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
print(_( "local_ahead").format(remote=remote, branch=branch))
|
logger.info(_( "local_ahead").format(remote=remote, branch=branch))
|
||||||
|
|
||||||
# Fetch the latest version info from the update server
|
# Fetch the latest version info from the update server
|
||||||
def get_latest_version_info():
|
def get_latest_version_info():
|
||||||
|
@ -40,10 +41,10 @@ def get_latest_version_info():
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
return response.json()
|
return response.json()
|
||||||
else:
|
else:
|
||||||
print(f"{RED}{_( 'version_error')} {response.status_code}{RESET}")
|
logger.error(f"{RED}{_( 'version_error')} {response.status_code}{RESET}")
|
||||||
return None
|
return None
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
print(f"{RED}{_( 'version_error')} {e}{RESET}")
|
logger.error(f"{RED}{_( 'version_error')} {e}{RESET}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Check if an update is available and perform update if needed
|
# Check if an update is available and perform update if needed
|
||||||
|
@ -54,7 +55,7 @@ def check_for_update():
|
||||||
|
|
||||||
latest_version_info = get_latest_version_info()
|
latest_version_info = get_latest_version_info()
|
||||||
if not latest_version_info:
|
if not latest_version_info:
|
||||||
print(f"{_('fetch_update_fail')}")
|
logger.error(f"{_('fetch_update_fail')}")
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
latest_version = latest_version_info.get("version")
|
latest_version = latest_version_info.get("version")
|
||||||
|
@ -62,25 +63,25 @@ def check_for_update():
|
||||||
download_url = latest_version_info.get("download_url")
|
download_url = latest_version_info.get("download_url")
|
||||||
|
|
||||||
if not latest_version or not download_url:
|
if not latest_version or not download_url:
|
||||||
print(f"{RED}{_(LOCALE, 'invalid_server')}{RESET}")
|
logger.error(f"{RED}{_(LOCALE, 'invalid_server')}{RESET}")
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
# Check if local_version is valid
|
# Check if local_version is valid
|
||||||
if local_version == "0.0.0" or None:
|
if local_version == "0.0.0" or None:
|
||||||
print(f"{RED}{_('cant_find_local_version')}{RESET}")
|
logger.error(f"{RED}{_('cant_find_local_version')}{RESET}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Compare local and latest versions
|
# Compare local and latest versions
|
||||||
if local_version < latest_version:
|
if local_version < latest_version:
|
||||||
print(f"{YELLOW}{_('new_version').format(latest_version=latest_version, local_version=local_version)}{RESET}")
|
logger.info(f"{YELLOW}{_('new_version').format(latest_version=latest_version, local_version=local_version)}{RESET}")
|
||||||
print(f"{YELLOW}{_('changelog').format(VERSION_URL=VERSION_URL)}{RESET}")
|
logger.info(f"{YELLOW}{_('changelog').format(VERSION_URL=VERSION_URL)}{RESET}")
|
||||||
auto_update()
|
auto_update()
|
||||||
elif beta == True:
|
elif beta == True:
|
||||||
print(f"{YELLOW}You are running an \"unstable\" version of Goober, do not expect it to work properly.\nVersion {local_version}{RESET}")
|
logger.warning(f"You are running an \"unstable\" version of Goober, do not expect it to work properly.\nVersion {local_version}{RESET}")
|
||||||
elif local_version > latest_version:
|
elif local_version > latest_version:
|
||||||
print(f"{YELLOW}{_('modification_warning')}{RESET}")
|
logger.warning(f"{_('modification_warning')}")
|
||||||
elif local_version == latest_version:
|
elif local_version == latest_version:
|
||||||
print(f"{GREEN}{_('latest_version')} {local_version}{RESET}")
|
logger.info(f"{_('latest_version')} {local_version}")
|
||||||
print(f"{_('latest_version2').format(VERSION_URL=VERSION_URL)}\n\n")
|
logger.info(f"{_('latest_version2').format(VERSION_URL=VERSION_URL)}\n\n")
|
||||||
launched = True
|
launched = True
|
||||||
return latest_version
|
return latest_version
|
Loading…
Add table
Add a link
Reference in a new issue