From f67971f8b0b1d79e85832ae48742cae1ab157f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=82nderson=20Q?= Date: Fri, 11 Sep 2026 12:04:12 -0300 Subject: [PATCH 1/2] fix: resolve TRON Discord credential in worktrees --- engine/discord.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/engine/discord.py b/engine/discord.py index 99f1918..48d07d9 100644 --- a/engine/discord.py +++ b/engine/discord.py @@ -15,7 +15,16 @@ ENV = ROOT / ".env" # The operator-managed bot credential is shared by TRON worktrees. Keep the # engine-local file first for standalone installs and tests. -MODES_ENV = ROOT.parents[2] / "tron-modes" / ".env" +def _modes_env() -> Path: + """Find the shared modes env from either a checkout or an added worktree.""" + for parent in ROOT.parents: + candidate = parent / "tron-modes" / ".env" + if candidate.exists(): + return candidate + return ROOT.parents[2] / "tron-modes" / ".env" + + +MODES_ENV = _modes_env() CHANNEL_ID = "1547918251651112971" MESSAGE_URL = f"https://discord.com/api/v10/channels/{CHANNEL_ID}/messages" _state = {"loaded": False, "token": None, "after": None} From b421512dc6cd8694a67c207e7fd839fe7b061acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=82nderson=20Q?= Date: Fri, 11 Sep 2026 14:16:38 -0300 Subject: [PATCH 2/2] fix: identify TRON Discord requests --- engine/discord.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/engine/discord.py b/engine/discord.py index 48d07d9..fd39822 100644 --- a/engine/discord.py +++ b/engine/discord.py @@ -47,10 +47,14 @@ def _load(): def _request(url, data=None, timeout=10): + headers = { + "Authorization": f"Bot {_state['token']}", + "User-Agent": "42labs-tron/1.0", + } + if data is not None: + headers["Content-Type"] = "application/json" request = urllib.request.Request( - url, data=data, - headers={"Authorization": f"Bot {_state['token']}", - "Content-Type": "application/json"}) + url, data=data, headers=headers) with urllib.request.urlopen(request, timeout=timeout) as response: return json.loads(response.read().decode())