aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-09-02 22:51:20 +0200
committerCerapter <cerap@protonmail.com>2018-09-02 22:51:20 +0200
commitc8142f3f53ba926b4e5ab729ed1ca8c47998d4df (patch)
treecc8e0b01f371bcce12b8423903e7f6f66e2ef2a9
parent34d6f6fa544ca90140e138c557fa651c74d76d4a (diff)
Curse added: `/shake id`, `/unshake id`.
Randomises word order in IC and OOC chat.
-rw-r--r--server/aoprotocol.py4
-rw-r--r--server/client_manager.py8
-rw-r--r--server/commands.py38
3 files changed, 49 insertions, 1 deletions
diff --git a/server/aoprotocol.py b/server/aoprotocol.py
index 5dbb192e..8516c9f8 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 37d6f5b2..b11937c1 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 fab23d13..c1d5ba86 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 <id>.')
+ raise ArgumentError('You must specify a target. Use /undisemvowel <id>.')
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 <id>.')
+ 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 <id>.')
+ 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.')