mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-25 12:42:14 +03:00
core/DuplicateMessages: black / quotes pass
This commit is contained in:
parent
20d784ae09
commit
32fb1b00ab
@ -41,33 +41,33 @@ class DuplicateMessages(Thread):
|
||||
"""Detect if the given message is in the duplicates cache."""
|
||||
with self.lock:
|
||||
# Test messages are never duplicate, would be a pain to wait for another test :D
|
||||
if re.search('test', json['$schemaRef'], re.I):
|
||||
if re.search("test", json["$schemaRef"], re.I):
|
||||
return False
|
||||
|
||||
# Shallow copy, minus headers
|
||||
json_test = {
|
||||
'$schemaRef': json['$schemaRef'],
|
||||
'message': dict(json['message']),
|
||||
"$schemaRef": json["$schemaRef"],
|
||||
"message": dict(json["message"]),
|
||||
}
|
||||
|
||||
# Remove timestamp (Mainly to avoid multiple scan messages and faction influences)
|
||||
json_test['message'].pop('timestamp')
|
||||
json_test["message"].pop("timestamp")
|
||||
|
||||
# Convert journal starPos to avoid software modification in dupe messages
|
||||
if 'StarPos' in json_test['message']:
|
||||
json_test['message']['StarPos'] = [int(round(x * 32)) for x in json_test['message']['StarPos']]
|
||||
if "StarPos" in json_test["message"]:
|
||||
json_test["message"]["StarPos"] = [int(round(x * 32)) for x in json_test["message"]["StarPos"]]
|
||||
|
||||
# Prevent journal Docked event with small difference in distance from start
|
||||
if 'DistFromStarLS' in json_test['message']:
|
||||
json_test['message']['DistFromStarLS'] = int(json_test['message']['DistFromStarLS'] + 0.5)
|
||||
if "DistFromStarLS" in json_test["message"]:
|
||||
json_test["message"]["DistFromStarLS"] = int(json_test["message"]["DistFromStarLS"] + 0.5)
|
||||
|
||||
# Remove journal ScanType and DistanceFromArrivalLS (Avoid duplicate scan messages after SAAScanComplete)
|
||||
json_test['message'].pop('ScanType', None)
|
||||
json_test['message'].pop('DistanceFromArrivalLS', None)
|
||||
json_test["message"].pop("ScanType", None)
|
||||
json_test["message"].pop("DistanceFromArrivalLS", None)
|
||||
|
||||
message = simplejson.dumps(json_test, sort_keys=True) # Ensure most duplicate messages will get the same
|
||||
# key
|
||||
key = hashlib.sha256(message.encode('utf8')).hexdigest()
|
||||
key = hashlib.sha256(message.encode("utf8")).hexdigest()
|
||||
|
||||
if key not in self.caches:
|
||||
self.caches[key] = datetime.utcnow()
|
||||
|
Loading…
x
Reference in New Issue
Block a user