From 0c87c523d2314399192081bf66133fb39ce6adf7 Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Mon, 15 Mar 2010 17:32:02 -0400 Subject: [PATCH] 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. --- plugins/MessageParser/plugin.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index acf808075..a7aabaabb 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -106,9 +106,6 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): if len(actions) > 0: 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): """[] @@ -136,7 +133,8 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): db.commit() irc.replySuccess() else: - irc.error('That trigger is locked.') + irc.reply('That trigger is locked.') + return add = wrap(add, ['channel', 'something', 'something']) def remove(self, irc, msg, args, channel, regexp): @@ -152,10 +150,12 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): if cursor.rowcount != 0: (id, locked) = map(int, cursor.fetchone()) else: - irc.error('There is no such regexp trigger.') + irc.reply('There is no such regexp trigger.') + return 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) db.commit() @@ -175,7 +175,8 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): if cursor.rowcount != 0: (regexp, action) = cursor.fetchone() 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)) show = wrap(show, ['channel', 'something']) @@ -193,7 +194,8 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): if cursor.rowcount != 0: regexps = cursor.fetchall() 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 ] irc.reply("'" + "','".join(s) + "'")