Added a raiseError optional argument to getChannel.

This commit is contained in:
Jeremy Fincher 2004-02-05 07:17:11 +00:00
parent 6771c24ca6
commit 19a86f3873

View File

@ -50,7 +50,7 @@ import ircutils
import callbacks
import structures
def getChannel(msg, args):
def getChannel(msg, args, raiseError=True):
"""Returns the channel the msg came over or the channel given in args.
If the channel was given in args, args is modified (the channel is
@ -70,8 +70,11 @@ def getChannel(msg, args):
elif ircutils.isChannel(msg.args[0]):
return msg.args[0]
else:
raise callbacks.Error, 'Command must be sent in a channel or ' \
'include a channel in its arguments.'
if raiseError:
raise callbacks.Error, 'Command must be sent in a channel or ' \
'include a channel in its arguments.'
else:
return None
def getArgs(args, required=1, optional=0):
"""Take the required/optional arguments from args.