# 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

class NSAccountCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_nickserv_nick"], "ACCOUNT {}".format(" ".join(data["params"]))])

class NSCertCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_nickserv_nick"], "CERT {}".format(" ".join(data["params"]))])

class CSRegisterCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_chanserv_nick"], "REGISTER {}".format(" ".join(data["params"]))])

class CSAccessCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_chanserv_nick"], "ACCESS {}".format(" ".join(data["params"]))])

class CSCdropCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_chanserv_nick"], "CDROP {}".format(" ".join(data["params"]))])

class BSStartCommand(Command):
    def __init__(self, module):
        self.module = module
    
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_bidserv_nick"], "START {}".format(" ".join(data["params"]))])
    
    def processParams(self, user, params):
        if user.registered > 0:

# 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/db_services_leaf.py
from twisted.words.protocols import irc
from txircd.modbase import Command
from txircd.utils import irc_lower


class NSAccountCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_nickserv_nick"], "ACCOUNT {}".format(" ".join(data["params"]))])

class NSCertCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_nickserv_nick"], "CERT {}".format(" ".join(data["params"]))])

class CSRegisterCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_chanserv_nick"], "REGISTER {}".format(" ".join(data["params"]))])

class CSAccessCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_chanserv_nick"], "ACCESS {}".format(" ".join(data["params"]))])

class CSCdropCommand(Command):
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_chanserv_nick"], "CDROP {}".format(" ".join(data["params"]))])

class BSStartCommand(Command):
    def __init__(self, module):
        self.module = module
    
    def onUse(self, user, data):
        user.handleCommand("PRIVMSG", None, [self.ircd.servconfig["services_bidserv_nick"], "START {}".format(" ".join(data["params"]))])
    
    def processParams(self, user, params):
        if user.registered > 0:

            user.sendMessage(irc.ERR_NOTREGISTERED, "START", ":You have not registered")