Curse added: /shake id, /unshake id.

Randomises word order in IC and OOC chat.
This commit is contained in:
Cerapter 2018-09-02 22:51:20 +02:00
parent 34d6f6fa54
commit c8142f3f53
3 changed files with 49 additions and 1 deletions

View File

@ -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])

View File

@ -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
@ -335,6 +336,13 @@ class ClientManager:
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()
self.server = server

View File

@ -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.')