From adb53a0a35634ce1e2c2ea4ef6a06f86ffab9fe3 Mon Sep 17 00:00:00 2001 From: Daniel F Date: Fri, 19 Mar 2010 09:55:43 -0400 Subject: [PATCH] preserve usage count upon overwriting an existing regexp entry. --- plugins/MessageParser/plugin.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index 6bf62c69c..2cae23f87 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -159,12 +159,13 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): etc. being interpolated from the regexp match groups.""" db = self.getDb(channel) cursor = db.cursor() - cursor.execute("SELECT id, locked FROM triggers WHERE regexp=?", (regexp,)) + cursor.execute("SELECT id, usage_count, locked FROM triggers WHERE regexp=?", (regexp,)) results = cursor.fetchall() if len(results) != 0: - (id, locked) = map(int, results[0]) + (id, usage_count, locked) = map(int, results[0]) else: - locked = False + locked = 0 + usage_count = 0 if not locked: if ircdb.users.hasUser(msg.prefix): name = ircdb.users.getUser(msg.prefix).name @@ -172,7 +173,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): name = msg.nick cursor.execute("""INSERT INTO triggers VALUES (NULL, ?, ?, ?, ?, ?, ?)""", - (regexp, name, int(time.time()), 0, action, 0,)) + (regexp, name, int(time.time()), usage_count, action, locked,)) db.commit() irc.replySuccess() else: