@@ -0,0 +1,962 @@
+from twisted.words.protocols import irc%0Afrom txircd.modbase import Mode%0A%0Aclass PasswordMode(Mode):%0A%09def commandPermission(self, user, cmd, data):%0A%09%09if cmd != %22JOIN%22:%0A%09%09%09return data%0A%09%09channels = data%5B%22targetchan%22%5D%0A%09%09keys = data%5B%22keys%22%5D%0A%09%09removeChannels = %5B%5D%0A%09%09for index, chan in channels.enumerate():%0A%09%09%09if %22k%22 in chan.mode and chan.mode%5B%22k%22%5D != keys%5Bindex%5D:%0A%09%09%09%09removeChannels.append(chan)%0A%09%09%09%09user.sendMessage(irc.ERR_BADCHANNELKEY, chan.name, %22:Cannot join channel (Incorrect channel key)%22)%0A%09%09for chan in removeChannels:%0A%09%09%09index = channels.index(chan) # We need to do this anyway to eliminate the effects of shifting when removing earlier elements%0A%09%09%09channels.pop(index)%0A%09%09%09keys.pop(index)%0A%09%09data%5B%22targetchan%22%5D = channels%0A%09%09data%5B%22keys%22%5D = keys%0A%09%09return data%0A%0Aclass Spawner(object):%0A%09def __init__(self, ircd):%0A%09%09self.ircd = ircd%0A%09%0A%09def spawn(self):%0A%09%09return %7B%0A%09%09%09%22modes%22: %7B%0A%09%09%09%09%22cuk%22: PasswordMode()%0A%09%09%09%7D%0A%09%09%7D%0A%09%0A%09def cleanup(self):%0A%09%09self.ircd.removeMode(%22cuk%22)

Implement channel mode +k