From 2d0ff37640582c9707952e29802a86284c6bea51 Mon Sep 17 00:00:00 2001 From: Niceygy Date: Sun, 5 Nov 2023 13:05:10 +0000 Subject: [PATCH] add username support --- .gitignore | 3 +++ game.py | 8 ++++++-- log.py | 3 ++- main.py | 8 +++++--- 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..490310b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +dist/ +*.spec \ No newline at end of file diff --git a/game.py b/game.py index fe3d6b0..af8209d 100644 --- a/game.py +++ b/game.py @@ -1,6 +1,10 @@ import json import os import glob +import getpass + +global username +username = getpass.getuser() global eventAssociationsMain global eventAssociationsDocked @@ -78,13 +82,13 @@ def eventHandler(event): print("Fileheader found, skipping") else: print(f"Found event: {event}") - system = getSystem(load("C:/Users/Nicey/Saved Games/Frontier Developments/Elite Dangerous")) + system = getSystem(load("C:/Users/"+username+"/Saved Games/Frontier Developments/Elite Dangerous")) if system: # Check if the string exists return eventAssociationsMain[event] + system else: return eventAssociationsMain[event] elif event in eventAssociationsDocked: - station = getStation(load("C:/Users/Nicey/Saved Games/Frontier Developments/Elite Dangerous")) + station = getStation(load("C:/Users/"+username+"/Saved Games/Frontier Developments/Elite Dangerous")) if station: # Check if the string exists print(f"Returning: {eventAssociationsDocked[event] + station}") return eventAssociationsDocked[event] + station diff --git a/log.py b/log.py index 1168075..17e0585 100644 --- a/log.py +++ b/log.py @@ -11,4 +11,5 @@ def onStart(): print("EDDP started") print("Log file: " + logDir + "/" + logFile) print("Log directory: " + logDir) - print("Log file: " + logFile) \ No newline at end of file + print("Log file: " + logFile) + return logDir + logFile \ No newline at end of file diff --git a/main.py b/main.py index 011e537..df50990 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,10 @@ from discordrp import Presence import time +import getpass from game import getCMDR, load, getSystem, eventHandler - +global username +username = getpass.getuser() def updatePrecense(presence, state, start_time, cmdr): @@ -26,7 +28,7 @@ def updatePrecense(presence, state, start_time, cmdr): start_time = int(time.time()) with Presence(client_id) as presence: - logFileLoaded = load("C:/Users/Nicey/Saved Games/Frontier Developments/Elite Dangerous") + logFileLoaded = load("C:/Users/"+username+"/Saved Games/Frontier Developments/Elite Dangerous") print("Connected") cmdr = getCMDR(logFileLoaded) updatePrecense(presence, "In the main menu", start_time, cmdr) @@ -34,7 +36,7 @@ def updatePrecense(presence, state, start_time, cmdr): while True: time.sleep(15) - logs = load("C:/Users/Nicey/Saved Games/Frontier Developments/Elite Dangerous") + logs = load("C:/Users/"+username+"/Saved Games/Frontier Developments/Elite Dangerous") for log in logs: if "event" in log: currently = eventHandler(log["event"])