Compare commits
6 commits
eb5109424b
...
66a98a5499
Author | SHA1 | Date | |
---|---|---|---|
66a98a5499 | |||
![]() |
53e0eb5289 | ||
![]() |
016e907d39 | ||
![]() |
cb45a9fffc | ||
![]() |
7c6be59dc9 | ||
![]() |
c565f962c5 |
7 changed files with 34 additions and 24 deletions
19
bot.py
19
bot.py
|
@ -113,6 +113,7 @@ async def on_ready() -> None:
|
||||||
global launched
|
global launched
|
||||||
global slash_commands_enabled
|
global slash_commands_enabled
|
||||||
global NAME
|
global NAME
|
||||||
|
global status
|
||||||
|
|
||||||
folder_name: str = "cogs"
|
folder_name: str = "cogs"
|
||||||
if launched:
|
if launched:
|
||||||
|
@ -136,8 +137,15 @@ async def on_ready() -> None:
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
if not song:
|
if not song:
|
||||||
return
|
return
|
||||||
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f"{song}"))
|
|
||||||
|
status = {
|
||||||
|
"idle": discord.Status.idle,
|
||||||
|
"dnd": discord.Status.dnd,
|
||||||
|
"invisible": discord.Status.invisible,
|
||||||
|
"online": discord.Status.online
|
||||||
|
}.get(status.lower(), discord.Status.online)
|
||||||
|
await bot.change_presence(status=status, activity=discord.Activity(type=discord.ActivityType.listening, name=f"{song}"))
|
||||||
launched = True
|
launched = True
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
|
@ -225,7 +233,7 @@ async def talk(ctx: commands.Context, sentence_size: int = 5) -> None:
|
||||||
|
|
||||||
# Command: Generate an image
|
# Command: Generate an image
|
||||||
@bot.hybrid_command(description=f"{(_('command_desc_help'))}")
|
@bot.hybrid_command(description=f"{(_('command_desc_help'))}")
|
||||||
async def impact(ctx: commands.Context) -> None:
|
async def impact(ctx: commands.Context, text: Optional[str] = None) -> None:
|
||||||
assets_folder: str = "assets/images"
|
assets_folder: str = "assets/images"
|
||||||
temp_input: Optional[str] = None
|
temp_input: Optional[str] = None
|
||||||
|
|
||||||
|
@ -259,7 +267,8 @@ async def impact(ctx: commands.Context) -> None:
|
||||||
shutil.copy(fallback_image, temp_input)
|
shutil.copy(fallback_image, temp_input)
|
||||||
input_path = temp_input
|
input_path = temp_input
|
||||||
|
|
||||||
output_path: Optional[str] = await gen_meme(input_path)
|
output_path: Optional[str] = await gen_meme(input_path, custom_text=text)
|
||||||
|
|
||||||
|
|
||||||
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):
|
||||||
|
@ -371,7 +380,7 @@ async def on_message(message: discord.Message) -> None:
|
||||||
|
|
||||||
if str(message.author.id) in BLACKLISTED_USERS:
|
if str(message.author.id) in BLACKLISTED_USERS:
|
||||||
return
|
return
|
||||||
|
|
||||||
if message.content.startswith((f"{PREFIX}talk", f"{PREFIX}mem", f"{PREFIX}help", f"{PREFIX}stats", f"{PREFIX}")):
|
if message.content.startswith((f"{PREFIX}talk", f"{PREFIX}mem", f"{PREFIX}help", f"{PREFIX}stats", f"{PREFIX}")):
|
||||||
logger.info(f"{(_('command_ran')).format(message=message)}")
|
logger.info(f"{(_('command_ran')).format(message=message)}")
|
||||||
await bot.process_commands(message)
|
await bot.process_commands(message)
|
||||||
|
|
|
@ -11,6 +11,7 @@ AUTOUPDATE="True"
|
||||||
SONG="Basket Case - Green Day"
|
SONG="Basket Case - Green Day"
|
||||||
CHECKSDISABLED="Frue"
|
CHECKSDISABLED="Frue"
|
||||||
REACT="True"
|
REACT="True"
|
||||||
|
STATUS="idle"
|
||||||
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"
|
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="
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ 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"))
|
||||||
|
status = os.getenv("STATUS")
|
||||||
showmemenabled = os.getenv("SHOWMEMENABLED")
|
showmemenabled = os.getenv("SHOWMEMENABLED")
|
||||||
BLACKLISTED_USERS = os.getenv("BLACKLISTEDUSERS", "").split(",")
|
BLACKLISTED_USERS = os.getenv("BLACKLISTEDUSERS", "").split(",")
|
||||||
USERTRAIN_ENABLED = os.getenv("USERTRAINENABLED", "true").lower() == "true"
|
USERTRAIN_ENABLED = os.getenv("USERTRAINENABLED", "true").lower() == "true"
|
||||||
|
@ -43,13 +44,11 @@ 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
|
||||||
ALIVEPING = os.getenv("ALIVEPING")
|
ALIVEPING = os.getenv("ALIVEPING")
|
||||||
AUTOUPDATE = os.getenv("AUTOUPDATE")
|
AUTOUPDATE = os.getenv("AUTOUPDATE")
|
||||||
# IGNOREWARNING = False # is this either??? i don't think so?
|
song = os.getenv("SONG")
|
||||||
song = os.getenv("song")
|
|
||||||
arch = platform.machine()
|
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"
|
latest_version = "0.0.0"
|
||||||
local_version = "2.3.3"
|
local_version = "2.3.4"
|
||||||
os.environ['gooberlocal_version'] = local_version
|
os.environ['gooberlocal_version'] = local_version
|
||||||
REACT = os.getenv("REACT")
|
REACT = os.getenv("REACT")
|
||||||
if get_git_branch() == "dev":
|
if get_git_branch() == "dev":
|
||||||
|
|
|
@ -37,7 +37,7 @@ def split_text_to_fit(text, font, max_width, draw):
|
||||||
midpoint = len(words) // 2
|
midpoint = len(words) // 2
|
||||||
return " ".join(words[:midpoint]), " ".join(words[midpoint:])
|
return " ".join(words[:midpoint]), " ".join(words[midpoint:])
|
||||||
|
|
||||||
async def gen_meme(input_image_path, sentence_size=5, max_attempts=10):
|
async def gen_meme(input_image_path, sentence_size=5, max_attempts=10, custom_text=None):
|
||||||
markov_model = load_markov_model()
|
markov_model = load_markov_model()
|
||||||
if not markov_model or not os.path.isfile(input_image_path):
|
if not markov_model or not os.path.isfile(input_image_path):
|
||||||
return None
|
return None
|
||||||
|
@ -52,19 +52,22 @@ async def gen_meme(input_image_path, sentence_size=5, max_attempts=10):
|
||||||
font = load_font(font_size)
|
font = load_font(font_size)
|
||||||
|
|
||||||
response = None
|
response = None
|
||||||
for _ in range(20):
|
if custom_text:
|
||||||
if sentence_size == 1:
|
response = custom_text
|
||||||
candidate = markov_model.make_short_sentence(max_chars=100, tries=100)
|
else:
|
||||||
if candidate:
|
for _ in range(20):
|
||||||
candidate = candidate.split()[0]
|
if sentence_size == 1:
|
||||||
else:
|
candidate = markov_model.make_short_sentence(max_chars=100, tries=100)
|
||||||
candidate = markov_model.make_sentence(tries=100, max_words=sentence_size)
|
if candidate:
|
||||||
|
candidate = candidate.split()[0]
|
||||||
|
else:
|
||||||
|
candidate = markov_model.make_sentence(tries=100, max_words=sentence_size)
|
||||||
|
|
||||||
if candidate and candidate not in generated_sentences:
|
if candidate and candidate not in generated_sentences:
|
||||||
if sentence_size > 1:
|
if sentence_size > 1:
|
||||||
candidate = improve_sentence_coherence(candidate)
|
candidate = improve_sentence_coherence(candidate)
|
||||||
generated_sentences.add(candidate)
|
generated_sentences.add(candidate)
|
||||||
response = candidate
|
response = candidate
|
||||||
break
|
break
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
|
|
2
todo.txt
2
todo.txt
|
@ -1,4 +1,2 @@
|
||||||
- fix missing translations in some cases
|
|
||||||
- revamp wiki
|
- revamp wiki
|
||||||
- clean the rest
|
|
||||||
- alot
|
- alot
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue