@@ -0,0 +1,2507 @@
+from twisted.plugin import IPlugin%0Afrom twisted.words.protocols import irc%0Afrom txircd.module_interface import ICommand, IModuleData, Command, ModuleData%0Afrom zope.interface import implements%0A%0Aclass SamodeCommand(ModuleData, Command):%0A    implements(IPlugin, IModuleData, ICommand)%0A%0A    name = %22SamodeCommand%22%0A%0A    def hookIRCd(self, ircd):%0A        self.ircd = ircd%0A%0A    def userCommands(self):%0A        return %5B (%22SAMODE%22, 1, self) %5D%0A%0A    def actions(self):%0A        return %5B (%22commandpermission-SAMODE%22, 1, self.restrictToOpers),%0A                (%22channelstatusoverride%22, 1, self.checkStatusOverride)%5D%0A%0A    def restrictToOpers(self, user, command, data):%0A        if not self.ircd.runActionUntilValue(%22userhasoperpermission%22, user, %22command-samode%22, users=%5Buser%5D):%0A            user.sendMessage(irc.ERR_NOPRIVILEGES, %22:Permission denied - You do not have the correct operator privileges%22)%0A            return False%0A        return None%0A%0A    def checkStatusOverride(self, channel, user, mode, param):%0A        if %22overriding-modes%22 in user.cache:%0A            return True%0A        return None%0A%0A    def parseParams(self, user, params, prefix, tags):%0A        if len(params) %3C 2:%0A            user.sendSingleError(%22SamodeCmd%22, irc.ERR_NEEDMOREPARAMS, %22SAMODE%22, %22:Not enough parameters%22)%0A            return None%0A        if params%5B0%5D in self.ircd.channels:%0A            return %7B%0A                %22targetchannel%22: self.ircd.channels%5Bparams%5B0%5D%5D,%0A                %22modes%22: params%5B1%5D,%0A                %22params%22: params%5B2:%5D%0A            %7D%0A        if params%5B0%5D in self.ircd.userNicks:%0A            return %7B%0A                %22targetuser%22: self.ircd.users%5Bself.ircd.userNicks%5Bparams%5B0%5D%5D%5D,%0A                %22modes%22: params%5B1%5D,%0A                %22params%22: params%5B2:%5D%0A            %7D%0A        user.sendSingleError(%22SamodeCmd%22, irc.ERR_NOSUCHNICK, %22:No such nick/channel%22)%0A        return None%0A%0A    def affectedChannels(self, user, data):%0A        if %22targetchannel%22 in data:%0A            return %5B data%5B%22targetchannel%22%5D %5D%0A        return %5B%5D%0A%0A    def execute(self, user, data):%0A        if %22targetchannel%22 in data:%0A            user.cache%5B%22overriding-modes%22%5D = True%0A            channel = data%5B%22targetchannel%22%5D%0A            channel.setModes(user.uuid, data%5B%22modes%22%5D, data%5B%22params%22%5D)%0A        elif %22targetuser%22 in data:%0A            u = data%5B%22targetuser%22%5D%0A            u.setModes(user.uuid, data%5B%22modes%22%5D, data%5B%22params%22%5D)%0A        if %22overriding-modes%22 in user.cache:%0A            del user.cache%5B%22overriding-modes%22%5D%0A        return True%0A%0Asamode = SamodeCommand()

Implement the SAMODE command