mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Improve play command (5.3.5)
This commit is contained in:
parent
a9217efa75
commit
c450d5e283
6 changed files with 116 additions and 27 deletions
91
poetry.lock
generated
91
poetry.lock
generated
|
@ -130,6 +130,17 @@ pytz = "*"
|
|||
regex = "*"
|
||||
tzlocal = "*"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "A library to handle automated deprecations"
|
||||
name = "deprecation"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "2.0.7"
|
||||
|
||||
[package.dependencies]
|
||||
packaging = "*"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "A python wrapper for the Discord API"
|
||||
|
@ -146,6 +157,23 @@ websockets = ">=6.0,<7.0 || >7.0,<8.0 || >8.0,<8.0.1 || >8.0.1,<9.0"
|
|||
docs = ["sphinx (1.8.5)", "sphinxcontrib-trio (1.1.0)", "sphinxcontrib-websupport"]
|
||||
voice = ["PyNaCl (1.3.0)"]
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python audio data toolkit (ID3 and MP3)"
|
||||
name = "eyed3"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "0.9"
|
||||
|
||||
[package.dependencies]
|
||||
deprecation = "*"
|
||||
filetype = "*"
|
||||
|
||||
[package.extras]
|
||||
art-plugin = ["pylast", "requests", "pillow"]
|
||||
display-plugin = ["grako"]
|
||||
yaml-plugin = ["ruamel.yaml"]
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python bindings for FFmpeg - with complex filtering support"
|
||||
|
@ -160,6 +188,14 @@ future = "*"
|
|||
[package.extras]
|
||||
dev = ["future (0.17.1)", "numpy (1.16.4)", "pytest-mock (1.10.4)", "pytest (4.6.1)", "Sphinx (2.1.0)", "tox (3.12.1)"]
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Infer file type and MIME type of any file/buffer. No external dependencies."
|
||||
name = "filetype"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
version = "1.0.5"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Clean single-source support for Python 3 and 2"
|
||||
|
@ -340,6 +376,18 @@ optional = false
|
|||
python-versions = ">=3.5"
|
||||
version = "4.7.4"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Core utilities for Python packages"
|
||||
name = "packaging"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
version = "20.1"
|
||||
|
||||
[package.dependencies]
|
||||
pyparsing = ">=2.0.2"
|
||||
six = "*"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Protocol Buffers"
|
||||
|
@ -392,6 +440,14 @@ six = "*"
|
|||
docs = ["sphinx (>=1.6.5)", "sphinx-rtd-theme"]
|
||||
tests = ["pytest (>=3.2.1,<3.3.0 || >3.3.0)", "hypothesis (>=3.27.0)"]
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "Python parsing module"
|
||||
name = "pyparsing"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
version = "2.4.6"
|
||||
|
||||
[[package]]
|
||||
category = "main"
|
||||
description = "A python implmementation of GNU readline."
|
||||
|
@ -506,7 +562,7 @@ description = "A multipurpose bot and web framework"
|
|||
name = "royalnet"
|
||||
optional = false
|
||||
python-versions = ">=3.8,<4.0"
|
||||
version = "5.3.2"
|
||||
version = "5.3.4"
|
||||
|
||||
[package.dependencies]
|
||||
dateparser = ">=0.7.2,<0.8.0"
|
||||
|
@ -520,6 +576,10 @@ version = ">=10.0,<11.0"
|
|||
optional = true
|
||||
version = ">=1.3.1,<2.0.0"
|
||||
|
||||
[package.dependencies.eyed3]
|
||||
optional = true
|
||||
version = ">=0.9,<0.10"
|
||||
|
||||
[package.dependencies.ffmpeg_python]
|
||||
optional = true
|
||||
version = ">=0.2.0,<0.3.0"
|
||||
|
@ -571,7 +631,7 @@ version = "*"
|
|||
[package.extras]
|
||||
alchemy_easy = ["sqlalchemy (>=1.3.10,<2.0.0)", "psycopg2_binary (>=2.8.4,<3.0.0)"]
|
||||
alchemy_hard = ["sqlalchemy (>=1.3.10,<2.0.0)", "psycopg2 (>=2.8.4,<3.0.0)"]
|
||||
bard = ["ffmpeg_python (>=0.2.0,<0.3.0)", "youtube-dl"]
|
||||
bard = ["ffmpeg_python (>=0.2.0,<0.3.0)", "youtube-dl", "eyed3 (>=0.9,<0.10)"]
|
||||
coloredlogs = ["coloredlogs (>=10.0,<11.0)"]
|
||||
constellation = ["starlette (>=0.12.13,<0.13.0)", "uvicorn (>=0.10.7,<0.11.0)", "python-multipart (>=0.0.5,<0.0.6)"]
|
||||
discord = ["discord.py (>=1.3.1,<2.0.0)", "pynacl (>=1.3.0,<2.0.0)"]
|
||||
|
@ -779,7 +839,7 @@ python-versions = "*"
|
|||
version = "2020.1.24"
|
||||
|
||||
[metadata]
|
||||
content-hash = "42c6027b2f63431368e45a56c73fb12bf5283dfd4c41bf3cb1862ef54d4f67ea"
|
||||
content-hash = "a2861f9b2781d6d02936f4dce63792690d7757812ac6a4f42fd7cc2932435e6f"
|
||||
python-versions = "^3.8"
|
||||
|
||||
[metadata.files]
|
||||
|
@ -887,13 +947,26 @@ dateparser = [
|
|||
{file = "dateparser-0.7.2-py2.py3-none-any.whl", hash = "sha256:983d84b5e3861cb0aa240cad07f12899bb10b62328aae188b9007e04ce37d665"},
|
||||
{file = "dateparser-0.7.2.tar.gz", hash = "sha256:e1eac8ef28de69a554d5fcdb60b172d526d61924b1a40afbbb08df459a36006b"},
|
||||
]
|
||||
deprecation = [
|
||||
{file = "deprecation-2.0.7-py2.py3-none-any.whl", hash = "sha256:dc9b4f252b7aca8165ce2764a71da92a653b5ffbf7a389461d7a640f6536ecb2"},
|
||||
{file = "deprecation-2.0.7.tar.gz", hash = "sha256:c0392f676a6146f0238db5744d73e786a43510d54033f80994ef2f4c9df192ed"},
|
||||
]
|
||||
"discord.py" = [
|
||||
{file = "discord.py-1.3.1-py3-none-any.whl", hash = "sha256:8bfe5628d31771744000f19135c386c74ac337479d7282c26cc1627b9d31f360"},
|
||||
]
|
||||
eyed3 = [
|
||||
{file = "eyeD3-0.9-py2.py3-none-any.whl", hash = "sha256:6015669333df2115809102ccf1b29585115b5c233cf4530d9f995ad562634819"},
|
||||
{file = "eyeD3-0.9-py3.8.egg", hash = "sha256:8e3a7a2ce2932260f77c6234d624737807cdb4404f5bac3c5348c1f9da3d7250"},
|
||||
{file = "eyeD3-0.9.tar.gz", hash = "sha256:8874762fd4fd93fa64676185ccaa77ea8b3396aea65ba86bca7325f1136f9c8a"},
|
||||
]
|
||||
ffmpeg-python = [
|
||||
{file = "ffmpeg-python-0.2.0.tar.gz", hash = "sha256:65225db34627c578ef0e11c8b1eb528bb35e024752f6f10b78c011f6f64c4127"},
|
||||
{file = "ffmpeg_python-0.2.0-py3-none-any.whl", hash = "sha256:ac441a0404e053f8b6a1113a77c0f452f1cfc62f6344a769475ffdc0f56c23c5"},
|
||||
]
|
||||
filetype = [
|
||||
{file = "filetype-1.0.5-py2.py3-none-any.whl", hash = "sha256:4967124d982a71700d94a08c49c4926423500e79382a92070f5ab248d44fe461"},
|
||||
{file = "filetype-1.0.5.tar.gz", hash = "sha256:17a3b885f19034da29640b083d767e0f13c2dcb5dcc267945c8b6e5a5a9013c7"},
|
||||
]
|
||||
future = [
|
||||
{file = "future-0.18.2.tar.gz", hash = "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"},
|
||||
]
|
||||
|
@ -1011,6 +1084,10 @@ multidict = [
|
|||
{file = "multidict-4.7.4-cp38-cp38-win_amd64.whl", hash = "sha256:5414f388ffd78c57e77bd253cf829373721f450613de53dc85a08e34d806e8eb"},
|
||||
{file = "multidict-4.7.4.tar.gz", hash = "sha256:d7d428488c67b09b26928950a395e41cc72bb9c3d5abfe9f0521940ee4f796d4"},
|
||||
]
|
||||
packaging = [
|
||||
{file = "packaging-20.1-py2.py3-none-any.whl", hash = "sha256:170748228214b70b672c581a3dd610ee51f733018650740e98c7df862a583f73"},
|
||||
{file = "packaging-20.1.tar.gz", hash = "sha256:e665345f9eef0c621aa0bf2f8d78cf6d21904eef16a93f020240b704a57f1334"},
|
||||
]
|
||||
protobuf = [
|
||||
{file = "protobuf-3.11.2-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:3f509f7e50d806a434fe4a5fbf602516002a0f092889209fff7db82060efffc0"},
|
||||
{file = "protobuf-3.11.2-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:4571da974019849201fc1ec6626b9cea54bd11b6bed140f8f737c0a33ea37de5"},
|
||||
|
@ -1126,6 +1203,10 @@ pynacl = [
|
|||
{file = "PyNaCl-1.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:bf459128feb543cfca16a95f8da31e2e65e4c5257d2f3dfa8c0c1031139c9c92"},
|
||||
{file = "PyNaCl-1.3.0.tar.gz", hash = "sha256:0c6100edd16fefd1557da078c7a31e7b7d7a52ce39fdca2bec29d4f7b6e7600c"},
|
||||
]
|
||||
pyparsing = [
|
||||
{file = "pyparsing-2.4.6-py2.py3-none-any.whl", hash = "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec"},
|
||||
{file = "pyparsing-2.4.6.tar.gz", hash = "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f"},
|
||||
]
|
||||
pyreadline = [
|
||||
{file = "pyreadline-2.1.win-amd64.exe", hash = "sha256:9ce5fa65b8992dfa373bddc5b6e0864ead8f291c94fbfec05fbd5c836162e67b"},
|
||||
{file = "pyreadline-2.1.win32.exe", hash = "sha256:65540c21bfe14405a3a77e4c085ecfce88724743a4ead47c66b84defcf82c32e"},
|
||||
|
@ -1181,8 +1262,8 @@ riotwatcher = [
|
|||
{file = "riotwatcher-2.7.1.tar.gz", hash = "sha256:5349271c7e00637b7619491a6070e66603705db60558ea2a690e7016f6e6d9a4"},
|
||||
]
|
||||
royalnet = [
|
||||
{file = "royalnet-5.3.2-py3-none-any.whl", hash = "sha256:760814233a47c87c22d26d41d8f6a6a2dbd1f05663e1e924c5349f93838208de"},
|
||||
{file = "royalnet-5.3.2.tar.gz", hash = "sha256:0d35f21748a11229b7762b7e21c29f19da3ea2fa88672c19a1e17862b1597c5e"},
|
||||
{file = "royalnet-5.3.4-py3-none-any.whl", hash = "sha256:25994b002d2883a91b1a885fb08419499873f67d482ea19f564051e296eb4e31"},
|
||||
{file = "royalnet-5.3.4.tar.gz", hash = "sha256:75800c9da52750dcd2d49e45bf527e92212b272d81467a63c9a375dadf24e11d"},
|
||||
]
|
||||
royalspells = [
|
||||
{file = "royalspells-3.2.tar.gz", hash = "sha256:2bd4a9a66514532e35c02c3907425af48c7cb292364c4843c795719a82b25dfe"},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[tool.poetry]
|
||||
name = "royalpack"
|
||||
version = "5.3.4"
|
||||
version = "5.3.5"
|
||||
description = "A Royalnet command pack for the Royal Games community"
|
||||
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
|
||||
license = "AGPL-3.0+"
|
||||
|
@ -25,7 +25,7 @@
|
|||
steam = "^0.9.1"
|
||||
|
||||
[tool.poetry.dependencies.royalnet]
|
||||
version = "^5.3.2"
|
||||
version = "^5.3.4"
|
||||
# Maybe... there is a way to make these selectable?
|
||||
extras = [
|
||||
"telegram",
|
||||
|
|
|
@ -13,6 +13,9 @@ class FunkwhaleCommand(PlayCommand):
|
|||
|
||||
syntax = "{ricerca}"
|
||||
|
||||
def get_embed_color(self):
|
||||
return 0x009FE3
|
||||
|
||||
async def get_url(self, args):
|
||||
search = urllib.parse.quote(args.joined(require_at_least=1))
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import pickle
|
||||
import base64
|
||||
import discord
|
||||
import asyncio as aio
|
||||
from typing import *
|
||||
from royalnet.commands import *
|
||||
from royalnet.utils import *
|
||||
from royalnet.backpack.tables import User, Discord
|
||||
|
||||
|
||||
|
@ -17,14 +15,16 @@ class PlayCommand(Command):
|
|||
syntax = "{url}"
|
||||
|
||||
async def get_url(self, args: CommandArgs):
|
||||
return args.joined(require_at_least=1)
|
||||
url = args.joined(require_at_least=1)
|
||||
if not (url.startswith("http://") or url.startswith("https://")):
|
||||
raise 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: CommandArgs, data: CommandData) -> None:
|
||||
# if not (url.startswith("http://") or url.startswith("https://")):
|
||||
# raise CommandError(f"Il comando [c]{self.interface.prefix}play[/c] funziona solo per riprodurre file da"
|
||||
# f" un URL.\n"
|
||||
# f"Se vuoi cercare un video, come misura temporanea puoi usare "
|
||||
# f"[c]ytsearch:nomevideo[/c] o [c]scsearch:nomevideo[/c] come url.")
|
||||
if self.interface.name == "discord":
|
||||
message: discord.Message = data.message
|
||||
guild: discord.Guild = message.guild
|
||||
|
@ -46,9 +46,14 @@ class PlayCommand(Command):
|
|||
else:
|
||||
user_str = str(f"<@{user_discord.discord_id}>")
|
||||
|
||||
self.loop.create_task(self.interface.call_herald_event("discord", "discord_play",
|
||||
play_task: aio.Task = self.loop.create_task(
|
||||
self.interface.call_herald_event("discord", "discord_play",
|
||||
url=await self.get_url(args),
|
||||
guild_id=guild_id,
|
||||
user=user_str))
|
||||
user=user_str,
|
||||
force_color=self.get_embed_color())
|
||||
)
|
||||
|
||||
# await data.reply("✅ Richiesta di riproduzione inviata!")
|
||||
await data.reply("⌛ Attendi un attimo...")
|
||||
|
||||
await play_task
|
||||
|
|
|
@ -17,6 +17,7 @@ class DiscordPlayEvent(Event):
|
|||
url: str,
|
||||
guild_id: Optional[int] = None,
|
||||
user: Optional[str] = None,
|
||||
force_color: Optional[int] = None,
|
||||
**kwargs) -> dict:
|
||||
if not isinstance(self.serf, DiscordSerf):
|
||||
raise UnsupportedError()
|
||||
|
@ -70,7 +71,10 @@ class DiscordPlayEvent(Event):
|
|||
await main_channel.send(escape(f"▶️ Aggiunt{'o' if len(added) == 1 else 'i'} {len(added)} file alla"
|
||||
f" coda:"))
|
||||
for ytd in added:
|
||||
await main_channel.send(embed=ytd.embed())
|
||||
embed: discord.Embed = ytd.embed()
|
||||
if force_color:
|
||||
embed._colour = discord.Colour(force_color)
|
||||
await main_channel.send(embed=embed)
|
||||
|
||||
if len(too_long) > 0:
|
||||
if user:
|
||||
|
@ -87,12 +91,8 @@ class DiscordPlayEvent(Event):
|
|||
return {
|
||||
"added": [{
|
||||
"title": ytd.info.title,
|
||||
"stringified_base64_pickled_discord_embed": str(base64.b64encode(pickle.dumps(ytd.embed())),
|
||||
encoding="ascii")
|
||||
} for ytd in added],
|
||||
"too_long": [{
|
||||
"title": ytd.info.title,
|
||||
"stringified_base64_pickled_discord_embed": str(base64.b64encode(pickle.dumps(ytd.embed())),
|
||||
encoding="ascii")
|
||||
} for ytd in too_long]
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
semantic = "5.3.4"
|
||||
semantic = "5.3.5"
|
||||
|
|
Loading…
Reference in a new issue