From ef30a5b3699d281a5425512bb785d093eb2df235 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 12 Jan 2020 14:21:32 +0100 Subject: [PATCH] =?UTF-8?q?Fissato=20il=20bug=20del=20bot=20che=20non=20me?= =?UTF-8?q?tte=20pi=C3=B9=20le=20canzoni?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 50 ++++++++++++++++---------------- pyproject.toml | 2 +- royalpack/events/discord_play.py | 35 +++++++++++++--------- 3 files changed, 47 insertions(+), 40 deletions(-) diff --git a/poetry.lock b/poetry.lock index fd6e11ea..6b7aeb0e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -295,7 +295,7 @@ description = "multidict implementation" name = "multidict" optional = false python-versions = ">=3.5" -version = "4.7.3" +version = "4.7.4" [[package]] category = "main" @@ -385,7 +385,7 @@ description = "We have made you a wrapper you can't refuse" name = "python-telegram-bot" optional = false python-versions = "*" -version = "12.2.0" +version = "12.3.0" [package.dependencies] certifi = "*" @@ -451,7 +451,7 @@ description = "A multipurpose bot and web framework" name = "royalnet" optional = false python-versions = ">=3.8,<4.0" -version = "5.2.1" +version = "5.2.4" [package.dependencies] dateparser = ">=0.7.2,<0.8.0" @@ -723,7 +723,7 @@ python-versions = "*" version = "2020.1.1" [metadata] -content-hash = "bcb120a4e881fcde2001d4cda54ecd19c291ee6243afe7b71b4aed0b227d2f6a" +content-hash = "8713e8d5f419fe8df4c610273aed1529ca44d9d3e4af542b89807b76743f146b" python-versions = "^3.8" [metadata.files] @@ -897,23 +897,23 @@ matrix-nio = [ {file = "matrix-nio-0.6.tar.gz", hash = "sha256:25a4ac9d5e1435035f5c5b6e9a6b453ac66ade25cb455ba6bbe9cc3ae1e0ef50"}, ] multidict = [ - {file = "multidict-4.7.3-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:ed5f3378c102257df9e2dc9ce6468dabf68bee9ec34969cfdc472631aba00316"}, - {file = "multidict-4.7.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:15a61c0df2d32487e06f6084eabb48fd9e8b848315e397781a70caf9670c9d78"}, - {file = "multidict-4.7.3-cp35-cp35m-win32.whl", hash = "sha256:d1f45e5bb126662ba66ee579831ce8837b1fd978115c9657e32eb3c75b92973d"}, - {file = "multidict-4.7.3-cp35-cp35m-win_amd64.whl", hash = "sha256:a02fade7b5476c4f88efe9593ff2f3286698d8c6d715ba4f426954f73f382026"}, - {file = "multidict-4.7.3-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:78bed18e7f1eb21f3d10ff3acde900b4d630098648fe1d65bb4abfb3e22c4900"}, - {file = "multidict-4.7.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:0f04bf4c15d8417401a10a650c349ccc0285943681bfd87d3690587d7714a9b4"}, - {file = "multidict-4.7.3-cp36-cp36m-win32.whl", hash = "sha256:63ba2be08d82ea2aa8b0f7942a74af4908664d26cb4ff60c58eadb1e33e7da00"}, - {file = "multidict-4.7.3-cp36-cp36m-win_amd64.whl", hash = "sha256:3c5e2dcbe6b04cbb4303e47a896757a77b676c5e5db5528be7ff92f97ba7ab95"}, - {file = "multidict-4.7.3-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:c2bfc0db3166e68515bc4a2b9164f4f75ae9c793e9635f8651f2c9ffc65c8dad"}, - {file = "multidict-4.7.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c66d11870ae066499a3541963e6ce18512ca827c2aaeaa2f4e37501cee39ac5d"}, - {file = "multidict-4.7.3-cp37-cp37m-win32.whl", hash = "sha256:aacbde3a8875352a640efa2d1b96e5244a29b0f8df79cbf1ec6470e86fd84697"}, - {file = "multidict-4.7.3-cp37-cp37m-win_amd64.whl", hash = "sha256:5e5fb8bfebf87f2e210306bf9dd8de2f1af6782b8b78e814060ae9254ab1f297"}, - {file = "multidict-4.7.3-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:5d2b32b890d9e933d3ced417924261802a857abdee9507b68c75014482145c03"}, - {file = "multidict-4.7.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:cc7f2202b753f880c2e4123f9aacfdb94560ba893e692d24af271dac41f8b8d9"}, - {file = "multidict-4.7.3-cp38-cp38-win32.whl", hash = "sha256:bfcad6da0b8839f01a819602aaa5c5a5b4c85ecbfae9b261a31df3d9262fb31e"}, - {file = "multidict-4.7.3-cp38-cp38-win_amd64.whl", hash = "sha256:73740fcdb38f0adcec85e97db7557615b50ec4e5a3e73e35878720bcee963382"}, - {file = "multidict-4.7.3.tar.gz", hash = "sha256:be813fb9e5ce41a5a99a29cdb857144a1bd6670883586f995b940a4878dc5238"}, + {file = "multidict-4.7.4-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:93166e0f5379cf6cd29746989f8a594fa7204dcae2e9335ddba39c870a287e1c"}, + {file = "multidict-4.7.4-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:a8ed33e8f9b67e3b592c56567135bb42e7e0e97417a4b6a771e60898dfd5182b"}, + {file = "multidict-4.7.4-cp35-cp35m-win32.whl", hash = "sha256:a38baa3046cce174a07a59952c9f876ae8875ef3559709639c17fdf21f7b30dd"}, + {file = "multidict-4.7.4-cp35-cp35m-win_amd64.whl", hash = "sha256:9a7b115ee0b9b92d10ebc246811d8f55d0c57e82dbb6a26b23c9a9a6ad40ce0c"}, + {file = "multidict-4.7.4-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:dcfed56aa085b89d644af17442cdc2debaa73388feba4b8026446d168ca8dad7"}, + {file = "multidict-4.7.4-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:f29b885e4903bd57a7789f09fe9d60b6475a6c1a4c0eca874d8558f00f9d4b51"}, + {file = "multidict-4.7.4-cp36-cp36m-win32.whl", hash = "sha256:13f3ebdb5693944f52faa7b2065b751cb7e578b8dd0a5bb8e4ab05ad0188b85e"}, + {file = "multidict-4.7.4-cp36-cp36m-win_amd64.whl", hash = "sha256:4fba5204d32d5c52439f88437d33ad14b5f228e25072a192453f658bddfe45a7"}, + {file = "multidict-4.7.4-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:a6d219f49821f4b2c85c6d426346a5d84dab6daa6f85ca3da6c00ed05b54022d"}, + {file = "multidict-4.7.4-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:63810343ea07f5cd86ba66ab66706243a6f5af075eea50c01e39b4ad6bc3c57a"}, + {file = "multidict-4.7.4-cp37-cp37m-win32.whl", hash = "sha256:26502cefa86d79b86752e96639352c7247846515c864d7c2eb85d036752b643c"}, + {file = "multidict-4.7.4-cp37-cp37m-win_amd64.whl", hash = "sha256:5eee66f882ab35674944dfa0d28b57fa51e160b4dce0ce19e47f495fdae70703"}, + {file = "multidict-4.7.4-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:527124ef435f39a37b279653ad0238ff606b58328ca7989a6df372fd75d7fe26"}, + {file = "multidict-4.7.4-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:83c6ddf0add57c6b8a7de0bc7e2d656be3eefeff7c922af9a9aae7e49f225625"}, + {file = "multidict-4.7.4-cp38-cp38-win32.whl", hash = "sha256:6bd10adf9f0d6a98ccc792ab6f83d18674775986ba9bacd376b643fe35633357"}, + {file = "multidict-4.7.4-cp38-cp38-win_amd64.whl", hash = "sha256:5414f388ffd78c57e77bd253cf829373721f450613de53dc85a08e34d806e8eb"}, + {file = "multidict-4.7.4.tar.gz", hash = "sha256:d7d428488c67b09b26928950a395e41cc72bb9c3d5abfe9f0521940ee4f796d4"}, ] psycopg2-binary = [ {file = "psycopg2-binary-2.8.4.tar.gz", hash = "sha256:3a2522b1d9178575acee4adf8fd9f979f9c0449b00b4164bb63c3475ea6528ed"}, @@ -1025,8 +1025,8 @@ python-multipart = [ {file = "python-multipart-0.0.5.tar.gz", hash = "sha256:f7bb5f611fc600d15fa47b3974c8aa16e93724513b49b5f95c81e6624c83fa43"}, ] python-telegram-bot = [ - {file = "python-telegram-bot-12.2.0.tar.gz", hash = "sha256:346d42771c2b23384c59f5f41e05bd7e801a0ce118d8dcb95209bb73d5f694c5"}, - {file = "python_telegram_bot-12.2.0-py2.py3-none-any.whl", hash = "sha256:3beee89cba3bc3217566c96199f04776dd25f541ac8992da27fd247b2d208a14"}, + {file = "python-telegram-bot-12.3.0.tar.gz", hash = "sha256:41608512a3025a04ff7472efcaae344ad7533a77ae207685bb10fc2fc8282f7b"}, + {file = "python_telegram_bot-12.3.0-py2.py3-none-any.whl", hash = "sha256:5e2156f829402e41bb5ea7196e450bf7f121c5689c5100ae180507d72f3777f5"}, ] pytz = [ {file = "pytz-2019.3-py2.py3-none-any.whl", hash = "sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d"}, @@ -1064,8 +1064,8 @@ riotwatcher = [ {file = "riotwatcher-2.7.1.tar.gz", hash = "sha256:5349271c7e00637b7619491a6070e66603705db60558ea2a690e7016f6e6d9a4"}, ] royalnet = [ - {file = "royalnet-5.2.1-py3-none-any.whl", hash = "sha256:50f9dee08a39f3bf31ed5f0a1ca8666bd1627d7ca81ba8cee79f318fe777133f"}, - {file = "royalnet-5.2.1.tar.gz", hash = "sha256:e11b155f5952eb4df327892b07529c3f16a2426c76274d880d269e6b310389bd"}, + {file = "royalnet-5.2.4-py3-none-any.whl", hash = "sha256:074d741ab78b96c98803a0816fd8e2fc61ecae3017f7c41ea8af40fc3675d07b"}, + {file = "royalnet-5.2.4.tar.gz", hash = "sha256:a38f02fa6560a0c05896957aeb504894292eae0a2e3f607d696b242026fed863"}, ] royalspells = [ {file = "royalspells-3.2.tar.gz", hash = "sha256:2bd4a9a66514532e35c02c3907425af48c7cb292364c4843c795719a82b25dfe"}, diff --git a/pyproject.toml b/pyproject.toml index 98256425..a23cdfc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ markovify = "^0.8.0" [tool.poetry.dependencies.royalnet] - version = "^5.1.6" + version = "^5.2.4" # Maybe... there is a way to make these selectable? extras = [ "telegram", diff --git a/royalpack/events/discord_play.py b/royalpack/events/discord_play.py index 883eb863..2ca09f0c 100644 --- a/royalpack/events/discord_play.py +++ b/royalpack/events/discord_play.py @@ -18,21 +18,28 @@ class DiscordPlayEvent(Event): **kwargs) -> dict: if not isinstance(self.serf, DiscordSerf): raise UnsupportedError() - client: discord.Client = self.serf.client - if len(self.serf.voice_players) == 1: - voice_player: VoicePlayer = self.serf.voice_players[0] + + # TODO: fix this in Royalnet sometime + candidate_players: List[VoicePlayer] = [] + for player in self.serf.voice_players: + player: VoicePlayer + if not player.voice_client.is_connected(): + continue + if guild_id is not None: + guild = self.serf.client.get_guild(guild_id) + if guild != player.voice_client.guild: + continue + candidate_players.append(player) + + if len(candidate_players) == 0: + raise UserError("Il bot non è in nessun canale vocale.\n" + "Evocalo prima con [c]summon[/c]!") + elif len(candidate_players) == 1: + voice_player = candidate_players[0] else: - if guild_id is None: - # TODO: trovare un modo per riprodurre canzoni su più server da Telegram - raise InvalidInputError("Non so in che Server riprodurre questo file...\n" - "Invia il comando su Discord, per favore!") - guild: discord.Guild = client.get_guild(guild_id) - if guild is None: - raise InvalidInputError("Impossibile trovare il Server specificato.") - voice_player: VoicePlayer = self.serf.find_voice_player(guild) - if voice_player is None: - raise UserError("Il bot non è in nessun canale vocale.\n" - "Evocalo prima con [c]summon[/c]!") + raise InvalidInputError("Non so in che Server riprodurre questo file...\n" + "Invia il comando su Discord, per favore!") + ytds = await YtdlDiscord.from_url(url) added: List[YtdlDiscord] = [] too_long: List[YtdlDiscord] = []