1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

monitor/tracking: Move .station_marketid to state['MarketID']

1. plugins/eddb.py uses this for MarketID-based station URLs.

* So do the 'rename'.
* Remove EDDB tracking in favour of this.
* Update PLUGINS.md
This commit is contained in:
Athanasius 2023-01-09 16:55:04 +00:00
parent 2a8dd14e24
commit 31e8d0372d
No known key found for this signature in database
GPG Key ID: 772697E181BB2767
4 changed files with 73 additions and 80 deletions

View File

@ -1295,9 +1295,9 @@ class AppWindow(object):
self.capi_query_holdoff_time = capi_response.query_time + companion.capi_query_cooldown
elif capi_response.capi_data['lastStarport']['id'] != monitor.station_marketid:
elif capi_response.capi_data['lastStarport']['id'] != monitor.state['MarketID']:
logger.warning(f"MarketID mis-match: {capi_response.capi_data['lastStarport']['id']!r} !="
f" {monitor.station_marketid!r}")
f" {monitor.state['MarketID']!r}")
raise companion.ServerLagging()
elif not monitor.state['OnFoot'] and capi_response.capi_data['ship']['id'] != monitor.state['ShipID']:

View File

@ -606,61 +606,62 @@ This gets called when EDMarketConnector sees a new entry in the game's journal.
Content of `state` (updated to the current journal entry):
| Field | Type | Description |
|:---------------------|:---------------------------:|:----------------------------------------------------------------------------------------------------------------|
| `GameLanguage` | `Optional[str]` | `language` value from `Fileheader` event. |
| `GameVersion` | `Optional[str]` | `version` value from `Fileheader` event. |
| `GameBuild` | `Optional[str]` | `build` value from `Fileheader` event. |
| `Captain`[3] | `Optional[str]` | Name of the commander who's crew you're on, if any |
| `Cargo` | `dict` | Current cargo. Note that this will be totals, and any mission specific duplicates will be counted together |
| `CargoJSON` | `dict` | content of cargo.json as of last read. |
| `Credits` | `int` | Current credits balance |
| `FID` | `str` | Frontier commander ID |
| `Horizons` | `bool` | From `LoadGame` event. |
| `Odyssey` | `bool` | From `LoadGame` event. `False` if not present, else the event value. |
| `Loan` | `Optional[int]` | Current loan amount, if any |
| `Raw` | `dict` | Current raw engineering materials |
| `Manufactured` | `dict` | Current manufactured engineering materials |
| `Encoded` | `dict` | Current encoded engineering materials |
| `Component` | `dict` | Current component materials |
| `Engineers` | `dict` | Current Raw engineering materials |
| `Rank` | `Dict[str, Tuple[int, int]` | Current ranks, each entry is a tuple of the current rank, and age |
| `Statistics` | `dict` | Contents of a Journal Statistics event, ie, data shown in the stats panel. See the Journal manual for more info |
| `Role` | `Optional[str]` | Current role if in multi-crew, one of `Idle`, `FireCon`, `FighterCon` |
| `Friends` | `set` | Currently online friend |
| `ShipID` | `int` | Frontier ID of current ship |
| `ShipIdent` | `str` | Current user-set ship ID |
| `ShipName` | `str` | Current user-set ship name |
| `ShipType` | `str` | Internal name for the current ship type |
| `HullValue` | `int` | Current ship value, excluding modules |
| `ModulesValue` | `int` | Value of the current ship's modules |
| `Rebuy` | `int` | Current ship's rebuy cost |
| `Modules` | `dict` | Currently fitted modules |
| `NavRoute` | `dict` | Last plotted multi-hop route[1] |
| `ModuleInfo` | `dict` | Last loaded ModulesInfo.json data |
| `IsDocked` | `bool` | Whether the Cmdr is currently docked *in their own ship*. |
| `OnFoot`[3] | `bool` | Whether the Cmdr is on foot |
| `Component` | `dict` | 'Component' MicroResources in Odyssey, `int` count each. |
| `Item` | `dict` | 'Item' MicroResources in Odyssey, `int` count each. |
| `Consumable` | `dict` | 'Consumable' MicroResources in Odyssey, `int` count each. |
| `Data` | `dict` | 'Data' MicroResources in Odyssey, `int` count each. |
| `BackPack` | `dict` | `dict` of Odyssey MicroResources in backpack. |
| `BackpackJSON` | `dict` | Content of Backpack.json as of last read. |
| `ShipLockerJSON` | `dict` | Content of ShipLocker.json as of last read. |
| `SuitCurrent` | `dict` | CAPI-returned data of currently worn suit. NB: May be `None` if no data. |
| `Suits` | `dict`[2] | CAPI-returned data of owned suits. NB: May be `None` if no data. |
| `SuitLoadoutCurrent` | `dict` | CAPI-returned data of current Suit Loadout. NB: May be `None` if no data. |
| `SuitLoadouts` | `dict`[2] | CAPI-returned data of all Suit Loadouts. NB: May be `None` if no data. |
| `Taxi` | `Optional[bool]` | Whether or not we're currently in a taxi. NB: This is best effort with what the journals provide. |
| `Dropship` | `Optional[bool]` | Whether or not the above taxi is a Dropship |
| `SystemAddress`[3] | `Optional[int]` | Unique [ID64](http://disc.thargoid.space/ID64) of the star system we're currently in |
| `SystemName`[3] | `Optional[str]` | Name of the star system we're currently in |
| `SystemPopulation`[3]| `Optional[int]` | Population of the star system we're currently in |
| `StarPos`[3] | `Optional[tuple[float]]` | Galaxy co-ordinates of the system we're currently in |
| `Body`[3][4] | `Optional[str]` | Name of the body we're currently on / in the SOI of |
| `BodyID`[3][4] | `Optional[int]` | ID of the body we're currently on / in the SOI of |
| `BodyType`[3][4] | `Optional[str]` | The type of body that `Body` refers to |
| `StationName` | `Optional[str]` | Name of the station we're docked at, if applicable |
| Field | Type | Description |
|:----------------------|:---------------------------:|:----------------------------------------------------------------------------------------------------------------|
| `GameLanguage` | `Optional[str]` | `language` value from `Fileheader` event. |
| `GameVersion` | `Optional[str]` | `version` value from `Fileheader` event. |
| `GameBuild` | `Optional[str]` | `build` value from `Fileheader` event. |
| `Captain`[3] | `Optional[str]` | Name of the commander who's crew you're on, if any |
| `Cargo` | `dict` | Current cargo. Note that this will be totals, and any mission specific duplicates will be counted together |
| `CargoJSON` | `dict` | content of cargo.json as of last read. |
| `Credits` | `int` | Current credits balance |
| `FID` | `str` | Frontier commander ID |
| `Horizons` | `bool` | From `LoadGame` event. |
| `Odyssey` | `bool` | From `LoadGame` event. `False` if not present, else the event value. |
| `Loan` | `Optional[int]` | Current loan amount, if any |
| `Raw` | `dict` | Current raw engineering materials |
| `Manufactured` | `dict` | Current manufactured engineering materials |
| `Encoded` | `dict` | Current encoded engineering materials |
| `Component` | `dict` | Current component materials |
| `Engineers` | `dict` | Current Raw engineering materials |
| `Rank` | `Dict[str, Tuple[int, int]` | Current ranks, each entry is a tuple of the current rank, and age |
| `Statistics` | `dict` | Contents of a Journal Statistics event, ie, data shown in the stats panel. See the Journal manual for more info |
| `Role` | `Optional[str]` | Current role if in multi-crew, one of `Idle`, `FireCon`, `FighterCon` |
| `Friends` | `set` | Currently online friend |
| `ShipID` | `int` | Frontier ID of current ship |
| `ShipIdent` | `str` | Current user-set ship ID |
| `ShipName` | `str` | Current user-set ship name |
| `ShipType` | `str` | Internal name for the current ship type |
| `HullValue` | `int` | Current ship value, excluding modules |
| `ModulesValue` | `int` | Value of the current ship's modules |
| `Rebuy` | `int` | Current ship's rebuy cost |
| `Modules` | `dict` | Currently fitted modules |
| `NavRoute` | `dict` | Last plotted multi-hop route[1] |
| `ModuleInfo` | `dict` | Last loaded ModulesInfo.json data |
| `IsDocked` | `bool` | Whether the Cmdr is currently docked *in their own ship*. |
| `OnFoot`[3] | `bool` | Whether the Cmdr is on foot |
| `Component` | `dict` | 'Component' MicroResources in Odyssey, `int` count each. |
| `Item` | `dict` | 'Item' MicroResources in Odyssey, `int` count each. |
| `Consumable` | `dict` | 'Consumable' MicroResources in Odyssey, `int` count each. |
| `Data` | `dict` | 'Data' MicroResources in Odyssey, `int` count each. |
| `BackPack` | `dict` | `dict` of Odyssey MicroResources in backpack. |
| `BackpackJSON` | `dict` | Content of Backpack.json as of last read. |
| `ShipLockerJSON` | `dict` | Content of ShipLocker.json as of last read. |
| `SuitCurrent` | `dict` | CAPI-returned data of currently worn suit. NB: May be `None` if no data. |
| `Suits` | `dict`[2] | CAPI-returned data of owned suits. NB: May be `None` if no data. |
| `SuitLoadoutCurrent` | `dict` | CAPI-returned data of current Suit Loadout. NB: May be `None` if no data. |
| `SuitLoadouts` | `dict`[2] | CAPI-returned data of all Suit Loadouts. NB: May be `None` if no data. |
| `Taxi` | `Optional[bool]` | Whether or not we're currently in a taxi. NB: This is best effort with what the journals provide. |
| `Dropship` | `Optional[bool]` | Whether or not the above taxi is a Dropship |
| `SystemAddress`[3] | `Optional[int]` | Unique [ID64](http://disc.thargoid.space/ID64) of the star system we're currently in |
| `SystemName`[3] | `Optional[str]` | Name of the star system we're currently in |
| `SystemPopulation`[3] | `Optional[int]` | Population of the star system we're currently in |
| `StarPos`[3] | `Optional[tuple[float]]` | Galaxy co-ordinates of the system we're currently in |
| `Body`[3][4] | `Optional[str]` | Name of the body we're currently on / in the SOI of |
| `BodyID`[3][4] | `Optional[int]` | ID of the body we're currently on / in the SOI of |
| `BodyType`[3][4] | `Optional[str]` | The type of body that `Body` refers to |
| `StationName`[3] | `Optional[str]` | Name of the station we're docked at, if applicable |
| `MarketID`[3] | `Optional[str]` | MarketID of the station we're docked at, if applicable |
[1] - Contents of `NavRoute` not changed if a `NavRouteClear` event is seen,
but plugins will see the `NavRouteClear` event.
@ -807,7 +808,7 @@ now track in the same manner as prior core EDDN plugin code. Check the
documentation above for some caveats. Do not just blindly use this data, or
the 'Body' name value.
`StationName` added to the `state` dictionary.
`StationName` and `MarketID` added to the `state` dictionary.
___

View File

@ -116,7 +116,6 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.mode: str | None = None
self.group: str | None = None
self.cmdr: str | None = None
self.station_marketid: int | None = None
self.stationtype: str | None = None
self.started: int | None = None # Timestamp of the LoadGame event
@ -311,7 +310,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['BodyID'] = None
self.state['BodyType'] = None
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None
self.is_beta = False
@ -541,7 +540,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
if self.state['StationName']:
entry['Docked'] = True
entry['MarketID'] = self.station_marketid
entry['MarketID'] = self.state['MarketID']
entry['StationName'] = self.state['StationName']
entry['StationType'] = self.stationtype
@ -586,7 +585,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['Body'] = None
self.state['BodyID'] = None
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None
self.started = None
@ -625,7 +624,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['BodyID'] = None
self.state['BodyType'] = None
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None
self.started = timegm(strptime(entry['timestamp'], '%Y-%m-%dT%H:%M:%SZ'))
@ -758,7 +757,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
elif event_type == 'undocked':
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None
self.state['IsDocked'] = False
@ -780,8 +779,10 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
# • StationType
# • MarketID
self.state['StationName'] = None
self.state['MarketID'] = None
if entry.get('OnStation'):
self.state['StationName'] = entry.get('StationName', '')
self.state['MarketID'] = entry.get('MarketID', '')
self.state['OnFoot'] = False
self.state['Taxi'] = entry['Taxi']
@ -845,7 +846,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
###############################################################
self.state['IsDocked'] = True
self.state['StationName'] = entry.get('StationName') # It may be None
self.station_marketid = entry.get('MarketID') # It may be None
self.state['MarketID'] = entry.get('MarketID') # It may be None
self.stationtype = entry.get('StationType') # It may be None
self.stationservices = entry.get('StationServices') # None under E:D < 2.4
@ -957,7 +958,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
###############################################################
if event_type == 'fsdjump':
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None
@ -969,7 +970,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
if entry.get('BodyType') and entry['BodyType'] == 'Station':
self.state['StationName'] = entry.get('Body')
self.station_marketid = entry.get('MarketID') # May be None
self.state['MarketID'] = entry.get('MarketID') # May be None
self.stationtype = entry.get('StationType') # May be None
self.stationservices = entry.get('StationServices') # None in Odyssey for on-foot 'Location'
###############################################################
@ -1008,7 +1009,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
# Track: Current station, if applicable
###############################################################
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None
###############################################################
@ -1713,7 +1714,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['BodyID'] = None
self.state['BodyType'] = None
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None
self.state['OnFoot'] = False
@ -1732,7 +1733,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['BodyID'] = None
self.state['BodyType'] = None
self.state['StationName'] = None
self.station_marketid = None
self.state['MarketID'] = None
self.stationtype = None
self.stationservices = None

View File

@ -188,16 +188,7 @@ def journal_entry(
this.system_name = state['SystemName']
this.system_population = state['SystemPopulation']
this.station_name = state['StationName']
this.station_marketid = entry.get('MarketID') or this.station_marketid
# We might pick up StationName in DockingRequested, make sure we clear it if leaving
if entry['event'] in ('Undocked', 'FSDJump', 'SupercruiseEntry'):
this.station_marketid = None
if entry['event'] == 'Embark' and not entry.get('OnStation'):
# If we're embarking OnStation to a Taxi/Dropship we'll also get an
# Undocked event.
this.station_marketid = None
this.station_marketid = state['MarketID']
# Only change URL text if we are current provider.
if config.get_str('station_provider') == 'eddb':