# Path: txircd/modbase.py
# class Module(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
# 
# 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 Module
from txircd.utils import irc_lower
from fnmatch import fnmatch
        for channel in channels:
            lowerName = irc_lower(channel.name)
            safe = False
            if "channel_allowchans" in self.ircd.servconfig:
                for chanmask in self.ircd.servconfig["channel_allowchans"]:
                    if fnmatch(lowerName, irc_lower(chanmask)):
                        safe = True
            if not safe:
                for chanmask in self.ircd.servconfig["channel_denychans"]:
                    if fnmatch(lowerName, irc_lower(chanmask)):
                        remove.append(channel)
                        user.sendMessage(irc.ERR_CHANNOTALLOWED, channel.name, ":Channel {} is forbidden".format(channel.name))
                        break
        for chan in remove:
            index = channels.index(chan)
            channels.pop(index)
            keys.pop(index)
        data["targetchan"] = channels
        data["keys"] = keys
        return data

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.denychans = None
    
    def spawn(self):
        if "channel_denychans" not in self.ircd.servconfig:
            self.ircd.servconfig["channel_denychans"] = []
        self.denychans = DenychansModule().hook(self.ircd)

# Path: txircd/modbase.py
# class Module(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
# 
# Path: txircd/utils.py
# def irc_lower(str):
#     return str.lower().replace("[","{").replace("]","}").replace("/","|").replace("~","^")


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

        for channel in channels:
            lowerName = irc_lower(channel.name)
            safe = False
            if "channel_allowchans" in self.ircd.servconfig:
                for chanmask in self.ircd.servconfig["channel_allowchans"]:
                    if fnmatch(lowerName, irc_lower(chanmask)):
                        safe = True
            if not safe:
                for chanmask in self.ircd.servconfig["channel_denychans"]:
                    if fnmatch(lowerName, irc_lower(chanmask)):
                        remove.append(channel)
                        user.sendMessage(irc.ERR_CHANNOTALLOWED, channel.name, ":Channel {} is forbidden".format(channel.name))
                        break
        for chan in remove:
            index = channels.index(chan)
            channels.pop(index)
            keys.pop(index)
        data["targetchan"] = channels
        data["keys"] = keys
        return data

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.denychans = None
    
    def spawn(self):
        if "channel_denychans" not in self.ircd.servconfig:
            self.ircd.servconfig["channel_denychans"] = []
        self.denychans = DenychansModule().hook(self.ircd)

        return {