diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 6b07bc5..869c018 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -117,6 +117,9 @@ jobs: -e BOT_PORT=3001 \ $BOT_IMAGE + # Connect bot to proxy network so n8n can reach it + docker network connect proxy $BOT_CONTAINER 2>/dev/null || true + # Start new portfolio container echo "🆕 Starting new dev container..." docker run -d \ diff --git a/discord-presence-bot/index.js b/discord-presence-bot/index.js index 9062e60..9264a57 100644 --- a/discord-presence-bot/index.js +++ b/discord-presence-bot/index.js @@ -35,26 +35,37 @@ function updatePresence(guild) { cachedData.activities = presence.activities ? presence.activities .filter((a) => a.type !== ActivityType.Custom) - .map((a) => ({ - name: a.name, - type: a.type, - details: a.details || null, - state: a.state || null, - assets: a.assets - ? { - large_image: a.assets.largeImage || null, - large_text: a.assets.largeText || null, - small_image: a.assets.smallImage || null, - small_text: a.assets.smallText || null, - } - : null, - timestamps: a.timestamps - ? { - start: a.timestamps.start?.toISOString() || null, - end: a.timestamps.end?.toISOString() || null, - } - : null, - })) + .map((a) => { + const entry = { + name: a.name, + type: a.type, + details: a.details || null, + state: a.state || null, + assets: a.assets + ? { + large_image: a.assets.largeImage || null, + large_text: a.assets.largeText || null, + small_image: a.assets.smallImage || null, + small_text: a.assets.smallText || null, + } + : null, + timestamps: a.timestamps + ? { + start: a.timestamps.start?.toISOString() || null, + end: a.timestamps.end?.toISOString() || null, + } + : null, + }; + if (a.applicationId && a.assets?.largeImage) { + const imgId = a.assets.largeImage.startsWith("mp:external") + ? `https://media.discordapp.net/${a.assets.largeImage.replace("mp:", "")}` + : `https://cdn.discordapp.com/app-assets/${a.applicationId}/${a.assets.largeImage}.png`; + entry.image = imgId; + } else if (a.assets?.largeImage) { + entry.image = `https://cdn.discordapp.com/app-assets/0/${a.assets.largeImage}.png`; + } + return entry; + }) : []; const spotifyActivity = presence.activities diff --git a/docker-compose.production.yml b/docker-compose.production.yml index a5a99b0..6f81850 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -115,6 +115,7 @@ services: - BOT_PORT=3001 networks: - portfolio_net + - proxy healthcheck: test: ["CMD", "wget", "-qO-", "http://localhost:3001/presence"] interval: 30s diff --git a/docker-compose.yml b/docker-compose.yml index d9a1eeb..f891c7e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -99,6 +99,7 @@ services: - BOT_PORT=3001 networks: - portfolio_net + - proxy healthcheck: test: ["CMD", "wget", "-qO-", "http://localhost:3001/presence"] interval: 30s