Ejemplo n.º 1
0
 def do_perma_ban(self,
                  player=None,
                  steam_id_64=None,
                  reason="",
                  admin_name=""):
     with invalidates(Rcon.get_players, Rcon.get_perma_bans):
         return super().do_perma_ban(player, steam_id_64, reason,
                                     admin_name)
Ejemplo n.º 2
0
 def set_votekick_threshold(self, threshold_pairs):
     # Todo use proper data structure
     with invalidates(self.get_votekick_threshold):
         res = super().set_votekick_threshold(threshold_pairs)
         print(f"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! {res}")
         logger.error("Threshold res %s", res)
         if res.lower().startswith("error"):
             logger.error("Unable to set votekick threshold: %s", res)
             raise CommandFailedError(res)
Ejemplo n.º 3
0
 def do_temp_ban(self,
                 player=None,
                 steam_id_64=None,
                 duration_hours=2,
                 reason="",
                 admin_name=""):
     with invalidates(Rcon.get_players, Rcon.get_temp_bans):
         return super().do_temp_ban(player, steam_id_64, duration_hours,
                                    reason, admin_name)
 def do_temp_ban(
     self, player=None, steam_id_64=None, duration_hours=2, reason="", admin_name=""
 ):
     if player and player in super().get_players():
         # When banning a player by steam id, if he is currently in game he won't be banned immedietly
         steam_id_64 = None
     with invalidates(Rcon.get_players, Rcon.get_temp_bans):
         return super().do_temp_ban(
             player, steam_id_64, duration_hours, reason, admin_name
         )
Ejemplo n.º 5
0
    def set_maprotation(self, rotation):
        if not rotation:
            raise CommandFailedError("Empty rotation")
        first = rotation.pop(0)

        with invalidates(Rcon.get_map_rotation):
            current = set(self.get_map_rotation())
            self.do_remove_maps_from_rotation(current - set([first]))
            self.do_add_maps_to_rotation(rotation)

        return [first] + rotation
Ejemplo n.º 6
0
    def set_profanities(self, profanities):
        current = self.get_profanities()
        with invalidates(self.get_profanities):
            removed = set(current) - set(profanities)
            added = set(profanities) - set(current)
            if removed:
                self.do_unban_profanities(list(removed))
            if added:
                self.do_ban_profanities(list(added))

        return profanities
Ejemplo n.º 7
0
 def change_server_name(self, new_name):
     with invalidates(Rcon.get_name):
         remote_path = f"{self.base_path}/ServerConfig/Server.ini"
         logger.info("Updating name in %s", remote_path)
         f = BytesIO()
         self.adapter.get_file(remote_path, f)
         print(f.getvalue())
         config = ConfigParser()
         config.read_string(f.getvalue().decode())
         config.set("Server", "Name", f'"{new_name}"')
         temp_f = StringIO()
         config.write(temp_f)
         f = BytesIO(temp_f.getvalue().encode())
         self.adapter.put_file(f, remote_path)
         logger.info("Updated name to %s", new_name)
Ejemplo n.º 8
0
    def set_maprotation(self, rotation):
        if not rotation:
            raise CommandFailedError("Empty rotation")

        rotation = list(rotation)
        logger.info("Apply map rotation %s", rotation)

        with invalidates(Rcon.get_map_rotation):
            current = self.get_map_rotation()
            if rotation == current:
                logger.debug("Map rotation is the same, nothing to do")
                return current

            print(rotation, current)

            if len(current) == 1:
                logger.debug("Current rotation is a single map")
                for idx, m in enumerate(rotation):
                    if m not in current:
                        self.do_add_map_to_rotation(m)
                    if m in current and idx != 0:
                        self.do_remove_map_from_rotation(m)
                        self.do_add_map_to_rotation(m)
                if current[0] not in rotation:
                    self.do_remove_map_from_rotation(m)
                return rotation

            first = rotation.pop(0)
            to_remove = set(current) - {first}
            if to_remove == set(current):
                self.do_add_map_to_rotation(first)

            self.do_remove_maps_from_rotation(to_remove)
            self.do_add_maps_to_rotation(rotation)

        return [first] + rotation
Ejemplo n.º 9
0
 def set_map(self, map_name):
     with invalidates(Rcon.get_map):
         res = super().set_map(map_name)
         if res != "SUCCESS":
             raise CommandFailedError(res)
Ejemplo n.º 10
0
 def do_reset_votekick_threshold(self):
     with invalidates(self.get_votekick_threshold):
         return super().do_reset_votekick_threshold()
Ejemplo n.º 11
0
 def do_perma_ban(self, player, reason):
     with invalidates(Rcon.get_players, Rcon.get_perma_bans):
         return super().do_perma_ban(player, reason)
Ejemplo n.º 12
0
 def set_votekick_enabled(self, bool_):
     with invalidates(self.get_votekick_enabled):
         return super().set_votekick_enabled("on" if bool_ else "off")
Ejemplo n.º 13
0
 def set_autobalance_enabled(self, bool_):
     with invalidates(self.get_autobalance_enabled):
         return super().set_autobalance_enabled("on" if bool_ else "off")
Ejemplo n.º 14
0
 def set_vip_slots_num(self, num):
     with invalidates(Rcon.get_vip_slots_num):
         return super().set_vip_slots_num(num)
Ejemplo n.º 15
0
 def set_queue_length(self, num):
     with invalidates(Rcon.get_queue_length):
         return super().set_queue_length(num)
Ejemplo n.º 16
0
 def set_max_ping_autokick(self, max_ms):
     with invalidates(Rcon.get_max_ping_autokick):
         return super().set_max_ping_autokick(max_ms)
Ejemplo n.º 17
0
 def set_idle_autokick_time(self, minutes):
     with invalidates(Rcon.get_idle_autokick_time):
         return super().set_idle_autokick_time(minutes)
Ejemplo n.º 18
0
 def do_remove_maps_from_rotation(self, maps):
     with invalidates(Rcon.get_map_rotation):
         for map_name in maps:
             super().do_remove_map_from_rotation(map_name)
         return 'SUCCESS'
Ejemplo n.º 19
0
 def do_remove_perma_ban(self, ban_log):
     with invalidates(Rcon.get_perma_bans):
         return super().do_remove_perma_ban(ban_log)
Ejemplo n.º 20
0
 def do_ban_profanities(self, profanities):
     if not isinstance(profanities, list):
         profanities = [profanities]
     with invalidates(self.get_profanities):
         return super().do_ban_profanities(",".join(profanities))
Ejemplo n.º 21
0
 def do_add_vip(self, name, steam_id_64):
     with invalidates(Rcon.get_vip_ids):
         return super().do_add_vip(steam_id_64, name)
Ejemplo n.º 22
0
 def do_remove_vip(self, steam_id_64):
     with invalidates(Rcon.get_vip_ids):
         return super().do_remove_vip(steam_id_64)
Ejemplo n.º 23
0
 def do_add_admin(self, steam_id_64, role, name):
     with invalidates(Rcon.get_admin_ids):
         return super().do_add_admin(steam_id_64, role, name)
Ejemplo n.º 24
0
 def do_kick(self, player, reason):
     with invalidates(Rcon.get_players):
         return super().do_kick(player, reason)
Ejemplo n.º 25
0
 def set_team_switch_cooldown(self, minutes):
     with invalidates(Rcon.get_team_switch_cooldown):
         return super().set_team_switch_cooldown(minutes)
Ejemplo n.º 26
0
 def do_add_maps_to_rotation(self, maps):
     with invalidates(Rcon.get_map_rotation):
         for map_name in maps:
             super().do_add_map_to_rotation(map_name)
         return "SUCCESS"
Ejemplo n.º 27
0
 def set_autobalance_threshold(self, max_diff):
     with invalidates(Rcon.get_autobalance_threshold):
         return super().set_autobalance_threshold(max_diff)