Exemplo n.º 1
0
    def load(self, sock, source, name):
        user = User.objects.filter(sock=sock).first()
        if not user.oper:
            yield ERR_NOPRIVILEGES()
            return

        name = str(name)  # We store plugin names as str (not unicode)

        result = yield self.call(load(name), "plugins")
        yield Message(u"NOTICE", u"*", result.value)
Exemplo n.º 2
0
    def unload(self, sock, source, name):
        user = User.objects.filter(sock=sock).first()
        if not user.oper:
            yield ERR_NOPRIVILEGES()
            return

        name = str(name)  # We store plugin names as str (not unicode)
        result = yield self.call(query(name), "plugins")

        if result.value is None:
            yield Message(u"NOTICE", u"*", u"No such plugin: {0}".format(name))
            return

        result = yield self.call(unload(name), "plugins")
        yield Message(u"NOTICE", u"*", result.value)
Exemplo n.º 3
0
    def restart(self, sock, source):
        user = User.objects.filter(sock=sock).first()
        if not user.oper:
            yield ERR_NOPRIVILEGES()
            return

        yield self.call(close(), "server")

        args = sys.argv[:]
        self.parent.logger.info(u("Restarting... Args: {0}".format(args)))

        args.insert(0, sys.executable)
        if sys.platform == 'win32':
            args = ["\"{0}\"".format(arg) for arg in args]

        os.execv(sys.executable, args)
Exemplo n.º 4
0
    def kill(self, sock, source, target, reason=None):
        user = User.objects.filter(sock=sock).first()
        if not user.oper:
            return ERR_NOPRIVILEGES()

        nick = User.objects.filter(nick=target).first()
        if nick is None:
            return ERR_NOSUCHNICK(target)

        reason = u("Killed: {0}").format(reason) if reason else nick.nick

        self.fire(
            response.create("quit",
                            nick.sock,
                            nick.source,
                            reason,
                            disconnect=False))
        self.fire(reply(nick.sock, ERROR(reason)), "server")
        Timer(1, close(nick.sock), "server").register(self)
Exemplo n.º 5
0
    def die(self, sock, source):
        user = User.objects.filter(sock=sock).first()
        if not user.oper:
            return ERR_NOPRIVILEGES()

        raise SystemExit(0)