from twisted.words.protocols import irc
from txircd.modbase import Mode

class TopiclockMode(Mode):
	def checkPermission(self, user, cmd, data):
		if cmd != "TOPIC":
			return data
		if "topic" not in data:
			return data
		targetChannel = data["targetchan"]
		if "t" in targetChannel.mode and not user.hasAccess(self.ircd.servconfig["channel_minimum_level"]["TOPIC"], targetChannel.name):
			user.sendMessage(irc.ERR_CHANOPRIVSNEEDED, targetChannel.name, ":You do not have access to change the topic on this channel")
			return {}
		return data

class Spawner(object):
	def __init__(self, ircd):
		self.ircd = ircd
	
	def spawn(self):
		if "channel_minimum_level" not in self.ircd.servconfig:
			self.ircd.servconfig["channel_minimum_level"] = {}
		if "TOPIC" not in self.ircd.servconfig["channel_minimum_level"]:
			self.ircd.servconfig["channel_minimum_level"]["TOPIC"] = "o"
		return {
			"modes": {
				"cnt": TopiclockMode()
			}
		}
	
	def cleanup(self):
		self.ircd.removeMode("cnt")
@@ -306,16 +306,36 @@
 sAccess(
+targetChannel.name, 
 self.irc
@@ -380,36 +380,16 @@
 %22TOPIC%22%5D
-, targetChannel.name
 ):%0A%09%09%09us

Fix the order of parameters to hasAccess, which broke all topic changing when +t was set