@@ -0,0 +1,1248 @@
+from twisted.plugin import IPlugin%0Afrom txircd.module_interface import IModuleData, ModuleData%0Afrom zope.interface import implements%0A%0Aclass ChannelLevel(ModuleData):%0A%09implements(IModuleData)%0A%09%0A%09name = %22ChannelLevel%22%0A%09core = True%0A%09%0A%09def actions(self):%0A%09%09return %5B (%22checkchannellevel%22, 1, self.levelCheck),%0A%09%09         (%22checkexemptchanops%22, 1, self.exemptCheck) %5D%0A%09%0A%09def minLevelFromConfig(self, configKey, checkType, defaultLevel):%0A%09%09configLevel = self.ircd.config.get(configKey, %7B%7D).get(checkType, defaultLevel)%0A%09%09try:%0A%09%09%09minLevel = int(configLevel)%0A%09%09except ValueError:%0A%09%09%09if configLevel not in self.ircd.channelStatuses:%0A%09%09%09%09return False # If the status doesn't exist, then, to be safe, we must assume NOBODY is above the line.%0A%09%09%09minLevel = self.ircd.channelStatuses%5BconfigLevel%5D%5B1%5D%0A%09%09return minLevel%0A%09%0A%09def levelCheck(self, levelType, channel, user):%0A%09%09minLevel = self.minLevelFromConfig(%22channel_minimum_level%22, levelType, 100)%0A%09%09return channel.userRank(user) %3E= minLevel%0A%09%0A%09def exemptCheck(self, exemptType, channel, user):%0A%09%09minLevel = self.minLevelFromConfig(%22channel_exempt_level%22, exemptType, 0)%0A%09%09if not minLevel:%0A%09%09%09return False # No minimum level == no exemptions%0A%09%09return channel.userRank(user) %3E= minLevel%0A%0AchanLevel = ChannelLevel()

Implement a consistent way to check channel rank requirements