From 26413177a62299013e2d0152e946d5eacac14054 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 1 Dec 2022 13:45:10 +0000 Subject: [PATCH] Inara: Also check opponentName on EscapeInterdiction And sprinkly comments around giving a reason for the checks. --- plugins/inara.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index bb9147ff..5ad5df07 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1069,6 +1069,7 @@ def journal_entry( # noqa: C901, CCR001 elif 'Power' in entry: data['opponentName'] = entry['Power'] + # Paranoia in case of e.g. Thargoid activity not having complete data if data['opponentName'] == "": logger.warning('Dropping addCommanderCombatInterdicted message because opponentName came out as ""') @@ -1091,6 +1092,7 @@ def journal_entry( # noqa: C901, CCR001 elif 'Power' in entry: data['opponentName'] = entry['Power'] + # Paranoia in case of e.g. Thargoid activity not having complete data if data['opponentName'] == "": logger.warning('Dropping addCommanderCombatInterdiction message because opponentName came out as ""') @@ -1098,15 +1100,23 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('addCommanderCombatInterdiction', entry['timestamp'], data) elif event_name == 'EscapeInterdiction': - new_add_event( - 'addCommanderCombatInterdictionEscape', - entry['timestamp'], - { - 'starsystemName': system, - 'opponentName': entry['Interdictor'], - 'isPlayer': entry['IsPlayer'], - } - ) + # 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 ""' + ) + + else: + new_add_event( + 'addCommanderCombatInterdictionEscape', + entry['timestamp'], + { + 'starsystemName': system, + 'opponentName': entry['Interdictor'], + 'isPlayer': entry['IsPlayer'], + } + ) elif event_name == 'PVPKill': new_add_event(