# Path: txircd/modbase.py
# class Module(object):
#     def hook(self, base):
#         self.ircd = base
#         return self


from txircd.modbase import Module
    
    def capAcknowledgeRemove(self, user, capability):
        return False
    
    def capClear(self, user, capability):
        return True
    
    def namesListEntry(self, user, channel, listingUser, representation):
        if "cap" not in user.cache or "multi-prefix" not in user.cache["cap"]:
            return representation
        while representation[0] in self.ircd.prefix_symbols:
            representation = representation[1:]
        statusModes = channel.users[listingUser]
        return "{}{}".format("".join([self.ircd.prefixes[status][0] for status in statusModes]), representation)
    
    def whoStatus(self, user, targetUser, filters, fields, channel, udata):
        if channel:
            udata["status"] = "".join([self.ircd.prefixes[status][0] for status in channel.users[targetUser]])
        return udata

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.multi_prefix = None
    
    def spawn(self):
        self.multi_prefix = MultiPrefix().hook(self.ircd)
        if "cap" not in self.ircd.module_data_cache:
            self.ircd.module_data_cache["cap"] = {}
        self.ircd.module_data_cache["cap"]["multi-prefix"] = self.multi_prefix

# Path: txircd/modbase.py
# class Module(object):
#     def hook(self, base):
#         self.ircd = base
#         return self


# Path: txircd/modules/ircv3_multi-prefix.py
from txircd.modbase import Module

    
    def capAcknowledgeRemove(self, user, capability):
        return False
    
    def capClear(self, user, capability):
        return True
    
    def namesListEntry(self, user, channel, listingUser, representation):
        if "cap" not in user.cache or "multi-prefix" not in user.cache["cap"]:
            return representation
        while representation[0] in self.ircd.prefix_symbols:
            representation = representation[1:]
        statusModes = channel.users[listingUser]
        return "{}{}".format("".join([self.ircd.prefixes[status][0] for status in statusModes]), representation)
    
    def whoStatus(self, user, targetUser, filters, fields, channel, udata):
        if channel:
            udata["status"] = "".join([self.ircd.prefixes[status][0] for status in channel.users[targetUser]])
        return udata

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.multi_prefix = None
    
    def spawn(self):
        self.multi_prefix = MultiPrefix().hook(self.ircd)
        if "cap" not in self.ircd.module_data_cache:
            self.ircd.module_data_cache["cap"] = {}
        self.ircd.module_data_cache["cap"]["multi-prefix"] = self.multi_prefix

        return {