1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-02 08:31:16 +03:00

Send blackmarket messages to EDDN

This commit is contained in:
Jonathan Harris 2016-09-15 17:03:42 +01:00
parent 4d3fe1808c
commit 6f4a3b37a3
2 changed files with 41 additions and 17 deletions

View File

@ -3,6 +3,7 @@
import sys import sys
from sys import platform from sys import platform
from collections import OrderedDict
from functools import partial from functools import partial
import json import json
from os import mkdir from os import mkdir
@ -526,13 +527,11 @@ class AppWindow:
self.w.after(int(SERVER_RETRY * 1000), self.getandsend) self.w.after(int(SERVER_RETRY * 1000), self.getandsend)
# Send interesting events to EDDN # Send interesting events to EDDN
try:
if (config.getint('output') & config.OUT_SYS_EDDN and monitor.cmdr and if (config.getint('output') & config.OUT_SYS_EDDN and monitor.cmdr and
(entry['event'] == 'FSDJump' and system_changed or (entry['event'] == 'FSDJump' and system_changed or
entry['event'] == 'Docked' and station_changed or entry['event'] == 'Docked' and station_changed or
entry['event'] == 'Scan' and monitor.system)): entry['event'] == 'Scan' and monitor.system)):
try:
self.status['text'] = _('Sending data to EDDN...')
# strip out properties disallowed by the schema # strip out properties disallowed by the schema
for thing in ['CockpitBreach', 'BoostUsed', 'FuelLevel', 'FuelUsed', 'JumpDist']: for thing in ['CockpitBreach', 'BoostUsed', 'FuelLevel', 'FuelUsed', 'JumpDist']:
entry.pop(thing, None) entry.pop(thing, None)
@ -544,9 +543,26 @@ class AppWindow:
if 'StarSystem' not in entry: if 'StarSystem' not in entry:
entry['StarSystem'] = monitor.system entry['StarSystem'] = monitor.system
self.status['text'] = _('Sending data to EDDN...')
eddn.export_journal_entry(monitor.cmdr, monitor.is_beta, entry) eddn.export_journal_entry(monitor.cmdr, monitor.is_beta, entry)
self.status['text'] = '' self.status['text'] = ''
elif (config.getint('output') & config.OUT_MKT_EDDN and monitor.cmdr and
entry['event'] == 'MarketSell' and entry.get('BlackMarket')):
# Construct blackmarket message
msg = OrderedDict([
('systemName', monitor.system),
('stationName', monitor.station),
('timestamp', entry['timestamp']),
('name', entry['Type']),
('sellPrice', entry['SellPrice']),
('prohibited' , entry.get('IllegalGoods', False)),
])
self.status['text'] = _('Sending data to EDDN...')
eddn.export_blackmarket(monitor.cmdr, monitor.is_beta, msg)
self.status['text'] = ''
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
if __debug__: print_exc() if __debug__: print_exc()
self.status['text'] = _("Error: Can't connect to EDDN") self.status['text'] = _("Error: Can't connect to EDDN")
@ -559,6 +575,7 @@ class AppWindow:
if not config.getint('hotkey_mute'): if not config.getint('hotkey_mute'):
hotkeymgr.play_bad() hotkeymgr.play_bad()
def edsmpoll(self): def edsmpoll(self):
result = self.edsm.result result = self.edsm.result
if result['done']: if result['done']:

View File

@ -151,5 +151,12 @@ class _EDDN:
'message' : entry 'message' : entry
}) })
def export_blackmarket(self, cmdr, is_beta, msg):
self.send(cmdr, {
'$schemaRef' : 'http://schemas.elite-markets.net/eddn/blackmarket/1' + (is_beta and '/test' or ''),
'message' : msg
})
# singleton # singleton
eddn = _EDDN() eddn = _EDDN()