From 3a0dbb906a7f39eba572ffb567f1e5ab8b96a791 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 9 Feb 2022 15:01:56 +0000 Subject: [PATCH] eddn: export_journal_approachsettlement() implementation --- plugins/eddn.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/plugins/eddn.py b/plugins/eddn.py index 9efe2c6a..f2185156 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -1090,6 +1090,46 @@ class EDDN: this.eddn.export_journal_entry(cmdr, entry, msg) return None + def export_journal_approachsettlement( + self, cmdr: str, is_beta: bool, entry: MutableMapping[str, Any] + ) -> Optional[str]: + """ + Send an ApproachSettlement to EDDN on the correct schema. + + :param cmdr: the commander under which this upload is made + :param is_beta: whether or not we are in beta mode + :param entry: the journal entry to send + """ + # { + # "BodyID": 32, + # "BodyName": "Ix 5 a a", + # "Latitude": 17.090912, + # "Longitude": 160.236679, + # "MarketID": 3915738368, + # "Name": "Arnold Defence Base", + # "SystemAddress": 2381282543963, + # "event": "ApproachSettlement", + # "timestamp": "2021-10-14T12:37:54Z" + # } + ####################################################################### + # Augmentations + ####################################################################### + # In this case should add StarSystem and StarPos + ret = this.eddn.entry_augment_system_data(entry, entry['StarSystem']) + if isinstance(ret, str): + return ret + + entry = ret + ####################################################################### + + msg = { + '$schemaRef': f'https://eddn.edcd.io/schemas/approachsettlement/1{"/test" if is_beta else ""}', + 'message': entry + } + + this.eddn.export_journal_entry(cmdr, entry, msg) + return None + def canonicalise(self, item: str) -> str: """ Canonicalise the given commodity name. @@ -1405,6 +1445,9 @@ def journal_entry( # noqa: C901, CCR001 elif event_name == 'navroute': return this.eddn.export_journal_navroute(cmdr, is_beta, entry) + elif event_name == 'approachsettlement': + return this.eddn.export_journal_approachsettlement(cmdr, is_beta, entry) + # Send journal schema events to EDDN, but not when on a crew if (config.get_int('output') & config.OUT_SYS_EDDN and not state['Captain'] and (event_name in ('location', 'fsdjump', 'docked', 'scan', 'saasignalsfound', 'carrierjump')) and