# 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/utils.py
# def irc_lower(str):
#     return str.lower().replace("[","{").replace("]","}").replace("/","|").replace("~","^")


from twisted.words.protocols import irc
from txircd.modbase import Command
from txircd.utils import irc_lower
from fnmatch import fnmatch
        if "listdata" in self.ircd.actions:
            for action in self.ircd.actions["listdata"]:
                chancache = action(user, chancache)
                if not chancache:
                    break
        for cdata in chancache:
            user.sendMessage(irc.RPL_LIST, cdata["name"], str(cdata["users"]), ":[{}] {}".format(cdata["channel"].modeString(user), cdata["topic"]))
        user.sendMessage(irc.RPL_LISTEND, ":End of channel list")
    
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "LIST", ":You have not registered")
            return {}
        if params:
            chanFilter = irc_lower(params[0]).split(",")
        else:
            chanFilter = None
        return {
            "user": user,
            "chanfilter": chanFilter
        }

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
    
    def spawn(self):
        return {
            "commands": {
                "LIST": ListCommand()

# 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/utils.py
# def irc_lower(str):
#     return str.lower().replace("[","{").replace("]","}").replace("/","|").replace("~","^")


# Path: txircd/modules/cmd_list.py
from twisted.words.protocols import irc
from txircd.modbase import Command
from txircd.utils import irc_lower
from fnmatch import fnmatch

        if "listdata" in self.ircd.actions:
            for action in self.ircd.actions["listdata"]:
                chancache = action(user, chancache)
                if not chancache:
                    break
        for cdata in chancache:
            user.sendMessage(irc.RPL_LIST, cdata["name"], str(cdata["users"]), ":[{}] {}".format(cdata["channel"].modeString(user), cdata["topic"]))
        user.sendMessage(irc.RPL_LISTEND, ":End of channel list")
    
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "LIST", ":You have not registered")
            return {}
        if params:
            chanFilter = irc_lower(params[0]).split(",")
        else:
            chanFilter = None
        return {
            "user": user,
            "chanfilter": chanFilter
        }

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
    
    def spawn(self):
        return {
            "commands": {
                "LIST": ListCommand()

            }