make NEW multi-lock capable
authorJoerg Jaspert <joerg@debian.org>
Thu, 16 Apr 2009 21:48:25 +0000 (23:48 +0200)
committerJoerg Jaspert <joerg@debian.org>
Thu, 16 Apr 2009 21:48:25 +0000 (23:48 +0200)
Signed-off-by: Joerg Jaspert <joerg@debian.org>
Dak/plugin.py

index f1bdc04..840c2b9 100644 (file)
@@ -214,12 +214,22 @@ class Dak(callbacks.Plugin):
                 irc.error("Can't lock all, there are existing locks")
                 return
             if self.locks.has_key(key):
-                if self.locks[key] == msg.nick:
+                if key == "NEW":
+                    if msg.nick in self.locks[key]:
+                        irc.reply("Loser, you already locked %s" % (key) )
+                    else:
+                        self.locks[key].append(msg.nick)
+                        irc.reply("also locked %s" % (key))
+                elif self.locks[key] == msg.nick:
                     irc.reply("Loser, you already locked %s" % (key) )
                 else:
                     irc.reply("You suck, this is already locked by %s" % (self.locks[key]) )
             else:
-                self.locks[key]=msg.nick
+                if key == "NEW":
+                    self.locks[key] = []
+                    self.locks[key].append(msg.nick)
+                else:
+                    self.locks[key]=msg.nick
                 irc.reply("locked %s" % (key) )
     lock = wrap(lock, ['text'])
 
@@ -234,7 +244,11 @@ class Dak(callbacks.Plugin):
 
         unlocked="unlocked: "
         if self.locks.has_key(what):
-            if self.locks[what] == msg.nick:
+            if what == "NEW":
+                if msg.nick in self.locks[what]:
+                    self.locks[what].remove(msg.nick)
+                    irc.reply("unlocked %s" % (what))
+            elif self.locks[what] == msg.nick:
                 del(self.locks[what])
                 irc.reply("unlocked %s" % (what) )
             else:
@@ -242,8 +256,14 @@ class Dak(callbacks.Plugin):
         else:
             keys=[]
             for key in self.locks:
-                if self.locks[key] == msg.nick:
-                    keys.append(key)
+                if key == "NEW":
+                    if msg.nick in self.locks[key]:
+                        self.locks[key].remove(msg.nick)
+                        if len(self.locks[key]) == 0:
+                            keys.append(key)
+                else:
+                    if self.locks[key] == msg.nick:
+                        keys.append(key)
             for key in keys:
                 del(self.locks[key])
             unlocked += ", ".join(keys)