Added option to use lists in PyIRCBot.messageHasCommand for easier command aliasing

This commit is contained in:
dave 2014-10-07 22:41:34 -07:00
parent fc16f0c803
commit 2ee8408dba
2 changed files with 10 additions and 1 deletions

View File

@ -513,6 +513,15 @@ class PyIRCBot(asynchat.async_chat):
@staticmethod @staticmethod
def messageHasCommand(command, message, requireArgs=False): 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 """Check if a message has a command with or without args in it
:param command: the command string to look for, like !ban :param command: the command string to look for, like !ban

View File

@ -43,7 +43,7 @@ class Weather(ModuleBase):
if hasUnit: if hasUnit:
hasUnit = hasUnit.upper() hasUnit = hasUnit.upper()
cmd = self.bot.messageHasCommand(".w", trailing) cmd = self.bot.messageHasCommand([".w", ".weather"], trailing)
if cmd: if cmd:
if len(cmd.args_str)>0: if len(cmd.args_str)>0:
self.send_weather(replyTo, fromWho, cmd.args_str, hasUnit) self.send_weather(replyTo, fromWho, cmd.args_str, hasUnit)