Skip to content

Commit

Permalink
Merge pull request #771 from MarechJ/hotfix/automod_flags
Browse files Browse the repository at this point in the history
Hotfix/automod flags
  • Loading branch information
FlorianSW authored Dec 8, 2024
2 parents 6dfce08 + aade3a8 commit 182ee97
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
13 changes: 5 additions & 8 deletions rcon/automods/level_thresholds.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,16 @@ def punitions_to_apply(

with self.watch_state(team, squad_name) as watch_status:


author = AUTOMOD_USERNAME + ("-DryRun" if self.config.dry_run else "")

for player in squad["players"]:
profile = player.get("profile", {})
aplayer = PunishPlayer(
player_id=player["player_id"],
name=player["name"],
squad=squad_name,
team=team,
flags=player.get("profile", {}).get("flags", []),
flags=profile.get("flags") if profile else [],
role=player.get("role"),
lvl=int(player.get("level")),
details=PunishDetails(
Expand Down Expand Up @@ -340,12 +340,9 @@ def punitions_to_apply(

# Server max level threshold check
max_level = self.config.max_level
if (
aplayer.lvl > max_level > 0
and not any(
flag_entry.flag in self.config.whitelist_flags
for flag_entry in aplayer.flags
)
if aplayer.lvl > max_level > 0 and not any(
flag_entry.flag in self.config.whitelist_flags
for flag_entry in aplayer.flags
):
message = self.config.max_level_message
try:
Expand Down
32 changes: 16 additions & 16 deletions rcon/automods/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,23 @@ def add_squad_state(self, team: str, squad_name: str, squad: dict):
try:
if any(s.team == team and s.name == squad_name for s in self.squads_state):
return
self.squads_state.append(
ASquad(
team=team,
name=squad_name,
players=[
PunishPlayer(
player_id=p.get("player_id"),
name=p.get("name"),
squad=p.get("unit_name"),
team=p.get("team"),
flags=p.get("profile", {}).get("flags", []),
role=p.get("role"),
lvl=p.get("level"),
)
for p in squad.get("players", [])
],

players = []
for player in squad.get("players", []):
profile = player.get("profile", {})
punish_player = PunishPlayer(
player_id=player.get("player_id"),
name=player.get("name"),
squad=player.get("unit_name"),
team=player.get("team"),
flags=profile.get("flags") if profile else [],
role=player.get("role"),
lvl=player.get("level"),
)
players.append(punish_player)

self.squads_state.append(
ASquad(team=team, name=squad_name, players=players)
)
except:
logger.exception("Unable to add squad info")
Expand Down
3 changes: 2 additions & 1 deletion rcon/automods/no_leader.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,13 @@ def punitions_to_apply(
author = AUTOMOD_USERNAME + ("-DryRun" if self.config.dry_run else "")

for player in squad["players"]:
profile = player.get("profile", {})
aplayer = PunishPlayer(
player_id=player["player_id"],
name=player["name"],
squad=squad_name,
team=team,
flags=player.get("profile", {}).get("flags", []),
flags=profile.get("flags") if profile else [],
role=player.get("role"),
lvl=int(player.get("level")),
details=PunishDetails(
Expand Down
3 changes: 2 additions & 1 deletion rcon/automods/no_solotank.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@ def punitions_to_apply(
author = AUTOMOD_USERNAME + ("-DryRun" if self.config.dry_run else "")

for player in squad["players"]:
profile = player.get("profile", {})
aplayer = PunishPlayer(
player_id=player["player_id"],
name=player["name"],
squad=squad_name,
team=team,
flags=player.get("profile", {}).get("flags", []),
flags=profile.get("flags") if profile else [],
role=player.get("role"),
lvl=int(player.get("level")),
details=PunishDetails(
Expand Down
3 changes: 2 additions & 1 deletion rcon/automods/seeding_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,13 @@ def punitions_to_apply(
author = AUTOMOD_USERNAME + ("-DryRun" if self.config.dry_run else "")

for player in squad["players"]:
profile = player.get("profile", {})
aplayer = PunishPlayer(
player_id=player["player_id"],
name=player["name"],
squad=squad_name,
team=team,
flags=player.get("profile", {}).get("flags", []),
flags=profile.get("flags") if profile else [],
role=player.get("role"),
lvl=int(player.get("level")),
details=PunishDetails(
Expand Down

0 comments on commit 182ee97

Please sign in to comment.