Skip to content

Commit

Permalink
Log the names of hosted games
Browse files Browse the repository at this point in the history
This is helpful when tracking down policy violations in game names.
  • Loading branch information
Dunedan committed May 18, 2024
1 parent cd00d9a commit f683ae4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions xpartamupp/xpartamupp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,19 @@ def add_game(self, jid, data):
data['nbp-init'] = data['nbp']
data['state'] = 'init'
except (KeyError, TypeError, ValueError):
logger.warning("Received invalid data for add game from 0ad: %s", data)
logger.warning("Received invalid data for add game from %s: %s", jid, data)
return False
else:
if jid not in self.games:
logger.info('%s registered a game with the name "%s"', jid, data.get("name"))
else:
immutable_keys = ["IP", "name", "hostJID", "hostUsername", "mods"]
for key, value in data.items():
if key in immutable_keys and self.games[jid].get(key) != value:
logger.warning(
"Game hosted by %s changed immutable property \"%s\": "
"\"%s\" -> \"%s\"", jid, key, self.games[jid].get(key), value)

self.games[jid] = data
return True

Expand Down Expand Up @@ -127,7 +137,7 @@ def change_game_state(self, jid, data):
self.games[jid]['nbp'] = data['nbp']
self.games[jid]['players'] = data['players']
except (KeyError, ValueError):
logger.warning("Received invalid data for change game state from 0ad: %s", data)
logger.warning("Received invalid data for change game state from %s: %s", jid, data)
return False
else:
if 'startTime' not in self.games[jid]:
Expand Down

0 comments on commit f683ae4

Please sign in to comment.