From f9cc5d566396207ed98a5310cd25aa485d449d79 Mon Sep 17 00:00:00 2001 From: Daniel F Date: Fri, 19 Mar 2010 10:44:23 -0400 Subject: [PATCH] add lock and unlock command methods --- plugins/MessageParser/plugin.py | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/plugins/MessageParser/plugin.py b/plugins/MessageParser/plugin.py index 2cae23f87..b057e39f7 100644 --- a/plugins/MessageParser/plugin.py +++ b/plugins/MessageParser/plugin.py @@ -207,6 +207,44 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler): irc.replySuccess() remove = wrap(remove, ['channel', 'something']) + def lock(self, irc, msg, args, channel, regexp): + """[] + + Locks the so that it cannot be + removed or overwritten to. is only necessary if the message isn't + sent in the channel itself. + """ + db = self.getDb(channel) + cursor = db.cursor() + cursor.execute("SELECT id FROM triggers WHERE regexp=?", (regexp,)) + results = cursor.fetchall() + if len(results) == 0: + irc.reply('There is no such regexp trigger.') + return + cursor.execute("UPDATE triggers SET locked=1 WHERE regexp=?", (regexp,)) + db.commit() + irc.replySuccess() + lock = wrap(lock, ['channel', 'text']) + + def unlock(self, irc, msg, args, channel, regexp): + """[] + + Unlocks the entry associated with so that it can be + removed or overwritten. is only necessary if the message isn't + sent in the channel itself. + """ + db = self.getDb(channel) + cursor = db.cursor() + cursor.execute("SELECT id FROM triggers WHERE regexp=?", (regexp,)) + results = cursor.fetchall() + if len(results) == 0: + irc.reply('There is no such regexp trigger.') + return + cursor.execute("UPDATE triggers SET locked=0 WHERE regexp=?", (regexp,)) + db.commit() + irc.replySuccess() + unlock = wrap(unlock, ['channel', 'text']) + def show(self, irc, msg, args, channel, regexp): """[]