diff --git a/server/aoprotocol.py b/server/aoprotocol.py index 5dbb192..8516c9f 100644 --- a/server/aoprotocol.py +++ b/server/aoprotocol.py @@ -403,6 +403,8 @@ class AOProtocol(asyncio.Protocol): if pos not in ('def', 'pro', 'hld', 'hlp', 'jud', 'wit'): return msg = text[:256] + if self.client.shaken: + msg = self.client.shake_message(msg) if self.client.disemvowel: msg = self.client.disemvowel_message(msg) self.client.pos = pos @@ -463,6 +465,8 @@ class AOProtocol(asyncio.Protocol): except (ClientError, AreaError, ArgumentError, ServerError) as ex: self.client.send_host_message(ex) else: + if self.client.shaken: + args[1] = self.client.shake_message(args[1]) if self.client.disemvowel: args[1] = self.client.disemvowel_message(args[1]) self.client.area.send_command('CT', self.client.name, args[1]) diff --git a/server/client_manager.py b/server/client_manager.py index 37d6f5b..b11937c 100644 --- a/server/client_manager.py +++ b/server/client_manager.py @@ -47,6 +47,7 @@ class ClientManager: self.is_cm = False self.evi_list = [] self.disemvowel = False + self.shaken = False self.muted_global = False self.muted_adverts = False self.is_muted = False @@ -334,6 +335,13 @@ class ClientManager: def disemvowel_message(self, message): message = re.sub("[aeiou]", "", message, flags=re.IGNORECASE) return re.sub(r"\s+", " ", message) + + def shake_message(self, message): + import random + parts = message.split() + random.shuffle(parts) + return ' '.join(parts) + def __init__(self, server): self.clients = set() diff --git a/server/commands.py b/server/commands.py index fab23d1..c1d5ba8 100644 --- a/server/commands.py +++ b/server/commands.py @@ -855,7 +855,7 @@ def ooc_cmd_undisemvowel(client, arg): try: targets = client.server.client_manager.get_targets(client, TargetType.ID, int(arg), False) except: - raise ArgumentError('You must specify a target. Use /disemvowel .') + raise ArgumentError('You must specify a target. Use /undisemvowel .') if targets: for c in targets: logger.log_server('Undisemvowelling {}.'.format(c.get_ip()), client) @@ -865,6 +865,42 @@ def ooc_cmd_undisemvowel(client, arg): else: client.send_host_message('No targets found.') +def ooc_cmd_shake(client, arg): + if not client.is_mod: + raise ClientError('You must be authorized to do that.') + elif len(arg) == 0: + raise ArgumentError('You must specify a target.') + try: + targets = client.server.client_manager.get_targets(client, TargetType.ID, int(arg), False) + except: + raise ArgumentError('You must specify a target. Use /shake .') + if targets: + for c in targets: + logger.log_server('Shaking {}.'.format(c.get_ip()), client) + logger.log_mod('Shaking {}.'.format(c.get_ip()), client) + c.shaken = True + client.send_host_message('Shook {} existing client(s).'.format(len(targets))) + else: + client.send_host_message('No targets found.') + +def ooc_cmd_unshake(client, arg): + if not client.is_mod: + raise ClientError('You must be authorized to do that.') + elif len(arg) == 0: + raise ArgumentError('You must specify a target.') + try: + targets = client.server.client_manager.get_targets(client, TargetType.ID, int(arg), False) + except: + raise ArgumentError('You must specify a target. Use /unshake .') + if targets: + for c in targets: + logger.log_server('Unshaking {}.'.format(c.get_ip()), client) + logger.log_mod('Unshaking {}.'.format(c.get_ip()), client) + c.shaken = False + client.send_host_message('Unshook {} existing client(s).'.format(len(targets))) + else: + client.send_host_message('No targets found.') + def ooc_cmd_blockdj(client, arg): if not client.is_mod: raise ClientError('You must be authorized to do that.')