BEGINNINGS! of the multi-CM system.
- Allows people to become CMs of multiple areas. - Allows people to appoint CMs besides themselves using `/cm id]`. - CMs can now freely leave the areas they CM in without losing CM status. - CMs that own an area, but aren't there, still show up in them when using `/getarea` with the `[RCM]` = Remote Case Manager tag. - CMs get all IC and OOC messages from their areas. - CMs can use `/s` to send a message to all the areas they own, or `/a [area_id]` to send a message only to a specific area. This is usable both IC and OOC.
This commit is contained in:
parent
3de7e346ba
commit
0156849cc2
@ -336,6 +336,8 @@ class AOProtocol(asyncio.Protocol):
|
|||||||
if not self.client.area.can_send_message(self.client):
|
if not self.client.area.can_send_message(self.client):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
target_area = []
|
||||||
|
|
||||||
if self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.STR_OR_EMPTY, self.ArgType.STR,
|
if self.validate_net_cmd(args, self.ArgType.STR, self.ArgType.STR_OR_EMPTY, self.ArgType.STR,
|
||||||
self.ArgType.STR,
|
self.ArgType.STR,
|
||||||
self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.INT,
|
self.ArgType.STR, self.ArgType.STR, self.ArgType.STR, self.ArgType.INT,
|
||||||
@ -399,6 +401,28 @@ class AOProtocol(asyncio.Protocol):
|
|||||||
if len(re.sub(r'[{}\\`|(~~)]','', text).replace(' ', '')) < 3 and text != '<' and text != '>':
|
if len(re.sub(r'[{}\\`|(~~)]','', text).replace(' ', '')) < 3 and text != '<' and text != '>':
|
||||||
self.client.send_host_message("While that is not a blankpost, it is still pretty spammy. Try forming sentences.")
|
self.client.send_host_message("While that is not a blankpost, it is still pretty spammy. Try forming sentences.")
|
||||||
return
|
return
|
||||||
|
if text.startswith('/a'):
|
||||||
|
part = text.split(' ')
|
||||||
|
try:
|
||||||
|
aid = int(part[1])
|
||||||
|
if self.client in self.server.area_manager.get_area_by_id(aid).owners:
|
||||||
|
target_area.append(aid)
|
||||||
|
if not target_area:
|
||||||
|
self.client.send_host_message('You don\'t own {}!'.format(self.server.area_manager.get_area_by_id(aid).name))
|
||||||
|
return
|
||||||
|
text = ' '.join(part[2:])
|
||||||
|
except ValueError:
|
||||||
|
self.client.send_host_message("That does not look like a valid area ID!")
|
||||||
|
return
|
||||||
|
elif text.startswith('/s'):
|
||||||
|
part = text.split(' ')
|
||||||
|
for a in self.server.area_manager.areas:
|
||||||
|
if self.client in a.owners:
|
||||||
|
target_area.append(a.id)
|
||||||
|
if not target_area:
|
||||||
|
self.client.send_host_message('You don\'t any areas!')
|
||||||
|
return
|
||||||
|
text = ' '.join(part[1:])
|
||||||
if msg_type not in ('chat', '0', '1'):
|
if msg_type not in ('chat', '0', '1'):
|
||||||
return
|
return
|
||||||
if anim_type not in (0, 1, 2, 5, 6):
|
if anim_type not in (0, 1, 2, 5, 6):
|
||||||
@ -441,7 +465,7 @@ class AOProtocol(asyncio.Protocol):
|
|||||||
button = 0
|
button = 0
|
||||||
# Turn off the ding.
|
# Turn off the ding.
|
||||||
ding = 0
|
ding = 0
|
||||||
if color == 2 and not (self.client.is_mod or self.client.is_cm):
|
if color == 2 and not (self.client.is_mod or self.client in self.client.area.owners):
|
||||||
color = 0
|
color = 0
|
||||||
if color == 6:
|
if color == 6:
|
||||||
text = re.sub(r'[^\x00-\x7F]+',' ', text) #remove all unicode to prevent redtext abuse
|
text = re.sub(r'[^\x00-\x7F]+',' ', text) #remove all unicode to prevent redtext abuse
|
||||||
@ -498,6 +522,15 @@ class AOProtocol(asyncio.Protocol):
|
|||||||
self.client.area.send_command('MS', msg_type, pre, folder, anim, msg, pos, sfx, anim_type, cid,
|
self.client.area.send_command('MS', msg_type, pre, folder, anim, msg, pos, sfx, anim_type, cid,
|
||||||
sfx_delay, button, self.client.evi_list[evidence], flip, ding, color, showname,
|
sfx_delay, button, self.client.evi_list[evidence], flip, ding, color, showname,
|
||||||
charid_pair, other_folder, other_emote, offset_pair, other_offset, other_flip, nonint_pre)
|
charid_pair, other_folder, other_emote, offset_pair, other_offset, other_flip, nonint_pre)
|
||||||
|
|
||||||
|
self.client.area.send_owner_command('MS', msg_type, pre, folder, anim, '[' + self.client.area.abbreviation + ']' + msg, pos, sfx, anim_type, cid,
|
||||||
|
sfx_delay, button, self.client.evi_list[evidence], flip, ding, color, showname,
|
||||||
|
charid_pair, other_folder, other_emote, offset_pair, other_offset, other_flip, nonint_pre)
|
||||||
|
|
||||||
|
self.server.area_manager.send_remote_command(target_area, 'MS', msg_type, pre, folder, anim, msg, pos, sfx, anim_type, cid,
|
||||||
|
sfx_delay, button, self.client.evi_list[evidence], flip, ding, color, showname,
|
||||||
|
charid_pair, other_folder, other_emote, offset_pair, other_offset, other_flip, nonint_pre)
|
||||||
|
|
||||||
self.client.area.set_next_msg_delay(len(msg))
|
self.client.area.set_next_msg_delay(len(msg))
|
||||||
logger.log_server('[IC][{}][{}]{}'.format(self.client.area.abbreviation, self.client.get_char_name(), msg), self.client)
|
logger.log_server('[IC][{}][{}]{}'.format(self.client.area.abbreviation, self.client.get_char_name(), msg), self.client)
|
||||||
|
|
||||||
@ -557,6 +590,7 @@ class AOProtocol(asyncio.Protocol):
|
|||||||
if self.client.disemvowel:
|
if self.client.disemvowel:
|
||||||
args[1] = self.client.disemvowel_message(args[1])
|
args[1] = self.client.disemvowel_message(args[1])
|
||||||
self.client.area.send_command('CT', self.client.name, args[1])
|
self.client.area.send_command('CT', self.client.name, args[1])
|
||||||
|
self.client.area.send_owner_command('CT', '[' + self.client.area.abbreviation + ']' + self.client.name, args[1])
|
||||||
logger.log_server(
|
logger.log_server(
|
||||||
'[OOC][{}][{}]{}'.format(self.client.area.abbreviation, self.client.get_char_name(),
|
'[OOC][{}][{}]{}'.format(self.client.area.abbreviation, self.client.get_char_name(),
|
||||||
args[1]), self.client)
|
args[1]), self.client)
|
||||||
|
@ -54,7 +54,6 @@ class AreaManager:
|
|||||||
self.showname_changes_allowed = showname_changes_allowed
|
self.showname_changes_allowed = showname_changes_allowed
|
||||||
self.shouts_allowed = shouts_allowed
|
self.shouts_allowed = shouts_allowed
|
||||||
self.abbreviation = abbreviation
|
self.abbreviation = abbreviation
|
||||||
self.owned = False
|
|
||||||
self.cards = dict()
|
self.cards = dict()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -71,6 +70,8 @@ class AreaManager:
|
|||||||
self.jukebox_votes = []
|
self.jukebox_votes = []
|
||||||
self.jukebox_prev_char_id = -1
|
self.jukebox_prev_char_id = -1
|
||||||
|
|
||||||
|
self.owners = []
|
||||||
|
|
||||||
class Locked(Enum):
|
class Locked(Enum):
|
||||||
FREE = 1,
|
FREE = 1,
|
||||||
SPECTATABLE = 2,
|
SPECTATABLE = 2,
|
||||||
@ -84,12 +85,6 @@ class AreaManager:
|
|||||||
self.clients.remove(client)
|
self.clients.remove(client)
|
||||||
if len(self.clients) == 0:
|
if len(self.clients) == 0:
|
||||||
self.change_status('IDLE')
|
self.change_status('IDLE')
|
||||||
if client.is_cm:
|
|
||||||
client.is_cm = False
|
|
||||||
self.owned = False
|
|
||||||
self.server.area_manager.send_arup_cms()
|
|
||||||
if self.is_locked != self.Locked.FREE:
|
|
||||||
self.unlock()
|
|
||||||
|
|
||||||
def unlock(self):
|
def unlock(self):
|
||||||
self.is_locked = self.Locked.FREE
|
self.is_locked = self.Locked.FREE
|
||||||
@ -102,6 +97,8 @@ class AreaManager:
|
|||||||
self.is_locked = self.Locked.SPECTATABLE
|
self.is_locked = self.Locked.SPECTATABLE
|
||||||
for i in self.clients:
|
for i in self.clients:
|
||||||
self.invite_list[i.id] = None
|
self.invite_list[i.id] = None
|
||||||
|
for i in self.owners:
|
||||||
|
self.invite_list[i.id] = None
|
||||||
self.server.area_manager.send_arup_lock()
|
self.server.area_manager.send_arup_lock()
|
||||||
self.send_host_message('This area is spectatable now.')
|
self.send_host_message('This area is spectatable now.')
|
||||||
|
|
||||||
@ -109,6 +106,8 @@ class AreaManager:
|
|||||||
self.is_locked = self.Locked.LOCKED
|
self.is_locked = self.Locked.LOCKED
|
||||||
for i in self.clients:
|
for i in self.clients:
|
||||||
self.invite_list[i.id] = None
|
self.invite_list[i.id] = None
|
||||||
|
for i in self.owners:
|
||||||
|
self.invite_list[i.id] = None
|
||||||
self.server.area_manager.send_arup_lock()
|
self.server.area_manager.send_arup_lock()
|
||||||
self.send_host_message('This area is locked now.')
|
self.send_host_message('This area is locked now.')
|
||||||
|
|
||||||
@ -125,8 +124,14 @@ class AreaManager:
|
|||||||
for c in self.clients:
|
for c in self.clients:
|
||||||
c.send_command(cmd, *args)
|
c.send_command(cmd, *args)
|
||||||
|
|
||||||
|
def send_owner_command(self, cmd, *args):
|
||||||
|
for c in self.owners:
|
||||||
|
if not c in self.clients:
|
||||||
|
c.send_command(cmd, *args)
|
||||||
|
|
||||||
def send_host_message(self, msg):
|
def send_host_message(self, msg):
|
||||||
self.send_command('CT', self.server.config['hostname'], msg, '1')
|
self.send_command('CT', self.server.config['hostname'], msg, '1')
|
||||||
|
self.send_owner_command('CT', '[' + self.abbreviation + ']' + self.server.config['hostname'], msg, '1')
|
||||||
|
|
||||||
def set_next_msg_delay(self, msg_length):
|
def set_next_msg_delay(self, msg_length):
|
||||||
delay = min(3000, 100 + 60 * msg_length)
|
delay = min(3000, 100 + 60 * msg_length)
|
||||||
@ -301,6 +306,14 @@ class AreaManager:
|
|||||||
for client in self.clients:
|
for client in self.clients:
|
||||||
client.send_command('LE', *self.get_evidence_list(client))
|
client.send_command('LE', *self.get_evidence_list(client))
|
||||||
|
|
||||||
|
def get_cms(self):
|
||||||
|
msg = ''
|
||||||
|
for i in self.owners:
|
||||||
|
msg = msg + '[' + str(i.id) + '] ' + i.get_char_name() + ', '
|
||||||
|
if len(msg) > 2:
|
||||||
|
msg = msg[:-2]
|
||||||
|
return msg
|
||||||
|
|
||||||
class JukeboxVote:
|
class JukeboxVote:
|
||||||
def __init__(self, client, name, length, showname):
|
def __init__(self, client, name, length, showname):
|
||||||
self.client = client
|
self.client = client
|
||||||
@ -366,6 +379,11 @@ class AreaManager:
|
|||||||
else:
|
else:
|
||||||
return name.upper()
|
return name.upper()
|
||||||
|
|
||||||
|
def send_remote_command(self, area_ids, cmd, *args):
|
||||||
|
for a_id in area_ids:
|
||||||
|
self.get_area_by_id(a_id).send_command(cmd, *args)
|
||||||
|
self.get_area_by_id(a_id).send_owner_command(cmd, *args)
|
||||||
|
|
||||||
def send_arup_players(self):
|
def send_arup_players(self):
|
||||||
players_list = [0]
|
players_list = [0]
|
||||||
for area in self.areas:
|
for area in self.areas:
|
||||||
@ -382,9 +400,8 @@ class AreaManager:
|
|||||||
cms_list = [2]
|
cms_list = [2]
|
||||||
for area in self.areas:
|
for area in self.areas:
|
||||||
cm = 'FREE'
|
cm = 'FREE'
|
||||||
for client in area.clients:
|
if len(area.owners) > 0:
|
||||||
if client.is_cm:
|
cm = area.get_cms()
|
||||||
cm = client.get_char_name()
|
|
||||||
cms_list.append(cm)
|
cms_list.append(cm)
|
||||||
self.server.send_arup(cms_list)
|
self.server.send_arup(cms_list)
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ class ClientManager:
|
|||||||
self.is_dj = True
|
self.is_dj = True
|
||||||
self.can_wtce = True
|
self.can_wtce = True
|
||||||
self.pos = ''
|
self.pos = ''
|
||||||
self.is_cm = False
|
|
||||||
self.evi_list = []
|
self.evi_list = []
|
||||||
self.disemvowel = False
|
self.disemvowel = False
|
||||||
self.shaken = False
|
self.shaken = False
|
||||||
@ -140,7 +139,7 @@ class ClientManager:
|
|||||||
.format(self.area.abbreviation, old_char, self.get_char_name()), self)
|
.format(self.area.abbreviation, old_char, self.get_char_name()), self)
|
||||||
|
|
||||||
def change_music_cd(self):
|
def change_music_cd(self):
|
||||||
if self.is_mod or self.is_cm:
|
if self.is_mod or self in self.area.owners:
|
||||||
return 0
|
return 0
|
||||||
if self.mus_mute_time:
|
if self.mus_mute_time:
|
||||||
if time.time() - self.mus_mute_time < self.server.config['music_change_floodguard']['mute_length']:
|
if time.time() - self.mus_mute_time < self.server.config['music_change_floodguard']['mute_length']:
|
||||||
@ -157,7 +156,7 @@ class ClientManager:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def wtce_mute(self):
|
def wtce_mute(self):
|
||||||
if self.is_mod or self.is_cm:
|
if self.is_mod or self in self.area.owners:
|
||||||
return 0
|
return 0
|
||||||
if self.wtce_mute_time:
|
if self.wtce_mute_time:
|
||||||
if time.time() - self.wtce_mute_time < self.server.config['wtce_floodguard']['mute_length']:
|
if time.time() - self.wtce_mute_time < self.server.config['wtce_floodguard']['mute_length']:
|
||||||
@ -218,10 +217,8 @@ class ClientManager:
|
|||||||
msg = '=== Areas ==='
|
msg = '=== Areas ==='
|
||||||
for i, area in enumerate(self.server.area_manager.areas):
|
for i, area in enumerate(self.server.area_manager.areas):
|
||||||
owner = 'FREE'
|
owner = 'FREE'
|
||||||
if area.owned:
|
if len(area.owners) > 0:
|
||||||
for client in [x for x in area.clients if x.is_cm]:
|
owner = 'CM: {}'.format(area.get_cms())
|
||||||
owner = 'CM: {}'.format(client.get_char_name())
|
|
||||||
break
|
|
||||||
lock = {area.Locked.FREE: '', area.Locked.SPECTATABLE: '[SPECTATABLE]', area.Locked.LOCKED: '[LOCKED]'}
|
lock = {area.Locked.FREE: '', area.Locked.SPECTATABLE: '[SPECTATABLE]', area.Locked.LOCKED: '[LOCKED]'}
|
||||||
msg += '\r\nArea {}: {} (users: {}) [{}][{}]{}'.format(area.abbreviation, area.name, len(area.clients), area.status, owner, lock[area.is_locked])
|
msg += '\r\nArea {}: {} (users: {}) [{}][{}]{}'.format(area.abbreviation, area.name, len(area.clients), area.status, owner, lock[area.is_locked])
|
||||||
if self.area == area:
|
if self.area == area:
|
||||||
@ -244,12 +241,18 @@ class ClientManager:
|
|||||||
for client in area.clients:
|
for client in area.clients:
|
||||||
if (not mods) or client.is_mod:
|
if (not mods) or client.is_mod:
|
||||||
sorted_clients.append(client)
|
sorted_clients.append(client)
|
||||||
|
for owner in area.owners:
|
||||||
|
if not (mods or owner in area.clients):
|
||||||
|
sorted_clients.append(owner)
|
||||||
if not sorted_clients:
|
if not sorted_clients:
|
||||||
return ''
|
return ''
|
||||||
sorted_clients = sorted(sorted_clients, key=lambda x: x.get_char_name())
|
sorted_clients = sorted(sorted_clients, key=lambda x: x.get_char_name())
|
||||||
for c in sorted_clients:
|
for c in sorted_clients:
|
||||||
info += '\r\n'
|
info += '\r\n'
|
||||||
if c.is_cm:
|
if c in area.owners:
|
||||||
|
if not c in area.clients:
|
||||||
|
info += '[RCM]'
|
||||||
|
else:
|
||||||
info +='[CM]'
|
info +='[CM]'
|
||||||
info += '[{}] {}'.format(c.id, c.get_char_name())
|
info += '[{}] {}'.format(c.id, c.get_char_name())
|
||||||
if self.is_mod:
|
if self.is_mod:
|
||||||
@ -266,7 +269,7 @@ class ClientManager:
|
|||||||
cnt = 0
|
cnt = 0
|
||||||
info = '\n== Area List =='
|
info = '\n== Area List =='
|
||||||
for i in range(len(self.server.area_manager.areas)):
|
for i in range(len(self.server.area_manager.areas)):
|
||||||
if len(self.server.area_manager.areas[i].clients) > 0:
|
if len(self.server.area_manager.areas[i].clients) > 0 or len(self.server.area_manager.areas[i].owners) > 0:
|
||||||
cnt += len(self.server.area_manager.areas[i].clients)
|
cnt += len(self.server.area_manager.areas[i].clients)
|
||||||
info += '{}'.format(self.get_area_info(i, mods))
|
info += '{}'.format(self.get_area_info(i, mods))
|
||||||
info = 'Current online: {}'.format(cnt) + info
|
info = 'Current online: {}'.format(cnt) + info
|
||||||
@ -382,6 +385,13 @@ class ClientManager:
|
|||||||
def remove_client(self, client):
|
def remove_client(self, client):
|
||||||
if client.area.jukebox:
|
if client.area.jukebox:
|
||||||
client.area.remove_jukebox_vote(client, True)
|
client.area.remove_jukebox_vote(client, True)
|
||||||
|
for a in self.server.area_manager.areas:
|
||||||
|
if client in a.owners:
|
||||||
|
a.owners.remove(client)
|
||||||
|
client.server.area_manager.send_arup_cms()
|
||||||
|
if len(a.owners) == 0:
|
||||||
|
if a.is_locked != a.Locked.FREE:
|
||||||
|
a.unlock()
|
||||||
heappush(self.cur_id, client.id)
|
heappush(self.cur_id, client.id)
|
||||||
self.clients.remove(client)
|
self.clients.remove(client)
|
||||||
|
|
||||||
|
@ -23,6 +23,34 @@ from server.constants import TargetType
|
|||||||
from server import logger
|
from server import logger
|
||||||
from server.exceptions import ClientError, ServerError, ArgumentError, AreaError
|
from server.exceptions import ClientError, ServerError, ArgumentError, AreaError
|
||||||
|
|
||||||
|
def ooc_cmd_a(client, arg):
|
||||||
|
if len(arg) == 0:
|
||||||
|
raise ArgumentError('You must specify an area.')
|
||||||
|
arg = arg.split(' ')
|
||||||
|
|
||||||
|
try:
|
||||||
|
area = client.server.area_manager.get_area_by_id(int(arg[0]))
|
||||||
|
except AreaError:
|
||||||
|
raise
|
||||||
|
|
||||||
|
message_areas_cm(client, [area], ' '.join(arg[1:]))
|
||||||
|
|
||||||
|
def ooc_cmd_s(client, arg):
|
||||||
|
areas = []
|
||||||
|
for a in client.server.area_manager.areas:
|
||||||
|
if client in a.owners:
|
||||||
|
areas.append(a)
|
||||||
|
if not areas:
|
||||||
|
client.send_host_message('You aren\'t a CM in any area!')
|
||||||
|
return
|
||||||
|
message_areas_cm(client, areas, arg)
|
||||||
|
|
||||||
|
def message_areas_cm(client, areas, message):
|
||||||
|
for a in areas:
|
||||||
|
if not client in a.owners:
|
||||||
|
client.send_host_message('You are not a CM in {}!'.format(a.name))
|
||||||
|
return
|
||||||
|
a.send_command('CT', client.name, message)
|
||||||
|
|
||||||
def ooc_cmd_switch(client, arg):
|
def ooc_cmd_switch(client, arg):
|
||||||
if len(arg) == 0:
|
if len(arg) == 0:
|
||||||
@ -90,7 +118,7 @@ def ooc_cmd_allow_iniswap(client, arg):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def ooc_cmd_allow_blankposting(client, arg):
|
def ooc_cmd_allow_blankposting(client, arg):
|
||||||
if not client.is_mod and not client.is_cm:
|
if not client.is_mod and not client in client.area.owners:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
client.area.blankposting_allowed = not client.area.blankposting_allowed
|
client.area.blankposting_allowed = not client.area.blankposting_allowed
|
||||||
answer = {True: 'allowed', False: 'forbidden'}
|
answer = {True: 'allowed', False: 'forbidden'}
|
||||||
@ -98,7 +126,7 @@ def ooc_cmd_allow_blankposting(client, arg):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def ooc_cmd_force_nonint_pres(client, arg):
|
def ooc_cmd_force_nonint_pres(client, arg):
|
||||||
if not client.is_mod and not client.is_cm:
|
if not client.is_mod and not client in client.area.owners:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
client.area.non_int_pres_only = not client.area.non_int_pres_only
|
client.area.non_int_pres_only = not client.area.non_int_pres_only
|
||||||
answer = {True: 'non-interrupting only', False: 'non-interrupting or interrupting as you choose'}
|
answer = {True: 'non-interrupting only', False: 'non-interrupting or interrupting as you choose'}
|
||||||
@ -179,7 +207,7 @@ def ooc_cmd_currentmusic(client, arg):
|
|||||||
client.area.current_music_player))
|
client.area.current_music_player))
|
||||||
|
|
||||||
def ooc_cmd_jukebox_toggle(client, arg):
|
def ooc_cmd_jukebox_toggle(client, arg):
|
||||||
if not client.is_mod and not client.is_cm:
|
if not client.is_mod and not client in client.area.owners:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
if len(arg) != 0:
|
if len(arg) != 0:
|
||||||
raise ArgumentError('This command has no arguments.')
|
raise ArgumentError('This command has no arguments.')
|
||||||
@ -188,7 +216,7 @@ def ooc_cmd_jukebox_toggle(client, arg):
|
|||||||
client.area.send_host_message('{} [{}] has set the jukebox to {}.'.format(client.get_char_name(), client.id, client.area.jukebox))
|
client.area.send_host_message('{} [{}] has set the jukebox to {}.'.format(client.get_char_name(), client.id, client.area.jukebox))
|
||||||
|
|
||||||
def ooc_cmd_jukebox_skip(client, arg):
|
def ooc_cmd_jukebox_skip(client, arg):
|
||||||
if not client.is_mod and not client.is_cm:
|
if not client.is_mod and not client in client.area.owners:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
if len(arg) != 0:
|
if len(arg) != 0:
|
||||||
raise ArgumentError('This command has no arguments.')
|
raise ArgumentError('This command has no arguments.')
|
||||||
@ -276,7 +304,7 @@ def ooc_cmd_pos(client, arg):
|
|||||||
client.send_host_message('Position changed.')
|
client.send_host_message('Position changed.')
|
||||||
|
|
||||||
def ooc_cmd_forcepos(client, arg):
|
def ooc_cmd_forcepos(client, arg):
|
||||||
if not client.is_cm and not client.is_mod:
|
if not client in client.area.owners and not client.is_mod:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
|
|
||||||
args = arg.split()
|
args = arg.split()
|
||||||
@ -689,25 +717,55 @@ def ooc_cmd_evi_swap(client, arg):
|
|||||||
def ooc_cmd_cm(client, arg):
|
def ooc_cmd_cm(client, arg):
|
||||||
if 'CM' not in client.area.evidence_mod:
|
if 'CM' not in client.area.evidence_mod:
|
||||||
raise ClientError('You can\'t become a CM in this area')
|
raise ClientError('You can\'t become a CM in this area')
|
||||||
if client.area.owned == False:
|
if len(client.area.owners) == 0:
|
||||||
client.area.owned = True
|
if len(arg) > 0:
|
||||||
client.is_cm = True
|
raise ArgumentError('You cannot \'nominate\' people to be CMs when you are not one.')
|
||||||
|
client.area.owners.append(client)
|
||||||
if client.area.evidence_mod == 'HiddenCM':
|
if client.area.evidence_mod == 'HiddenCM':
|
||||||
client.area.broadcast_evidence_list()
|
client.area.broadcast_evidence_list()
|
||||||
client.server.area_manager.send_arup_cms()
|
client.server.area_manager.send_arup_cms()
|
||||||
client.area.send_host_message('{} is CM in this area now.'.format(client.get_char_name()))
|
client.area.send_host_message('{} [{}] is CM in this area now.'.format(client.get_char_name(), client.id))
|
||||||
|
elif client in client.area.owners:
|
||||||
|
if len(arg) > 0:
|
||||||
|
arg = arg.split(' ')
|
||||||
|
for id in arg:
|
||||||
|
try:
|
||||||
|
id = int(id)
|
||||||
|
c = client.server.client_manager.get_targets(client, TargetType.ID, id, False)[0]
|
||||||
|
if c in client.area.owners:
|
||||||
|
client.send_host_message('{} [{}] is already a CM here.'.format(c.get_char_name(), c.id))
|
||||||
|
else:
|
||||||
|
client.area.owners.append(c)
|
||||||
|
if client.area.evidence_mod == 'HiddenCM':
|
||||||
|
client.area.broadcast_evidence_list()
|
||||||
|
client.server.area_manager.send_arup_cms()
|
||||||
|
client.area.send_host_message('{} [{}] is CM in this area now.'.format(c.get_char_name(), c.id))
|
||||||
|
except:
|
||||||
|
client.send_host_message('{} does not look like a valid ID.'.format(id))
|
||||||
|
else:
|
||||||
|
raise ClientError('You must be authorized to do that.')
|
||||||
|
|
||||||
|
|
||||||
def ooc_cmd_uncm(client, arg):
|
def ooc_cmd_uncm(client, arg):
|
||||||
if client.is_cm:
|
if client in client.area.owners:
|
||||||
client.is_cm = False
|
if len(arg) > 0:
|
||||||
client.area.owned = False
|
arg = arg.split(' ')
|
||||||
client.area.blankposting_allowed = True
|
|
||||||
if client.area.is_locked != client.area.Locked.FREE:
|
|
||||||
client.area.unlock()
|
|
||||||
client.server.area_manager.send_arup_cms()
|
|
||||||
client.area.send_host_message('{} is no longer CM in this area.'.format(client.get_char_name()))
|
|
||||||
else:
|
else:
|
||||||
raise ClientError('You cannot give up being the CM when you are not one')
|
arg = [client.id]
|
||||||
|
for id in arg:
|
||||||
|
try:
|
||||||
|
id = int(id)
|
||||||
|
c = client.server.client_manager.get_targets(client, TargetType.ID, id, False)[0]
|
||||||
|
if c in client.area.owners:
|
||||||
|
client.area.owners.remove(c)
|
||||||
|
client.server.area_manager.send_arup_cms()
|
||||||
|
client.area.send_host_message('{} [{}] is no longer CM in this area.'.format(c.get_char_name(), c.id))
|
||||||
|
else:
|
||||||
|
client.send_host_message('You cannot remove someone from CMing when they aren\'t a CM.')
|
||||||
|
except:
|
||||||
|
client.send_host_message('{} does not look like a valid ID.'.format(id))
|
||||||
|
else:
|
||||||
|
raise ClientError('You must be authorized to do that.')
|
||||||
|
|
||||||
def ooc_cmd_unmod(client, arg):
|
def ooc_cmd_unmod(client, arg):
|
||||||
client.is_mod = False
|
client.is_mod = False
|
||||||
@ -721,7 +779,7 @@ def ooc_cmd_area_lock(client, arg):
|
|||||||
return
|
return
|
||||||
if client.area.is_locked == client.area.Locked.LOCKED:
|
if client.area.is_locked == client.area.Locked.LOCKED:
|
||||||
client.send_host_message('Area is already locked.')
|
client.send_host_message('Area is already locked.')
|
||||||
if client.is_cm:
|
if client in client.area.owners:
|
||||||
client.area.lock()
|
client.area.lock()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -733,7 +791,7 @@ def ooc_cmd_area_spectate(client, arg):
|
|||||||
return
|
return
|
||||||
if client.area.is_locked == client.area.Locked.SPECTATABLE:
|
if client.area.is_locked == client.area.Locked.SPECTATABLE:
|
||||||
client.send_host_message('Area is already spectatable.')
|
client.send_host_message('Area is already spectatable.')
|
||||||
if client.is_cm:
|
if client in client.area.owners:
|
||||||
client.area.spectator()
|
client.area.spectator()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -742,7 +800,7 @@ def ooc_cmd_area_spectate(client, arg):
|
|||||||
def ooc_cmd_area_unlock(client, arg):
|
def ooc_cmd_area_unlock(client, arg):
|
||||||
if client.area.is_locked == client.area.Locked.FREE:
|
if client.area.is_locked == client.area.Locked.FREE:
|
||||||
raise ClientError('Area is already unlocked.')
|
raise ClientError('Area is already unlocked.')
|
||||||
if not client.is_cm:
|
if not client in client.area.owners:
|
||||||
raise ClientError('Only CM can unlock area.')
|
raise ClientError('Only CM can unlock area.')
|
||||||
client.area.unlock()
|
client.area.unlock()
|
||||||
client.send_host_message('Area is unlocked.')
|
client.send_host_message('Area is unlocked.')
|
||||||
@ -750,9 +808,9 @@ def ooc_cmd_area_unlock(client, arg):
|
|||||||
def ooc_cmd_invite(client, arg):
|
def ooc_cmd_invite(client, arg):
|
||||||
if not arg:
|
if not arg:
|
||||||
raise ClientError('You must specify a target. Use /invite <id>')
|
raise ClientError('You must specify a target. Use /invite <id>')
|
||||||
if not client.area.is_locked:
|
if client.area.is_locked == client.area.Locked.FREE:
|
||||||
raise ClientError('Area isn\'t locked.')
|
raise ClientError('Area isn\'t locked.')
|
||||||
if not client.is_cm and not client.is_mod:
|
if not client in client.area.owners and not client.is_mod:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
try:
|
try:
|
||||||
c = client.server.client_manager.get_targets(client, TargetType.ID, int(arg), False)[0]
|
c = client.server.client_manager.get_targets(client, TargetType.ID, int(arg), False)[0]
|
||||||
@ -763,9 +821,9 @@ def ooc_cmd_invite(client, arg):
|
|||||||
raise ClientError('You must specify a target. Use /invite <id>')
|
raise ClientError('You must specify a target. Use /invite <id>')
|
||||||
|
|
||||||
def ooc_cmd_uninvite(client, arg):
|
def ooc_cmd_uninvite(client, arg):
|
||||||
if not client.is_cm and not client.is_mod:
|
if not client in client.area.owners and not client.is_mod:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
if not client.area.is_locked and not client.is_mod:
|
if client.area.is_locked == client.area.Locked.FREE:
|
||||||
raise ClientError('Area isn\'t locked.')
|
raise ClientError('Area isn\'t locked.')
|
||||||
if not arg:
|
if not arg:
|
||||||
raise ClientError('You must specify a target. Use /uninvite <id>')
|
raise ClientError('You must specify a target. Use /uninvite <id>')
|
||||||
@ -776,7 +834,7 @@ def ooc_cmd_uninvite(client, arg):
|
|||||||
for c in targets:
|
for c in targets:
|
||||||
client.send_host_message("You have removed {} from the whitelist.".format(c.get_char_name()))
|
client.send_host_message("You have removed {} from the whitelist.".format(c.get_char_name()))
|
||||||
c.send_host_message("You were removed from the area whitelist.")
|
c.send_host_message("You were removed from the area whitelist.")
|
||||||
if client.area.is_locked:
|
if client.area.is_locked != client.area.Locked.FREE:
|
||||||
client.area.invite_list.pop(c.id)
|
client.area.invite_list.pop(c.id)
|
||||||
except AreaError:
|
except AreaError:
|
||||||
raise
|
raise
|
||||||
@ -788,7 +846,7 @@ def ooc_cmd_uninvite(client, arg):
|
|||||||
def ooc_cmd_area_kick(client, arg):
|
def ooc_cmd_area_kick(client, arg):
|
||||||
if not client.is_mod:
|
if not client.is_mod:
|
||||||
raise ClientError('You must be authorized to do that.')
|
raise ClientError('You must be authorized to do that.')
|
||||||
if not client.area.is_locked and not client.is_mod:
|
if client.area.is_locked == client.area.Locked.FREE:
|
||||||
raise ClientError('Area isn\'t locked.')
|
raise ClientError('Area isn\'t locked.')
|
||||||
if not arg:
|
if not arg:
|
||||||
raise ClientError('You must specify a target. Use /area_kick <id> [destination #]')
|
raise ClientError('You must specify a target. Use /area_kick <id> [destination #]')
|
||||||
@ -809,7 +867,7 @@ def ooc_cmd_area_kick(client, arg):
|
|||||||
client.send_host_message("Attempting to kick {} to area {}.".format(c.get_char_name(), output))
|
client.send_host_message("Attempting to kick {} to area {}.".format(c.get_char_name(), output))
|
||||||
c.change_area(area)
|
c.change_area(area)
|
||||||
c.send_host_message("You were kicked from the area to area {}.".format(output))
|
c.send_host_message("You were kicked from the area to area {}.".format(output))
|
||||||
if client.area.is_locked:
|
if client.area.is_locked != client.area.Locked.FREE:
|
||||||
client.area.invite_list.pop(c.id)
|
client.area.invite_list.pop(c.id)
|
||||||
except AreaError:
|
except AreaError:
|
||||||
raise
|
raise
|
||||||
@ -1070,7 +1128,7 @@ def ooc_cmd_notecard_clear(client, arg):
|
|||||||
raise ClientError('You do not have a note card.')
|
raise ClientError('You do not have a note card.')
|
||||||
|
|
||||||
def ooc_cmd_notecard_reveal(client, arg):
|
def ooc_cmd_notecard_reveal(client, arg):
|
||||||
if not client.is_cm and not client.is_mod:
|
if not client in client.area.owners and not client.is_mod:
|
||||||
raise ClientError('You must be a CM or moderator to reveal cards.')
|
raise ClientError('You must be a CM or moderator to reveal cards.')
|
||||||
if len(client.area.cards) == 0:
|
if len(client.area.cards) == 0:
|
||||||
raise ClientError('There are no cards to reveal in this area.')
|
raise ClientError('There are no cards to reveal in this area.')
|
||||||
|
@ -39,13 +39,13 @@ class EvidenceList:
|
|||||||
if client.area.evidence_mod == 'FFA':
|
if client.area.evidence_mod == 'FFA':
|
||||||
pass
|
pass
|
||||||
if client.area.evidence_mod == 'Mods':
|
if client.area.evidence_mod == 'Mods':
|
||||||
if not client.is_cm:
|
if not client in client.area.owners:
|
||||||
return False
|
return False
|
||||||
if client.area.evidence_mod == 'CM':
|
if client.area.evidence_mod == 'CM':
|
||||||
if not client.is_cm and not client.is_mod:
|
if not client in client.area.owners and not client.is_mod:
|
||||||
return False
|
return False
|
||||||
if client.area.evidence_mod == 'HiddenCM':
|
if client.area.evidence_mod == 'HiddenCM':
|
||||||
if not client.is_cm and not client.is_mod:
|
if not client in client.area.owners and not client.is_mod:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user