def on_control(self, command, params, silent, **kwargs): extra = kwargs.get('extra', {}) uniqueid = extra.get('uniqueid', '') if not has_access(uniqueid, 'admin'): return True parsed_params = shell_parse(params) # Test if there is a --force parameter. If so then ignore any exceptions. # Otherwise, build a list of exceptions based on the admin users. uniqueid_exceptions = [] if parsed_params and parsed_params[0] == '--force': parsed_params = parsed_params[1:] else: # If there was no force param, then add all people who are admins or higher # onto the list of exceptions. for user in cget('users', default=[]): entry = cget('users', user, default={'uniqueid': None}) if has_access(entry['uniqueid'], 'user'): uniqueid_exceptions.append(entry['uniqueid']) action = '' # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Kick if command == 'k' or command == 'kick': action = 'kick' rcon_client.kick_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Reverse kick elif command == 'rkick' or command == 'rk': action = 'rkick' rcon_client.rkick_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Ban elif command == 'b' or command == 'ban' or command == 'kb': action = 'ban' rcon_client.ban_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Reverse ban elif command == 'rban' or command == 'rb' or command == 'rkb': action = 'rban' rcon_client.rban_ex(names=parsed_params, uniqueid_exceptions=uniqueid_exceptions) #if action: # if not silent: # rcon_client.hsay('', '[%s]: %s' % (action, params)) # This will print out a warning as to why the action was not performed on # the list of players. #if 'exceptions' in ret and ret['exceptions']: #names = [rcon_client.cache['players'][uniqueid]['name'] for uniqueid in ret['exceptions']] #rcon_client.say('[%s]: Use --force to %s exceptions.' % (action, action)) return True
def on_command(self, command, params, silent, **kwargs): extra = kwargs.get('extra', {}) uniqueid = extra.get('uniqueid', '') # We don't have access. Return. if not has_access(uniqueid, 'admin'): # Keep processing other plugins. return True # No reason to do anything if we're silent. if silent: return True players = None if command == 'id': # If they passed params, then get the players by their names parsed_commands = shell_parse(params) if parsed_commands: players = rcon_client.get_players(names=parsed_commands) else: # Otherwise, just use all the players players = rcon_client.get_players() elif command == 'idteam' and params: # Get the correct team name based on what they passed. team = None if params == 'c' or params == 'ct': team = 'CT' elif params == 't': team = 'TERRORIST' # If we have a team, get the players on that team. if team: players = rcon_client.find_players('team', team) if players: reactor.callInThread(self.display_players, players) # Keep processing other plugins. return True