feat: sanityzacja tytułów w Discordzie oraz linki i embedy dla powiadomień z panelu web
This commit is contained in:
2 files changed
+31
-10
No files matched your search
@@ -141,7 +141,7 @@ class MusicBot(commands.Cog):
|
||||
self.get_queue(guild_id).append(player)
|
||||
await self.trigger_state_change()
|
||||
await interaction.followup.send(
|
||||
f"Dodano do kolejki: {player.title}",
|
||||
f"Dodano do kolejki: {discord.utils.escape_markdown(player.title)}",
|
||||
ephemeral=False
|
||||
)
|
||||
else:
|
||||
@@ -155,7 +155,7 @@ class MusicBot(commands.Cog):
|
||||
)
|
||||
)
|
||||
await interaction.followup.send(
|
||||
f"Teraz odtwarzane: {player.title}",
|
||||
f"Teraz odtwarzane: {discord.utils.escape_markdown(player.title)}",
|
||||
ephemeral=False
|
||||
)
|
||||
except Exception as e:
|
||||
@@ -186,7 +186,7 @@ class MusicBot(commands.Cog):
|
||||
self.bot.loop
|
||||
)
|
||||
)
|
||||
await self.send_to_last_channel(guild_id, f"Teraz odtwarzane (zapętlone): {player.title}")
|
||||
await self.send_to_last_channel(guild_id, f"Teraz odtwarzane (zapętlone): {discord.utils.escape_markdown(player.title)}")
|
||||
return
|
||||
except Exception as e:
|
||||
print(f"Error repeating song: {e}")
|
||||
@@ -203,17 +203,17 @@ class MusicBot(commands.Cog):
|
||||
self.bot.loop
|
||||
)
|
||||
)
|
||||
await self.send_to_last_channel(guild_id, f"Teraz odtwarzane: {next_player.title}")
|
||||
await self.send_to_last_channel(guild_id, f"Teraz odtwarzane: {discord.utils.escape_markdown(next_player.title)}")
|
||||
else:
|
||||
self.set_current(guild_id, None)
|
||||
await self.trigger_state_change()
|
||||
await self.send_to_last_channel(guild_id, "Kolejka jest pusta.")
|
||||
|
||||
async def send_to_last_channel(self, guild_id: int, text: str):
|
||||
async def send_to_last_channel(self, guild_id: int, text: str = None, embed: discord.Embed = None):
|
||||
channel = self.get_notification_channel(guild_id)
|
||||
if channel:
|
||||
try:
|
||||
await channel.send(text)
|
||||
await channel.send(content=text if text else None, embed=embed)
|
||||
except Exception as e:
|
||||
print(f"Failed to send message: {e}")
|
||||
|
||||
@@ -229,7 +229,7 @@ class MusicBot(commands.Cog):
|
||||
)
|
||||
return
|
||||
|
||||
queue_list = "\n".join([f"{i + 1}. {item.title}" for i, item in enumerate(queue)])
|
||||
queue_list = "\n".join([f"{i + 1}. {discord.utils.escape_markdown(item.title)}" for i, item in enumerate(queue)])
|
||||
await interaction.response.send_message(
|
||||
f"Aktualna kolejka:\n{queue_list}",
|
||||
ephemeral=False
|
||||
@@ -331,7 +331,7 @@ class MusicBot(commands.Cog):
|
||||
current = self.get_current(guild_id)
|
||||
if current:
|
||||
await interaction.response.send_message(
|
||||
f"Teraz odtwarzane: {current.title}",
|
||||
f"Teraz odtwarzane: {discord.utils.escape_markdown(current.title)}",
|
||||
ephemeral=False
|
||||
)
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user