From 2ee8408dba9f7a8238117a42ac4b8acba4d610ad Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 7 Oct 2014 22:41:34 -0700 Subject: [PATCH] Added option to use lists in PyIRCBot.messageHasCommand for easier command aliasing --- pyircbot/core/pyircbot.py | 9 +++++++++ pyircbot/modules/Weather.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pyircbot/core/pyircbot.py b/pyircbot/core/pyircbot.py index e3ef362..571d524 100644 --- a/pyircbot/core/pyircbot.py +++ b/pyircbot/core/pyircbot.py @@ -513,6 +513,15 @@ class PyIRCBot(asynchat.async_chat): @staticmethod def messageHasCommand(command, message, requireArgs=False): + if not type(command)==list: + command = [command] + for item in command: + cmd = PyIRCBot.messageHasCommandSingle(item, message, requireArgs) + if cmd: + return cmd + + @staticmethod + def messageHasCommandSingle(command, message, requireArgs=False): """Check if a message has a command with or without args in it :param command: the command string to look for, like !ban diff --git a/pyircbot/modules/Weather.py b/pyircbot/modules/Weather.py index f22e699..df8d5cb 100644 --- a/pyircbot/modules/Weather.py +++ b/pyircbot/modules/Weather.py @@ -43,7 +43,7 @@ class Weather(ModuleBase): if hasUnit: hasUnit = hasUnit.upper() - cmd = self.bot.messageHasCommand(".w", trailing) + cmd = self.bot.messageHasCommand([".w", ".weather"], trailing) if cmd: if len(cmd.args_str)>0: self.send_weather(replyTo, fromWho, cmd.args_str, hasUnit)