From 720a83db36c915b0c23fda71c85ca86ea441fba3 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Tue, 2 Jan 2018 17:13:02 +0000 Subject: [PATCH] Send EDShipyard and Coriolis links --- plugins/edsm.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/edsm.py b/plugins/edsm.py index 61c9e52a..9e4cda72 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -7,7 +7,6 @@ import requests import sys import time import urllib2 -from calendar import timegm from Queue import Queue from threading import Thread @@ -34,6 +33,7 @@ this = sys.modules[__name__] # For holding module globals this.session = requests.Session() this.queue = Queue() # Items to be sent to EDSM by worker thread this.discardedEvents = [] # List discarded events from EDSM +this.lastship = None # Description of last ship that we sent to EDSM this.lastlookup = False # whether the last lookup succeeded # Game state @@ -241,6 +241,15 @@ def cmdr_data(data, is_beta): this.lastlookup = False this.system.update_idletasks() + # Send ship info to EDSM + ship = companion.ship(data) + if ship != this.lastship: + cmdr = data['commander']['name'] + timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime()) + this.queue.put((cmdr, { 'event': 'Coriolis', 'timestamp': timestamp, 'url': coriolis.url(data, is_beta) } )) + this.queue.put((cmdr, { 'event': 'EDShipyard', 'timestamp': timestamp, 'url': edshipyard.url(data, is_beta) } )) + this.lastship = ship + # Worker thread def worker():