Exemplo n.º 1
0
    def net_cmd_mc(self, args):
        """ Play music.

        MC#<song_name:int>#<???:int>#%

        """
        if not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.INT):
            if not self.validate_net_cmd(args, self.ArgType.STR,
                                         self.ArgType.INT, self.ArgType.STR):
                return
        if args[1] != self.client.char_id:
            return
        try:
            area = self.server.area_manager.get_area_by_name(args[0])
            self.client.change_area(area)
        except AreaError:
            try:
                name, length = self.server.get_song_data(args[0])
                self.client.area.play_music(name, self.client.char_id, length)
                logger.log_server(
                    "[{}][{}]Changed music to {}.".format(
                        self.client.area.id, self.client.get_char_name(),
                        name),
                    self.client,
                )
            except ServerError:
                return
        except ClientError as ex:
            self.client.send_host_message(ex)
Exemplo n.º 2
0
def ooc_cmd_login(client, arg):
    if len(arg) == 0:
        raise ArgumentError("You must specify the password.")
    try:
        client.auth_mod(arg)
    except ClientError:
        raise
    client.send_host_message("Logged in as a moderator.")
    logger.log_server("Logged in as moderator.", client)
Exemplo n.º 3
0
def ooc_cmd_need(client, arg):
    if client.muted_adverts:
        raise ClientError("You have advertisements muted.")
    if len(arg) == 0:
        raise ArgumentError("You must specify what you need.")
    client.server.broadcast_need(client, arg)
    logger.log_server(
        "[{}][{}][NEED]{}.".format(client.area.id, client.get_char_name(), arg), client
    )
Exemplo n.º 4
0
def ooc_cmd_cleardoc(client, arg):
    if len(arg) != 0:
        raise ArgumentError("This command has no arguments.")
    client.send_host_message("Document cleared.")
    logger.log_server(
        "[{}][{}]Cleared document. Old link: {}".format(
            client.area.id, client.get_char_name(), client.area.doc
        )
    )
    client.area.change_doc()
Exemplo n.º 5
0
def ooc_cmd_g(client, arg):
    if client.muted_global:
        raise ClientError("You have the global chat muted.")
    if len(arg) == 0:
        raise ArgumentError("Can't send an empty message.")
    client.server.broadcast_global(client, arg)
    logger.log_server(
        "[{}][{}][GLOBAL]{}.".format(client.area.id, client.get_char_name(), arg),
        client,
    )
Exemplo n.º 6
0
def ooc_cmd_gm(client, arg):
    if not client.is_mod:
        raise ClientError("You must be authorized to do that.")
    if client.muted_global:
        raise ClientError("You have the global chat muted.")
    if len(arg) == 0:
        raise ArgumentError("Can't send an empty message.")
    client.server.broadcast_global(client, arg, True)
    logger.log_server(
        "[{}][{}][GLOBAL-MOD]{}.".format(client.area.id, client.get_char_name(), arg),
        client,
    )
Exemplo n.º 7
0
def ooc_cmd_coinflip(client, arg):
    if len(arg) != 0:
        raise ArgumentError("This command has no arguments.")
    coin = ["heads", "tails"]
    flip = random.choice(coin)
    client.area.send_host_message(
        "{} flipped a coin and got {}.".format(client.get_char_name(), flip)
    )
    logger.log_server(
        "[{}][{}]Used /coinflip and got {}.".format(
            client.area.id, client.get_char_name(), flip
        )
    )
Exemplo n.º 8
0
def ooc_cmd_play(client, arg):
    if not client.is_mod:
        raise ClientError("You must be authorized to do that.")
    if len(arg) == 0:
        raise ArgumentError("You must specify a song.")
    client.area.play_music(arg, client, -1)
    client.area.add_music_playing(client, arg)
    logger.log_server(
        "[{}][{}]Changed music to {}.".format(
            client.area.id, client.get_char_name(), arg
        ),
        client,
    )
Exemplo n.º 9
0
def ooc_cmd_unmute(client, arg):
    if not client.is_mod:
        raise ClientError("You must be authorized to do that.")
    if len(arg) == 0:
        raise ArgumentError("You must specify a target.")
    targets = client.server.client_manager.get_targets(client, arg)
    if targets:
        for c in targets:
            logger.log_server("Unmuted {}.".format(c.get_ip()), client)
            c.is_muted = False
        client.send_host_message("Unmuted {} existing client(s).".format(len(targets)))
    else:
        client.send_host_message("No targets found.")
Exemplo n.º 10
0
def ooc_cmd_announce(client, arg):
    if not client.is_mod:
        raise ClientError("You must be authorized to do that.")
    if len(arg) == 0:
        raise ArgumentError("Can't send an empty message.")
    client.server.send_all_cmd_pred(
        "CT",
        "{}".format(client.server.config["hostname"]),
        "=== Announcement ===\r\n{}\r\n==================".format(arg),
    )
    logger.log_server(
        "[{}][{}][ANNOUNCEMENT]{}.".format(client.area.id, client.get_char_name(), arg),
        client,
    )
Exemplo n.º 11
0
def ooc_cmd_lm(client, arg):
    if not client.is_mod:
        raise ClientError("You must be authorized to do that.")
    if len(arg) == 0:
        raise ArgumentError("Can't send an empty message.")
    client.area.send_command(
        "CT",
        "{}[MOD][{}]".format(client.server.config["hostname"], client.get_char_name()),
        arg,
    )
    logger.log_server(
        "[{}][{}][LOCAL-MOD]{}.".format(client.area.id, client.get_char_name(), arg),
        client,
    )
Exemplo n.º 12
0
 def change_character(self, char_id, force=False):
     if not self.server.is_valid_char_id(char_id):
         raise ClientError("Invalid Character ID.")
     if not force and not self.area.is_char_available(char_id):
         raise ClientError("Character not available.")
     old_char = self.get_char_name()
     self.char_id = char_id
     self.send_command("PV", self.id, "CID", self.char_id)
     logger.log_server(
         "[{}]Changed character from {} to {}.".format(
             self.area.id, old_char, self.get_char_name()
         ),
         self,
     )
Exemplo n.º 13
0
    def net_cmd_rt(self, args):
        """ Plays the Testimony/CE animation.

        RT#<type:string>#%

        """
        if not self.validate_net_cmd(args, self.ArgType.STR):
            return
        if args[0] not in ("testimony1", "testimony2", "notguilty", "guilty"):
            return
        self.client.area.send_command("RT", args[0])
        logger.log_server(
            "[{}]{} used a judge action".format(self.client.area.id,
                                                self.client.get_char_name()),
            self.client,
        )
Exemplo n.º 14
0
def ooc_cmd_ipban(client, arg):
    if not client.is_mod:
        raise ClientError("You must be authorized to do that.")
    ip = arg.strip()
    if len(ip) < 7:
        raise ArgumentError("You must specify an IP.")
    try:
        client.server.ban_manager.add_ban(ip)
    except ServerError:
        raise
    targets = client.server.client_manager.get_targets_by_ip(ip)
    if targets:
        for c in targets:
            c.disconnect()
        client.send_host_message("Kicked {} existing client(s).".format(len(targets)))
    client.send_host_message("Added {} to the banlist.".format(ip))
    logger.log_server("Banned {}.".format(ip), client)
Exemplo n.º 15
0
def ooc_cmd_status(client, arg):
    if len(arg) == 0:
        client.send_host_message("Current status: {}".format(client.area.status))
    else:
        try:
            client.area.change_status(arg)
            client.area.send_host_message(
                "{} changed status to {}.".format(
                    client.get_char_name(), client.area.status
                )
            )
            logger.log_server(
                "[{}][{}]Changed status to {}".format(
                    client.area.id, client.get_char_name(), client.area.status
                )
            )
        except AreaError:
            raise
Exemplo n.º 16
0
    def net_cmd_hp(self, args):
        """ Sets the penalty bar.

        HP#<type:int>#<new_value:int>#%

        """
        if not self.validate_net_cmd(args, self.ArgType.INT, self.ArgType.INT):
            return
        try:
            self.client.area.change_hp(args[0], args[1])
            logger.log_server(
                "[{}]{} changed HP ({}) to {}".format(
                    self.client.area.id, self.client.get_char_name(), args[0],
                    args[1]),
                self.client,
            )
        except AreaError:
            return
Exemplo n.º 17
0
def ooc_cmd_doc(client, arg):
    if len(arg) == 0:
        client.send_host_message("Document: {}".format(client.area.doc))
        logger.log_server(
            "[{}][{}]Requested document. Link: {}".format(
                client.area.id, client.get_char_name(), client.area.doc
            )
        )
    else:
        client.area.change_doc(arg)
        client.area.send_host_message(
            "{} changed the doc link.".format(client.get_char_name())
        )
        logger.log_server(
            "[{}][{}]Changed document to: {}".format(
                client.area.id, client.get_char_name(), arg
            )
        )
Exemplo n.º 18
0
def ooc_cmd_bg(client, arg):
    if len(arg) == 0:
        raise ArgumentError("You must specify a name. Use /bg <background>.")
    if not client.is_mod and client.area.bg_lock:
        raise AreaError("This area's background is locked")
    try:
        client.area.change_background(arg)
    except AreaError:
        raise
    client.area.send_host_message(
        "{} changed the background to {}.".format(client.get_char_name(), arg)
    )
    logger.log_server(
        "[{}][{}]Changed background to {}".format(
            client.area.id, client.get_char_name(), arg
        ),
        client,
    )
Exemplo n.º 19
0
def ooc_cmd_roll(client, arg):
    roll_max = 11037
    if len(arg) != 0:
        try:
            val = int(arg)
            if not 1 <= val <= roll_max:
                raise ArgumentError(
                    "Roll value must be between 1 and {}.".format(roll_max)
                )
        except ValueError:
            raise ArgumentError("Argument must be a number")
    else:
        val = 6
    roll = random.randint(1, val)
    client.area.send_host_message(
        "{} rolled {} out of {}.".format(client.get_char_name(), roll, val)
    )
    logger.log_server(
        "[{}][{}]Used /roll and got {} out of {}.".format(
            client.area.id, client.get_char_name(), roll, val
        )
    )
Exemplo n.º 20
0
    def change_area(self, area):
        if self.software != "AOClassic":
            raise ClientError("To change areas, you must use the AO Classic client.")
        if self.area == area:
            raise ClientError("You are already in this area.")
        old_area = self.area
        if not area.is_char_available(self.char_id):
            try:
                new_char_id = area.get_rand_avail_char_id()
            except AreaError:
                raise ClientError("No available characters in that area.")
            self.area.remove_client(self)
            self.area = area
            area.new_client(self)
            self.change_character(new_char_id)
            self.send_host_message(
                "Character taken, switched to {}.".format(self.get_char_name())
            )
        else:
            self.area.remove_client(self)
            self.area = area
            area.new_client(self)
        self.send_host_message("Changed area to {}.".format(area.name))
        logger.log_server(
            "[{}]Changed area from {} ({}) to {} ({}).".format(
                self.get_char_name(),
                old_area.name,
                old_area.id,
                self.area.name,
                self.area.id,
            ),
            self,
        )

        self.send_command("HP", 1, self.area.get_attr("health.defense"))
        self.send_command("HP", 2, self.area.get_attr("health.prosecution"))
        self.send_command("BN", self.area.get_attr("background.name"))
        self.send_evidence_list()
        self.server.send_arup_players()
Exemplo n.º 21
0
    def net_cmd_ct(self, args):
        """ OOC Message

        CT#<name:string>#<message:string>#%

        """
        if not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.STR):
            return
        ooc_name = args[0]
        if self.client.get_attr("ooc.name") != ooc_name:
            self.client.set_attr("ooc.name", ooc_name)
        if ooc_name.startswith(self.server.config["hostname"]
                               ) or ooc_name.startswith("<dollar>G"):
            self.client.send_host_message("That name is reserved!")
            return
        if args[1].startswith("/"):
            spl = args[1][1:].split(" ", 1)
            cmd = spl[0]
            arg = ""
            if len(spl) == 2:
                arg = spl[1][:256]
            try:
                getattr(commands, "ooc_cmd_{}".format(cmd))(self.client, arg)
            except AttributeError:
                self.client.send_host_message("Invalid command.")
            except (ClientError, AreaError, ArgumentError, ServerError) as ex:
                self.client.send_host_message(ex)
        else:
            self.client.area.send_command("CT", ooc_name, args[1])
            logger.log_server(
                "[OOC][{}][{}][{}]{}".format(
                    self.client.area.id,
                    self.client.get_char_name(),
                    ooc_name,
                    args[1],
                ),
                self.client,
            )
Exemplo n.º 22
0
    def net_cmd_zz(self, args):
        """ Sent on mod call.

        """
        if not self.validate_net_cmd(args, self.ArgType.STR):
            return

        msg = args[0][:80]

        self.client.send_host_message("Moderator called.")
        self.server.send_all_cmd_pred(
            "ZZ",
            "{} ({}) in {} ({}): {}".format(
                self.client.get_char_name(),
                self.client.get_ip(),
                self.client.area.name,
                self.client.area.id,
                msg,
            ),
            pred=lambda c: c.get_attr("is_moderator"),
        )
        logger.log_server("[{}]{} called a moderator with reason: {}.".format(
            self.client.area.id, self.client.get_char_name(), msg))
Exemplo n.º 23
0
            other_folder,
            other_emote,
            offset_pair,
            other_offset,
            other_flip,
            nonint_pre,
            loop_sfx,
            screenshake,
            frame_screenshake,
            frame_realization,
            frame_sfx,
        )
        self.client.area.set_next_msg_delay(len(msg))
        logger.log_server(
            "[IC][{}][{}]{}".format(self.client.area.id,
                                    self.client.get_char_name(), msg),
            self.client,
        )

    def net_cmd_ct(self, args):
        """ OOC Message

        CT#<name:string>#<message:string>#%

        """
        if not self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.STR):
            return
        ooc_name = args[0]
        if self.client.get_attr("ooc.name") != ooc_name:
            self.client.set_attr("ooc.name", ooc_name)
        if ooc_name.startswith(self.server.config["hostname"]