From 46710e1c4de4bfe5f17910aad71f7fb2003ae90c Mon Sep 17 00:00:00 2001 From: David Sangrey <davidsangrey@gmail.com> Date: Mon, 4 Mar 2024 18:04:15 -0500 Subject: [PATCH] Merge pull request #2165 from HullSeals/enhancement/2163/update-inara-to-use-isthargoid-flag [2163] Update Inara plugin to better handle Thargoid Combat events --- plugins/inara.py | 59 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index d523bb2e..5fc7adab 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -997,7 +997,18 @@ 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 = OrderedDict([('starsystemName', system), @@ -1014,8 +1025,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: @@ -1037,31 +1051,42 @@ 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: 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 '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' + # 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(