# Path: txircd/modbase.py
# class Command(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def onUse(self, user, data):
#         pass
#     def processParams(self, user, params):
#         return {
#             "user": user,
#             "params": params
#         }
#     def updateActivity(self, user):
#         user.lastactivity = now()
# 
# 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 Command, Mode
                user.cache["knocks"].remove(channel.name)
    
    def removeKnockOnInvite(self, command, data):
        if command != "INVITE":
            return
        targetUser = data["targetuser"]
        targetChan = data["targetchan"]
        if "knocks" in targetUser.cache and targetChan.name in targetUser.cache["knocks"]:
            targetUser.cache["knocks"].remove(targetChan.name)

class NoknockMode(Mode):
    def checkPermission(self, user, cmd, data):
        if "targetchan" not in data:
            return data
        cdata = data["targetchan"]
        if cmd == "KNOCK" and "K" in cdata.mode:
            user.sendMessage(irc.ERR_TOOMANYKNOCK, cdata.name, ":Channel is +K")
            return {}
        return data

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.knockCmd = None
    
    def spawn(self):
        self.knockCmd = KnockCommand()
        return {
            "commands": {
                "KNOCK": self.knockCmd

# Path: txircd/modbase.py
# class Command(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def onUse(self, user, data):
#         pass
#     def processParams(self, user, params):
#         return {
#             "user": user,
#             "params": params
#         }
#     def updateActivity(self, user):
#         user.lastactivity = now()
# 
# 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/knock.py
from twisted.words.protocols import irc
from txircd.modbase import Command, Mode

                user.cache["knocks"].remove(channel.name)
    
    def removeKnockOnInvite(self, command, data):
        if command != "INVITE":
            return
        targetUser = data["targetuser"]
        targetChan = data["targetchan"]
        if "knocks" in targetUser.cache and targetChan.name in targetUser.cache["knocks"]:
            targetUser.cache["knocks"].remove(targetChan.name)

class NoknockMode(Mode):
    def checkPermission(self, user, cmd, data):
        if "targetchan" not in data:
            return data
        cdata = data["targetchan"]
        if cmd == "KNOCK" and "K" in cdata.mode:
            user.sendMessage(irc.ERR_TOOMANYKNOCK, cdata.name, ":Channel is +K")
            return {}
        return data

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.knockCmd = None
    
    def spawn(self):
        self.knockCmd = KnockCommand()
        return {
            "commands": {
                "KNOCK": self.knockCmd

            },