Added option to use lists in PyIRCBot.messageHasCommand for easier command aliasing
This commit is contained in:
parent
fc16f0c803
commit
2ee8408dba
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue