1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

eddn: Implement schema fssallbodiesfound/1

This commit is contained in:
Athanasius 2022-02-11 16:17:03 +00:00
parent 67c2077962
commit a93ee14c05
No known key found for this signature in database
GPG Key ID: AE3E527847057C7D

View File

@ -1145,6 +1145,44 @@ class EDDN:
this.eddn.export_journal_entry(cmdr, entry, msg)
return None
def export_journal_fssallbodiesfound(
self, cmdr: str, system_name: str, system_starpos: list, is_beta: bool, entry: MutableMapping[str, Any]
) -> Optional[str]:
"""
Send an FSSAllBodiesFound message to EDDN on the correct schema.
:param cmdr: the commander under which this upload is made
:param system_name: Name of current star system
:param system_starpos: Coordinates of current star system
:param is_beta: whether or not we are in beta mode
:param entry: the journal entry to send
"""
# {
# "Count": 3,
# "SystemAddress": 9466778822057,
# "SystemName": "LP 704-74",
# "event": "FSSAllBodiesFound",
# "timestamp": "2022-02-09T18:15:14Z"
# }
#######################################################################
# Augmentations
#######################################################################
# In this case should add StarSystem and StarPos
ret = this.eddn.entry_augment_system_data(entry, system_name, system_starpos)
if isinstance(ret, str):
return ret
entry = ret
#######################################################################
msg = {
'$schemaRef': f'https://eddn.edcd.io/schemas/fssallbodiesfound/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.
@ -1469,6 +1507,15 @@ def journal_entry( # noqa: C901, CCR001
entry
)
elif event_name == 'fssallbodiesfound':
return this.eddn.export_journal_fssallbodiesfound(
cmdr,
system,
state['StarPos'],
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