sanitize command inputs
This commit is contained in:
parent
a1e64551ed
commit
66d9ccca1c
@ -29,7 +29,7 @@ class Event(commands.Cog):
|
|||||||
aliases=['ev'],
|
aliases=['ev'],
|
||||||
description='Finds the event with the given name.',
|
description='Finds the event with the given name.',
|
||||||
help='!event pkcooking')
|
help='!event pkcooking')
|
||||||
async def event(self, ctx: commands.Context, *, arg: str = ""):
|
async def event(self, ctx: commands.Context, *, arg: commands.clean_content = ""):
|
||||||
self.logger.info(f'Searching for event "{arg}".')
|
self.logger.info(f'Searching for event "{arg}".')
|
||||||
|
|
||||||
event: EventMaster
|
event: EventMaster
|
||||||
|
@ -48,7 +48,7 @@ class Music(commands.Cog):
|
|||||||
aliases=['music'],
|
aliases=['music'],
|
||||||
description='Finds the song with the given name.',
|
description='Finds the song with the given name.',
|
||||||
help='!song grgr')
|
help='!song grgr')
|
||||||
async def song(self, ctx: commands.Context, *, arg: str):
|
async def song(self, ctx: commands.Context, *, arg: commands.clean_content):
|
||||||
self.logger.info(f'Searching for song "{arg}".')
|
self.logger.info(f'Searching for song "{arg}".')
|
||||||
|
|
||||||
song = masters.music.get(arg, ctx)
|
song = masters.music.get(arg, ctx)
|
||||||
@ -100,7 +100,7 @@ class Music(commands.Cog):
|
|||||||
aliases=[],
|
aliases=[],
|
||||||
description='Finds the chart with the given name.',
|
description='Finds the chart with the given name.',
|
||||||
help='!chart grgr\n!chart grgr normal')
|
help='!chart grgr\n!chart grgr normal')
|
||||||
async def chart(self, ctx: commands.Context, *, arg: str):
|
async def chart(self, ctx: commands.Context, *, arg: commands.clean_content):
|
||||||
self.logger.info(f'Searching for chart "{arg}".')
|
self.logger.info(f'Searching for chart "{arg}".')
|
||||||
|
|
||||||
name, difficulty = self.parse_chart_args(arg)
|
name, difficulty = self.parse_chart_args(arg)
|
||||||
@ -123,7 +123,7 @@ class Music(commands.Cog):
|
|||||||
aliases=['mixes'],
|
aliases=['mixes'],
|
||||||
description='Finds the sections of the chart with the given name.',
|
description='Finds the sections of the chart with the given name.',
|
||||||
help='!sections grgr')
|
help='!sections grgr')
|
||||||
async def sections(self, ctx: commands.Context, *, arg: str):
|
async def sections(self, ctx: commands.Context, *, arg: commands.clean_content):
|
||||||
self.logger.info(f'Searching for chart sections "{arg}".')
|
self.logger.info(f'Searching for chart sections "{arg}".')
|
||||||
|
|
||||||
name, difficulty = self.parse_chart_args(arg)
|
name, difficulty = self.parse_chart_args(arg)
|
||||||
@ -151,7 +151,7 @@ class Music(commands.Cog):
|
|||||||
aliases=['songsearch', 'song_search'],
|
aliases=['songsearch', 'song_search'],
|
||||||
description='Finds songs matching the given name.',
|
description='Finds songs matching the given name.',
|
||||||
help='!songs grgr')
|
help='!songs grgr')
|
||||||
async def songs(self, ctx: commands.Context, *, arg: str = ''):
|
async def songs(self, ctx: commands.Context, *, arg: commands.clean_content = ''):
|
||||||
self.logger.info(f'Searching for songs "{arg}".' if arg else 'Listing songs.')
|
self.logger.info(f'Searching for songs "{arg}".' if arg else 'Listing songs.')
|
||||||
arguments = parse_arguments(arg)
|
arguments = parse_arguments(arg)
|
||||||
songs = masters.music.get_sorted(arguments.text_argument, ctx)
|
songs = masters.music.get_sorted(arguments.text_argument, ctx)
|
||||||
@ -287,7 +287,7 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
return embeds, files
|
return embeds, files
|
||||||
|
|
||||||
def parse_chart_args(self, arg: str) -> Tuple[str, ChartDifficulty]:
|
def parse_chart_args(self, arg: commands.clean_content) -> Tuple[str, ChartDifficulty]:
|
||||||
split_args = arg.split()
|
split_args = arg.split()
|
||||||
|
|
||||||
difficulty = ChartDifficulty.Expert
|
difficulty = ChartDifficulty.Expert
|
||||||
|
@ -11,10 +11,12 @@ class Utility(commands.Cog):
|
|||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@commands.command(hidden=True)
|
@commands.command(hidden=True)
|
||||||
|
@commands.is_owner()
|
||||||
async def romanize(self, ctx: commands.Context, *, arg: str):
|
async def romanize(self, ctx: commands.Context, *, arg: str):
|
||||||
await ctx.send(romanize(arg))
|
await ctx.send(romanize(arg))
|
||||||
|
|
||||||
@commands.command(hidden=True, ignore_extra=False)
|
@commands.command(hidden=True, ignore_extra=False)
|
||||||
|
@commands.is_owner()
|
||||||
async def similarity_score(self, ctx: commands.Context, source: str, target: str):
|
async def similarity_score(self, ctx: commands.Context, source: str, target: str):
|
||||||
await ctx.send(str(FuzzyMatcher().score(romanize(source), romanize(target))))
|
await ctx.send(str(FuzzyMatcher().score(romanize(source), romanize(target))))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user