mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 06:00:42 +01:00
Changed privmsgs.getArgs to raise ArgumentError, and make the necessary changes in callbacks to Do The Right Thing
This commit is contained in:
parent
df77cfaccf
commit
46f3012f9a
@ -150,6 +150,9 @@ class Error(Exception):
|
|||||||
"""Generic class for errors in Privmsg callbacks."""
|
"""Generic class for errors in Privmsg callbacks."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class ArgumentError(Error):
|
||||||
|
pass
|
||||||
|
|
||||||
class Tokenizer:
|
class Tokenizer:
|
||||||
quotes = '"`'
|
quotes = '"`'
|
||||||
nonbacktickquotes = '"'
|
nonbacktickquotes = '"'
|
||||||
@ -237,11 +240,10 @@ class IrcObjectProxy:
|
|||||||
else:
|
else:
|
||||||
command = getattr(callback, name)
|
command = getattr(callback, name)
|
||||||
callback.callCommand(command, self, self.msg, self.args)
|
callback.callCommand(command, self, self.msg, self.args)
|
||||||
|
except ArgumentError:
|
||||||
|
self.reply(self.msg, command.__doc__.splitlines()[0])
|
||||||
except Error, e:
|
except Error, e:
|
||||||
if str(e) == '':
|
self.reply(self.msg, debug.exnToString(e))
|
||||||
self.reply(self.msg, command.__doc__.splitlines()[0])
|
|
||||||
else:
|
|
||||||
self.reply(self.msg, debug.exnToString(e))
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
debug.recoverableException()
|
debug.recoverableException()
|
||||||
self.reply(self.msg, debug.exnToString(e))
|
self.reply(self.msg, debug.exnToString(e))
|
||||||
|
@ -69,7 +69,7 @@ def getArgs(args, needed=1, optional=0):
|
|||||||
let the caller handle sending the help message.
|
let the caller handle sending the help message.
|
||||||
"""
|
"""
|
||||||
if len(args) < needed:
|
if len(args) < needed:
|
||||||
raise callbacks.Error
|
raise callbacks.ArgumentError
|
||||||
if len(args) < needed + optional:
|
if len(args) < needed + optional:
|
||||||
ret = list(args) + ([''] * (needed + optional - len(args)))
|
ret = list(args) + ([''] * (needed + optional - len(args)))
|
||||||
elif len(args) >= needed + optional:
|
elif len(args) >= needed + optional:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user