# 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()
# 
# Path: txircd/server.py
# class ModuleMessage(Command):
#     arguments = [
#         ("destserver", String()),
#         ("type", String()),
#         ("args", ListOf(String()))
#     ]
#     errors = {
#         HandshakeNotYetComplete: "HANDSHAKE_NOT_COMPLETE"
#     }


from twisted.words.protocols import irc
from txircd.modbase import Command
from txircd.server import ModuleMessage
                user.sendMessage("CAP", "NAK", ":{}".format(" ".join(nak)))
        elif subcmd == "ACK":
            ack = []
            nak = []
            for capability in data["list"]:
                if capability:
                    if capability[0] == "-":
                        capabilityName = capability[1:]
                        if capabilityName in self.ircd.module_data_cache["cap"] and self.ircd.module_data_cache["cap"][capabilityName].capAcknowledgeRemove(user, capability):
                            if "cap" in user.cache and capabilityName in user.cache["cap"]:
                                user.cache["cap"].remove(capabilityName)
                            ack.append(capability)
                        else:
                            nak.append(capability)
                    elif capability in self.ircd.module_data_cache["cap"]:
                        if self.ircd.module_data_cache["cap"][capability].capAcknowledge(user, capability):
                            if "cap" in user.cache:
                                user.cache["cap"].append(capability)
                            else:
                                user.cache["cap"] = [capability]
                            ack.append(capability)
                        else:
                            nak.append(capability)
                    else:
                        nak.append(capability)
            if ack:
                user.sendMessage("CAP", "ACK", ":{}".format(" ".join(ack)))
            if nak:
                user.sendMessage("CAP", "NAK", ":{}".format(" ".join(nak)))
        elif subcmd == "CLEAR":

# 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()
# 
# Path: txircd/server.py
# class ModuleMessage(Command):
#     arguments = [
#         ("destserver", String()),
#         ("type", String()),
#         ("args", ListOf(String()))
#     ]
#     errors = {
#         HandshakeNotYetComplete: "HANDSHAKE_NOT_COMPLETE"
#     }


# Path: txircd/modules/ircv3_cap.py
from twisted.words.protocols import irc
from txircd.modbase import Command
from txircd.server import ModuleMessage

                user.sendMessage("CAP", "NAK", ":{}".format(" ".join(nak)))
        elif subcmd == "ACK":
            ack = []
            nak = []
            for capability in data["list"]:
                if capability:
                    if capability[0] == "-":
                        capabilityName = capability[1:]
                        if capabilityName in self.ircd.module_data_cache["cap"] and self.ircd.module_data_cache["cap"][capabilityName].capAcknowledgeRemove(user, capability):
                            if "cap" in user.cache and capabilityName in user.cache["cap"]:
                                user.cache["cap"].remove(capabilityName)
                            ack.append(capability)
                        else:
                            nak.append(capability)
                    elif capability in self.ircd.module_data_cache["cap"]:
                        if self.ircd.module_data_cache["cap"][capability].capAcknowledge(user, capability):
                            if "cap" in user.cache:
                                user.cache["cap"].append(capability)
                            else:
                                user.cache["cap"] = [capability]
                            ack.append(capability)
                        else:
                            nak.append(capability)
                    else:
                        nak.append(capability)
            if ack:
                user.sendMessage("CAP", "ACK", ":{}".format(" ".join(ack)))
            if nak:
                user.sendMessage("CAP", "NAK", ":{}".format(" ".join(nak)))
        elif subcmd == "CLEAR":

            if "cap" not in user.cache: