mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-06 09:34:05 +01:00
Catch an exception when adding/replacing a factoid.
This commit is contained in:
parent
efce872b01
commit
9f612df8d9
@ -409,8 +409,9 @@ class MoobotFactoids(callbacks.Privmsg):
|
|||||||
elif 'is' in tokens:
|
elif 'is' in tokens:
|
||||||
p = 'is'.__eq__
|
p = 'is'.__eq__
|
||||||
else:
|
else:
|
||||||
s = 'Invalid tokens for {add,change}Factoid: %s' % \
|
self.log.debug('Invalid tokens for {add,replace}Factoid: %s.',
|
||||||
utils.quoted(tokens)
|
tokens)
|
||||||
|
s = 'Missing an \'is\' or \'_is_\'.'
|
||||||
raise ValueError, s
|
raise ValueError, s
|
||||||
(key, newfact) = map(' '.join, utils.itersplit(p, tokens, maxsplit=1))
|
(key, newfact) = map(' '.join, utils.itersplit(p, tokens, maxsplit=1))
|
||||||
key = self._sanitizeKey(key)
|
key = self._sanitizeKey(key)
|
||||||
@ -420,7 +421,10 @@ class MoobotFactoids(callbacks.Privmsg):
|
|||||||
# First, check and see if the entire message matches a factoid key
|
# First, check and see if the entire message matches a factoid key
|
||||||
channel = plugins.getChannel(msg.args[0])
|
channel = plugins.getChannel(msg.args[0])
|
||||||
id = self._getUserId(irc, msg.prefix)
|
id = self._getUserId(irc, msg.prefix)
|
||||||
(key, fact) = self._getKeyAndFactoid(tokens)
|
try:
|
||||||
|
(key, fact) = self._getKeyAndFactoid(tokens)
|
||||||
|
except ValueError, e:
|
||||||
|
irc.error(str(e), Raise=True)
|
||||||
# Check and make sure it's not in the DB already
|
# Check and make sure it's not in the DB already
|
||||||
if self.db.getFactoid(channel, key):
|
if self.db.getFactoid(channel, key):
|
||||||
irc.error('Factoid "%s" already exists.' % key, Raise=True)
|
irc.error('Factoid "%s" already exists.' % key, Raise=True)
|
||||||
@ -466,7 +470,10 @@ class MoobotFactoids(callbacks.Privmsg):
|
|||||||
channel = plugins.getChannel(msg.args[0])
|
channel = plugins.getChannel(msg.args[0])
|
||||||
id = self._getUserId(irc, msg.prefix)
|
id = self._getUserId(irc, msg.prefix)
|
||||||
del tokens[0] # remove the "no,"
|
del tokens[0] # remove the "no,"
|
||||||
(key, fact) = self._getKeyAndFactoid(tokens)
|
try:
|
||||||
|
(key, fact) = self._getKeyAndFactoid(tokens)
|
||||||
|
except ValueError, e:
|
||||||
|
irc.error(str(e), Raise=True)
|
||||||
_ = self._getFactoid(irc, channel, key)
|
_ = self._getFactoid(irc, channel, key)
|
||||||
self._checkNotLocked(irc, channel, key)
|
self._checkNotLocked(irc, channel, key)
|
||||||
self.db.removeFactoid(channel, key)
|
self.db.removeFactoid(channel, key)
|
||||||
|
Loading…
Reference in New Issue
Block a user