From db7fabd9544ecedfb4c76f141f8a788fac4e870d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 29 Apr 2020 19:29:07 +0200 Subject: [PATCH] Add elevatormusic --- royalpack/commands/__init__.py | 4 ++- royalpack/commands/elevatormusic.py | 50 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 royalpack/commands/elevatormusic.py diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index ca50ac4b..ecf3b565 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -52,6 +52,7 @@ from .funkwhalealbum import FunkwhalealbumCommand from .lazyfunkwhalealbum import LazyfunkwhalealbumCommand from .matchmaking import MatchmakingCommand from .cvstats import CvstatsCommand +from .elevatormusic import ElevatormusicCommand # Enter the commands of your Pack here! available_commands = [ @@ -107,7 +108,8 @@ available_commands = [ FunkwhalealbumCommand, LazyfunkwhalealbumCommand, MatchmakingCommand, - CvstatsCommand + CvstatsCommand, + ElevatormusicCommand, ] # Don't change this, it should automatically generate __all__ diff --git a/royalpack/commands/elevatormusic.py b/royalpack/commands/elevatormusic.py new file mode 100644 index 00000000..5041de2d --- /dev/null +++ b/royalpack/commands/elevatormusic.py @@ -0,0 +1,50 @@ +import random +import royalnet.commands as rc +from .play import PlayCommand + + +class ElevatormusicCommand(PlayCommand): + name: str = "elevatormusic" + + aliases = ["elevator", "em"] + + description: str = "Aggiungi un po' di musica da ascensore alla chat vocale." + + syntax = "[indice]" + + _pool = [ + "https://www.youtube.com/watch?v=_tAcIGhh5Yo", + "https://www.youtube.com/watch?v=xy_NKN75Jhw", + "https://www.youtube.com/watch?v=PLRrL9OsAF8", + "https://www.youtube.com/watch?v=0TmoYBcLul8", + "https://www.youtube.com/watch?v=9v9-Nw4nAZg", + "https://www.youtube.com/watch?v=VBlFHuCzPgY", + "https://www.youtube.com/watch?v=mD3v1B_aXw0", + "https://www.youtube.com/watch?v=RCSbmSmyAcY", + "https://www.youtube.com/watch?v=kbdtBLD8Lbg", + "https://www.youtube.com/watch?v=JjT0p2z4hGg", + "https://www.youtube.com/watch?v=cc_KpOufpgM", + "https://www.youtube.com/watch?v=dlNEUYBt7Ls", + "https://www.youtube.com/watch?v=YVWdQGuE0-E", + "https://www.youtube.com/watch?v=1nVAg8VujGA", + "https://www.youtube.com/watch?v=G4mshu6BUio", + "https://www.youtube.com/watch?v=Y6_Aij3n8hk", + "https://www.youtube.com/watch?v=SbIaYZEUF1M", + "https://www.youtube.com/watch?v=Nf8FCLT8S6A", + ] + + async def get_urls(self, args): + index = args.optional(0) + if index is not None: + try: + return [self._pool[int(index)]] + except ValueError: + raise rc.InvalidInputError("L'indice deve essere un numero.\n" + f"Gli indici delle canzoni iniziano a [c]0[/c] e finiscono a" + f" [c]{len(self._pool) - 1}[/c].") + except IndexError: + raise rc.InvalidInputError(f"Indice non valido.\n" + f"Gli indici delle canzoni iniziano a [c]0[/c] e finiscono a" + f" [c]{len(self._pool) - 1}[/c].") + else: + return [random.sample(self._pool, 1)[0]]