use irc.reply instead of irc.error for conditions that are expected to normally occur on occasion,

also, add returns after error conditions (i assumed earlier that irc.error returned) - this fixes some bugs.
This commit is contained in:
Daniel Folkinshteyn 2010-03-15 17:32:02 -04:00
parent f6a86a81ce
commit 0c87c523d2

View File

@ -106,9 +106,6 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
if len(actions) > 0: if len(actions) > 0:
irc.replies(actions, prefixNick=False) irc.replies(actions, prefixNick=False)
#if re.search('some stuff', msgtext):
# irc.reply('some stuff detected', prefixNick=False)
def add(self, irc, msg, args, channel, regexp, action): def add(self, irc, msg, args, channel, regexp, action):
"""[<channel>] <regexp> <action> """[<channel>] <regexp> <action>
@ -136,7 +133,8 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
db.commit() db.commit()
irc.replySuccess() irc.replySuccess()
else: else:
irc.error('That trigger is locked.') irc.reply('That trigger is locked.')
return
add = wrap(add, ['channel', 'something', 'something']) add = wrap(add, ['channel', 'something', 'something'])
def remove(self, irc, msg, args, channel, regexp): def remove(self, irc, msg, args, channel, regexp):
@ -152,10 +150,12 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
if cursor.rowcount != 0: if cursor.rowcount != 0:
(id, locked) = map(int, cursor.fetchone()) (id, locked) = map(int, cursor.fetchone())
else: else:
irc.error('There is no such regexp trigger.') irc.reply('There is no such regexp trigger.')
return
if locked: if locked:
irc.error('This regexp trigger is locked.') irc.reply('This regexp trigger is locked.')
return
cursor.execute("""DELETE FROM triggers WHERE id=%s""", id) cursor.execute("""DELETE FROM triggers WHERE id=%s""", id)
db.commit() db.commit()
@ -175,7 +175,8 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
if cursor.rowcount != 0: if cursor.rowcount != 0:
(regexp, action) = cursor.fetchone() (regexp, action) = cursor.fetchone()
else: else:
irc.error('There is no such regexp trigger.') irc.reply('There is no such regexp trigger.')
return
irc.reply("The trigger for regexp '%s' is '%s'" % (regexp, action)) irc.reply("The trigger for regexp '%s' is '%s'" % (regexp, action))
show = wrap(show, ['channel', 'something']) show = wrap(show, ['channel', 'something'])
@ -193,7 +194,8 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
if cursor.rowcount != 0: if cursor.rowcount != 0:
regexps = cursor.fetchall() regexps = cursor.fetchall()
else: else:
irc.error('There is no available regexp triggers.') irc.reply('There are no regexp triggers in the database.')
return
s = [ regexp[0] for regexp in regexps ] s = [ regexp[0] for regexp in regexps ]
irc.reply("'" + "','".join(s) + "'") irc.reply("'" + "','".join(s) + "'")