Browse Source

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

dave/xdcc
dave 8 years ago
parent
commit
2ee8408dba
  1. 9
      pyircbot/core/pyircbot.py
  2. 2
      pyircbot/modules/Weather.py

9
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

2
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)

Loading…
Cancel
Save