Logging update.
This commit is contained in:
		
							parent
							
								
									7d207208dc
								
							
						
					
					
						commit
						a21dd24380
					
				@ -413,7 +413,7 @@ 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)
 | 
				
			||||||
        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.id, 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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (self.client.area.is_recording):
 | 
					        if (self.client.area.is_recording):
 | 
				
			||||||
            self.client.area.recorded_messages.append(args)
 | 
					            self.client.area.recorded_messages.append(args)
 | 
				
			||||||
@ -467,7 +467,7 @@ class AOProtocol(asyncio.Protocol):
 | 
				
			|||||||
                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])
 | 
				
			||||||
            logger.log_server(
 | 
					            logger.log_server(
 | 
				
			||||||
                '[OOC][{}][{}][{}]{}'.format(self.client.area.id, self.client.get_char_name(), self.client.name,
 | 
					                '[OOC][{}][{}]{}'.format(self.client.area.abbreviation, self.client.get_char_name(),
 | 
				
			||||||
                                             args[1]), self.client)
 | 
					                                             args[1]), self.client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def net_cmd_mc(self, args):
 | 
					    def net_cmd_mc(self, args):
 | 
				
			||||||
@ -504,7 +504,7 @@ class AOProtocol(asyncio.Protocol):
 | 
				
			|||||||
                            return
 | 
					                            return
 | 
				
			||||||
                        showname = args[2]
 | 
					                        showname = args[2]
 | 
				
			||||||
                    self.client.area.add_jukebox_vote(self.client, name, length, showname)
 | 
					                    self.client.area.add_jukebox_vote(self.client, name, length, showname)
 | 
				
			||||||
                    logger.log_server('[{}][{}]Added a jukebox vote for {}.'.format(self.client.area.id, self.client.get_char_name(), name), self.client)
 | 
					                    logger.log_server('[{}][{}]Added a jukebox vote for {}.'.format(self.client.area.abbreviation, self.client.get_char_name(), name), self.client)
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    if len(args) > 2:
 | 
					                    if len(args) > 2:
 | 
				
			||||||
                        showname = args[2]
 | 
					                        showname = args[2]
 | 
				
			||||||
@ -517,7 +517,7 @@ class AOProtocol(asyncio.Protocol):
 | 
				
			|||||||
                        self.client.area.play_music(name, self.client.char_id, length)
 | 
					                        self.client.area.play_music(name, self.client.char_id, length)
 | 
				
			||||||
                        self.client.area.add_music_playing(self.client, name)
 | 
					                        self.client.area.add_music_playing(self.client, name)
 | 
				
			||||||
                    logger.log_server('[{}][{}]Changed music to {}.'
 | 
					                    logger.log_server('[{}][{}]Changed music to {}.'
 | 
				
			||||||
                                    .format(self.client.area.id, self.client.get_char_name(), name), self.client)
 | 
					                                    .format(self.client.area.abbreviation, self.client.get_char_name(), name), self.client)
 | 
				
			||||||
            except ServerError:
 | 
					            except ServerError:
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
        except ClientError as ex:
 | 
					        except ClientError as ex:
 | 
				
			||||||
@ -556,7 +556,7 @@ class AOProtocol(asyncio.Protocol):
 | 
				
			|||||||
        elif len(args) == 2:
 | 
					        elif len(args) == 2:
 | 
				
			||||||
            self.client.area.send_command('RT', args[0], args[1])
 | 
					            self.client.area.send_command('RT', args[0], args[1])
 | 
				
			||||||
        self.client.area.add_to_judgelog(self.client, 'used {}'.format(sign))
 | 
					        self.client.area.add_to_judgelog(self.client, 'used {}'.format(sign))
 | 
				
			||||||
        logger.log_server("[{}]{} Used WT/CE".format(self.client.area.id, self.client.get_char_name()), self.client)
 | 
					        logger.log_server("[{}]{} Used WT/CE".format(self.client.area.abbreviation, self.client.get_char_name()), self.client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def net_cmd_hp(self, args):
 | 
					    def net_cmd_hp(self, args):
 | 
				
			||||||
        """ Sets the penalty bar.
 | 
					        """ Sets the penalty bar.
 | 
				
			||||||
@ -573,7 +573,7 @@ class AOProtocol(asyncio.Protocol):
 | 
				
			|||||||
            self.client.area.change_hp(args[0], args[1])
 | 
					            self.client.area.change_hp(args[0], args[1])
 | 
				
			||||||
            self.client.area.add_to_judgelog(self.client, 'changed the penalties')
 | 
					            self.client.area.add_to_judgelog(self.client, 'changed the penalties')
 | 
				
			||||||
            logger.log_server('[{}]{} changed HP ({}) to {}'
 | 
					            logger.log_server('[{}]{} changed HP ({}) to {}'
 | 
				
			||||||
                              .format(self.client.area.id, self.client.get_char_name(), args[0], args[1]), self.client)
 | 
					                              .format(self.client.area.abbreviation, self.client.get_char_name(), args[0], args[1]), self.client)
 | 
				
			||||||
        except AreaError:
 | 
					        except AreaError:
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -633,12 +633,12 @@ class AOProtocol(asyncio.Protocol):
 | 
				
			|||||||
            self.server.send_all_cmd_pred('ZZ', '[{}] {} ({}) in {} without reason (not using the Case Café client?)'
 | 
					            self.server.send_all_cmd_pred('ZZ', '[{}] {} ({}) in {} without reason (not using the Case Café client?)'
 | 
				
			||||||
                                      .format(current_time, self.client.get_char_name(), self.client.get_ip(), self.client.area.name), pred=lambda c: c.is_mod)
 | 
					                                      .format(current_time, self.client.get_char_name(), self.client.get_ip(), self.client.area.name), pred=lambda c: c.is_mod)
 | 
				
			||||||
            self.client.set_mod_call_delay()
 | 
					            self.client.set_mod_call_delay()
 | 
				
			||||||
            logger.log_server('[{}][{}]{} called a moderator.'.format(self.client.get_ip(), self.client.area.id, self.client.get_char_name()))
 | 
					            logger.log_server('[{}]{} called a moderator.'.format(self.client.area.abbreviation, self.client.get_char_name()), self.client)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.server.send_all_cmd_pred('ZZ', '[{}] {} ({}) in {} with reason: {}'
 | 
					            self.server.send_all_cmd_pred('ZZ', '[{}] {} ({}) in {} with reason: {}'
 | 
				
			||||||
                                        .format(current_time, self.client.get_char_name(), self.client.get_ip(), self.client.area.name, args[0][:100]), pred=lambda c: c.is_mod)
 | 
					                                        .format(current_time, self.client.get_char_name(), self.client.get_ip(), self.client.area.name, args[0][:100]), pred=lambda c: c.is_mod)
 | 
				
			||||||
            self.client.set_mod_call_delay()
 | 
					            self.client.set_mod_call_delay()
 | 
				
			||||||
            logger.log_server('[{}][{}]{} called a moderator: {}.'.format(self.client.get_ip(), self.client.area.id, self.client.get_char_name(), args[0]))
 | 
					            logger.log_server('[{}]{} called a moderator: {}.'.format(self.client.area.abbreviation, self.client.get_char_name(), args[0]), self.client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def net_cmd_opKICK(self, args):
 | 
					    def net_cmd_opKICK(self, args):
 | 
				
			||||||
        self.net_cmd_ct(['opkick', '/kick {}'.format(args[0])])
 | 
					        self.net_cmd_ct(['opkick', '/kick {}'.format(args[0])])
 | 
				
			||||||
 | 
				
			|||||||
@ -124,7 +124,7 @@ class ClientManager:
 | 
				
			|||||||
            self.send_command('PV', self.id, 'CID', self.char_id)
 | 
					            self.send_command('PV', self.id, 'CID', self.char_id)
 | 
				
			||||||
            self.area.send_command('CharsCheck', *self.get_available_char_list())
 | 
					            self.area.send_command('CharsCheck', *self.get_available_char_list())
 | 
				
			||||||
            logger.log_server('[{}]Changed character from {} to {}.'
 | 
					            logger.log_server('[{}]Changed character from {} to {}.'
 | 
				
			||||||
                              .format(self.area.id, 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.is_cm:
 | 
				
			||||||
 | 
				
			|||||||
@ -47,7 +47,7 @@ def ooc_cmd_bg(client, arg):
 | 
				
			|||||||
    except AreaError:
 | 
					    except AreaError:
 | 
				
			||||||
        raise
 | 
					        raise
 | 
				
			||||||
    client.area.send_host_message('{} changed the background to {}.'.format(client.get_char_name(), arg))
 | 
					    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)
 | 
					    logger.log_server('[{}][{}]Changed background to {}'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_bglock(client,arg):
 | 
					def ooc_cmd_bglock(client,arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -59,7 +59,7 @@ def ooc_cmd_bglock(client,arg):
 | 
				
			|||||||
    else:
 | 
					    else:
 | 
				
			||||||
        client.area.bg_lock = "true"
 | 
					        client.area.bg_lock = "true"
 | 
				
			||||||
    client.area.send_host_message('A mod has set the background lock to {}.'.format(client.area.bg_lock))
 | 
					    client.area.send_host_message('A mod has set the background lock to {}.'.format(client.area.bg_lock))
 | 
				
			||||||
    logger.log_server('[{}][{}]Changed bglock to {}'.format(client.area.id, client.get_char_name(), client.area.bg_lock), client)
 | 
					    logger.log_server('[{}][{}]Changed bglock to {}'.format(client.area.abbreviation, client.get_char_name(), client.area.bg_lock), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_evidence_mod(client, arg):
 | 
					def ooc_cmd_evidence_mod(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -125,7 +125,7 @@ def ooc_cmd_roll(client, arg):
 | 
				
			|||||||
        roll = '(' + roll + ')'
 | 
					        roll = '(' + roll + ')'
 | 
				
			||||||
    client.area.send_host_message('{} rolled {} out of {}.'.format(client.get_char_name(), roll, val[0]))
 | 
					    client.area.send_host_message('{} rolled {} out of {}.'.format(client.get_char_name(), roll, val[0]))
 | 
				
			||||||
    logger.log_server(
 | 
					    logger.log_server(
 | 
				
			||||||
        '[{}][{}]Used /roll and got {} out of {}.'.format(client.area.id, client.get_char_name(), roll, val[0]))
 | 
					        '[{}][{}]Used /roll and got {} out of {}.'.format(client.area.abbreviation, client.get_char_name(), roll, val[0]), client)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
def ooc_cmd_rollp(client, arg):
 | 
					def ooc_cmd_rollp(client, arg):
 | 
				
			||||||
    roll_max = 11037
 | 
					    roll_max = 11037
 | 
				
			||||||
@ -154,7 +154,7 @@ def ooc_cmd_rollp(client, arg):
 | 
				
			|||||||
    client.area.send_host_message('{} rolled.'.format(client.get_char_name(), roll, val[0]))
 | 
					    client.area.send_host_message('{} rolled.'.format(client.get_char_name(), roll, val[0]))
 | 
				
			||||||
    SALT = ''.join(random.choices(string.ascii_uppercase + string.digits, k=16))
 | 
					    SALT = ''.join(random.choices(string.ascii_uppercase + string.digits, k=16))
 | 
				
			||||||
    logger.log_server(
 | 
					    logger.log_server(
 | 
				
			||||||
        '[{}][{}]Used /roll and got {} out of {}.'.format(client.area.id, client.get_char_name(), hashlib.sha1((str(roll) + SALT).encode('utf-8')).hexdigest() + '|' + SALT, val[0]))
 | 
					        '[{}][{}]Used /roll and got {} out of {}.'.format(client.area.abbreviation, client.get_char_name(), hashlib.sha1((str(roll) + SALT).encode('utf-8')).hexdigest() + '|' + SALT, val[0]), client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_currentmusic(client, arg):
 | 
					def ooc_cmd_currentmusic(client, arg):
 | 
				
			||||||
    if len(arg) != 0:
 | 
					    if len(arg) != 0:
 | 
				
			||||||
@ -201,7 +201,7 @@ def ooc_cmd_jukebox_skip(client, arg):
 | 
				
			|||||||
        client.area.send_host_message('{} has forced a skip, restarting the only jukebox song.'.format(changer))
 | 
					        client.area.send_host_message('{} has forced a skip, restarting the only jukebox song.'.format(changer))
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        client.area.send_host_message('{} has forced a skip to the next jukebox song.'.format(changer))
 | 
					        client.area.send_host_message('{} has forced a skip to the next jukebox song.'.format(changer))
 | 
				
			||||||
    logger.log_server('[{}][{}]Skipped the current jukebox song.'.format(client.area.id, client.get_char_name()))
 | 
					    logger.log_server('[{}][{}]Skipped the current jukebox song.'.format(client.area.abbreviation, client.get_char_name()), client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_jukebox(client, arg):
 | 
					def ooc_cmd_jukebox(client, arg):
 | 
				
			||||||
    if len(arg) != 0:
 | 
					    if len(arg) != 0:
 | 
				
			||||||
@ -256,7 +256,7 @@ def ooc_cmd_coinflip(client, arg):
 | 
				
			|||||||
    flip = random.choice(coin)
 | 
					    flip = random.choice(coin)
 | 
				
			||||||
    client.area.send_host_message('{} flipped a coin and got {}.'.format(client.get_char_name(), flip))
 | 
					    client.area.send_host_message('{} flipped a coin and got {}.'.format(client.get_char_name(), flip))
 | 
				
			||||||
    logger.log_server(
 | 
					    logger.log_server(
 | 
				
			||||||
        '[{}][{}]Used /coinflip and got {}.'.format(client.area.id, client.get_char_name(), flip))
 | 
					        '[{}][{}]Used /coinflip and got {}.'.format(client.area.abbreviation, client.get_char_name(), flip), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_motd(client, arg):
 | 
					def ooc_cmd_motd(client, arg):
 | 
				
			||||||
    if len(arg) != 0:
 | 
					    if len(arg) != 0:
 | 
				
			||||||
@ -316,7 +316,7 @@ def ooc_cmd_forcepos(client, arg):
 | 
				
			|||||||
    client.area.send_host_message(
 | 
					    client.area.send_host_message(
 | 
				
			||||||
        '{} forced {} client(s) into /pos {}.'.format(client.get_char_name(), len(targets), pos))
 | 
					        '{} forced {} client(s) into /pos {}.'.format(client.get_char_name(), len(targets), pos))
 | 
				
			||||||
    logger.log_server(
 | 
					    logger.log_server(
 | 
				
			||||||
        '[{}][{}]Used /forcepos {} for {} client(s).'.format(client.area.id, client.get_char_name(), pos, len(targets)))
 | 
					        '[{}][{}]Used /forcepos {} for {} client(s).'.format(client.area.abbreviation, client.get_char_name(), pos, len(targets)), client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_help(client, arg):
 | 
					def ooc_cmd_help(client, arg):
 | 
				
			||||||
    if len(arg) != 0:
 | 
					    if len(arg) != 0:
 | 
				
			||||||
@ -340,7 +340,8 @@ def ooc_cmd_kick(client, arg):
 | 
				
			|||||||
        targets = client.server.client_manager.get_targets(client, TargetType.IPID, ipid, False)
 | 
					        targets = client.server.client_manager.get_targets(client, TargetType.IPID, ipid, False)
 | 
				
			||||||
        if targets:
 | 
					        if targets:
 | 
				
			||||||
            for c in targets:
 | 
					            for c in targets:
 | 
				
			||||||
                logger.log_server('Kicked {}.'.format(c.ipid), client)
 | 
					                logger.log_server('Kicked {} [{}]({}).'.format(c.get_char_name(), c.id, c.ipid), client)
 | 
				
			||||||
 | 
					                logger.log_mod('Kicked {} [{}]({}).'.format(c.get_char_name(), c.id, c.ipid), client)
 | 
				
			||||||
                client.send_host_message("{} was kicked.".format(c.get_char_name()))
 | 
					                client.send_host_message("{} was kicked.".format(c.get_char_name()))
 | 
				
			||||||
                c.disconnect()
 | 
					                c.disconnect()
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
@ -370,6 +371,7 @@ def ooc_cmd_ban(client, arg):
 | 
				
			|||||||
                client.send_host_message('{} clients was kicked.'.format(len(targets)))
 | 
					                client.send_host_message('{} clients was kicked.'.format(len(targets)))
 | 
				
			||||||
            client.send_host_message('{} was banned.'.format(ipid))
 | 
					            client.send_host_message('{} was banned.'.format(ipid))
 | 
				
			||||||
            logger.log_server('Banned {}.'.format(ipid), client)
 | 
					            logger.log_server('Banned {}.'.format(ipid), client)
 | 
				
			||||||
 | 
					            logger.log_mod('Banned {}.'.format(ipid), client)
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
def ooc_cmd_unban(client, arg):
 | 
					def ooc_cmd_unban(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -384,6 +386,7 @@ def ooc_cmd_unban(client, arg):
 | 
				
			|||||||
        except:
 | 
					        except:
 | 
				
			||||||
            raise ClientError('{} does not look like a valid IPID.'.format(raw_ipid))
 | 
					            raise ClientError('{} does not look like a valid IPID.'.format(raw_ipid))
 | 
				
			||||||
        logger.log_server('Unbanned {}.'.format(raw_ipid), client)
 | 
					        logger.log_server('Unbanned {}.'.format(raw_ipid), client)
 | 
				
			||||||
 | 
					        logger.log_mod('Unbanned {}.'.format(raw_ipid), client)
 | 
				
			||||||
        client.send_host_message('Unbanned {}'.format(raw_ipid))
 | 
					        client.send_host_message('Unbanned {}'.format(raw_ipid))
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_play(client, arg):
 | 
					def ooc_cmd_play(client, arg):
 | 
				
			||||||
@ -393,7 +396,7 @@ def ooc_cmd_play(client, arg):
 | 
				
			|||||||
        raise ArgumentError('You must specify a song.')
 | 
					        raise ArgumentError('You must specify a song.')
 | 
				
			||||||
    client.area.play_music(arg, client.char_id, -1)
 | 
					    client.area.play_music(arg, client.char_id, -1)
 | 
				
			||||||
    client.area.add_music_playing(client, arg)
 | 
					    client.area.add_music_playing(client, arg)
 | 
				
			||||||
    logger.log_server('[{}][{}]Changed music to {}.'.format(client.area.id, client.get_char_name(), arg), client)
 | 
					    logger.log_server('[{}][{}]Changed music to {}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_mute(client, arg):
 | 
					def ooc_cmd_mute(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -410,6 +413,8 @@ def ooc_cmd_mute(client, arg):
 | 
				
			|||||||
                msg = 'Muted ' + str(ipid) + ' clients'
 | 
					                msg = 'Muted ' + str(ipid) + ' clients'
 | 
				
			||||||
                for c in clients:
 | 
					                for c in clients:
 | 
				
			||||||
                    c.is_muted = True
 | 
					                    c.is_muted = True
 | 
				
			||||||
 | 
					                    logger.log_server('Muted {} [{}]({}).'.format(c.get_char_name(), c.id, c.ipid), client)
 | 
				
			||||||
 | 
					                    logger.log_mod('Muted {} [{}]({}).'.format(c.get_char_name(), c.id, c.ipid), client)
 | 
				
			||||||
                    msg += ' ' + c.get_char_name() + ' [' + str(c.id) + '],'
 | 
					                    msg += ' ' + c.get_char_name() + ' [' + str(c.id) + '],'
 | 
				
			||||||
                msg = msg[:-1]
 | 
					                msg = msg[:-1]
 | 
				
			||||||
                msg += '.'
 | 
					                msg += '.'
 | 
				
			||||||
@ -434,6 +439,8 @@ def ooc_cmd_unmute(client, arg):
 | 
				
			|||||||
                msg = 'Unmuted ' + str(ipid) + ' clients'
 | 
					                msg = 'Unmuted ' + str(ipid) + ' clients'
 | 
				
			||||||
                for c in clients:
 | 
					                for c in clients:
 | 
				
			||||||
                    c.is_muted = False
 | 
					                    c.is_muted = False
 | 
				
			||||||
 | 
					                    logger.log_server('Unmuted {} [{}]({}).'.format(c.get_char_name(), c.id, c.ipid), client)
 | 
				
			||||||
 | 
					                    logger.log_mod('Unmuted {} [{}]({}).'.format(c.get_char_name(), c.id, c.ipid), client)
 | 
				
			||||||
                    msg += ' ' + c.get_char_name() + ' [' + str(c.id) + '],'
 | 
					                    msg += ' ' + c.get_char_name() + ' [' + str(c.id) + '],'
 | 
				
			||||||
                msg = msg[:-1]
 | 
					                msg = msg[:-1]
 | 
				
			||||||
                msg += '.'
 | 
					                msg += '.'
 | 
				
			||||||
@ -454,6 +461,7 @@ def ooc_cmd_login(client, arg):
 | 
				
			|||||||
        client.area.broadcast_evidence_list()
 | 
					        client.area.broadcast_evidence_list()
 | 
				
			||||||
    client.send_host_message('Logged in as a moderator.')
 | 
					    client.send_host_message('Logged in as a moderator.')
 | 
				
			||||||
    logger.log_server('Logged in as moderator.', client)
 | 
					    logger.log_server('Logged in as moderator.', client)
 | 
				
			||||||
 | 
					    logger.log_mod('Logged in as moderator.', client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_g(client, arg):
 | 
					def ooc_cmd_g(client, arg):
 | 
				
			||||||
    if client.muted_global:
 | 
					    if client.muted_global:
 | 
				
			||||||
@ -461,7 +469,7 @@ def ooc_cmd_g(client, arg):
 | 
				
			|||||||
    if len(arg) == 0:
 | 
					    if len(arg) == 0:
 | 
				
			||||||
        raise ArgumentError("You can't send an empty message.")
 | 
					        raise ArgumentError("You can't send an empty message.")
 | 
				
			||||||
    client.server.broadcast_global(client, arg)
 | 
					    client.server.broadcast_global(client, arg)
 | 
				
			||||||
    logger.log_server('[{}][{}][GLOBAL]{}.'.format(client.area.id, client.get_char_name(), arg), client)
 | 
					    logger.log_server('[{}][{}][GLOBAL]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_gm(client, arg):
 | 
					def ooc_cmd_gm(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -471,7 +479,8 @@ def ooc_cmd_gm(client, arg):
 | 
				
			|||||||
    if len(arg) == 0:
 | 
					    if len(arg) == 0:
 | 
				
			||||||
        raise ArgumentError("Can't send an empty message.")
 | 
					        raise ArgumentError("Can't send an empty message.")
 | 
				
			||||||
    client.server.broadcast_global(client, arg, True)
 | 
					    client.server.broadcast_global(client, arg, True)
 | 
				
			||||||
    logger.log_server('[{}][{}][GLOBAL-MOD]{}.'.format(client.area.id, client.get_char_name(), arg), client)
 | 
					    logger.log_server('[{}][{}][GLOBAL-MOD]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
 | 
					    logger.log_mod('[{}][{}][GLOBAL-MOD]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_m(client, arg):
 | 
					def ooc_cmd_m(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -479,7 +488,8 @@ def ooc_cmd_m(client, arg):
 | 
				
			|||||||
    if len(arg) == 0:
 | 
					    if len(arg) == 0:
 | 
				
			||||||
        raise ArgumentError("You can't send an empty message.")
 | 
					        raise ArgumentError("You can't send an empty message.")
 | 
				
			||||||
    client.server.send_modchat(client, arg)
 | 
					    client.server.send_modchat(client, arg)
 | 
				
			||||||
    logger.log_server('[{}][{}][MODCHAT]{}.'.format(client.area.id, client.get_char_name(), arg), client)
 | 
					    logger.log_server('[{}][{}][MODCHAT]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
 | 
					    logger.log_mod('[{}][{}][MODCHAT]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_lm(client, arg):
 | 
					def ooc_cmd_lm(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -488,7 +498,8 @@ def ooc_cmd_lm(client, arg):
 | 
				
			|||||||
        raise ArgumentError("Can't send an empty message.")
 | 
					        raise ArgumentError("Can't send an empty message.")
 | 
				
			||||||
    client.area.send_command('CT', '{}[MOD][{}]'
 | 
					    client.area.send_command('CT', '{}[MOD][{}]'
 | 
				
			||||||
                             .format(client.server.config['hostname'], client.get_char_name()), arg)
 | 
					                             .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)
 | 
					    logger.log_server('[{}][{}][LOCAL-MOD]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
 | 
					    logger.log_mod('[{}][{}][LOCAL-MOD]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_announce(client, arg):
 | 
					def ooc_cmd_announce(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
@ -497,7 +508,8 @@ def ooc_cmd_announce(client, arg):
 | 
				
			|||||||
        raise ArgumentError("Can't send an empty message.")
 | 
					        raise ArgumentError("Can't send an empty message.")
 | 
				
			||||||
    client.server.send_all_cmd_pred('CT', '{}'.format(client.server.config['hostname']),
 | 
					    client.server.send_all_cmd_pred('CT', '{}'.format(client.server.config['hostname']),
 | 
				
			||||||
                                    '=== Announcement ===\r\n{}\r\n=================='.format(arg))
 | 
					                                    '=== Announcement ===\r\n{}\r\n=================='.format(arg))
 | 
				
			||||||
    logger.log_server('[{}][{}][ANNOUNCEMENT]{}.'.format(client.area.id, client.get_char_name(), arg), client)
 | 
					    logger.log_server('[{}][{}][ANNOUNCEMENT]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
 | 
					    logger.log_mod('[{}][{}][ANNOUNCEMENT]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_toggleglobal(client, arg):
 | 
					def ooc_cmd_toggleglobal(client, arg):
 | 
				
			||||||
    if len(arg) != 0:
 | 
					    if len(arg) != 0:
 | 
				
			||||||
@ -515,7 +527,7 @@ def ooc_cmd_need(client, arg):
 | 
				
			|||||||
    if len(arg) == 0:
 | 
					    if len(arg) == 0:
 | 
				
			||||||
        raise ArgumentError("You must specify what you need.")
 | 
					        raise ArgumentError("You must specify what you need.")
 | 
				
			||||||
    client.server.broadcast_need(client, arg)
 | 
					    client.server.broadcast_need(client, arg)
 | 
				
			||||||
    logger.log_server('[{}][{}][NEED]{}.'.format(client.area.id, client.get_char_name(), arg), client)
 | 
					    logger.log_server('[{}][{}][NEED]{}.'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
def ooc_cmd_toggleadverts(client, arg):
 | 
					def ooc_cmd_toggleadverts(client, arg):
 | 
				
			||||||
    if len(arg) != 0:
 | 
					    if len(arg) != 0:
 | 
				
			||||||
@ -530,11 +542,11 @@ def ooc_cmd_doc(client, arg):
 | 
				
			|||||||
    if len(arg) == 0:
 | 
					    if len(arg) == 0:
 | 
				
			||||||
        client.send_host_message('Document: {}'.format(client.area.doc))
 | 
					        client.send_host_message('Document: {}'.format(client.area.doc))
 | 
				
			||||||
        logger.log_server(
 | 
					        logger.log_server(
 | 
				
			||||||
            '[{}][{}]Requested document. Link: {}'.format(client.area.id, client.get_char_name(), client.area.doc))
 | 
					            '[{}][{}]Requested document. Link: {}'.format(client.area.abbreviation, client.get_char_name(), client.area.doc), client)
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        client.area.change_doc(arg)
 | 
					        client.area.change_doc(arg)
 | 
				
			||||||
        client.area.send_host_message('{} changed the doc link.'.format(client.get_char_name()))
 | 
					        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))
 | 
					        logger.log_server('[{}][{}]Changed document to: {}'.format(client.area.abbreviation, client.get_char_name(), arg), client)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_cleardoc(client, arg):
 | 
					def ooc_cmd_cleardoc(client, arg):
 | 
				
			||||||
@ -542,7 +554,7 @@ def ooc_cmd_cleardoc(client, arg):
 | 
				
			|||||||
        raise ArgumentError('This command has no arguments.')
 | 
					        raise ArgumentError('This command has no arguments.')
 | 
				
			||||||
    client.area.send_host_message('{} cleared the doc link.'.format(client.get_char_name()))
 | 
					    client.area.send_host_message('{} cleared the doc link.'.format(client.get_char_name()))
 | 
				
			||||||
    logger.log_server('[{}][{}]Cleared document. Old link: {}'
 | 
					    logger.log_server('[{}][{}]Cleared document. Old link: {}'
 | 
				
			||||||
                      .format(client.area.id, client.get_char_name(), client.area.doc))
 | 
					                      .format(client.area.abbreviation, client.get_char_name(), client.area.doc), client)
 | 
				
			||||||
    client.area.change_doc()
 | 
					    client.area.change_doc()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -554,7 +566,7 @@ def ooc_cmd_status(client, arg):
 | 
				
			|||||||
            client.area.change_status(arg)
 | 
					            client.area.change_status(arg)
 | 
				
			||||||
            client.area.send_host_message('{} changed status to {}.'.format(client.get_char_name(), client.area.status))
 | 
					            client.area.send_host_message('{} changed status to {}.'.format(client.get_char_name(), client.area.status))
 | 
				
			||||||
            logger.log_server(
 | 
					            logger.log_server(
 | 
				
			||||||
                '[{}][{}]Changed status to {}'.format(client.area.id, client.get_char_name(), client.area.status))
 | 
					                '[{}][{}]Changed status to {}'.format(client.area.abbreviation, client.get_char_name(), client.area.status), client)
 | 
				
			||||||
        except AreaError:
 | 
					        except AreaError:
 | 
				
			||||||
            raise
 | 
					            raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -829,6 +841,7 @@ def ooc_cmd_disemvowel(client, arg):
 | 
				
			|||||||
    if targets:
 | 
					    if targets:
 | 
				
			||||||
        for c in targets:
 | 
					        for c in targets:
 | 
				
			||||||
            logger.log_server('Disemvowelling {}.'.format(c.get_ip()), client)
 | 
					            logger.log_server('Disemvowelling {}.'.format(c.get_ip()), client)
 | 
				
			||||||
 | 
					            logger.log_mod('Disemvowelling {}.'.format(c.get_ip()), client)
 | 
				
			||||||
            c.disemvowel = True
 | 
					            c.disemvowel = True
 | 
				
			||||||
        client.send_host_message('Disemvowelled {} existing client(s).'.format(len(targets)))
 | 
					        client.send_host_message('Disemvowelled {} existing client(s).'.format(len(targets)))
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
@ -846,6 +859,7 @@ def ooc_cmd_undisemvowel(client, arg):
 | 
				
			|||||||
    if targets:
 | 
					    if targets:
 | 
				
			||||||
        for c in targets:
 | 
					        for c in targets:
 | 
				
			||||||
            logger.log_server('Undisemvowelling {}.'.format(c.get_ip()), client)
 | 
					            logger.log_server('Undisemvowelling {}.'.format(c.get_ip()), client)
 | 
				
			||||||
 | 
					            logger.log_mod('Undisemvowelling {}.'.format(c.get_ip()), client)
 | 
				
			||||||
            c.disemvowel = False
 | 
					            c.disemvowel = False
 | 
				
			||||||
        client.send_host_message('Undisemvowelled {} existing client(s).'.format(len(targets)))
 | 
					        client.send_host_message('Undisemvowelled {} existing client(s).'.format(len(targets)))
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
@ -865,6 +879,8 @@ def ooc_cmd_blockdj(client, arg):
 | 
				
			|||||||
    for target in targets:
 | 
					    for target in targets:
 | 
				
			||||||
        target.is_dj = False
 | 
					        target.is_dj = False
 | 
				
			||||||
        target.send_host_message('A moderator muted you from changing the music.')
 | 
					        target.send_host_message('A moderator muted you from changing the music.')
 | 
				
			||||||
 | 
					        logger.log_server('BlockDJ\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
 | 
					        logger.log_mod('BlockDJ\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
        target.area.remove_jukebox_vote(target, True)
 | 
					        target.area.remove_jukebox_vote(target, True)
 | 
				
			||||||
    client.send_host_message('blockdj\'d {}.'.format(targets[0].get_char_name()))
 | 
					    client.send_host_message('blockdj\'d {}.'.format(targets[0].get_char_name()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -882,6 +898,8 @@ def ooc_cmd_unblockdj(client, arg):
 | 
				
			|||||||
    for target in targets:
 | 
					    for target in targets:
 | 
				
			||||||
        target.is_dj = True
 | 
					        target.is_dj = True
 | 
				
			||||||
        target.send_host_message('A moderator unmuted you from changing the music.')
 | 
					        target.send_host_message('A moderator unmuted you from changing the music.')
 | 
				
			||||||
 | 
					        logger.log_server('UnblockDJ\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
 | 
					        logger.log_mod('UnblockDJ\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
    client.send_host_message('Unblockdj\'d {}.'.format(targets[0].get_char_name()))
 | 
					    client.send_host_message('Unblockdj\'d {}.'.format(targets[0].get_char_name()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_blockwtce(client, arg):
 | 
					def ooc_cmd_blockwtce(client, arg):
 | 
				
			||||||
@ -898,6 +916,8 @@ def ooc_cmd_blockwtce(client, arg):
 | 
				
			|||||||
    for target in targets:
 | 
					    for target in targets:
 | 
				
			||||||
        target.can_wtce = False
 | 
					        target.can_wtce = False
 | 
				
			||||||
        target.send_host_message('A moderator blocked you from using judge signs.')
 | 
					        target.send_host_message('A moderator blocked you from using judge signs.')
 | 
				
			||||||
 | 
					        logger.log_server('BlockWTCE\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
 | 
					        logger.log_mod('BlockWTCE\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
    client.send_host_message('blockwtce\'d {}.'.format(targets[0].get_char_name()))
 | 
					    client.send_host_message('blockwtce\'d {}.'.format(targets[0].get_char_name()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_unblockwtce(client, arg):
 | 
					def ooc_cmd_unblockwtce(client, arg):
 | 
				
			||||||
@ -914,6 +934,8 @@ def ooc_cmd_unblockwtce(client, arg):
 | 
				
			|||||||
    for target in targets:
 | 
					    for target in targets:
 | 
				
			||||||
        target.can_wtce = True
 | 
					        target.can_wtce = True
 | 
				
			||||||
        target.send_host_message('A moderator unblocked you from using judge signs.')
 | 
					        target.send_host_message('A moderator unblocked you from using judge signs.')
 | 
				
			||||||
 | 
					        logger.log_server('UnblockWTCE\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
 | 
					        logger.log_mod('UnblockWTCE\'d {} [{}]({}).'.format(target.get_char_name(), target.id, target.get_ip()), client)
 | 
				
			||||||
    client.send_host_message('unblockwtce\'d {}.'.format(targets[0].get_char_name()))
 | 
					    client.send_host_message('unblockwtce\'d {}.'.format(targets[0].get_char_name()))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def ooc_cmd_notecard(client, arg):
 | 
					def ooc_cmd_notecard(client, arg):
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,7 @@ def setup_logger(debug):
 | 
				
			|||||||
    logging.Formatter.converter = time.gmtime
 | 
					    logging.Formatter.converter = time.gmtime
 | 
				
			||||||
    debug_formatter = logging.Formatter('[%(asctime)s UTC]%(message)s')
 | 
					    debug_formatter = logging.Formatter('[%(asctime)s UTC]%(message)s')
 | 
				
			||||||
    srv_formatter = logging.Formatter('[%(asctime)s UTC]%(message)s')
 | 
					    srv_formatter = logging.Formatter('[%(asctime)s UTC]%(message)s')
 | 
				
			||||||
 | 
					    mod_formatter = logging.Formatter('[%(asctime)s UTC]%(message)s')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    debug_log = logging.getLogger('debug')
 | 
					    debug_log = logging.getLogger('debug')
 | 
				
			||||||
    debug_log.setLevel(logging.DEBUG)
 | 
					    debug_log.setLevel(logging.DEBUG)
 | 
				
			||||||
@ -44,6 +45,14 @@ def setup_logger(debug):
 | 
				
			|||||||
    server_handler.setFormatter(srv_formatter)
 | 
					    server_handler.setFormatter(srv_formatter)
 | 
				
			||||||
    server_log.addHandler(server_handler)
 | 
					    server_log.addHandler(server_handler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mod_log = logging.getLogger('mod')
 | 
				
			||||||
 | 
					    mod_log.setLevel(logging.INFO)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mod_handler = logging.FileHandler('logs/mod.log', encoding='utf-8')
 | 
				
			||||||
 | 
					    mod_handler.setLevel(logging.INFO)
 | 
				
			||||||
 | 
					    mod_handler.setFormatter(mod_formatter)
 | 
				
			||||||
 | 
					    mod_log.addHandler(mod_handler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def log_debug(msg, client=None):
 | 
					def log_debug(msg, client=None):
 | 
				
			||||||
    msg = parse_client_info(client) + msg
 | 
					    msg = parse_client_info(client) + msg
 | 
				
			||||||
@ -55,10 +64,15 @@ def log_server(msg, client=None):
 | 
				
			|||||||
    logging.getLogger('server').info(msg)
 | 
					    logging.getLogger('server').info(msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def log_mod(msg, client=None):
 | 
				
			||||||
 | 
					    msg = parse_client_info(client) + msg
 | 
				
			||||||
 | 
					    logging.getLogger('mod').info(msg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def parse_client_info(client):
 | 
					def parse_client_info(client):
 | 
				
			||||||
    if client is None:
 | 
					    if client is None:
 | 
				
			||||||
        return ''
 | 
					        return ''
 | 
				
			||||||
    info = client.get_ip()
 | 
					    info = client.get_ip()
 | 
				
			||||||
    if client.is_mod:
 | 
					    if client.is_mod:
 | 
				
			||||||
        return '[{:<15}][{}][MOD]'.format(info, client.id)
 | 
					        return '[{:<15}][{:<3}][{}][MOD]'.format(info, client.id, client.name)
 | 
				
			||||||
    return '[{:<15}][{}]'.format(info, client.id)
 | 
					    return '[{:<15}][{:<3}][{}]'.format(info, client.id, client.name)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user