# 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 notifyUsers(self, user, namespace, key, oldValue, value):
        try:
            user.nickname # Cause a failure if it's not a user
            if not (namespace == "ext" and key == "accountname"):
                return
            notify = set()
            for channel in self.ircd.channels.itervalues():
                if user in channel.users:
                    for u in channel.users.iterkeys():
                        notify.add(u)
            notify.remove(user)
            for u in notify:
                if "cap" in u.cache and "account-notify" in u.cache["cap"]:
                    u.sendMessage("ACCOUNT", value if value else "*", to=None, prefix=user.prefix())
        except:
            pass # This will fail very quickly if it's a channel.  Just do nothing in that case.

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.account_notify = None
    
    def spawn(self):
        self.account_notify = AccountNotify().hook(self.ircd)

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


# Path: txircd/modules/ircv3_account-notify.py
from txircd.modbase import Module

    def capAcknowledgeRemove(self, user, capability):
        return False
    
    def capClear(self, user, capability):
        return True
    
    def notifyUsers(self, user, namespace, key, oldValue, value):
        try:
            user.nickname # Cause a failure if it's not a user
            if not (namespace == "ext" and key == "accountname"):
                return
            notify = set()
            for channel in self.ircd.channels.itervalues():
                if user in channel.users:
                    for u in channel.users.iterkeys():
                        notify.add(u)
            notify.remove(user)
            for u in notify:
                if "cap" in u.cache and "account-notify" in u.cache["cap"]:
                    u.sendMessage("ACCOUNT", value if value else "*", to=None, prefix=user.prefix())
        except:
            pass # This will fail very quickly if it's a channel.  Just do nothing in that case.

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.account_notify = None
    
    def spawn(self):
        self.account_notify = AccountNotify().hook(self.ircd)

        if "cap" not in self.ircd.module_data_cache: