From ee726b93ff893f142178b612a0f01005ca637593 Mon Sep 17 00:00:00 2001 From: Joscha Date: Thu, 11 Apr 2019 23:26:58 +0000 Subject: [PATCH] Check if a command has arguments --- yaboli/command.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yaboli/command.py b/yaboli/command.py index 99ce2ab..d716eda 100644 --- a/yaboli/command.py +++ b/yaboli/command.py @@ -102,6 +102,9 @@ class ArgumentData: self._fancy = self._parse_fancy(basic) return self._fancy + def has_args(self) -> bool: + return bool(self.basic()) # The list of arguments is empty + class SpecificArgumentData(ArgumentData): def __init__(self, nick: str, argstr: str) -> None: super().__init__(argstr) @@ -224,7 +227,7 @@ class GeneralCommand(Command): data: CommandData, ) -> None: # Do we have arguments if we shouldn't? - if not self._args and data.general.basic(): + if not self._args and data.general.has_args(): return await self._cmdfunc(room, message, data.general) @@ -263,7 +266,7 @@ class SpecificCommand(Command): return # Yay, a rare occurrence of this structure! # Do we have arguments if we shouldn't? - if not self._args and data.specific.basic(): + if not self._args and data.specific.has_args(): return await self._cmdfunc(room, message, data.specific)