From af3b9d250a5aae2a346d8c617622c61c68a9aa64 Mon Sep 17 00:00:00 2001 From: Phoebe <jens.connemann@gmail.com> Date: Sun, 25 Feb 2024 15:20:14 +0100 Subject: [PATCH 1/5] Check for and use ``isThargoid`` flag - Check and use ``isThargoid`` flag for Interdiction events. - Also updates the Paranoia check to also work in case of missing and not just empty parameter. --- plugins/inara.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 121ae227..601bb98e 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1019,8 +1019,11 @@ def journal_entry( # noqa: C901, CCR001 elif 'Power' in entry: data['opponentName'] = entry['Power'] + elif 'IsThargoid' in entry and entry['IsThargoid']: + data['opponentName'] = 'Thargoid' + # Paranoia in case of e.g. Thargoid activity not having complete data - if data['opponentName'] == "": + if 'opponentName' not in data or data['opponentName'] == "": logger.warning('Dropping addCommanderCombatInterdicted message because opponentName came out as ""') else: @@ -1042,8 +1045,13 @@ def journal_entry( # noqa: C901, CCR001 elif 'Power' in entry: data['opponentName'] = entry['Power'] + # Shouldn't be needed here as Interdiction events can't target Thargoids (yet) + # but done just in case of future changes or so + elif 'IsThargoid' in entry and entry['IsThargoid']: + data['opponentName'] = 'Thargoid' + # Paranoia in case of e.g. Thargoid activity not having complete data - if data['opponentName'] == "": + if 'opponentName' not in data or data['opponentName'] == "": logger.warning('Dropping addCommanderCombatInterdiction message because opponentName came out as ""') else: From a45527e104932a28be7955f6f8d153428a83ce9b Mon Sep 17 00:00:00 2001 From: Phoebe <jens.connemann@gmail.com> Date: Sun, 25 Feb 2024 15:32:44 +0100 Subject: [PATCH 2/5] Check for ``EscapeInterdiction`` events as well Also rewrites the ``EscapeInterdiction`` path to match the other Interdiction paths. --- plugins/inara.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 601bb98e..8528f07b 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1058,23 +1058,23 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('addCommanderCombatInterdiction', entry['timestamp'], data) elif event_name == 'EscapeInterdiction': + data = { + 'starsystemName': system, + 'isPlayer': entry['IsPlayer'], + } + + if 'Interdictor' in entry: + data['opponentName'] = entry['Interdictor'] + + elif 'isThargoid' in entry and entry['isThargoid']: + data['opponentName'] = 'Thargoid' + # Paranoia in case of e.g. Thargoid activity not having complete data - if entry.get('Interdictor') is None or entry['Interdictor'] == "": - logger.warning( - 'Dropping addCommanderCombatInterdictionEscape message' - 'because opponentName came out as ""' - ) + if 'opponentName' not in data or data['opponentName'] == "": + logger.warning('Dropping addCommanderCombatInterdiction message because opponentName came out as ""') else: - new_add_event( - 'addCommanderCombatInterdictionEscape', - entry['timestamp'], - { - 'starsystemName': system, - 'opponentName': entry['Interdictor'], - 'isPlayer': entry['IsPlayer'], - } - ) + new_add_event('addCommanderCombatInterdictionEscape', entry['timestamp'], data) elif event_name == 'PVPKill': new_add_event( From 68a2767c39294fa9683d6e6f838b760d8c7de5bd Mon Sep 17 00:00:00 2001 From: Phoebe <jens.connemann@gmail.com> Date: Sun, 25 Feb 2024 19:14:08 +0100 Subject: [PATCH 3/5] Match remaining parts of ``EscapeInterdiction`` --- plugins/inara.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/inara.py b/plugins/inara.py index 8528f07b..0a18b9ae 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1066,6 +1066,12 @@ def journal_entry( # noqa: C901, CCR001 if 'Interdictor' in entry: data['opponentName'] = entry['Interdictor'] + elif 'Faction' in entry: + data['opponentName'] = entry['Faction'] + + elif 'Power' in entry: + data['opponentName'] = entry['Power'] + elif 'isThargoid' in entry and entry['isThargoid']: data['opponentName'] = 'Thargoid' From 249f89f0fef2b9e32e5592d8a5a528a81c09ce8c Mon Sep 17 00:00:00 2001 From: Phoebe <jens.connemann@gmail.com> Date: Sun, 25 Feb 2024 19:46:49 +0100 Subject: [PATCH 4/5] Add checks to ``Died`` event --- plugins/inara.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index 0a18b9ae..ae416f84 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1001,7 +1001,17 @@ def journal_entry( # noqa: C901, CCR001 elif 'KillerName' in entry: data['opponentName'] = entry['KillerName'] - new_add_event('addCommanderCombatDeath', entry['timestamp'], data) + elif 'KillerShip' in entry: + data['opponentName'] = entry['KillerShip'] + + # Paranoia in case of e.g. Thargoid activity not having complete data + opponent_name_issue = 'opponentName' not in data or data['opponentName'] == "" + wing_opponent_names_issue = 'wingOpponentNames' not in data or data['wingOpponentNames'] == [] + if opponent_name_issue and wing_opponent_names_issue: + logger.warning('Dropping addCommanderCombatDeath message because opponentName and wingOpponentNames came out as ""') + + else: + new_add_event('addCommanderCombatDeath', entry['timestamp'], data) elif event_name == 'Interdicted': data = { From 99daff1295e4088a61051bfe9e7002aa9a35b0be Mon Sep 17 00:00:00 2001 From: Phoebe <jens.connemann@gmail.com> Date: Sun, 25 Feb 2024 20:45:59 +0100 Subject: [PATCH 5/5] Flake8 --- plugins/inara.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index ae416f84..0e0eb7bf 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1008,7 +1008,8 @@ def journal_entry( # noqa: C901, CCR001 opponent_name_issue = 'opponentName' not in data or data['opponentName'] == "" wing_opponent_names_issue = 'wingOpponentNames' not in data or data['wingOpponentNames'] == [] if opponent_name_issue and wing_opponent_names_issue: - logger.warning('Dropping addCommanderCombatDeath message because opponentName and wingOpponentNames came out as ""') + logger.warning('Dropping addCommanderCombatDeath message' + 'because opponentName and wingOpponentNames came out as ""') else: new_add_event('addCommanderCombatDeath', entry['timestamp'], data)