improved presets

This commit is contained in:
AF 2023-01-15 11:15:45 +00:00
parent 08192b5d93
commit b8b378a5bb
4 changed files with 11 additions and 4 deletions

View File

@ -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`')

View File

@ -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()

View File

@ -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:

View File

@ -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)}