better shortened lyrics for non-botspam chans

This commit is contained in:
codey 2025-03-25 06:25:04 -04:00
parent 6018de870d
commit 436755f884
2 changed files with 13 additions and 4 deletions

View File

@ -196,6 +196,11 @@ class Meme(commands.Cog):
except:
pass
await db_conn.commit()
try:
await self.update_meme_lb()
except Exception as e:
logging.info("Failed to update meme leaderboard following increment: %s",
str(e))
async def init_meme_leaderboard(self) -> None:

View File

@ -62,7 +62,7 @@ class Sing(commands.Cog):
return await ctx.respond("**Error**: No song specified, no activity found to read.")
if interaction:
await ctx.respond("*Searching...*", ephemeral=True) # Must respond to interactions within 3 seconds, per Discord
await ctx.respond("*Searching...*") # Must respond to interactions within 3 seconds, per Discord
parsed = self.utility.parse_song_input(song, activity)
@ -88,7 +88,9 @@ class Sing(commands.Cog):
search_result_wrapped: list[str] = search_result[1] # Second index is the wrapped lyrics
search_result_wrapped_short: list[str] = search_result[2] # Third is short wrapped lyrics
if not ctx.channel.id in BOT_CHANIDS:
search_result_wrapped = search_result_wrapped_short # Replace with shortened lyrics for non spamchans
short_lyrics = " ".join(search_result_wrapped_short) # Replace with shortened lyrics for non spamchans
short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip())
return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}")
embeds: list[Optional[discord.Embed]] = []
embed_url: str = f"[on codey.lol](https://codey.lol/#{urllib.parse.quote(search_artist)}/{urllib.parse.quote(search_song)})"
c: int = 0
@ -152,7 +154,7 @@ class Sing(commands.Cog):
if isinstance(parsed, tuple):
(search_artist, search_song, search_subsearch) = parsed
await ctx.respond("*Searching...*", ephemeral=True) # Must respond to interactions within 3 seconds, per Discord
await ctx.respond("*Searching...*") # Must respond to interactions within 3 seconds, per Discord
search_result: Optional[list] = await self.utility.lyric_search(search_artist, search_song,
search_subsearch)
if not search_result:
@ -170,7 +172,9 @@ class Sing(commands.Cog):
search_result_wrapped_short: list[str] = search_result[2] # Third index is shortened lyrics
if not IS_SPAMCHAN:
search_result_wrapped = search_result_wrapped_short # Swap for shortened lyrics if not spam chan
short_lyrics = " ".join(search_result_wrapped_short) # Replace with shortened lyrics for non spamchans
short_lyrics = regex.sub(r'\p{Vert_Space}', ' / ', short_lyrics.strip())
return await ctx.respond(f"**{search_result_song}** by **{search_result_artist}**\n-# {short_lyrics}")
embeds: list[Optional[discord.Embed]] = []
c: int = 0