# Path: txircd/modbase.py
# class Mode(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def checkSet(self, user, target, param):
#         return [True, param]
#     def checkUnset(self, user, target, param):
#         return [True, param]
#     def showParam(self, user, target, param):
#         return param
#     def checkPermission(self, user, cmd, data):
#         return data


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

class SecretMode(Mode):
    def checkPermission(self, user, cmd, data):
        if cmd != "NAMES":
            return data
        remove = []
        for chan in data["targetchan"]:
            if "s" in chan.mode and user not in chan.users:
                user.sendMessage(irc.ERR_NOSUCHNICK, chan, ":No such nick/channel")
                remove.append(chan)
        for chan in remove:
            data["targetchan"].remove(chan)
        return data
    
    def listOutput(self, user, chanlist):
        remove = []
        for cdata in chanlist:
            if "s" in cdata["channel"].mode and user not in cdata["channel"].users:
                remove.append(cdata)
        for item in remove:
            chanlist.remove(item)
        return chanlist
    # other +s stuff is hiding in other modules.


# Path: txircd/modbase.py
# class Mode(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def checkSet(self, user, target, param):
#         return [True, param]
#     def checkUnset(self, user, target, param):
#         return [True, param]
#     def showParam(self, user, target, param):
#         return param
#     def checkPermission(self, user, cmd, data):
#         return data


# Path: txircd/modules/cmode_s.py
from twisted.words.protocols import irc
from txircd.modbase import Mode


class SecretMode(Mode):
    def checkPermission(self, user, cmd, data):
        if cmd != "NAMES":
            return data
        remove = []
        for chan in data["targetchan"]:
            if "s" in chan.mode and user not in chan.users:
                user.sendMessage(irc.ERR_NOSUCHNICK, chan, ":No such nick/channel")
                remove.append(chan)
        for chan in remove:
            data["targetchan"].remove(chan)
        return data
    
    def listOutput(self, user, chanlist):
        remove = []
        for cdata in chanlist:
            if "s" in cdata["channel"].mode and user not in cdata["channel"].users:
                remove.append(cdata)
        for item in remove:
            chanlist.remove(item)
        return chanlist
    # other +s stuff is hiding in other modules.


class Spawner(object):