diff --git a/royalpack/commands/__init__.py b/royalpack/commands/__init__.py index 9ce8b05e..e6d4b17a 100644 --- a/royalpack/commands/__init__.py +++ b/royalpack/commands/__init__.py @@ -11,58 +11,32 @@ from .diarioquote import DiarioquoteCommand from .diarioshuffle import DiarioshuffleCommand from .dota import DotaCommand from .eat import EatCommand -from .elevatormusic import ElevatormusicCommand from .emojify import EmojifyCommand from .eval import EvalCommand from .exec import ExecCommand from .fortune import FortuneCommand -from .funkwhale import FunkwhaleCommand -from .funkwhalealbum import FunkwhalealbumCommand -from .funkwhaleplaylist import FunkwhaleplaylistCommand from .givefiorygi import GivefiorygiCommand from .givetreasure import GivetreasureCommand -from .googlevideo import GooglevideoCommand from .help import HelpCommand -from .lazyfunkwhale import LazyfunkwhaleCommand -from .lazyfunkwhalealbum import LazyfunkwhalealbumCommand -from .lazyfunkwhaleplaylist import LazyfunkwhaleplaylistCommand -from .lazygooglevideo import LazygooglevideoCommand -from .lazypeertube import LazypeertubeCommand -from .lazyplay import LazyplayCommand -from .lazysoundcloud import LazysoundcloudCommand -from .lazyyahoovideo import LazyyahoovideoCommand -from .lazyyoutube import LazyyoutubeCommand from .leagueoflegends import LeagueoflegendsCommand from .magickfiorygi import MagickfiorygiCommand from .magicktreasure import MagicktreasureCommand from .matchmaking import MatchmakingCommand -from .pause import PauseCommand -from .peertube import PeertubeCommand from .peertubeupdates import PeertubeUpdatesCommand from .ping import PingCommand -from .play import PlayCommand -from .playmode import PlaymodeCommand from .pmots import PmotsCommand from .dog import DogCommand -from .queue import QueueCommand from .rage import RageCommand from .reminder import ReminderCommand from .royalpackversion import RoyalpackCommand from .ship import ShipCommand -from .skip import SkipCommand from .smecds import SmecdsCommand -from .soundcloud import SoundcloudCommand from .spell import SpellCommand from .steammatch import SteammatchCommand from .steampowered import SteampoweredCommand -from .summon import SummonCommand from .treasure import TreasureCommand from .trivia import TriviaCommand from .userinfo import UserinfoCommand -from .videochannel import VideochannelCommand -from .voicestatus import VoicestatusCommand -from .yahoovideo import YahoovideoCommand -from .youtube import YoutubeCommand # Enter the commands of your Pack here! available_commands = [ @@ -78,58 +52,32 @@ available_commands = [ DiarioshuffleCommand, DotaCommand, EatCommand, - ElevatormusicCommand, EmojifyCommand, EvalCommand, ExecCommand, FortuneCommand, - FunkwhalealbumCommand, - FunkwhaleCommand, - FunkwhaleplaylistCommand, GivefiorygiCommand, GivetreasureCommand, - GooglevideoCommand, HelpCommand, - LazyfunkwhalealbumCommand, - LazyfunkwhaleCommand, - LazyfunkwhaleplaylistCommand, - LazygooglevideoCommand, - LazypeertubeCommand, - LazyplayCommand, - LazysoundcloudCommand, - LazyyahoovideoCommand, - LazyyoutubeCommand, LeagueoflegendsCommand, MagickfiorygiCommand, MagicktreasureCommand, MatchmakingCommand, - PauseCommand, - PeertubeCommand, PeertubeUpdatesCommand, PingCommand, - PlayCommand, - PlaymodeCommand, PmotsCommand, DogCommand, - QueueCommand, RageCommand, ReminderCommand, RoyalpackCommand, ShipCommand, - SkipCommand, SmecdsCommand, - SoundcloudCommand, SpellCommand, SteammatchCommand, SteampoweredCommand, - SummonCommand, TreasureCommand, TriviaCommand, UserinfoCommand, - VideochannelCommand, - VoicestatusCommand, - YahoovideoCommand, - YoutubeCommand, ] # Don't change this, it should automatically generate __all__ diff --git a/royalpack/commands/elevatormusic.py b/royalpack/commands/elevatormusic.py deleted file mode 100644 index 52929e46..00000000 --- a/royalpack/commands/elevatormusic.py +++ /dev/null @@ -1,52 +0,0 @@ -from typing import * -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]] diff --git a/royalpack/commands/funkwhale.py b/royalpack/commands/funkwhale.py deleted file mode 100644 index b46cdfeb..00000000 --- a/royalpack/commands/funkwhale.py +++ /dev/null @@ -1,31 +0,0 @@ -from typing import * -import aiohttp -import urllib.parse -import royalnet.commands as rc - -from .play import PlayCommand - - -class FunkwhaleCommand(PlayCommand): - name: str = "funkwhale" - - aliases = ["fuckwhale", "fw", "royalwhale", "rw"] - - description: str = "Cerca una canzone su RoyalWhale e aggiungila alla coda della chat vocale." - - syntax = "{ricerca}" - - def get_embed_color(self): - return 0x009FE3 - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/search?query={search}") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - if len(j["tracks"]) < 1: - raise rc.UserError("Nessun file audio trovato con il nome richiesto.") - return [f'{self.config["Funkwhale"]["instance_url"]}{j["tracks"][0]["listen_url"]}'] diff --git a/royalpack/commands/funkwhalealbum.py b/royalpack/commands/funkwhalealbum.py deleted file mode 100644 index fe132f56..00000000 --- a/royalpack/commands/funkwhalealbum.py +++ /dev/null @@ -1,32 +0,0 @@ -from typing import * -import aiohttp -import urllib.parse -import royalnet.commands as rc - -from .play import PlayCommand - - -class FunkwhalealbumCommand(PlayCommand): - name: str = "funkwhalealbum" - - aliases = ["fwa", "fwalbum", "funkwhalea"] - - description: str = "Cerca un album su RoyalWhale e aggiungila alla coda della chat vocale." - - syntax = "{ricerca}" - - def get_embed_color(self): - return 0x009FE3 - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/search?query={search}") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - if len(j["albums"]) < 1: - raise rc.UserError("Nessun file audio trovato con il nome richiesto.") - album = j["albums"][0] - return [f'{self.config["Funkwhale"]["instance_url"]}{track["listen_url"]}' for track in album["tracks"]] diff --git a/royalpack/commands/funkwhaleplaylist.py b/royalpack/commands/funkwhaleplaylist.py deleted file mode 100644 index bdd3eb33..00000000 --- a/royalpack/commands/funkwhaleplaylist.py +++ /dev/null @@ -1,38 +0,0 @@ -from typing import * -import aiohttp -import urllib.parse -import royalnet.commands as rc - -from .play import PlayCommand - - -class FunkwhaleplaylistCommand(PlayCommand): - name: str = "funkwhaleplaylist" - - aliases = ["fwp", "fwplaylist", "funkwhalep"] - - description: str = "Cerca una playlist su RoyalWhale e aggiungila alla coda della chat vocale." - - syntax = "{ricerca}" - - def get_embed_color(self): - return 0x009FE3 - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/playlists/?q={search}&ordering=-creation_date&playable=true") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - if len(j["results"]) < 1: - raise rc.UserError("Nessuna playlist trovata con il nome richiesto.") - playlist = j["results"][0] - playlist_id = playlist["id"] - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/playlists/{playlist_id}/tracks") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - return list(map(lambda t: f'{self.config["Funkwhale"]["instance_url"]}{t["track"]["listen_url"]}', j["results"])) diff --git a/royalpack/commands/googlevideo.py b/royalpack/commands/googlevideo.py deleted file mode 100644 index 3ec38790..00000000 --- a/royalpack/commands/googlevideo.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import * -from .play import PlayCommand - - -class GooglevideoCommand(PlayCommand): - name: str = "googlevideo" - - aliases = ["gv"] - - description: str = "Cerca un video su Google Video e lo aggiunge alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"gvsearch:{args.joined()}"] - - # Too bad gvsearch: always finds nothing. diff --git a/royalpack/commands/lazyfunkwhale.py b/royalpack/commands/lazyfunkwhale.py deleted file mode 100644 index fd3337fe..00000000 --- a/royalpack/commands/lazyfunkwhale.py +++ /dev/null @@ -1,31 +0,0 @@ -from typing import * -import royalnet.commands as rc -import aiohttp -import urllib.parse - -from .lazyplay import LazyplayCommand - - -class LazyfunkwhaleCommand(LazyplayCommand): - name: str = "lazyfunkwhale" - - aliases = ["lazyfuckwhale", "lfw", "lazyroyalwhale", "lrw"] - - description: str = "Cerca una canzone su RoyalWhale e aggiungila (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - def get_embed_color(self): - return 0x009FE3 - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/search?query={search}") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - if len(j["tracks"]) < 1: - raise rc.UserError("Nessun file audio trovato con il nome richiesto.") - return [f'{self.config["Funkwhale"]["instance_url"]}{j["tracks"][0]["listen_url"]}'] diff --git a/royalpack/commands/lazyfunkwhalealbum.py b/royalpack/commands/lazyfunkwhalealbum.py deleted file mode 100644 index 631e088e..00000000 --- a/royalpack/commands/lazyfunkwhalealbum.py +++ /dev/null @@ -1,32 +0,0 @@ -from typing import * -import royalnet.commands as rc -import aiohttp -import urllib.parse - -from .lazyplay import LazyplayCommand - - -class LazyfunkwhalealbumCommand(LazyplayCommand): - name: str = "lazyfunkwhalealbum" - - aliases = ["lfwa", "lfwalbum", "lazyfunkwhalea"] - - description: str = "Cerca un album su RoyalWhale e aggiungilo (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - def get_embed_color(self): - return 0x009FE3 - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/search?query={search}") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - if len(j["albums"]) < 1: - raise rc.UserError("Nessun file audio trovato con il nome richiesto.") - album = j["albums"][0] - return [f'{self.config["Funkwhale"]["instance_url"]}{track["listen_url"]}' for track in album["tracks"]] diff --git a/royalpack/commands/lazyfunkwhaleplaylist.py b/royalpack/commands/lazyfunkwhaleplaylist.py deleted file mode 100644 index caa9378d..00000000 --- a/royalpack/commands/lazyfunkwhaleplaylist.py +++ /dev/null @@ -1,36 +0,0 @@ -import aiohttp -import urllib.parse -import royalnet.commands as rc -from .lazyplay import LazyplayCommand - - -class LazyfunkwhaleplaylistCommand(LazyplayCommand): - name: str = "lazyfunkwhaleplaylist" - - aliases = ["lfwp", "lfwplaylist", "lazyfunkwhalep"] - - description: str = "Cerca una playlist su RoyalWhale e aggiungila (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - def get_embed_color(self): - return 0x009FE3 - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/playlists/?q={search}&ordering=-creation_date&playable=true") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - if len(j["results"]) < 1: - raise rc.UserError("Nessuna playlist trovata con il nome richiesto.") - playlist = j["results"][0] - playlist_id = playlist["id"] - async with session.get(self.config["Funkwhale"]["instance_url"] + - f"/api/v1/playlists/{playlist_id}/tracks") as response: - if response.status >= 400: - raise rc.ExternalError(f"Request returned {response.status}") - j = await response.json() - return list(map(lambda t: f'{self.config["Funkwhale"]["instance_url"]}{t["track"]["listen_url"]}', j["results"])) diff --git a/royalpack/commands/lazygooglevideo.py b/royalpack/commands/lazygooglevideo.py deleted file mode 100644 index e8bba83a..00000000 --- a/royalpack/commands/lazygooglevideo.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import * -from .lazyplay import LazyplayCommand - - -class LazygooglevideoCommand(LazyplayCommand): - name: str = "lazygooglevideo" - - aliases = ["lgv"] - - description: str = "Cerca un video su Google Video e lo aggiunge (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"gvsearch:{args.joined()}"] - - # Too bad gvsearch: always finds nothing. diff --git a/royalpack/commands/lazypeertube.py b/royalpack/commands/lazypeertube.py deleted file mode 100644 index 691ce58c..00000000 --- a/royalpack/commands/lazypeertube.py +++ /dev/null @@ -1,26 +0,0 @@ -from typing import * -import royalnet.commands as rc -import aiohttp -import urllib.parse - -from .lazyplay import LazyplayCommand - - -class LazypeertubeCommand(LazyplayCommand): - name: str = "lazypeertube" - - aliases = ["lpt", "lazyroyaltube", "lrt"] - - description: str = "Cerca un video su RoyalTube e lo aggiunge (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Peertube"]["instance_url"] + - f"/api/v1/search/videos?search={search}") as response: - j = await response.json() - if j["total"] < 1: - raise rc.InvalidInputError("Nessun video trovato.") - return [f'{self.config["Peertube"]["instance_url"]}/videos/watch/{j["data"][0]["uuid"]}'] diff --git a/royalpack/commands/lazyplay.py b/royalpack/commands/lazyplay.py deleted file mode 100644 index 2ee9b7f4..00000000 --- a/royalpack/commands/lazyplay.py +++ /dev/null @@ -1,62 +0,0 @@ -from typing import * -import discord -import asyncio as aio -import royalnet.commands as rc -import royalnet.backpack.tables as rbt - - -class LazyplayCommand(rc.Command): - name: str = "lazyplay" - - aliases = ["lp"] - - description: str = "Aggiunge un url alla coda della chat vocale, ma lo scarica solo quando sta per essere" \ - " riprodotto." - - syntax = "{url}" - - async def get_urls(self, args: rc.CommandArgs): - url = args.joined(require_at_least=1) - if not (url.startswith("http://") or url.startswith("https://")): - raise rc.InvalidInputError(f"L'URL specificato non inizia con il nome di un protocollo supportato" - f" ([c]http://[/c] o [c]https://[/c]).") - return [url] - - def get_embed_color(self) -> Optional[int]: - return None - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name == "discord": - message: discord.Message = data.message - guild: discord.Guild = message.guild - if guild is None: - guild_id = None - else: - guild_id: Optional[int] = guild.id - else: - guild_id = None - - user: rbt.User = await data.get_author() - user_str = None - - if user is not None: - try: - user_discord: rbt.Discord = user.discord[0] - except (AttributeError, IndexError): - user_str = str(user) - else: - user_str = str(f"<@{user_discord.discord_id}>") - - urls = await self.get_urls(args) - - play_task: aio.Task = self.loop.create_task( - self.interface.call_herald_event("discord", "discord_lazy_play", - urls=urls, - guild_id=guild_id, - user=user_str, - force_color=self.get_embed_color()) - ) - - await data.reply("⌛ Attendi un attimo...") - - await play_task diff --git a/royalpack/commands/lazysoundcloud.py b/royalpack/commands/lazysoundcloud.py deleted file mode 100644 index e297c0ce..00000000 --- a/royalpack/commands/lazysoundcloud.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import * -from .lazyplay import LazyplayCommand - - -class LazysoundcloudCommand(LazyplayCommand): - name: str = "lazysoundcloud" - - aliases = ["lsc"] - - description: str = "Cerca un video su SoundCloud e lo aggiunge (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"scsearch:{args.joined()}"] diff --git a/royalpack/commands/lazyyahoovideo.py b/royalpack/commands/lazyyahoovideo.py deleted file mode 100644 index a2e51389..00000000 --- a/royalpack/commands/lazyyahoovideo.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import * -from .lazyplay import LazyplayCommand - - -class LazyyahoovideoCommand(LazyplayCommand): - name: str = "lazyyahoovideo" - - aliases = ["lyv"] - - description: str = "Cerca un video su Yahoo Video e lo aggiunge (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"yvsearch:{args.joined()}"] - - # Too bad yvsearch: always finds nothing. diff --git a/royalpack/commands/lazyyoutube.py b/royalpack/commands/lazyyoutube.py deleted file mode 100644 index 3dcb8f82..00000000 --- a/royalpack/commands/lazyyoutube.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import * -from .lazyplay import LazyplayCommand - - -class LazyyoutubeCommand(LazyplayCommand): - name: str = "lazyyoutube" - - aliases = ["lyt"] - - description: str = "Cerca un video su YouTube e lo aggiunge (lazy) alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"ytsearch:{args.joined()}"] diff --git a/royalpack/commands/pause.py b/royalpack/commands/pause.py deleted file mode 100644 index 4c71820d..00000000 --- a/royalpack/commands/pause.py +++ /dev/null @@ -1,27 +0,0 @@ -from typing import * -import discord -import royalnet.commands as rc - - -class PauseCommand(rc.Command): - name: str = "pause" - - aliases = ["resume"] - - description: str = "Metti in pausa o riprendi la riproduzione di un file." - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name == "discord": - message: discord.Message = data.message - guild: discord.Guild = message.guild - guild_id: Optional[int] = guild.id - else: - guild_id = None - response: Dict[str, Any] = await self.interface.call_herald_event("discord", "discord_pause", - guild_id=guild_id) - - if response["action"] == "paused": - await data.reply("⏸ Riproduzione messa in pausa.") - - elif response["action"] == "resumed": - await data.reply("▶️ Riproduzione ripresa!") diff --git a/royalpack/commands/peertube.py b/royalpack/commands/peertube.py deleted file mode 100644 index 20c112ec..00000000 --- a/royalpack/commands/peertube.py +++ /dev/null @@ -1,26 +0,0 @@ -from typing import * -import royalnet.commands as rc -import aiohttp -import urllib.parse - -from .play import PlayCommand - - -class PeertubeCommand(PlayCommand): - name: str = "peertube" - - aliases = ["pt", "royaltube", "rt"] - - description: str = "Cerca un video su RoyalTube e lo aggiunge alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - search = urllib.parse.quote(args.joined(require_at_least=1)) - async with aiohttp.ClientSession() as session: - async with session.get(self.config["Peertube"]["instance_url"] + - f"/api/v1/search/videos?search={search}") as response: - j = await response.json() - if j["total"] < 1: - raise rc.InvalidInputError("Nessun video trovato.") - return [f'{self.config["Peertube"]["instance_url"]}/videos/watch/{j["data"][0]["uuid"]}'] diff --git a/royalpack/commands/play.py b/royalpack/commands/play.py deleted file mode 100644 index 5754efdc..00000000 --- a/royalpack/commands/play.py +++ /dev/null @@ -1,64 +0,0 @@ -from typing import * -import discord -import asyncio as aio -import royalnet.commands as rc -import royalnet.backpack.tables as rbt - - -class PlayCommand(rc.Command): - name: str = "play" - - aliases = ["p"] - - description: str = "Aggiunge un url alla coda della chat vocale." - - syntax = "{url}" - - async def get_urls(self, args: rc.CommandArgs): - url = args.joined(require_at_least=1) - if not (url.startswith("http://") or url.startswith("https://")): - raise rc.InvalidInputError(f"L'URL specificato non inizia con il nome di un protocollo supportato" - f" ([c]http://[/c] o [c]https://[/c]).") - return [url] - - def get_embed_color(self) -> Optional[int]: - return None - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name == "discord": - message: discord.Message = data.message - guild: discord.Guild = message.guild - if guild is None: - guild_id = None - else: - guild_id: Optional[int] = guild.id - else: - guild_id = None - - user: rbt.User = await data.get_author() - user_str = None - - if user is not None: - try: - user_discord: rbt.Discord = user.discord[0] - except (AttributeError, IndexError): - user_str = str(user) - else: - user_str = str(f"<@{user_discord.discord_id}>") - - urls = await self.get_urls(args) - - play_task: aio.Task = self.loop.create_task( - self.interface.call_herald_event("discord", "discord_play", - urls=urls, - guild_id=guild_id, - user=user_str, - force_color=self.get_embed_color()) - ) - - if len(urls) > 1: - await data.reply("⌛ Attendi qualche minuto...") - else: - await data.reply("⌛ Attendi un attimo...") - - await play_task diff --git a/royalpack/commands/playmode.py b/royalpack/commands/playmode.py deleted file mode 100644 index 9ea12955..00000000 --- a/royalpack/commands/playmode.py +++ /dev/null @@ -1,56 +0,0 @@ -from typing import * -import royalnet.commands as rc -import discord -import royalnet.backpack.tables as rbt - - -class PlaymodeCommand(rc.Command): - name: str = "playmode" - - aliases = ["pm"] - - description: str = "Seleziona la modalità di riproduzione musicale." - - syntax: str = "{queue|pool}" - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name == "discord": - message: discord.Message = data.message - guild: discord.Guild = message.guild - if guild is None: - guild_id = None - else: - guild_id: Optional[int] = guild.id - else: - guild_id = None - - user: rbt.User = await data.get_author() - user_str = None - - if user is not None: - try: - user_discord: rbt.Discord = user.discord[0] - except (AttributeError, IndexError): - user_str = str(user) - else: - user_str = str(f"<@{user_discord.discord_id}>") - - response = await self.interface.call_herald_event("discord", "discord_playmode", - playable_string=args[0], - guild_id=guild_id, - user=user_str) - - if response["name"] == "RoyalQueue": - await data.reply(f"✅ Modalità di riproduzione impostata a [b]Queue[/b]:\n" - f"- Riproduci le canzoni nell'ordine scelto\n" - f"- Rimuovi le canzoni dopo averle riprodotte") - - elif response["name"] == "RoyalPool": - await data.reply(f"✅ Modalità di riproduzione impostata a [b]Pool[/b]:\n" - f"- Aggiungi canzoni al pool con [c]!p[/c], [c]!yt[/c] e [c]!fw[/c]\n" - f"- Riproduci all'infinito canzoni casuali dal pool\n" - f"- Non è possibile rimuovere canzoni dal pool, [c]!skip[/c]parle manderà solo avanti il pool\n" - f"- Interrompi la riproduzione del pool cambiando modalità di riproduzione") - - else: - await data.reply(f"✅ Modalità di riproduzione impostata a [c]{response['name']}[/c]!") \ No newline at end of file diff --git a/royalpack/commands/queue.py b/royalpack/commands/queue.py deleted file mode 100644 index 4ae2a39a..00000000 --- a/royalpack/commands/queue.py +++ /dev/null @@ -1,62 +0,0 @@ -from typing import * -import pickle -import base64 -import discord -import royalnet.commands as rc -import royalnet.utils as ru - - -class QueueCommand(rc.Command): - name: str = "queue" - - aliases = ["q"] - - description: str = "Visualizza la coda di riproduzione attuale." - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name == "discord": - message: discord.Message = data.message - guild: discord.Guild = message.guild - guild_id: Optional[int] = guild.id - else: - guild_id = None - response: Dict[str, Any] = await self.interface.call_herald_event("discord", "discord_queue", - guild_id=guild_id) - - queue_type = response["type"] - if queue_type == "RoyalQueue": - next_up = response["next_up"] - now_playing = response["now_playing"] - await data.reply(f"ℹ️ La coda contiene {len(next_up)} file.\n\n") - - if now_playing is not None: - reply = f"Attualmente, sta venendo riprodotto:\n" - if self.interface.name == "discord": - await data.reply(reply) - embed = pickle.loads(base64.b64decode(bytes(now_playing["stringified_base64_pickled_discord_embed"], - encoding="ascii"))) - # noinspection PyUnboundLocalVariable - await message.channel.send(embed=embed) - else: - reply += f"▶️ {now_playing['title']}\n\n" - await data.reply(reply) - else: - await data.reply("⏹ Attualmente, non sta venendo riprodotto nulla.") - - reply = "" - if len(next_up) >= 1: - reply += "I prossimi file in coda sono:\n" - if self.interface.name == "discord": - await data.reply(reply) - for item in next_up[:5]: - embed = pickle.loads(base64.b64decode(bytes(item["stringified_base64_pickled_discord_embed"], - encoding="ascii"))) - # noinspection PyUnboundLocalVariable - await message.channel.send(embed=embed) - else: - reply += ru.numberemojiformat([a["title"] for a in next_up[:5]]) - await data.reply(reply) - else: - await data.reply("ℹ️ Non ci sono altri file in coda.") - else: - raise rc.CommandError(f"Non so come visualizzare il contenuto di un [c]{queue_type}[/c].") diff --git a/royalpack/commands/skip.py b/royalpack/commands/skip.py deleted file mode 100644 index 277ad1c0..00000000 --- a/royalpack/commands/skip.py +++ /dev/null @@ -1,21 +0,0 @@ -from typing import * -import discord -import royalnet.commands as rc - - -class SkipCommand(rc.Command): - name: str = "skip" - - aliases = ["s"] - - description: str = "Salta il file attualmente in riproduzione." - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name == "discord": - message: discord.Message = data.message - guild: discord.Guild = message.guild - guild_id: Optional[int] = guild.id - else: - guild_id = None - response: Dict[str, Any] = await self.interface.call_herald_event("discord", "discord_skip", guild_id=guild_id) - await data.reply("⏩ File attuale saltato!") diff --git a/royalpack/commands/soundcloud.py b/royalpack/commands/soundcloud.py deleted file mode 100644 index b01d8ef7..00000000 --- a/royalpack/commands/soundcloud.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import * -from .play import PlayCommand - - -class SoundcloudCommand(PlayCommand): - name: str = "soundcloud" - - aliases = ["sc"] - - description: str = "Cerca un video su SoundCloud e lo aggiunge alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"scsearch:{args.joined()}"] diff --git a/royalpack/commands/summon.py b/royalpack/commands/summon.py deleted file mode 100644 index 18145a5a..00000000 --- a/royalpack/commands/summon.py +++ /dev/null @@ -1,29 +0,0 @@ -from typing import * -import royalnet.commands as rc -import discord - - -class SummonCommand(rc.Command): - name: str = "summon" - - aliases = ["cv"] - - description: str = "Evoca il bot in un canale vocale." - - syntax: str = "[nomecanale]" - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - channel_name = args.joined() - if self.interface.name == "discord": - message: discord.Message = data.message - guild_id = message.guild.id - user_id = message.author.id - else: - guild_id = None - user_id = None - response = await self.interface.call_herald_event("discord", "discord_summon", - channel_name=channel_name, guild_id=guild_id, user_id=user_id) - if self.interface.name == "discord": - await data.reply(f"✅ Mi sono connesso in <#{response['channel']['id']}>!") - else: - await data.reply(f"✅ Mi sono connesso in [b]#{response['channel']['name']}[/b]!") diff --git a/royalpack/commands/videochannel.py b/royalpack/commands/videochannel.py deleted file mode 100644 index a8801510..00000000 --- a/royalpack/commands/videochannel.py +++ /dev/null @@ -1,49 +0,0 @@ -from typing import * -import discord -import royalnet.commands as rc - - -class VideochannelCommand(rc.Command): - name: str = "videochannel" - - aliases = ["golive", "live", "video"] - - description: str = "Converti il canale vocale in un canale video." - - syntax = "[nomecanale]" - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name != "discord": - raise rc.UnsupportedError(f"{self} non è supportato su {self.interface.name}.") - bot: discord.Client = self.serf.client - message: discord.Message = data.message - channel_name: str = args.optional(0) - if channel_name: - guild: Optional[discord.Guild] = message.guild - if guild is not None: - channels: List[discord.abc.GuildChannel] = guild.channels - else: - channels = bot.get_all_channels() - matching_channels: List[discord.VoiceChannel] = [] - for channel in channels: - if isinstance(channel, discord.VoiceChannel): - if channel.name == channel_name: - matching_channels.append(channel) - if len(matching_channels) == 0: - raise rc.InvalidInputError("Non esiste alcun canale vocale con il nome specificato.") - elif len(matching_channels) > 1: - raise rc.UserError("Esiste più di un canale vocale con il nome specificato.") - channel = matching_channels[0] - else: - author: discord.Member = message.author - voice: Optional[discord.VoiceState] = author.voice - if voice is None: - raise rc.InvalidInputError("Non sei connesso a nessun canale vocale.") - channel = voice.channel - if author.is_on_mobile(): - await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n" - f"\n" - f"[b]Attenzione: la modalità video non funziona su Android e iOS![/b]") - return - await data.reply(f"📹 Per entrare in modalità video, clicca qui:\n" - f"") diff --git a/royalpack/commands/voicestatus.py b/royalpack/commands/voicestatus.py deleted file mode 100644 index 511a44ae..00000000 --- a/royalpack/commands/voicestatus.py +++ /dev/null @@ -1,44 +0,0 @@ -from typing import * -import royalnet.serf.discord as rsd -import royalnet.commands as rc - - -class VoicestatusCommand(rc.Command): - name: str = "voicestatus" - - description: str = "Visualizza lo stato interno dei voice player del bot." - - syntax: str = "" - - async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: - if self.interface.name != "discord": - raise rc.UnsupportedError("Questo comando funziona solo su Discord.") - serf: rsd.DiscordSerf = self.interface.serf - - message = [] - for index, voice_player in enumerate(serf.voice_players): - message.append(f"🎵 [b]Voice Player #{index}[/b]") - - voice_client = voice_player.voice_client - if voice_client.is_connected(): - message.append(f"🔵 Connected") - else: - message.append(f"🔴 Disconnected") - if voice_client.is_playing(): - message.append(f"🔵 Playing") - else: - message.append(f"⚪ Not playing") - if voice_client.is_paused(): - message.append(f"⚪ Paused") - else: - message.append(f"🔵 Not paused") - - playable = voice_player.playing - message.append(f"🔉 {playable.__class__.__name__}") - - message.append("") - - if len(serf.voice_players) == 0: - message.append("[i]Nessun voice player.[/i]") - - await data.reply("\n".join(message)) diff --git a/royalpack/commands/yahoovideo.py b/royalpack/commands/yahoovideo.py deleted file mode 100644 index 0632152a..00000000 --- a/royalpack/commands/yahoovideo.py +++ /dev/null @@ -1,17 +0,0 @@ -from typing import * -from .play import PlayCommand - - -class YahoovideoCommand(PlayCommand): - name: str = "yahoovideo" - - aliases = ["yv"] - - description: str = "Cerca un video su Yahoo Video e lo aggiunge alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"yvsearch:{args.joined()}"] - - # Too bad yvsearch: always finds nothing. diff --git a/royalpack/commands/youtube.py b/royalpack/commands/youtube.py deleted file mode 100644 index 29e05d72..00000000 --- a/royalpack/commands/youtube.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import * -from .play import PlayCommand - - -class YoutubeCommand(PlayCommand): - name: str = "youtube" - - aliases = ["yt"] - - description: str = "Cerca un video su YouTube e lo aggiunge alla coda della chat vocale." - - syntax = "{ricerca}" - - async def get_urls(self, args): - return [f"ytsearch:{args.joined()}"]