From b8b451b75101581e2756f43af45353a3411ba12a Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Mon, 9 May 2022 03:18:33 -0400 Subject: [PATCH] Validate arguments passed to "login" command --- matrix_appservice_kakaotalk/commands/auth.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/matrix_appservice_kakaotalk/commands/auth.py b/matrix_appservice_kakaotalk/commands/auth.py index e746f7d..6b76e62 100644 --- a/matrix_appservice_kakaotalk/commands/auth.py +++ b/matrix_appservice_kakaotalk/commands/auth.py @@ -69,8 +69,13 @@ async def login(evt: CommandEvent) -> None: await evt.reply("You're already logged in") return - save = len(evt.args) > 0 and evt.args[0] == "--save" - email = evt.args[0 if not save else 1] if len(evt.args) > 0 else None + num_args = len(evt.args) + save = num_args > 0 and evt.args[0] == "--save" + # TODO Once web login is implemented, don't make a mandatory argument + if not save and num_args != 1: + await evt.reply("**Usage:** `$cmdprefix+sp login [--save] `") + return + email = evt.args[0 if not save else 1] if num_args > 0 else None if email: evt.sender.command_status = {