From ba57a3e18dd5db76b883b302fcb37027a6058896 Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Wed, 7 Sep 2022 21:47:09 -0300 Subject: [PATCH] Now using hyperlinks in Queue and adding support message as random string --- Config/Configs.py | 4 ++++ Config/Embeds.py | 13 +++++++++++++ Handlers/QueueHandler.py | 4 ++-- Music/Song.py | 1 - Music/VulkanInitializer.py | 1 - 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Config/Configs.py b/Config/Configs.py index d8d6d4b..b7527ae 100644 --- a/Config/Configs.py +++ b/Config/Configs.py @@ -24,6 +24,10 @@ class VConfigs(Singleton): self.COMMANDS_PATH = f'{Folder().rootFolder}{self.COMMANDS_FOLDER_NAME}' self.VC_TIMEOUT = 300 + self.CHANCE_SHOW_PROJECT = 15 + self.PROJECT_URL = 'https://github.com/RafaelSolVargas/Vulkan' + self.SUPPORTING_ICON = 'https://i.pinimg.com/originals/d6/05/b4/d605b4f8c5d1c6ae20dc353ef9f091bd.png' + self.MAX_PLAYLIST_LENGTH = 50 self.MAX_PLAYLIST_FORCED_LENGTH = 5 self.MAX_SONGS_IN_PAGE = 10 diff --git a/Config/Embeds.py b/Config/Embeds.py index 21b716b..3de3466 100644 --- a/Config/Embeds.py +++ b/Config/Embeds.py @@ -1,3 +1,4 @@ +from random import random from Config.Messages import Messages from Config.Exceptions import VulkanError from discord import Embed @@ -12,6 +13,13 @@ class VEmbeds: self.__messages = Messages() self.__colors = VColors() + def __willShowProject(self) -> bool: + return (random() * 100 < self.__config.CHANCE_SHOW_PROJECT) + + def __addFooterContent(self, embed: Embed) -> Embed: + footerText = f'\u200b Please support this project by leaving a star: {self.__config.PROJECT_URL}' + return embed.set_footer(text=footerText, icon_url=self.__config.SUPPORTING_ICON) + def ONE_SONG_LOOPING(self, info: dict) -> Embed: title = self.__messages.ONE_SONG_LOOPING return self.SONG_INFO(info, title) @@ -113,6 +121,8 @@ class VEmbeds: value=position, inline=True) + if self.__willShowProject(): + embedvc = self.__addFooterContent(embedvc) return embedvc def SONG_MOVED(self, song_name: str, pos1: int, pos2: int) -> Embed: @@ -340,6 +350,9 @@ class VEmbeds: description=description, colour=self.__colors.BLUE ) + + if self.__willShowProject(): + embed = self.__addFooterContent(embed) return embed def INVITE(self, bot_id: str) -> Embed: diff --git a/Handlers/QueueHandler.py b/Handlers/QueueHandler.py index fea2f2a..1b016f1 100644 --- a/Handlers/QueueHandler.py +++ b/Handlers/QueueHandler.py @@ -74,8 +74,8 @@ class QueueHandler(AbstractHandler): # To work get the correct index of all songs startIndex = (pageNumber * self.config.MAX_SONGS_IN_PAGE) + 1 for pos, song in enumerate(songs, start=startIndex): - song_name = song.title if song.title else self.messages.SONG_DOWNLOADING - text += f"**`{pos}` - ** {song_name} - `{Utils.format_time(song.duration)}`\n" + song_name = song.title[:50] if song.title else self.messages.SONG_DOWNLOADING + text += f"**`{pos}` - ** [{song_name}]({song.identifier}) - `{Utils.format_time(song.duration)}`\n" embed = self.embeds.QUEUE(title, text) # Release the acquired Lock diff --git a/Music/Song.py b/Music/Song.py index 20f627d..eab512b 100644 --- a/Music/Song.py +++ b/Music/Song.py @@ -1,5 +1,4 @@ class Song: - def __init__(self, identifier: str, playlist, requester: str) -> None: self.__identifier = identifier self.__info = {'requester': requester} diff --git a/Music/VulkanInitializer.py b/Music/VulkanInitializer.py index 371328e..08ca1a0 100644 --- a/Music/VulkanInitializer.py +++ b/Music/VulkanInitializer.py @@ -1,4 +1,3 @@ -import os from random import choices import string from discord.bot import Bot