# 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/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.server import ModuleMessage
from txircd.utils import irc_lower
from fnmatch import fnmatch
            if fnmatch(irc_lower(server.name), serverMask):
                server.callRemote(ModuleMessage, destserver=server.name, type="Rehash", args=[])
                user.sendMessage(irc.RPL_REHASHING, self.ircd.config, ":Rehashing {}".format(server.name))
    
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "REHASH", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the required operator privileges")
            return {}
        if params:
            return {
                "user": user,
                "servers": params[0]
            }
        return {
            "user": user,
            "servers": self.ircd.name
        }
    
    def remoteRehash(self, command, args):
        self.ircd.rehash()

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.rehash_cmd = None
    
    def spawn(self):

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


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

            if fnmatch(irc_lower(server.name), serverMask):
                server.callRemote(ModuleMessage, destserver=server.name, type="Rehash", args=[])
                user.sendMessage(irc.RPL_REHASHING, self.ircd.config, ":Rehashing {}".format(server.name))
    
    def processParams(self, user, params):
        if user.registered > 0:
            user.sendMessage(irc.ERR_NOTREGISTERED, "REHASH", ":You have not registered")
            return {}
        if "o" not in user.mode:
            user.sendMessage(irc.ERR_NOPRIVILEGES, ":Permission denied - You do not have the required operator privileges")
            return {}
        if params:
            return {
                "user": user,
                "servers": params[0]
            }
        return {
            "user": user,
            "servers": self.ircd.name
        }
    
    def remoteRehash(self, command, args):
        self.ircd.rehash()

class Spawner(object):
    def __init__(self, ircd):
        self.ircd = ircd
        self.rehash_cmd = None
    
    def spawn(self):

        self.rehash_cmd = RehashCommand()