From b8b378a5bb127ded6aa774a91e342532cd47be1f Mon Sep 17 00:00:00 2001 From: timofey Date: Sun, 15 Jan 2023 11:15:45 +0000 Subject: [PATCH] improved presets --- v6d3music/commands.py | 2 +- v6d3music/core/ystate.py | 2 +- v6d3music/utils/argctx.py | 10 ++++++++-- v6d3music/utils/presets.py | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/v6d3music/commands.py b/v6d3music/commands.py index 45abb34..227cb3b 100644 --- a/v6d3music/commands.py +++ b/v6d3music/commands.py @@ -22,7 +22,7 @@ def get_of(mainservice: MainService) -> Callable[[str], command_type]: async def help_(ctx: Context, args: list[str]) -> None: match args: case []: - await ctx.reply('music bot') + await ctx.reply('music bot\nhttps://music.parrrate.ru/docs/usage.html') case [name]: await ctx.reply(f'help for {name}: `{name} help`') diff --git a/v6d3music/core/ystate.py b/v6d3music/core/ystate.py index cd1d70b..f15968c 100644 --- a/v6d3music/core/ystate.py +++ b/v6d3music/core/ystate.py @@ -48,7 +48,7 @@ class YState: try: return await future except OSError as e: - raise Explicit('extraction error\nunknown ytdl error') from e + raise Explicit('extraction error\nunknown ytdl error (probably due to video being unavailable, e.g. because of regional restrictions)') from e finally: self.results.task_done() diff --git a/v6d3music/utils/argctx.py b/v6d3music/utils/argctx.py index 2848ffd..2659c04 100644 --- a/v6d3music/utils/argctx.py +++ b/v6d3music/utils/argctx.py @@ -46,9 +46,9 @@ class BoundCtx: assert_admin(self.ctx.member) if not set(self.effects) <= set(string.ascii_letters + string.digits + '*,=+-/()|.^:_'): raise Explicit('malformed effects') - options = options_for_effects(self.effects) + return options_for_effects(self.effects) else: - options = None + return None class UrlCtx: @@ -81,6 +81,12 @@ class ArgCtx: effects = default_effects case _: raise RuntimeError + if url in presets: + raise Explicit('expected url, got preset. maybe you are missing `+`?') + if url in {'+', '-'}: + raise Explicit('expected url, got `+` or `-`. maybe you tried to use multiple effects?') + if url.startswith('+') or url.startswith('-"') or url.startswith('-\''): + raise Explicit('expected url, got `+` or `-"` or `-\'`. maybe you forgot to separate control symbol from the effects?') ctx = UrlCtx(url, effects) seconds = 0 match args: diff --git a/v6d3music/utils/presets.py b/v6d3music/utils/presets.py index e980797..f341a92 100644 --- a/v6d3music/utils/presets.py +++ b/v6d3music/utils/presets.py @@ -14,5 +14,6 @@ presets: dict[str, str] = { 'mono': f'{_prefix_preset}aeval=.5*val(0)+.5*val(1)|.5*val(1)+.5*val(0)', 'normal': f'{normal_prefix}', } +presets['ayylmao'] = presets['cursed'] allowed_presets = ['bassboost', 'bassbooboost', 'nightcore', 'daycore', 'mono', 'normal', ] allowed_effects = {'', *(presets[key] for key in allowed_presets)}