From 4e767a10e42ca6d46d0887f54dd177a2b90328a3 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 11 Jul 2020 16:23:00 +0300 Subject: [PATCH] Check for none instead of falsy in arg matching --- maubot/handlers/command.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maubot/handlers/command.py b/maubot/handlers/command.py index 4b11f47..eaf05d7 100644 --- a/maubot/handlers/command.py +++ b/maubot/handlers/command.py @@ -129,7 +129,7 @@ class CommandHandler: try: remaining_val, call_args[arg.name] = arg.match(remaining_val.strip(), evt=evt, instance=self.__bound_instance__) - if arg.required and not call_args[arg.name]: + if arg.required and call_args[arg.name] is None: raise ValueError("Argument required") except ArgumentSyntaxError as e: await evt.reply(e.message + (f"\n{self.__mb_usage__}" if e.show_usage else "")) @@ -303,7 +303,7 @@ class CustomArgument(Argument): orig_val = val val = re.split(r"\s", val, 1)[0] res = self.matcher(val) - if res: + if res is not None: return orig_val[len(val):], res return orig_val, None