mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
Let's allow errors to raise their complaint.
This commit is contained in:
parent
85cbffc5dd
commit
523204f080
@ -381,13 +381,16 @@ class RichReplyMethods(object):
|
|||||||
s = prefix
|
s = prefix
|
||||||
return plugins.standardSubstitute(self, self.msg, s)
|
return plugins.standardSubstitute(self, self.msg, s)
|
||||||
|
|
||||||
|
def _getConfig(self, wrapper):
|
||||||
|
return wrapper.get(self.msg.args[0])()
|
||||||
|
|
||||||
def replySuccess(self, s='', **kwargs):
|
def replySuccess(self, s='', **kwargs):
|
||||||
v = conf.supybot.replies.success.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.success)
|
||||||
s = self.__makeReply(v, s)
|
s = self.__makeReply(v, s)
|
||||||
self.reply(s, **kwargs)
|
self.reply(s, **kwargs)
|
||||||
|
|
||||||
def replyError(self, s='', **kwargs):
|
def replyError(self, s='', **kwargs):
|
||||||
v = conf.supybot.replies.error.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.error)
|
||||||
s = self.__makeReply(v, s)
|
s = self.__makeReply(v, s)
|
||||||
self.reply(s, **kwargs)
|
self.reply(s, **kwargs)
|
||||||
|
|
||||||
@ -415,43 +418,49 @@ class RichReplyMethods(object):
|
|||||||
else:
|
else:
|
||||||
self.reply(prefixer(s), **kwargs)
|
self.reply(prefixer(s), **kwargs)
|
||||||
|
|
||||||
def errorNoCapability(self, capability, s='', **kwargs):
|
def _error(self, s, Raise, **kwargs):
|
||||||
|
if Raise:
|
||||||
|
raise callbacks.Error, s
|
||||||
|
else:
|
||||||
|
self.error(s, **kwargs)
|
||||||
|
|
||||||
|
def errorNoCapability(self, capability, s='', Raise=False, **kwargs):
|
||||||
if isinstance(capability, basestring): # checkCommandCapability!
|
if isinstance(capability, basestring): # checkCommandCapability!
|
||||||
log.warning('Denying %s for lacking %r capability',
|
log.warning('Denying %s for lacking %r capability',
|
||||||
self.msg.prefix, capability)
|
self.msg.prefix, capability)
|
||||||
if not conf.supybot.reply.noCapabilityError():
|
if not self._getConfig(conf.supybot.reply.noCapabilityError):
|
||||||
v = conf.supybot.replies.noCapability.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.noCapability)
|
||||||
s = self.__makeReply(v % capability, s)
|
s = self.__makeReply(v % capability, s)
|
||||||
self.error(s, **kwargs)
|
self._error(s, Raise, **kwargs)
|
||||||
else:
|
else:
|
||||||
log.warning('Denying %s for some unspecified capability '
|
log.warning('Denying %s for some unspecified capability '
|
||||||
'(or a default)', self.msg.prefix)
|
'(or a default)', self.msg.prefix)
|
||||||
v = conf.supybot.replies.genericNoCapability.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.genericNoCapability)
|
||||||
self.error(self.__makeReply(v, s), **kwargs)
|
self._error(self.__makeReply(v, s), Raise, **kwargs)
|
||||||
|
|
||||||
def errorPossibleBug(self, s='', **kwargs):
|
def errorPossibleBug(self, s='', Raise=False, **kwargs):
|
||||||
v = conf.supybot.replies.possibleBug.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.possibleBug)
|
||||||
if s:
|
if s:
|
||||||
s += ' (%s)' % v
|
s += ' (%s)' % v
|
||||||
else:
|
else:
|
||||||
s = v
|
s = v
|
||||||
self.error(s, **kwargs)
|
self._error(s, Raise, **kwargs)
|
||||||
|
|
||||||
def errorNotRegistered(self, s='', **kwargs):
|
def errorNotRegistered(self, s='', Raise=False, **kwargs):
|
||||||
v = conf.supybot.replies.notRegistered.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.notRegistered)
|
||||||
self.error(self.__makeReply(v, s), **kwargs)
|
self._error(self.__makeReply(v, s), Raise, **kwargs)
|
||||||
|
|
||||||
def errorNoUser(self, s='', name='that user', **kwargs):
|
def errorNoUser(self, s='', name='that user', Raise=False, **kwargs):
|
||||||
v = conf.supybot.replies.noUser.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.noUser)
|
||||||
try:
|
try:
|
||||||
v = v % name
|
v = v % name
|
||||||
except TypeError:
|
except TypeError:
|
||||||
log.warning('supybot.replies.noUser should have one "%s" in it.')
|
log.warning('supybot.replies.noUser should have one "%s" in it.')
|
||||||
self.error(self.__makeReply(v, s), **kwargs)
|
self._error(self.__makeReply(v, s), Raise, **kwargs)
|
||||||
|
|
||||||
def errorRequiresPrivacy(self, s='', **kwargs):
|
def errorRequiresPrivacy(self, s='', Raise=False, **kwargs):
|
||||||
v = conf.supybot.replies.requiresPrivacy.get(self.msg.args[0])()
|
v = self._getConfig(conf.supybot.replies.requiresPrivacy)
|
||||||
self.error(self.__makeReply(v, s), **kwargs)
|
self._error(self.__makeReply(v, s), Raise, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class IrcObjectProxy(RichReplyMethods):
|
class IrcObjectProxy(RichReplyMethods):
|
||||||
@ -728,8 +737,8 @@ class CommandThread(threading.Thread):
|
|||||||
def __init__(self, target=None, args=None):
|
def __init__(self, target=None, args=None):
|
||||||
(self.name, self.command, self.cb) = args
|
(self.name, self.command, self.cb) = args
|
||||||
world.threadsSpawned += 1
|
world.threadsSpawned += 1
|
||||||
threadName = 'Thread #%s for %s.%s' % (world.threadsSpawned,
|
threadName = 'Thread #%s (for %s.%s)' % (world.threadsSpawned,
|
||||||
self.cb.name(), self.name)
|
self.cb.name(), self.name)
|
||||||
log.debug('Spawning thread %s' % threadName)
|
log.debug('Spawning thread %s' % threadName)
|
||||||
threading.Thread.__init__(self, target=target,
|
threading.Thread.__init__(self, target=target,
|
||||||
name=threadName, args=args)
|
name=threadName, args=args)
|
||||||
|
Loading…
Reference in New Issue
Block a user