42 Commits
Author SHA1 Message Date
nvidia-stock-bot-ci d90b7cdbf8 Bump build version to 4.1.1 [skip ci] 2026-08-26 13:45:26 +00:00
Djeex 5a7a60d299 CI/CD hardening: lint, secret scan, coverage gate, auto CVE-fix PRs, GHCR + GitHub mirror publishing (#32)
CI / build-and-scan (push) Successful in 1m37s
- release changelog: commits rendered as description (link), divider lines dropped
- gitleaks secret scan and hadolint on every push/PR
- ruff lint/format gate (Python repos) with a pytest --cov-fail-under gate
- scheduled CRITICAL Trivy failures attempt an apk upgrade rebuild and open a follow-up PR if it clears the finding, instead of just failing red
- images also published to ghcr.io/djeex/<repo>
- a matching GitHub Release is created on the GitHub mirror, with a notice pointing back to this repo as the source of truth
2026-08-26 15:43:40 +02:00
Djeex b3ed21eec2 Merge pull request 'Align CI release workflow with adguard-cidre/socat-proxy template' (#31) from fix-ci-release-template into main
CI / build-and-scan (push) Successful in 31s
Reviewed-on: #31
2026-08-23 23:24:58 +02:00
Djeex b0a220e7a2 Link each commit in the release changelog to its own commit page
CI / build-and-scan (pull_request) Successful in 56s
COMMIT_LIST only rendered the bare subject line per commit, with no
way to jump to that specific commit — only the triggering commit
(Source:) had a link. Each line now reads
"- [<short-sha>](<repo>/commit/<sha>) <subject>", matching the same
link style already used for Source.
2026-08-23 23:20:51 +02:00
Djeex ae737c0bd0 Align CI release workflow with adguard-cidre/socat-proxy template
CI / build-and-scan (pull_request) Successful in 1m59s
The publish/release step had drifted from the sibling repos' reference
template: PR-number extraction relied on the local commit log after
the version-bump commit was already made, so it could never find the
triggering PR (that commit's own message has no PR reference) — fixed
by keying off github.sha, the fixed triggering commit, instead.

Also aligned: docker login casing (Djeex, not djeex), Trivy pinned to
0.74.0, deprecation check made informative instead of build-blocking,
publish skipped entirely when no container-relevant file changed, and
the release body now lists the individual commits (with a --- divider
under each heading) instead of the raw changed-files list.
2026-08-23 22:39:58 +02:00
Djeex d0b3fc6e18 Merge pull request 'Run as non-root (911:911), bump to 4.1.0' (#30) from dev-v4.1 into main
CI / build-and-scan (push) Successful in 36s
Reviewed-on: #30
2026-08-23 15:17:09 +02:00
Djeex 5f66d1e1e0 Run as non-root (911:911), bump to 4.1.0
CI / build-and-scan (pull_request) Successful in 58s
2026-08-23 14:35:41 +02:00
gitea-ci-bot 8b7eac51c8 chore: bump version to 4.0.5 [skip ci] 2026-08-22 21:18:17 +00:00
Djeex fb1387e6cc Merge pull request 'chore(deps): update python docker tag to v3.14.7' (#28) from renovate/python-3.x into main
Reviewed-on: #28
2026-08-22 23:17:44 +02:00
Djeex d972fdf145 chore(deps): update python docker tag to v3.14.7 2026-08-22 21:16:28 +00:00
gitea-ci-bot 753750530d chore: bump version to 4.0.4 [skip ci] 2026-08-22 21:14:15 +00:00
Djeex f4f41abbe8 Merge pull request 'Add Gitea Actions CI/CD pipeline' (#27) from dev-ci into main
Reviewed-on: #27
2026-08-22 23:13:45 +02:00
Djeex 7fb3663097 Cover notifier.py error paths (TEST_MODE, HTTP error, connection error)
Brings app/notifier.py from 73% to 100% test coverage by exercising the
three notification functions' TEST_MODE early-return, non-204 response,
and requests exception branches — the exact paths a requests upgrade
regression would break silently.
2026-08-22 23:08:33 +02:00
Djeex 530aeba667 Add Gitea Actions CI/CD pipeline
Bring nvidia-stock-bot up to the same CI/CD maturity as adguard-cidre:
pytest suite (19 tests), multi-stage Dockerfile with a dedicated test
stage, pinned requests dependency, Gitea Actions workflow (build, smoke
test, unit tests, deprecation check, Trivy critical/high scan, version
bump + registry publish + release), and a Renovate config for automated
dependency updates.
2026-08-22 22:54:18 +02:00
Djeex 10290fd28d Merge pull request 'Better versionning' (#25) from fixed-cache into main
Reviewed-on: #25
2025-12-05 16:55:42 +01:00
Djeex b26a6a2d0a Better versionning 2025-12-05 16:46:44 +01:00
Djeex 78ee9ac9da Merge pull request 'fixed cache issues' (#24) from fixed-cache into main
Reviewed-on: #24
2025-12-05 16:26:57 +01:00
Djeex cef6886fd2 fixed cache issues 2025-12-05 16:20:42 +01:00
Djeex b3fe0fcf24 Merge pull request 'Fixed headers' (#23) from headers-fix into main
Reviewed-on: #23
2025-12-04 22:23:15 +01:00
Djeex 2484568e5f Fixed headers 2025-12-04 21:20:50 +00:00
Djeex 7f24145dc2 Minor changes 2025-10-03 13:31:00 +02:00
Djeex 8f626a7737 Merge pull request 'Python 3.13 - Adress CVE vulnerabilities' (#22) from python3.13 into main
Reviewed-on: #22
2025-09-19 23:14:44 +02:00
Djeex 4c57a3a310 Python 3.13 - Adress CVE vulnerabilities 2025-09-19 21:13:00 +00:00
Djeex 407e27238f fixed typo 2025-08-06 07:34:56 +00:00
Djeex 961c24a6c6 Better README 2025-07-13 15:02:55 +00:00
Djeex a16db7be01 Better formatting 2025-07-13 15:01:54 +00:00
Djeex 92db785511 Fixed typo 2025-07-13 15:00:51 +00:00
Djeex 1f3db4dec8 Renamed 2025-07-13 14:59:21 +00:00
Djeex 1edaa2c71d Screenshot better resolution + added "how it works" scheme + typo fixing. 2025-07-13 14:58:29 +00:00
Djeex 004d227fd1 Fixed readme + docker compose 2025-07-12 22:48:17 +00:00
Djeex 40d83cad12 Readme + docker compose fix 2025-07-12 22:47:45 +00:00
Djeex fc15c6fbbe Merge pull request 'v4.0 - Full localisation' (#21) from wip into main
Reviewed-on: #21
2025-07-12 23:50:41 +02:00
Djeex 0c77df266f Better comment and logging version at start 2025-07-12 21:47:02 +00:00
Djeex 4cd15d9bcc New COUNTRY variable. It sets notifications language, currency, and API localization. Removed DISCORD_NOTIFICATION_CURRENCY and DISCORD_NOTIFICATION_LANGUAGE 2025-07-12 17:36:58 +00:00
Djeex 3ba8c86b53 Merge pull request 'Added DISCORD_NOTIFICATION_CURRENCY env var' (#20) from wip into main
Reviewed-on: #20
2025-07-12 15:15:13 +02:00
Djeex c5a280d911 Added DISCORD_NOTIFICATION_CURRENCY env var 2025-07-12 13:05:52 +00:00
Djeex 1b15946a55 Merge pull request 'Better default env var' (#19) from wip into main
Reviewed-on: #19
2025-07-12 13:20:50 +02:00
Djeex af86d4aa8f Better default env var 2025-07-12 11:19:55 +00:00
Djeex f2b5b184ea Merge pull request 'Modular python files' (#18) from wip into main
Reviewed-on: #18
2025-07-11 13:51:23 +02:00
Djeex 50a9c1f827 Merge pull request 'Modular python files' (#16) from wip-modules into wip
Reviewed-on: #16
2025-07-11 13:47:23 +02:00
Djeex 584c222076 Revamp 2025-07-11 11:42:52 +00:00
Djeex 70a7df1f97 Modules 2025-07-11 10:24:38 +00:00
25 changed files with 1730 additions and 707 deletions
+289
View File
@@ -0,0 +1,289 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 6 * * 1"
jobs:
build-and-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Scan for secrets
run: |
# docker cp, not a build COPY: a repo's own .dockerignore (e.g. one that
# excludes .git for prod builds) would otherwise silently give an empty,
# falsely-clean scan.
CID=$(docker create zricethezav/gitleaks:v8.30.1 detect --source=/repo --no-banner -v)
docker cp . "$CID:/repo"
docker start -a "$CID"
STATUS=$?
docker rm "$CID" > /dev/null
exit $STATUS
- name: Lint Dockerfile with hadolint
run: docker run --rm -i hadolint/hadolint:v2.15.1-alpine hadolint --failure-threshold error - < Dockerfile
- name: Build Docker image
run: |
docker build -t nvidia-stock-bot:ci . 2>&1 | tee build.log
if grep -q "Building wheel for" build.log; then
echo "::warning::A dependency was built from source — check Python/Alpine compatibility"
fi
- name: Smoke test (syntax check)
run: |
docker run --rm --entrypoint python nvidia-stock-bot:ci -c "
import ast, glob
ok = True
for f in glob.glob('/app/*.py'):
with open(f) as fh:
source = fh.read()
try:
ast.parse(source, filename=f)
except SyntaxError as e:
print(f'::error::Syntax error in {f}: {e}')
ok = False
if not ok:
exit(1)
print('OK: syntax is valid')
"
- name: Run unit tests
run: |
docker build --target test -t nvidia-stock-bot:test .
docker run --rm nvidia-stock-bot:test pytest -v --cov=. --cov-report=term-missing --cov-fail-under=75
- name: Lint with ruff
run: docker build --target lint -t nvidia-stock-bot:lint .
- name: Check deprecation warnings
run: |
docker run --rm --entrypoint python \
-e DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/123456789012345678/abcdef" \
-e PRODUCT_NAMES="RTX 5090 Founders Edition" \
-e TEST_MODE=True \
nvidia-stock-bot:ci -W error::DeprecationWarning -c "import main" 2>&1 | tee deprecation.log || true
if grep -qi "deprecat" deprecation.log; then
echo "::warning::Deprecation warning detected, check logs"
fi
- name: Scan with Trivy (critical - blocking)
id: trivy_critical
continue-on-error: true
run: |
docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL nvidia-stock-bot:ci
- name: Handle CRITICAL findings
if: steps.trivy_critical.outcome == 'failure'
run: |
if [ "${{ github.event_name }}" != "schedule" ]; then
echo "::error::CRITICAL vulnerabilities found, failing the build."
exit 1
fi
echo "Scheduled scan found CRITICAL vulnerabilities — attempting an automatic apk upgrade + rescan."
sed -i '/^FROM .* AS base$/a RUN apk upgrade --no-cache' Dockerfile
docker build -t nvidia-stock-bot:remediated .
if docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 1 --severity CRITICAL nvidia-stock-bot:remediated; then
echo "apk upgrade clears the CRITICAL finding(s) — opening a PR for review."
BRANCH="auto/cve-fix-$(date +%Y%m%d)-$(echo "${{ github.sha }}" | cut -c1-7)"
git config user.name "nvidia-stock-bot-ci"
git config user.email "[email protected]"
git checkout -b "$BRANCH"
git add Dockerfile
git commit -m "Auto-remediate CRITICAL CVE via apk upgrade"
git config --unset-all http.https://git.djeex.fr/.extraheader || true
git push "https://Djeex:${{ secrets.CI_PUSH_TOKEN }}@git.djeex.fr/Djeex/nvidia-stock-bot.git" "HEAD:$BRANCH"
PR_JSON=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg head "$BRANCH" '{title: "🔒 Auto: remediate CRITICAL CVE via apk upgrade", head: $head, base: "main", body: "Opened automatically by the scheduled CVE scan. An `apk upgrade --no-cache` cleared the CRITICAL Trivy finding(s) in a rebuild — review the diff and merge to publish the fix."}')" \
"https://git.djeex.fr/api/v1/repos/Djeex/nvidia-stock-bot/pulls")
echo "PR API response: $(echo "$PR_JSON" | jq -r '.html_url // .message // "unknown"')"
else
echo "::error::apk upgrade does not clear the CRITICAL finding(s) — no automatic fix available, needs manual review."
exit 1
fi
- name: Scan with Trivy (high - informative)
run: |
docker run --rm \
-e DOCKER_HOST=tcp://dockerhost:2375 \
--add-host=dockerhost:host-gateway \
aquasec/trivy:0.74.0 image --exit-code 0 --severity HIGH nvidia-stock-bot:ci
- name: Publish tagged image
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
BEFORE="${{ github.event.before }}"
if [ -n "$BEFORE" ] && [ "$BEFORE" != "0000000000000000000000000000000000000000" ] && git cat-file -e "$BEFORE" 2>/dev/null; then
BASE_REF="$BEFORE"
else
BASE_REF="HEAD~1"
fi
CHANGED=$(git diff --name-only "$BASE_REF" "${{ github.sha }}")
echo "Changed files:"
echo "$CHANGED"
if ! echo "$CHANGED" | grep -qE '^(Dockerfile|VERSION)$|^app/'; then
echo "No container-relevant file changed, skipping publish."
exit 0
fi
if echo "$CHANGED" | grep -qE '^VERSION$'; then
echo "VERSION was manually edited in this push, using it as-is."
else
echo "VERSION untouched but container files changed, auto-bumping the build number (Z)."
OLD_VERSION=$(tr -d '[:space:]' < VERSION)
IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD_VERSION"
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
echo "$NEW_VERSION" > VERSION
git config user.name "nvidia-stock-bot-ci"
git config user.email "[email protected]"
git add VERSION
git commit -m "Bump build version to $NEW_VERSION [skip ci]"
# Belt and suspenders: actions/checkout can leave its own ephemeral
# credential injected as an extraheader, which would silently override
# the URL-embedded token below. persist-credentials:false on checkout
# should already prevent this, but strip it here too just in case.
git config --unset-all http.https://git.djeex.fr/.extraheader || true
git push "https://Djeex:${{ secrets.CI_PUSH_TOKEN }}@git.djeex.fr/Djeex/nvidia-stock-bot.git" HEAD:main
fi
VERSION=$(tr -d '[:space:]' < VERSION)
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
MINOR_TAG="${MAJOR}.${MINOR}"
IMAGE=git.djeex.fr/djeex/nvidia-stock-bot
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.djeex.fr -u Djeex --password-stdin
# Retag the already-built, already-scanned image — never rebuild for publish,
# so what ships is byte-for-byte what Trivy just scanned.
docker tag nvidia-stock-bot:ci "$IMAGE:latest"
docker tag nvidia-stock-bot:ci "$IMAGE:$MINOR_TAG"
docker tag nvidia-stock-bot:ci "$IMAGE:$VERSION"
docker push "$IMAGE:latest"
docker push "$IMAGE:$MINOR_TAG"
docker push "$IMAGE:$VERSION"
GHCR_IMAGE=ghcr.io/djeex/nvidia-stock-bot
echo "${{ secrets.GH_TOKEN }}" | docker login ghcr.io -u Djeex --password-stdin
docker tag nvidia-stock-bot:ci "$GHCR_IMAGE:latest"
docker tag nvidia-stock-bot:ci "$GHCR_IMAGE:$MINOR_TAG"
docker tag nvidia-stock-bot:ci "$GHCR_IMAGE:$VERSION"
docker push "$GHCR_IMAGE:latest"
docker push "$GHCR_IMAGE:$MINOR_TAG"
docker push "$GHCR_IMAGE:$VERSION"
TRIGGER_MSG=$(git log -1 --format=%s "${{ github.sha }}")
PR_NUM=$(echo "$TRIGGER_MSG" | grep -oE '#[0-9]+' | head -1 | tr -d '#' || true)
CATEGORY="🔧 Maintenance"
CHANGE_TITLE="$TRIGGER_MSG"
if [ -n "$PR_NUM" ]; then
PR_JSON=$(curl -s -H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
"https://git.djeex.fr/api/v1/repos/Djeex/nvidia-stock-bot/pulls/$PR_NUM")
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty' 2>/dev/null || true)
LABELS=$(echo "$PR_JSON" | jq -r '.labels[]?.name' 2>/dev/null || true)
if [ -n "$PR_TITLE" ]; then
CHANGE_TITLE="$PR_TITLE"
fi
if echo "$LABELS" | grep -qx 'bug'; then
CATEGORY="⚠️ Hotfix"
elif echo "$LABELS" | grep -qx 'major'; then
CATEGORY="💥 Breaking change"
elif echo "$LABELS" | grep -qx 'minor'; then
CATEGORY="✨ Update"
fi
fi
REPO_URL="https://git.djeex.fr/Djeex/nvidia-stock-bot"
COMMIT_LIST=$(git log --no-merges --format="- %s ([%h](${REPO_URL}/commit/%H))" "$BASE_REF".."${{ github.sha }}")
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
SOURCE_LINE="[${SHORT_SHA}](${REPO_URL}/commit/${{ github.sha }})"
if [ -n "$PR_NUM" ]; then
SOURCE_LINE="[#${PR_NUM}](${REPO_URL}/pulls/${PR_NUM}) · ${SOURCE_LINE}"
fi
BODY=$(cat <<EOF
## Changelog
### ${CATEGORY}
${CHANGE_TITLE}
**Source:** ${SOURCE_LINE}
**Image:** \`${IMAGE}:${VERSION}\`
**Commits:**
${COMMIT_LIST}
EOF
)
JSON_PAYLOAD=$(jq -n \
--arg tag "$VERSION" \
--arg name "$VERSION" \
--arg body "$BODY" \
'{tag_name: $tag, name: $name, target_commitish: "main", body: $body}')
curl -s -o /dev/null -w "Release API response: %{http_code}\n" -X POST \
-H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"https://git.djeex.fr/api/v1/repos/Djeex/nvidia-stock-bot/releases"
MIRROR_NOTICE="_This github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, PR, history and release note there._"
GH_BODY=$(printf '%s\n\n%s' "$MIRROR_NOTICE" "$BODY")
GH_JSON_PAYLOAD=$(jq -n \
--arg tag "$VERSION" \
--arg name "$VERSION" \
--arg body "$GH_BODY" \
--arg sha "${{ github.sha }}" \
'{tag_name: $tag, name: $name, target_commitish: $sha, body: $body}')
GH_STATUS=0
for i in 1 2 3 4 5; do
GH_STATUS=$(curl -s -o /tmp/gh_release.json -w "%{http_code}" -X POST \
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
-H "Content-Type: application/json" \
-d "$GH_JSON_PAYLOAD" \
"https://api.github.com/repos/Djeex/nvidia-stock-bot/releases")
if [ "$GH_STATUS" = "201" ]; then
break
fi
echo "GitHub Release attempt $i failed (HTTP $GH_STATUS) — mirror may not have synced this commit yet, retrying in 15s..."
sleep 15
done
echo "GitHub Release API response: $GH_STATUS"
if [ "$GH_STATUS" != "201" ]; then
cat /tmp/gh_release.json 2>/dev/null || true
fi
+4
View File
@@ -0,0 +1,4 @@
.venv
__pycache__/
.coverage
.pytest_cache/
+25 -9
View File
@@ -1,18 +1,34 @@
FROM python:3.11-alpine FROM python:3.14.7-alpine AS base
RUN apk add --no-cache ca-certificates RUN apk add --no-cache ca-certificates
WORKDIR /app WORKDIR /app
COPY app/nvidia-stock-bot.py /app/ COPY VERSION /VERSION
COPY /app/ /app/
COPY app/requirements.txt /app/
COPY app/localization.json /app/
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
ENV DISCORD_WEBHOOK_URL="https://example.com/webhook" \ FROM base AS test
REFRESH_TIME="30"
CMD ["python", "nvidia-stock-bot.py"] RUN pip install --no-cache-dir pytest==9.1.1 pytest-cov==7.1.0
COPY pytest.ini /app/pytest.ini
COPY /tests/ /app/tests/
CMD ["pytest", "-v"]
FROM base AS lint
RUN pip install --no-cache-dir ruff==0.16.4
COPY ruff.toml /app/ruff.toml
COPY /tests/ /app/tests/
RUN ruff check . && ruff format --check .
FROM base
RUN addgroup -g 911 nvbot && adduser -D -u 911 -G nvbot nvbot
USER nvbot
CMD ["python", "main.py"]
+25 -25
View File
@@ -11,9 +11,13 @@
**🤖 Nvidia Stock Bot** - A bot that alerts you in real-time about **Nvidia RTX FE** GPU stock availability through Discord notifications. **🤖 Nvidia Stock Bot** - A bot that alerts you in real-time about **Nvidia RTX FE** GPU stock availability through Discord notifications.
> [!NOTE] > [!NOTE]
>_The code was partially written and structured using a generative AI._ >_Github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, history and release note there. LLM used for bugs check and languages files generation._
>
>_Github repo is a mirror of https://git.djeex.fr/Djeex/nvidia-stock-bot. You'll find full package, history and release note there._ ## 🖼️ Screenshots
<div align="center" >
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-discord-screenshot.png" alt="Nvidia Stock Bot - screenshots">
</div>
## 📌 Table of Contents ## 📌 Table of Contents
@@ -21,19 +25,20 @@
- [🐳 Docker Installation without cloning the repo (quick)](#-docker-installation-without-the-repo-quick) - [🐳 Docker Installation without cloning the repo (quick)](#-docker-installation-without-the-repo-quick)
- [🐙 Docker Installation with the repo (developer)](#-docker-installation-with-the-repo) - [🐙 Docker Installation with the repo (developer)](#-docker-installation-with-the-repo)
- [🐍 Python Installation (developer)](#-python-installation) - [🐍 Python Installation (developer)](#-python-installation)
- [🖼️ Screenshots](#-screenshots)
- [🐞 Common issues](#-common-issues) - [🐞 Common issues](#-common-issues)
- [❓ How it works](#-how-it-works)
- [🧑‍💻 Contributors](#-contributors) - [🧑‍💻 Contributors](#-contributors)
## ✨ Features ## ✨ Features
- Selectable GPU models - Selectable GPU models
- Selectable country marketplace to check. It will set notifications language and currency accordingly
- Discord `@everyone` or specified role on SKU change (possible imminent drop) - Discord `@everyone` or specified role on SKU change (possible imminent drop)
- Discord `@everyone` or specified role notification when stock is detected, including model, price, and link - Discord `@everyone` or specified role notification when stock is detected, including model, price, and link
- Silent Discord notification when no stock is detected - Silent Discord notification when no stock is detected
- Selectable notification language - Selectable notification server name in notification footer
- Selectable notification server name in footer
- Selectable check frequency - Selectable check frequency
- Test mode to check without sending notifications
## 🐳 Docker Installation without the repo (quick) ## 🐳 Docker Installation without the repo (quick)
@@ -55,13 +60,10 @@ services:
restart: unless-stopped restart: unless-stopped
environment: environment:
# Minimal environment variables # Minimal environment variables
- PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090") - PRODUCT_NAMES= # Exact GPU name (e.g. 'RTX 5080, RTX 5090')
- DISCORD_WEBHOOK_URL= # Your Discord webhook URL - DISCORD_WEBHOOK_URL= # Your Discord webhook URL
- API_URL_SKU= # API listing the product for your country - COUNTRY= # Set your country (e.g. 'US')
- API_URL_STOCK= # API providing stock data for your country
- PRODUCT_URL= # GPU purchase URL for your country
- PYTHONUNBUFFERED=1 # Enables real-time log output - PYTHONUNBUFFERED=1 # Enables real-time log output
command: python nvidia-stock-bot.py
``` ```
**Environment Variables:** **Environment Variables:**
@@ -70,13 +72,13 @@ services:
|---------------------|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| |---------------------|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `PRODUCT_NAMES` | The exact GPU names you're searching for | `RTX 5080, RTX 5090` | | | `PRODUCT_NAMES` | The exact GPU names you're searching for | `RTX 5080, RTX 5090` | |
| `DISCORD_WEBHOOK_URL` | Your Discord webhook URL | A valid URL | | | `DISCORD_WEBHOOK_URL` | Your Discord webhook URL | A valid URL | |
| `COUNTRY` | Your country (only one). API localization, Discord notification currency and language will be set accordingly | `GB`, `US`, `CA`, `BE`, `NL`, `DK`, `DE`, `ES`, `FR`, `IT`, `NO`, `AT`, `PL`, `FI`, `SE`, `KR`, `JP` | `US` |
| `DISCORD_SERVER_NAME` | The name of your server, displayed in notification's footer | A text | Shared for free | | `DISCORD_SERVER_NAME` | The name of your server, displayed in notification's footer | A text | Shared for free |
| `DISCORD_NOTIFICATION_LANGUAGE` | Your language for notification's content | `bg`, `cs`, `da`, `de`, `el`, `en`, `es`, `et`, `fi`, `fr`, `ga`, `hr`, `hu`, `it`, `lt`, `lv`, `mt`, `nl`, `pl`, `pt`, `ro`, `sk`, `sl`, `sv` | `en` |
| `DISCORD_ROLES` | List of Discord roles ID in the same order than `PRODUCT_NAMES` values, found in your discord server settings (with user profile developer mode enabled) | `<@&12345><@&6789>` | @everyone | | `DISCORD_ROLES` | List of Discord roles ID in the same order than `PRODUCT_NAMES` values, found in your discord server settings (with user profile developer mode enabled) | `<@&12345><@&6789>` | @everyone |
| `REFRESH_TIME` | Script refresh interval in seconds | `60`, `30`, etc. | `30` | | `REFRESH_TIME` | Script refresh interval in seconds | `60`, `30`, etc. | `30` |
| `API_URL_SKU` | API listing the product | A URL. API url can change over time. For now, you can use the default one and change the `locale` parameter to yours (e.g. `locale=en-gb`) | `https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia` | | `API_URL_SKU` | API listing the product. Use it for development purpose. __Warning__ : it will override the locale set by `COUNTRY`. | An URL | `https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale={locale}&Manufacturer=Nvidia` |
| `API_URL_STOCK` | API providing stock data | A URL. API url can change over time. For now, you can use the default one and change the `locale` parameter to yours (e.g. `locale=en-gb`) | `https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus=` | | `API_URL_STOCK` | API providing stock data. Use it for development purpose. __Warning__ : it will override the locale set by `COUNTRY`. | A URL | `https://api.store.nvidia.com/partner/v1/feinventory?locale={locale}&skus=` |
| `PRODUCT_URL` | GPU purchase URL. There isn't any direct link workinf right now, so put the generic marketplace url listing all FE products | A URL. API url can change over time. For now, you can use the default one and change the locale parameter to yours (e.g. `/en-gb/`) | `https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&manufacturer=NVIDIA` | | `PRODUCT_URL` | GPU purchase URL. Use it for development purpose. __Warning__ : it will override the locale set by `COUNTRY`. | A URL | `https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale={locale}&page=1&limit=12&manufacturer=NVIDIA` |
| `TEST_MODE` | For testing without sending notifications | `True`, `False` | `False` | | `TEST_MODE` | For testing without sending notifications | `True`, `False` | `False` |
| `PYTHONUNBUFFERED` | Enables real-time log output | `1`, `0` | `1` | | `PYTHONUNBUFFERED` | Enables real-time log output | `1`, `0` | `1` |
@@ -152,12 +154,10 @@ git clone https://git.djeex.fr/Djeex/nvidia-stock-bot.git
```sh ```sh
export DISCORD_WEBHOOK_URL="https://your_discord_url" export DISCORD_WEBHOOK_URL="https://your_discord_url"
export COUNTRY=US
export PRODUCT_NAMES=RTX 5080, RTX 5090 export PRODUCT_NAMES=RTX 5080, RTX 5090
export DISCORD_ROLES=<@&12345>, <@&6789> export DISCORD_ROLES=<@&12345>, <@&6789>
export REFRESH_TIME="60" export REFRESH_TIME="60"
export API_URL_SKU="https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia&gpu=RTX%205080"
export API_URL_STOCK="https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus="
export PRODUCT_URL="https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&gpu=RTX%205080&manufacturer=NVIDIA"
export TEST_MODE=false export TEST_MODE=false
export PYTHONUNBUFFERED=1 export PYTHONUNBUFFERED=1
``` ```
@@ -168,19 +168,19 @@ export PYTHONUNBUFFERED=1
python nvidia-stock-bot.py python nvidia-stock-bot.py
``` ```
## 🖼️ Screenshots
<div align="center" >
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-discord.png" alt="Nvidia Stock Bot - screenshots">
</div>
## 🐞 Common issues ## 🐞 Common issues
Error when trying to reach product API url : Error when trying to reach product API url :
- `API_SKU_URL` may be wrong - Custom `API_SKU_URL` may be wrong
- Your IP may be blacklisted by nvidia. Try to use a VPN. - Your IP may be blacklisted by nvidia. Try to use a VPN.
- nvidia API may be down - nvidia API may be down
## ❓ How it works
<div align="center" >
<img src="https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/nvidia-stock-bot-scheme.svg" alt="Nvidia Stock Bot - screenshots">
</div>
## 🧑‍💻 Contributors ## 🧑‍💻 Contributors
Thanks for their contributions: Thanks for their contributions:
+1
View File
@@ -0,0 +1 @@
4.1.1
+205
View File
@@ -0,0 +1,205 @@
import json
import logging
import os
import re
import sys
# Read version from VERSION file
with open(
os.path.join(os.path.dirname(os.path.dirname(__file__)), "VERSION"), encoding="utf-8"
) as f:
VERSION = f.read().strip()
# Logger setup
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
)
# Logging starter
logging.info("=" * 60)
logging.info("🟩 Nvidia Stock Bot - Version %s", VERSION)
logging.info("Source: https://git.djeex.fr/Djeex/nvidia-stock-bot")
logging.info("Mirror: https://github.com/Djeex/nvidia-stock-bot")
logging.info("=" * 60)
# Env variables
try:
DISCORD_WEBHOOK_URL = os.environ["DISCORD_WEBHOOK_URL"]
DISCORD_SERVER_NAME = os.environ.get("DISCORD_SERVER_NAME", "Shared for free")
DISCORD_ROLES = os.environ.get("DISCORD_ROLES")
COUNTRY = os.environ.get("COUNTRY") or "US"
REFRESH_TIME = int(os.environ.get("REFRESH_TIME") or 30)
TEST_MODE = os.environ.get("TEST_MODE", "False").lower() == "true"
PRODUCT_NAMES = os.environ["PRODUCT_NAMES"]
# Errors and warning
except KeyError as e:
logging.error(f"Missing environment variable: {e}")
sys.exit(1)
except ValueError:
logging.error("REFRESH_TIME must be a valid integer.")
sys.exit(1)
if TEST_MODE:
logging.warning("🚧 Test mode is active. No real alerts will be sent.")
if not PRODUCT_NAMES:
logging.error("❌ PRODUCT_NAMES is required but not defined.")
sys.exit(1)
if not DISCORD_WEBHOOK_URL:
logging.error("❌ DISCORD_WEBHOOK_URL is required but not defined.")
sys.exit(1)
PRODUCT_NAMES = [name.strip() for name in PRODUCT_NAMES.split(",")]
# Role mapping
DISCORD_ROLE_MAP = {}
if not DISCORD_ROLES or not DISCORD_ROLES.strip():
logging.warning("⚠️ DISCORD_ROLES not defined or empty. Defaulting all roles to @everyone.")
for name in PRODUCT_NAMES:
DISCORD_ROLE_MAP[name] = "@everyone"
else:
roles = [r.strip() if r.strip() else "@everyone" for r in DISCORD_ROLES.split(",")]
if len(roles) != len(PRODUCT_NAMES):
logging.error("❌ The number of DISCORD_ROLES must match PRODUCT_NAMES.")
sys.exit(1)
for name, role in zip(PRODUCT_NAMES, roles):
if role != "@everyone" and not re.match(r"^<@&\d{17,20}>$", role):
logging.error(f"❌ Invalid DISCORD_ROLE format for {name}: {role}")
sys.exit(1)
DISCORD_ROLE_MAP[name] = role
# Masked webhook in terminal
match = re.search(r"/(\d+)/(.*)", DISCORD_WEBHOOK_URL)
if match:
webhook_id = match.group(1)
webhook_token = match.group(2)
masked_webhook_id = webhook_id[: len(webhook_id) - 10] + "*" * 10
masked_webhook_token = webhook_token[: len(webhook_token) - 120] + "*" * 10
wh_masked_url = f"https://discord.com/api/webhooks/{masked_webhook_id}/{masked_webhook_token}"
else:
wh_masked_url = "[Invalid webhook URL]"
# HTTP headers
HEADERS = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Referer": "https://partners.nvidia.com/",
"Origin": "https://partners.nvidia.com",
"Connection": "keep-alive",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Ch-Ua": '"Google Chrome";v="131", "Chromium";v="131", "Not.A/Brand";v="24"',
"Sec-Ch-Ua-Platform": '"macOS"',
"Cache-Control": "no-cache, no-store, must-revalidate",
"Pragma": "no-cache",
"Expires": "0",
}
# Load country setting and localization config
country_code = os.environ.get("COUNTRY", "US").upper()
try:
with open("localization.json", encoding="utf-8") as f:
localization_config = json.load(f)
except FileNotFoundError:
logging.error("❌ localization.json file not found.")
sys.exit(1)
# Find country entry
country_entry = next(
(entry for entry in localization_config if entry["country_code"].upper() == country_code), None
)
if not country_entry:
logging.warning(f"⚠️ Country '{country_code}' not found in localization.json. Defaulting to US.")
country_entry = next(
(entry for entry in localization_config if entry["country_code"].upper() == "US"), None
)
if not country_entry:
logging.error("❌ US fallback not found in localization.json.")
sys.exit(1)
# Extract language code and currency
full_lang_code = country_entry["language_code"]
language = full_lang_code[:2].lower() # e.g., "en-US" -> "en"
currency = country_entry["currency"]
# Load language file
try:
with open("languages.json", encoding="utf-8") as f:
loc_lang = json.load(f)
except FileNotFoundError:
logging.error("❌ languages.json file not found.")
sys.exit(1)
loc = loc_lang.get(language, loc_lang.get("en", {}))
logging.info(f"Notification language: {language} (from country {country_code})")
logging.info(f"Currency symbol: {currency}")
if not loc:
logging.warning(f"⚠️ Language '{language}' not found. Falling back to English.")
loc = loc_lang.get("en", {})
language = "en"
# Ensure all required keys are present
required_keys = [
"in_stock_title",
"out_of_stock_title",
"sku_change_title",
"buy_now",
"price",
"time",
"footer",
"sku_description",
"imminent_drop",
]
missing_keys = [key for key in required_keys if key not in loc]
fallback = loc_lang.get("en", {})
for key in missing_keys:
if key in fallback:
loc[key] = fallback[key]
else:
logging.error(f"❌ Missing required key '{key}' in both '{language}' and fallback 'en'.")
sys.exit(1)
# Localized API - Env var can be overrided for development purposes
locale = full_lang_code.lower()
API_URL_SKU = os.getenv(
"API_URL_SKU",
f"https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale={locale}&Manufacturer=Nvidia",
)
API_URL_STOCK = os.getenv(
"API_URL_STOCK", f"https://api.store.nvidia.com/partner/v1/feinventory?locale={locale}&skus="
)
PRODUCT_URL = os.getenv(
"PRODUCT_URL",
f"https://marketplace.nvidia.com/{locale}/consumer/graphics-cards/?locale={locale}&page=1&limit=12&manufacturer=NVIDIA",
)
# Public constants
in_stock_title = loc["in_stock_title"]
out_of_stock_title = loc["out_of_stock_title"]
sku_change_title = loc["sku_change_title"]
buy_now = loc["buy_now"]
price_label = loc["price"]
time_label = loc["time"]
footer = loc["footer"]
sku_description = loc["sku_description"]
imminent_drop = loc["imminent_drop"]
# Logging
logging.info(f"GPU: {PRODUCT_NAMES}")
logging.info(f"Discord Webhook URL: {wh_masked_url}")
logging.info(f"Discord Role Mention: {DISCORD_ROLES}")
logging.info(f"API URL SKU: {API_URL_SKU}")
logging.info(f"API URL Stock: {API_URL_STOCK}")
logging.info(f"Product URL: {PRODUCT_URL}")
logging.info(f"Refresh time: {REFRESH_TIME} seconds")
logging.info(f"Test Mode: {TEST_MODE}")
+121
View File
@@ -0,0 +1,121 @@
import logging
import time
import requests
from requests.adapters import HTTPAdapter, Retry
from env_config import API_URL_SKU, API_URL_STOCK, HEADERS, PRODUCT_NAMES, PRODUCT_URL
from notifier import (
send_discord_notification,
send_out_of_stock_notification,
send_sku_change_notification,
)
# HTTP session
session = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
session.mount("https://", HTTPAdapter(max_retries=retries))
session.headers.update(HEADERS)
# Keeping memory of last run
last_sku_dict = {}
global_stock_status_dict = {}
first_run_dict = {name: True for name in PRODUCT_NAMES}
# Stock check function
def check_rtx_50_founders():
global last_sku_dict, global_stock_status_dict, first_run_dict
# Fetching nvidia API data
try:
cache_buster = int(time.time() * 1000)
sku_url = f"{API_URL_SKU}&_t={cache_buster}"
response = session.get(sku_url, timeout=10)
logging.info(f"SKU API response: {response.status_code}")
response.raise_for_status()
data = response.json()
except requests.exceptions.RequestException as e:
logging.error(f"SKU API error: {e}")
return
# Checking productSKU and productUPC for all GPU set in PRODUCT_NAME
all_products = data["searchedProducts"]["productDetails"]
for product_name in PRODUCT_NAMES:
product_details = None
for p in all_products:
if p.get("gpu", "").strip() == product_name:
product_details = p
break
if not product_details:
logging.warning(f"⚠️ No product with GPU '{product_name}' found.")
continue
product_sku = product_details["productSKU"]
product_upc = product_details.get("productUPC", "")
if not isinstance(product_upc, list):
product_upc = [product_upc]
# Detect SKU changes
old_sku = last_sku_dict.get(product_name)
if old_sku and old_sku != product_sku and not first_run_dict[product_name]:
logging.warning(f"⚠️ SKU changed for {product_name}: {old_sku}{product_sku}")
send_sku_change_notification(product_name, old_sku, product_sku, PRODUCT_URL)
last_sku_dict[product_name] = product_sku
first_run_dict[product_name] = False
# Check product availability in API_URL_STOCK for each SKU
cache_buster = int(time.time() * 1000)
api_stock_url = f"{API_URL_STOCK}{product_sku}&_t={cache_buster}"
logging.info(f"[{product_name}] Checking stock: {api_stock_url}")
try:
response = session.get(api_stock_url, timeout=10)
logging.info(f"[{product_name}] Stock API response: {response.status_code}")
response.raise_for_status()
stock_data = response.json()
except requests.exceptions.RequestException as e:
logging.error(f"Stock API error: {e}")
continue
# Retrieve availibilty and price for each SKU
products = stock_data.get("listMap", [])
products_price = "Price not available"
if isinstance(products, list) and len(products) > 0:
for p in products:
price = p.get("price", "Price not available")
if price != "Price not available":
products_price = price
break
else:
logging.error(f"[{product_name}] Product list is empty or malformed.")
found_in_stock = set()
for p in products:
gpu_name = p.get("fe_sku", "").upper()
is_active = p.get("is_active") == "true"
if is_active and any(upc.upper() in gpu_name for upc in product_upc):
found_in_stock.add(gpu_name)
# Comparing previous state and notify
for upc in product_upc:
upc_upper = upc.upper()
currently_in_stock = upc_upper in found_in_stock
previously_in_stock = global_stock_status_dict.get((product_name, upc_upper), False)
if currently_in_stock and not previously_in_stock:
send_discord_notification(product_name, PRODUCT_URL, products_price)
global_stock_status_dict[(product_name, upc_upper)] = True
logging.info(f"[{product_name}] {upc} is now in stock!")
elif not currently_in_stock and previously_in_stock:
send_out_of_stock_notification(product_name, PRODUCT_URL, products_price)
global_stock_status_dict[(product_name, upc_upper)] = False
logging.info(f"[{product_name}] {upc} is now out of stock.")
elif currently_in_stock:
logging.info(f"[{product_name}] {upc} still in stock.")
else:
logging.info(f"[{product_name}] {upc} still out of stock.")
+266
View File
@@ -0,0 +1,266 @@
{
"en": {
"in_stock_title": "🚀 {gpu_name} IN STOCK!",
"out_of_stock_title": "❌ {gpu_name} is out of stock",
"sku_change_title": "🔄 SKU change detected for {gpu_name}",
"buy_now": "**:point_right: [Buy now]({product_link})**",
"price": "Price",
"time": "Time",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Old SKU** : `{old_sku}`\n**New SKU** : `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possible imminent drop!"
},
"bg": {
"in_stock_title": "🚀 {gpu_name} ИМА НАЛИЧНОСТ!",
"out_of_stock_title": "❌ {gpu_name} е изчерпан",
"sku_change_title": "🔄 Засечена промяна на SKU за {gpu_name}",
"buy_now": "**:point_right: [Купи сега]({product_link})**",
"price": "Цена",
"time": "Час",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Стар SKU**: `{old_sku}`\n**Нов SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Възможен наближаващ спад!"
},
"cs": {
"in_stock_title": "🚀 {gpu_name} SKLADEM!",
"out_of_stock_title": "❌ {gpu_name} je vyprodán",
"sku_change_title": "🔄 Změna SKU nalezena pro {gpu_name}",
"buy_now": "**:point_right: [Koupit nyní]({product_link})**",
"price": "Cena",
"time": "Čas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Starý SKU**: `{old_sku}`\n**Nový SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Možný blížící se pokles!"
},
"da": {
"in_stock_title": "🚀 {gpu_name} PÅ LAGER!",
"out_of_stock_title": "❌ {gpu_name} er udsolgt",
"sku_change_title": "🔄 SKU-ændring fundet for {gpu_name}",
"buy_now": "**:point_right: [Køb nu]({product_link})**",
"price": "Pris",
"time": "Tid",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Gammelt SKU**: `{old_sku}`\n**Nyt SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Muligt snarligt drop!"
},
"de": {
"in_stock_title": "🚀 {gpu_name} AUF LAGER!",
"out_of_stock_title": "❌ {gpu_name} ist ausverkauft",
"sku_change_title": "🔄 SKU-Änderung erkannt für {gpu_name}",
"buy_now": "**:point_right: [Jetzt kaufen]({product_link})**",
"price": "Preis",
"time": "Zeit",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Alte SKU**: `{old_sku}`\n**Neue SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Möglicher bevorstehender Drop!"
},
"el": {
"in_stock_title": "🚀 {gpu_name} ΔΙΑΘΕΣΙΜΟ!",
"out_of_stock_title": "❌ {gpu_name} εξαντλήθηκε",
"sku_change_title": "🔄 Ανίχνευση αλλαγής SKU για {gpu_name}",
"buy_now": "**:point_right: [Αγόρασε τώρα]({product_link})**",
"price": "Τιμή",
"time": "Ώρα",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Παλαιό SKU**: `{old_sku}`\n**Νέο SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Πιθανή επικείμενη πτώση!"
},
"es": {
"in_stock_title": "🚀 {gpu_name} ¡EN STOCK!",
"out_of_stock_title": "❌ {gpu_name} está agotado",
"sku_change_title": "🔄 Cambio de SKU detectado para {gpu_name}",
"buy_now": "**:point_right: [Comprar ahora]({product_link})**",
"price": "Precio",
"time": "Hora",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU antiguo**: `{old_sku}`\n**SKU nuevo**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ ¡Posible drop inminente!"
},
"et": {
"in_stock_title": "🚀 {gpu_name} LAOS!",
"out_of_stock_title": "❌ {gpu_name} on välja müüdud",
"sku_change_title": "🔄 Tuvastatud SKU muudatus {gpu_name}",
"buy_now": "**:point_right: [Osta kohe]({product_link})**",
"price": "Hind",
"time": "Aeg",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vana SKU**: `{old_sku}`\n**Uus SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Võimalik varsti tulemas drop!"
},
"fi": {
"in_stock_title": "🚀 {gpu_name} VARASTOSSA!",
"out_of_stock_title": "❌ {gpu_name} on loppunut",
"sku_change_title": "🔄 SKU-muutos havaittu {gpu_name}",
"buy_now": "**:point_right: [Osta nyt]({product_link})**",
"price": "Hinta",
"time": "Aika",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vanha SKU**: `{old_sku}`\n**Uusi SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Mahdollinen lähestyvä drop!"
},
"fr": {
"in_stock_title": "🚀 {gpu_name} EN STOCK !",
"out_of_stock_title": "❌ {gpu_name} est en rupture",
"sku_change_title": "🔄 Changement de SKU détecté pour {gpu_name}",
"buy_now": "**:point_right: [Acheter maintenant]({product_link})**",
"price": "Prix",
"time": "Heure",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Ancien SKU** : `{old_sku}`\n**Nouveau SKU** : `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Éventuel drop imminent!"
},
"hr": {
"in_stock_title": "🚀 {gpu_name} NA ZALIHI!",
"out_of_stock_title": "❌ {gpu_name} je rasprodan",
"sku_change_title": "🔄 Promjena SKU za {gpu_name}",
"buy_now": "**:point_right: [Kupi sada]({product_link})**",
"price": "Cijena",
"time": "Vrijeme",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Stari SKU**: `{old_sku}`\n**Novi SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Mogući nadolazeći drop!"
},
"hu": {
"in_stock_title": "🚀 {gpu_name} RAKTÁRON!",
"out_of_stock_title": "❌ {gpu_name} elfogyott",
"sku_change_title": "🔄 SKU változás észlelve: {gpu_name}",
"buy_now": "**:point_right: [Vásárlás most]({product_link})**",
"price": "Ár",
"time": "Idő",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Régi SKU**: `{old_sku}`\n**Új SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Lehetséges közelgő drop!"
},
"ga": {
"in_stock_title": "🚀 {gpu_name} I STOC!",
"out_of_stock_title": "❌ níl {gpu_name} ar fáil",
"sku_change_title": "🔄 SKU athraithe aimsithe do {gpu_name}",
"buy_now": "**:point_right: [Ceannaigh anois]({product_link})**",
"price": "Praghas",
"time": "Am",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Sean SKU**: `{old_sku}`\n**SKU Nua**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ I bhfad is gaire drop féideartha!"
},
"it": {
"in_stock_title": "🚀 {gpu_name} DISPONIBILE!",
"out_of_stock_title": "❌ {gpu_name} esaurito",
"sku_change_title": "🔄 Modifica SKU rilevata per {gpu_name}",
"buy_now": "**:point_right: [Acquista ora]({product_link})**",
"price": "Prezzo",
"time": "Ora",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vecchio SKU**: `{old_sku}`\n**Nuovo SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possibile drop imminente!"
},
"lv": {
"in_stock_title": "🚀 {gpu_name} KRĀJUMĀ!",
"out_of_stock_title": "❌ {gpu_name} nav pieejams",
"sku_change_title": "🔄 SKU izmaiņas: {gpu_name}",
"buy_now": "**:point_right: [Pirkt tagad]({product_link})**",
"price": "Cena",
"time": "Laiks",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vecais SKU**: `{old_sku}`\n**Jaunais SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Iespējams gaidāms drop!"
},
"lt": {
"in_stock_title": "🚀 {gpu_name} SANDĖLYJE!",
"out_of_stock_title": "❌ {gpu_name} išparduotas",
"sku_change_title": "🔄 SKU pakeitimas aptiktas: {gpu_name}",
"buy_now": "**:point_right: [Pirkti dabar]({product_link})**",
"price": "Kaina",
"time": "Laikas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Senas SKU**: `{old_sku}`\n**Naujas SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Rugsėjo drop'as gali artėti!"
},
"mt": {
"in_stock_title": "🚀 {gpu_name} F'ĠESTA!",
"out_of_stock_title": "❌ {gpu_name} mhux disponibbli",
"sku_change_title": "🔄 Bidla SKU skoperta għal {gpu_name}",
"buy_now": "**:point_right: [Ixtri issa]({product_link})**",
"price": "Prezz",
"time": "Ħin",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU Antik**: `{old_sku}`\n**SKU Ġdid**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possibbli drop imminenti!"
},
"nl": {
"in_stock_title": "🚀 {gpu_name} OP VOORRAAD!",
"out_of_stock_title": "❌ {gpu_name} is uitverkocht",
"sku_change_title": "🔄 SKU-wijziging gedetecteerd voor {gpu_name}",
"buy_now": "**:point_right: [Nu kopen]({product_link})**",
"price": "Prijs",
"time": "Tijd",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Oude SKU**: `{old_sku}`\n**Nieuwe SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Mogelijke aanstaande drop!"
},
"pl": {
"in_stock_title": "🚀 {gpu_name} DOSTĘPNE!",
"out_of_stock_title": "❌ {gpu_name} jest niedostępny",
"sku_change_title": "🔄 Wykryto zmianę SKU dla {gpu_name}",
"buy_now": "**:point_right: [Kup teraz]({product_link})**",
"price": "Cena",
"time": "Czas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Stare SKU**: `{old_sku}`\n**Nowe SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Możliwy nadchodzący drop!"
},
"pt": {
"in_stock_title": "🚀 {gpu_name} EM STOCK!",
"out_of_stock_title": "❌ {gpu_name} esgotado",
"sku_change_title": "🔄 Alteração de SKU detectada para {gpu_name}",
"buy_now": "**:point_right: [Comprar agora]({product_link})**",
"price": "Preço",
"time": "Hora",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU antigo**: `{old_sku}`\n**SKU novo**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possível drop iminente!"
},
"ro": {
"in_stock_title": "🚀 {gpu_name} ÎN STOC!",
"out_of_stock_title": "❌ {gpu_name} este epuizat",
"sku_change_title": "🔄 Schimbare SKU detectată pentru {gpu_name}",
"buy_now": "**:point_right: [Cumpără acum]({product_link})**",
"price": "Preț",
"time": "Timp",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU vechi**: `{old_sku}`\n**SKU nou**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Posibil drop iminent!"
},
"sk": {
"in_stock_title": "🚀 {gpu_name} NA SKLADE!",
"out_of_stock_title": "❌ {gpu_name} je vypredaný",
"sku_change_title": "🔄 Zmena SKU zistená pre {gpu_name}",
"buy_now": "**:point_right: [Kúp teraz]({product_link})**",
"price": "Cena",
"time": "Čas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Starý SKU**: `{old_sku}`\n**Nový SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Možný nadchádzajúci drop!"
},
"sl": {
"in_stock_title": "🚀 {gpu_name} NA ZALOGI!",
"out_of_stock_title": "❌ {gpu_name} je razprodan",
"sku_change_title": "🔄 Sprememba SKU zaznana za {gpu_name}",
"buy_now": "**:point_right: [Kupi zdaj]({product_link})**",
"price": "Cena",
"time": "Čas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Stari SKU**: `{old_sku}`\n**Novi SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Možen prihajajoči drop!"
},
"sv": {
"in_stock_title": "🚀 {gpu_name} I LAGER!",
"out_of_stock_title": "❌ {gpu_name} är slut",
"sku_change_title": "🔄 SKU-ändring upptäckt för {gpu_name}",
"buy_now": "**:point_right: [Köp nu]({product_link})**",
"price": "Pris",
"time": "Tid",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Gammalt SKU**: `{old_sku}`\n**Nytt SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Möjlig förestående drop!"
}
}
+87 -249
View File
@@ -1,266 +1,104 @@
{ [
"en": { {
"in_stock_title": "🚀 {gpu_name} IN STOCK!", "country": "United Kingdom",
"out_of_stock_title": "❌ {gpu_name} is out of stock", "country_code": "GB",
"sku_change_title": "🔄 SKU change detected for {gpu_name}", "language_code": "en-GB",
"buy_now": "**:point_right: [Buy now]({product_link})**", "currency": "£"
"price": "Price",
"time": "Time",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Old SKU** : `{old_sku}`\n**New SKU** : `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possible imminent drop!"
}, },
"bg": { {
"in_stock_title": "🚀 {gpu_name} ИМА НАЛИЧНОСТ!", "country": "United States",
"out_of_stock_title": "❌ {gpu_name} е изчерпан", "country_code": "US",
"sku_change_title": "🔄 Засечена промяна на SKU за {gpu_name}", "language_code": "en-US",
"buy_now": "**:point_right: [Купи сега]({product_link})**", "currency": "$"
"price": "Цена",
"time": "Час",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Стар SKU**: `{old_sku}`\n**Нов SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Възможен наближаващ спад!"
}, },
"cs": { {
"in_stock_title": "🚀 {gpu_name} SKLADEM!", "country": "Canada",
"out_of_stock_title": "❌ {gpu_name} je vyprodán", "country_code": "CA",
"sku_change_title": "🔄 Změna SKU nalezena pro {gpu_name}", "language_code": "en-CA",
"buy_now": "**:point_right: [Koupit nyní]({product_link})**", "currency": "$"
"price": "Cena",
"time": "Čas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Starý SKU**: `{old_sku}`\n**Nový SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Možný blížící se pokles!"
}, },
"da": { {
"in_stock_title": "🚀 {gpu_name} PÅ LAGER!", "country": "Belgium",
"out_of_stock_title": "❌ {gpu_name} er udsolgt", "country_code": "BE",
"sku_change_title": "🔄 SKU-ændring fundet for {gpu_name}", "language_code": "nl-BE",
"buy_now": "**:point_right: [Køb nu]({product_link})**", "currency": "€"
"price": "Pris",
"time": "Tid",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Gammelt SKU**: `{old_sku}`\n**Nyt SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Muligt snarligt drop!"
}, },
"de": { {
"in_stock_title": "🚀 {gpu_name} AUF LAGER!", "country": "Netherlands",
"out_of_stock_title": "❌ {gpu_name} ist ausverkauft", "country_code": "NL",
"sku_change_title": "🔄 SKU-Änderung erkannt für {gpu_name}", "language_code": "nl-NL",
"buy_now": "**:point_right: [Jetzt kaufen]({product_link})**", "currency": "€"
"price": "Preis",
"time": "Zeit",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Alte SKU**: `{old_sku}`\n**Neue SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Möglicher bevorstehender Drop!"
}, },
"el": { {
"in_stock_title": "🚀 {gpu_name} ΔΙΑΘΕΣΙΜΟ!", "country": "Denmark",
"out_of_stock_title": "❌ {gpu_name} εξαντλήθηκε", "country_code": "DK",
"sku_change_title": "🔄 Ανίχνευση αλλαγής SKU για {gpu_name}", "language_code": "da-DK",
"buy_now": "**:point_right: [Αγόρασε τώρα]({product_link})**", "currency": "kr"
"price": "Τιμή",
"time": "Ώρα",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Παλαιό SKU**: `{old_sku}`\n**Νέο SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Πιθανή επικείμενη πτώση!"
}, },
"es": { {
"in_stock_title": "🚀 {gpu_name} ¡EN STOCK!", "country": "Germany",
"out_of_stock_title": "❌ {gpu_name} está agotado", "country_code": "DE",
"sku_change_title": "🔄 Cambio de SKU detectado para {gpu_name}", "language_code": "de-DE",
"buy_now": "**:point_right: [Comprar ahora]({product_link})**", "currency": "€"
"price": "Precio",
"time": "Hora",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU antiguo**: `{old_sku}`\n**SKU nuevo**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ ¡Posible drop inminente!"
}, },
"et": { {
"in_stock_title": "🚀 {gpu_name} LAOS!", "country": "Spain",
"out_of_stock_title": "❌ {gpu_name} on välja müüdud", "country_code": "ES",
"sku_change_title": "🔄 Tuvastatud SKU muudatus {gpu_name}", "language_code": "es-ES",
"buy_now": "**:point_right: [Osta kohe]({product_link})**", "currency": "€"
"price": "Hind",
"time": "Aeg",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vana SKU**: `{old_sku}`\n**Uus SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Võimalik varsti tulemas drop!"
}, },
"fi": { {
"in_stock_title": "🚀 {gpu_name} VARASTOSSA!", "country": "France",
"out_of_stock_title": "❌ {gpu_name} on loppunut", "country_code": "FR",
"sku_change_title": "🔄 SKU-muutos havaittu {gpu_name}", "language_code": "fr-FR",
"buy_now": "**:point_right: [Osta nyt]({product_link})**", "currency": "€"
"price": "Hinta",
"time": "Aika",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vanha SKU**: `{old_sku}`\n**Uusi SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Mahdollinen lähestyvä drop!"
}, },
"fr": { {
"in_stock_title": "🚀 {gpu_name} EN STOCK !", "country": "Italy",
"out_of_stock_title": "❌ {gpu_name} est en rupture", "country_code": "IT",
"sku_change_title": "🔄 Changement de SKU détecté pour {gpu_name}", "language_code": "it-IT",
"buy_now": "**:point_right: [Acheter maintenant]({product_link})**", "currency": "€"
"price": "Prix",
"time": "Heure",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Ancien SKU** : `{old_sku}`\n**Nouveau SKU** : `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Éventuel drop imminent!"
}, },
"hr": { {
"in_stock_title": "🚀 {gpu_name} NA ZALIHI!", "country": "Norway",
"out_of_stock_title": "❌ {gpu_name} je rasprodan", "country_code": "NO",
"sku_change_title": "🔄 Promjena SKU za {gpu_name}", "language_code": "nb-NO",
"buy_now": "**:point_right: [Kupi sada]({product_link})**", "currency": "kr"
"price": "Cijena",
"time": "Vrijeme",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Stari SKU**: `{old_sku}`\n**Novi SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Mogući nadolazeći drop!"
}, },
"hu": { {
"in_stock_title": "🚀 {gpu_name} RAKTÁRON!", "country": "Austria",
"out_of_stock_title": "❌ {gpu_name} elfogyott", "country_code": "AT",
"sku_change_title": "🔄 SKU változás észlelve: {gpu_name}", "language_code": "de-AT",
"buy_now": "**:point_right: [Vásárlás most]({product_link})**", "currency": "€"
"price": "Ár",
"time": "Idő",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Régi SKU**: `{old_sku}`\n**Új SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Lehetséges közelgő drop!"
}, },
"ga": { {
"in_stock_title": "🚀 {gpu_name} I STOC!", "country": "Poland",
"out_of_stock_title": "❌ níl {gpu_name} ar fáil", "country_code": "PL",
"sku_change_title": "🔄 SKU athraithe aimsithe do {gpu_name}", "language_code": "pl-PL",
"buy_now": "**:point_right: [Ceannaigh anois]({product_link})**", "currency": "zł"
"price": "Praghas",
"time": "Am",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Sean SKU**: `{old_sku}`\n**SKU Nua**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ I bhfad is gaire drop féideartha!"
}, },
"it": { {
"in_stock_title": "🚀 {gpu_name} DISPONIBILE!", "country": "Finland",
"out_of_stock_title": "❌ {gpu_name} esaurito", "country_code": "FI",
"sku_change_title": "🔄 Modifica SKU rilevata per {gpu_name}", "language_code": "fi-FI",
"buy_now": "**:point_right: [Acquista ora]({product_link})**", "currency": "€"
"price": "Prezzo",
"time": "Ora",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vecchio SKU**: `{old_sku}`\n**Nuovo SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possibile drop imminente!"
}, },
"lv": { {
"in_stock_title": "🚀 {gpu_name} KRĀJUMĀ!", "country": "Sweden",
"out_of_stock_title": "❌ {gpu_name} nav pieejams", "country_code": "SE",
"sku_change_title": "🔄 SKU izmaiņas: {gpu_name}", "language_code": "sv-SE",
"buy_now": "**:point_right: [Pirkt tagad]({product_link})**", "currency": "kr"
"price": "Cena",
"time": "Laiks",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Vecais SKU**: `{old_sku}`\n**Jaunais SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Iespējams gaidāms drop!"
}, },
"lt": { {
"in_stock_title": "🚀 {gpu_name} SANDĖLYJE!", "country": "South Korea",
"out_of_stock_title": "❌ {gpu_name} išparduotas", "country_code": "KR",
"sku_change_title": "🔄 SKU pakeitimas aptiktas: {gpu_name}", "language_code": "ko-KR",
"buy_now": "**:point_right: [Pirkti dabar]({product_link})**", "currency": "₩"
"price": "Kaina",
"time": "Laikas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Senas SKU**: `{old_sku}`\n**Naujas SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Rugsėjo drop'as gali artėti!"
}, },
"mt": { {
"in_stock_title": "🚀 {gpu_name} F'ĠESTA!", "country": "Japan",
"out_of_stock_title": "❌ {gpu_name} mhux disponibbli", "country_code": "JP",
"sku_change_title": "🔄 Bidla SKU skoperta għal {gpu_name}", "language_code": "ja-JP",
"buy_now": "**:point_right: [Ixtri issa]({product_link})**", "currency": "¥"
"price": "Prezz",
"time": "Ħin",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU Antik**: `{old_sku}`\n**SKU Ġdid**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possibbli drop imminenti!"
},
"nl": {
"in_stock_title": "🚀 {gpu_name} OP VOORRAAD!",
"out_of_stock_title": "❌ {gpu_name} is uitverkocht",
"sku_change_title": "🔄 SKU-wijziging gedetecteerd voor {gpu_name}",
"buy_now": "**:point_right: [Nu kopen]({product_link})**",
"price": "Prijs",
"time": "Tijd",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Oude SKU**: `{old_sku}`\n**Nieuwe SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Mogelijke aanstaande drop!"
},
"pl": {
"in_stock_title": "🚀 {gpu_name} DOSTĘPNE!",
"out_of_stock_title": "❌ {gpu_name} jest niedostępny",
"sku_change_title": "🔄 Wykryto zmianę SKU dla {gpu_name}",
"buy_now": "**:point_right: [Kup teraz]({product_link})**",
"price": "Cena",
"time": "Czas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Stare SKU**: `{old_sku}`\n**Nowe SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Możliwy nadchodzący drop!"
},
"pt": {
"in_stock_title": "🚀 {gpu_name} EM STOCK!",
"out_of_stock_title": "❌ {gpu_name} esgotado",
"sku_change_title": "🔄 Alteração de SKU detectada para {gpu_name}",
"buy_now": "**:point_right: [Comprar agora]({product_link})**",
"price": "Preço",
"time": "Hora",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU antigo**: `{old_sku}`\n**SKU novo**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Possível drop iminente!"
},
"ro": {
"in_stock_title": "🚀 {gpu_name} ÎN STOC!",
"out_of_stock_title": "❌ {gpu_name} este epuizat",
"sku_change_title": "🔄 Schimbare SKU detectată pentru {gpu_name}",
"buy_now": "**:point_right: [Cumpără acum]({product_link})**",
"price": "Preț",
"time": "Timp",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**SKU vechi**: `{old_sku}`\n**SKU nou**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Posibil drop iminent!"
},
"sk": {
"in_stock_title": "🚀 {gpu_name} NA SKLADE!",
"out_of_stock_title": "❌ {gpu_name} je vypredaný",
"sku_change_title": "🔄 Zmena SKU zistená pre {gpu_name}",
"buy_now": "**:point_right: [Kúp teraz]({product_link})**",
"price": "Cena",
"time": "Čas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Starý SKU**: `{old_sku}`\n**Nový SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Možný nadchádzajúci drop!"
},
"sl": {
"in_stock_title": "🚀 {gpu_name} NA ZALOGI!",
"out_of_stock_title": "❌ {gpu_name} je razprodan",
"sku_change_title": "🔄 Sprememba SKU zaznana za {gpu_name}",
"buy_now": "**:point_right: [Kupi zdaj]({product_link})**",
"price": "Cena",
"time": "Čas",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Stari SKU**: `{old_sku}`\n**Novi SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Možen prihajajoči drop!"
},
"sv": {
"in_stock_title": "🚀 {gpu_name} I LAGER!",
"out_of_stock_title": "❌ {gpu_name} är slut",
"sku_change_title": "🔄 SKU-ändring upptäckt för {gpu_name}",
"buy_now": "**:point_right: [Köp nu]({product_link})**",
"price": "Pris",
"time": "Tid",
"footer": "NviBot • {DISCORD_SERVER_NAME}",
"sku_description": "**Gammalt SKU**: `{old_sku}`\n**Nytt SKU**: `{new_sku}`",
"imminent_drop": "{DISCORD_ROLE} ⚠️ Möjlig förestående drop!"
} }
} ]
+29
View File
@@ -0,0 +1,29 @@
import logging
import signal
import sys
import time
from env_config import REFRESH_TIME
from gpu_checker import check_rtx_50_founders
# Signal handler function
def handle_exit(signum, frame):
logging.info(f"🛑 Received signal {signum}. Exiting gracefully...")
sys.exit(0)
# Register signal handlers
signal.signal(signal.SIGINT, handle_exit) # Ctrl+C
signal.signal(signal.SIGTERM, handle_exit) # docker stop / kill -15
if __name__ == "__main__":
try:
while True:
start = time.time()
check_rtx_50_founders()
elapsed = time.time() - start
time.sleep(max(0, REFRESH_TIME - elapsed))
except KeyboardInterrupt:
logging.info("🛑 Script interrupted by user (KeyboardInterrupt). Exiting gracefully.")
sys.exit(0)
+136
View File
@@ -0,0 +1,136 @@
import logging
import time
import requests
from env_config import (
DISCORD_ROLE_MAP,
DISCORD_SERVER_NAME,
DISCORD_WEBHOOK_URL,
TEST_MODE,
buy_now,
currency,
footer,
imminent_drop,
in_stock_title,
out_of_stock_title,
price_label,
sku_change_title,
sku_description,
time_label,
)
AVATAR = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg"
THUMBNAIL = "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
# In stock
def send_discord_notification(gpu_name, product_link, products_price):
timestamp = int(time.time())
if TEST_MODE:
logging.info(f"[TEST MODE] Notification: {gpu_name} available!")
return
embed = {
"title": in_stock_title.format(gpu_name=gpu_name),
"color": 3066993,
"thumbnail": {"url": THUMBNAIL},
"author": {"name": "Nvidia Founder Editions"},
"fields": [
{"name": price_label, "value": f"`{currency}{products_price}`", "inline": True},
{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True},
],
"description": buy_now.format(product_link=product_link),
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": AVATAR,
},
}
payload = {
"content": DISCORD_ROLE_MAP.get(gpu_name, "@everyone"),
"username": "NviBot",
"avatar_url": AVATAR,
"embeds": [embed],
}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
if response.status_code == 204:
logging.info("✅ Notification sent to Discord.")
else:
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
# Out of stock
def send_out_of_stock_notification(gpu_name, product_link, products_price):
timestamp = int(time.time())
if TEST_MODE:
logging.info(f"[TEST MODE] Out of stock: {gpu_name}")
return
embed = {
"title": out_of_stock_title.format(gpu_name=gpu_name),
"color": 15158332,
"thumbnail": {"url": THUMBNAIL},
"url": product_link,
"author": {"name": "Nvidia Founder Editions"},
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": AVATAR,
},
"fields": [
{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True}
],
}
payload = {"username": "NviBot", "avatar_url": AVATAR, "embeds": [embed]}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
if response.status_code == 204:
logging.info("✅ Out-of-stock notification sent.")
else:
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
# SKU change
def send_sku_change_notification(gpu_name, old_sku, new_sku, product_link):
timestamp = int(time.time())
if TEST_MODE:
logging.info(f"[TEST MODE] SKU change: {old_sku}{new_sku}")
return
embed = {
"title": sku_change_title.format(gpu_name=gpu_name),
"url": product_link,
"description": sku_description.format(old_sku=old_sku, new_sku=new_sku),
"color": 16776960,
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": AVATAR,
},
"fields": [
{"name": time_label, "value": f"<t:{timestamp}:d> <t:{timestamp}:T>", "inline": True}
],
}
payload = {
"content": imminent_drop.format(DISCORD_ROLE=DISCORD_ROLE_MAP.get(gpu_name, "@everyone")),
"username": "NviBot",
"avatar_url": AVATAR,
"embeds": [embed],
}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
if response.status_code == 204:
logging.info("✅ SKU change notification sent.")
else:
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
-411
View File
@@ -1,411 +0,0 @@
import requests
import logging
import time
import os
import re
import json
from requests.adapters import HTTPAdapter, Retry
# Logger configuration
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
)
logging.info("Script started")
# Retrieve environment variables
try:
DISCORD_WEBHOOK_URL = os.environ.get('DISCORD_WEBHOOK_URL')
DISCORD_SERVER_NAME = os.environ.get('DISCORD_SERVER_NAME', 'Shared for free')
API_URL_SKU = os.environ.get('API_URL_SKU', 'https://api.nvidia.partners/edge/product/search?page=1&limit=100&locale=fr-fr&Manufacturer=Nvidia')
API_URL_STOCK = os.environ.get('API_URL_STOCK', 'https://api.store.nvidia.com/partner/v1/feinventory?locale=fr-fr&skus=')
REFRESH_TIME = int(os.environ.get('REFRESH_TIME'))
TEST_MODE = os.environ.get('TEST_MODE', 'False').lower() == 'true'
PRODUCT_URL = os.environ.get('PRODUCT_URL', 'https://marketplace.nvidia.com/fr-fr/consumer/graphics-cards/?locale=fr-fr&page=1&limit=12&manufacturer=NVIDIA')
DISCORD_ROLES = os.environ.get('DISCORD_ROLES')
PRODUCT_NAMES = os.environ.get('PRODUCT_NAMES')
if not PRODUCT_NAMES:
logging.error("❌ PRODUCT_NAMES is required but not defined.")
exit(1)
PRODUCT_NAMES = [name.strip() for name in PRODUCT_NAMES.split(',')]
DISCORD_ROLE_MAP = {}
if not DISCORD_ROLES or not DISCORD_ROLES.strip():
logging.warning("⚠️ DISCORD_ROLES not defined or empty. Defaulting all roles to @everyone.")
for name in PRODUCT_NAMES:
DISCORD_ROLE_MAP[name] = '@everyone'
else:
roles = [r.strip() if r.strip() else '@everyone' for r in DISCORD_ROLES.split(',')]
if len(roles) != len(PRODUCT_NAMES):
logging.error("❌ The number of DISCORD_ROLES must match PRODUCT_NAMES.")
exit(1)
for name, role in zip(PRODUCT_NAMES, roles):
if role != '@everyone' and not re.match(r'^<@&\d{17,20}>$', role):
logging.error(f"❌ Invalid DISCORD_ROLE format for {name}: {role}")
exit(1)
DISCORD_ROLE_MAP[name] = role
if not DISCORD_WEBHOOK_URL:
logging.error("❌ DISCORD_WEBHOOK_URL is required but not defined.")
exit(1)
# Regex to extract ID and token
match = re.search(r'/(\d+)/(.*)', DISCORD_WEBHOOK_URL)
if match:
webhook_id = match.group(1)
webhook_token = match.group(2)
# Mask last characters of the ID
masked_webhook_id = webhook_id[:len(webhook_id) - 10] + '*' * 10
# Mask last characters of the token
masked_webhook_token = webhook_token[:len(webhook_token) - 120] + '*' * 10
# Rebuild masked URL
wh_masked_url = f"https://discord.com/api/webhooks/{masked_webhook_id}/{masked_webhook_token}"
# Error logging
except KeyError as e:
logging.error(f"Missing environment variable: {e}")
exit(1)
except ValueError:
logging.error("REFRESH_TIME must be a valid integer.")
exit(1)
# Localization
try:
with open("localization.json", "r", encoding="utf-8") as f:
localization = json.load(f)
except FileNotFoundError:
logging.error("❌ localization.json file not found.")
exit(1)
language = os.environ.get("DISCORD_NOTIFICATION_LANGUAGE", "en").lower()
required_keys = [
"in_stock_title", "out_of_stock_title", "sku_change_title",
"buy_now", "price", "time", "footer",
"sku_description", "imminent_drop"
]
loc = localization.get(language, localization["en"])
logging.info(f"Notification language: {language}")
if not loc:
logging.warning(f"⚠️ Language '{language}' not found. Falling back to English.")
loc = localization.get("en")
language = "en"
if not loc:
logging.error("❌ No localization found for language 'en'. Cannot continue.")
sys.exit(1)
fallback = localization.get("en", {})
missing_keys = [key for key in required_keys if key not in loc]
if missing_keys:
logging.warning(f"⚠️ Missing keys in localization for '{language}': {', '.join(missing_keys)}. Falling back to English for those.")
for key in missing_keys:
if key in fallback:
loc[key] = fallback[key]
else:
logging.error(f"❌ Missing required key '{key}' in both '{language}' and fallback 'en'.")
sys.exit(1)
in_stock_title = loc["in_stock_title"]
out_of_stock_title = loc["out_of_stock_title"]
sku_change_title = loc["sku_change_title"]
buy_now = loc["buy_now"]
price_label = loc["price"]
time_label = loc["time"]
footer = loc["footer"]
sku_description = loc["sku_description"]
imminent_drop = loc["imminent_drop"]
# Display URLs and configurations
logging.info(f"GPU: {PRODUCT_NAMES}")
logging.info(f"Discord Webhook URL: {wh_masked_url}")
logging.info(f"Discord Role Mention: {DISCORD_ROLES}")
logging.info(f"API URL SKU: {API_URL_SKU}")
logging.info(f"API URL Stock: {API_URL_STOCK}")
logging.info(f"Product URL: {PRODUCT_URL}")
logging.info(f"Refresh time: {REFRESH_TIME} seconds")
logging.info(f"Test Mode: {TEST_MODE}")
# HTTP headers
HEADERS = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/131.0.0.0 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,"
"image/avif,image/webp,image/apng,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.5",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"Sec-GPC": "1",
}
# Session with retries
session = requests.Session()
retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
session.mount('https://', HTTPAdapter(max_retries=retries))
last_sku_dict = {}
global_stock_status_dict = {}
first_run_dict = {name: True for name in PRODUCT_NAMES}
# Discord notifications
def send_discord_notification(gpu_name: str, product_link: str, products_price: str):
# Get current UNIX timestamp
timestamp_unix = int(time.time())
if TEST_MODE:
logging.info(f"[TEST MODE] Discord Notification: {gpu_name} available!")
return
embed = {
"title": in_stock_title.format(gpu_name=gpu_name),
"color": 3066993,
"thumbnail": {
"url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
},
"author": {
"name": "Nvidia Founder Editions"
},
"fields": [
{
"name": price_label,
"value": f"`{products_price}€`",
"inline": True
},
{
"name": time_label,
"value": f"<t:{timestamp_unix}:d> <t:{timestamp_unix}:T>",
"inline": True
},
],
"description": buy_now.format(product_link=product_link),
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg"
}
}
payload = {
"content": f"{DISCORD_ROLE_MAP.get(gpu_name, '@everyone')}",
"username": "NviBot",
"avatar_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg",
"embeds": [embed]
}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
if response.status_code == 204:
logging.info("✅ Notification sent to Discord.")
else:
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
def send_out_of_stock_notification(gpu_name: str, product_link: str, products_price: str):
# Get current UNIX timestamp
timestamp_unix = int(time.time())
if TEST_MODE:
logging.info(f"[TEST MODE] Discord Notification: {gpu_name} out of stock!")
return
embed = {
"title": out_of_stock_title.format(gpu_name=gpu_name),
"color": 15158332, # Red for out of stock
"thumbnail": {
"url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/RTX5000.jpg"
},
"url": f"{product_link}",
"author": {
"name": "Nvidia Founder Editions"
},
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg"
},
"fields": [
{
"name": time_label,
"value": f"<t:{timestamp_unix}:d> <t:{timestamp_unix}:T>",
"inline": True
}
]
}
payload = {"username": "NviBot", "avatar_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg", "embeds": [embed]}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
if response.status_code == 204:
logging.info("'Out of stock' notification sent to Discord.")
else:
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
def send_sku_change_notification(gpu_name: str, old_sku: str, new_sku: str, product_link: str):
# Get current UNIX timestamp
timestamp_unix = int(time.time())
if TEST_MODE:
logging.info(f"[TEST MODE] SKU change detected: {old_sku}{new_sku}")
return
embed = {
"title": sku_change_title.format(gpu_name=gpu_name),
"url": f"{product_link}",
"description": sku_description.format(old_sku=old_sku, new_sku=new_sku),
"color": 16776960, # Yellow
"footer": {
"text": footer.format(DISCORD_SERVER_NAME=DISCORD_SERVER_NAME),
"icon_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg"
},
"fields": [
{
"name": time_label,
"value": f"<t:{timestamp_unix}:d> <t:{timestamp_unix}:T>",
"inline": True
}
]
}
payload = {
"content": imminent_drop.format(DISCORD_ROLE=DISCORD_ROLE_MAP.get(gpu_name, '@everyone')),
"username": "NviBot",
"avatar_url": "https://git.djeex.fr/Djeex/nvidia-stock-bot/raw/branch/main/assets/img/ds_wh_pp.jpg",
"embeds": [embed]
}
try:
response = requests.post(DISCORD_WEBHOOK_URL, json=payload)
if response.status_code == 204:
logging.info("✅ SKU change notification sent to Discord.")
else:
logging.error(f"❌ Webhook error: {response.status_code} - {response.text}")
except Exception as e:
logging.error(f"🚨 Error sending webhook: {e}")
# Stock search
def check_rtx_50_founders():
global last_sku_dict, global_stock_status_dict, first_run_dict
try:
response = session.get(API_URL_SKU, headers=HEADERS, timeout=10)
logging.info(f"SKU API response: {response.status_code}")
response.raise_for_status()
data = response.json()
except requests.exceptions.RequestException as e:
logging.error(f"SKU API error: {e}")
return
# All available products
all_products = data['searchedProducts']['productDetails']
for product_name in PRODUCT_NAMES:
product_details = None
for p in all_products:
if p.get("gpu", "").strip() == product_name:
product_details = p
break
if not product_details:
logging.warning(f"⚠️ No product with GPU '{product_name}' found.")
continue
product_sku = product_details['productSKU']
product_upc = product_details.get('productUPC', "")
if not isinstance(product_upc, list):
product_upc = [product_upc]
# Check SKU change
old_sku = last_sku_dict.get(product_name)
if old_sku and old_sku != product_sku and not first_run_dict[product_name]:
logging.warning(f"⚠️ SKU changed for {product_name}: {old_sku}{product_sku}")
send_sku_change_notification(product_name, old_sku, product_sku, PRODUCT_URL)
last_sku_dict[product_name] = product_sku
first_run_dict[product_name] = False
# Stock check
api_stock_url = API_URL_STOCK + product_sku
logging.info(f"[{product_name}] Checking stock: {api_stock_url}")
try:
response = session.get(api_stock_url, headers=HEADERS, timeout=10)
logging.info(f"[{product_name}] Stock API response: {response.status_code}")
response.raise_for_status()
stock_data = response.json()
except requests.exceptions.RequestException as e:
logging.error(f"Stock API error: {e}")
continue
products = stock_data.get("listMap", [])
products_price = "Price not available"
if isinstance(products, list) and len(products) > 0:
for p in products:
price = p.get("price", 'Price not available')
if price != 'Price not available':
products_price = price
break
else:
logging.error(f"[{product_name}] Product list is empty or malformed.")
found_in_stock = set()
for p in products:
gpu_name = p.get("fe_sku", "").upper()
is_active = p.get("is_active") == "true"
if is_active and any(upc.upper() in gpu_name for upc in product_upc):
found_in_stock.add(gpu_name)
for upc in product_upc:
upc_upper = upc.upper()
currently_in_stock = upc_upper in found_in_stock
previously_in_stock = global_stock_status_dict.get((product_name, upc_upper), False)
if currently_in_stock and not previously_in_stock:
send_discord_notification(product_name, PRODUCT_URL, products_price)
global_stock_status_dict[(product_name, upc_upper)] = True
logging.info(f"[{product_name}] {upc} is now in stock!")
elif not currently_in_stock and previously_in_stock:
send_out_of_stock_notification(product_name, PRODUCT_URL, products_price)
global_stock_status_dict[(product_name, upc_upper)] = False
logging.info(f"[{product_name}] {upc} is now out of stock.")
elif currently_in_stock:
logging.info(f"[{product_name}] {upc} still in stock.")
else:
logging.info(f"[{product_name}] {upc} still out of stock.")
# Loop
if __name__ == "__main__":
try:
while True:
start = time.time()
check_rtx_50_founders()
elapsed = time.time() - start
time.sleep(max(0, REFRESH_TIME - elapsed))
# Gracefully shut down
except KeyboardInterrupt:
logging.info("🛑 Script interrupted by user. Exiting gracefully.")
exit(0)
+1 -1
View File
@@ -1 +1 @@
requests requests==2.34.2
Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 739 KiB

+1 -3
View File
@@ -1,5 +1,3 @@
PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090") PRODUCT_NAMES= # Exact GPU name (e.g. "RTX 5080, RTX 5090")
DISCORD_WEBHOOK_URL= # Your Discord webhook URL DISCORD_WEBHOOK_URL= # Your Discord webhook URL
API_URL_SKU= # API listing the product for your country COUNTRY= # Set your country (e.g. 'US')
API_URL_STOCK= # API providing stock data for your country
PRODUCT_URL= # GPU purchase URL for your country
+4 -7
View File
@@ -7,10 +7,7 @@ services:
- .env - .env
environment: environment:
# Minimal environment variables # Minimal environment variables
- PRODUCT_NAMES=${PRODUCT_NAMES} # Exact GPU name (e.g. "RTX 5080, RTX 5090") - PRODUCT_NAMES=${PRODUCT_NAMES}
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL} # Your Discord webhook URL - DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
- API_URL_SKU=${API_URL_SKU} # API listing the product for your country - COUNTRY=${COUNTRY}
- API_URL_STOCK=${API_URL_STOCK} # API providing stock data for your country - PYTHONUNBUFFERED=1
- PRODUCT_URL=${PRODUCT_URL} # GPU purchase URL for your country
- PYTHONUNBUFFERED=1 # Enables real-time log output
command: python nvidia-stock-bot.py # Run the script
+1
View File
@@ -0,0 +1 @@
[pytest]
+29
View File
@@ -0,0 +1,29 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"timezone": "Europe/Paris",
"labels": ["bot"],
"vulnerabilityAlerts": {
"addLabels": ["bug"]
},
"packageRules": [
{
"matchManagers": ["pip_requirements"],
"matchUpdateTypes": ["patch", "minor"],
"automerge": true
},
{
"matchManagers": ["dockerfile"],
"matchUpdateTypes": ["patch"],
"automerge": true
},
{
"matchUpdateTypes": ["major"],
"addLabels": ["major"]
},
{
"matchUpdateTypes": ["minor"],
"addLabels": ["minor"]
}
]
}
+13
View File
@@ -0,0 +1,13 @@
line-length = 100
[lint]
select = ["E", "F", "I", "UP", "B"]
# E501: handled by the formatter. B905: zip() without strict= in env_config.py —
# app-logic change, left for the user to decide (see feedback-no-app-logic-changes).
ignore = ["E501", "B905"]
[lint.isort]
# Pinned explicitly: auto-detection of first-party modules differs between the
# host (app/ subdir + .git present) and the Docker lint stage (flattened to /app,
# no .git) — without this, import-sort results silently diverge between the two.
known-first-party = ["env_config", "gpu_checker", "notifier", "main"]
+17
View File
@@ -0,0 +1,17 @@
import os
import sys
_TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
_REPO_ROOT = os.path.dirname(_TESTS_DIR)
# app/*.py open their JSON config files with plain relative paths, so the
# process cwd must be the directory the app modules live in — matches how
# the Dockerfile runs them (WORKDIR /app).
_APP_DIR = os.path.join(_REPO_ROOT, "app")
if not os.path.isfile(os.path.join(_APP_DIR, "gpu_checker.py")):
_APP_DIR = _REPO_ROOT # container test stage: code copied flat next to tests/
if _APP_DIR not in sys.path:
sys.path.insert(0, _APP_DIR)
os.chdir(_APP_DIR)
+120
View File
@@ -0,0 +1,120 @@
import importlib
import sys
import pytest
MODULE_NAME = "env_config"
VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef"
ENV_KEYS = [
"DISCORD_WEBHOOK_URL",
"DISCORD_SERVER_NAME",
"DISCORD_ROLES",
"COUNTRY",
"REFRESH_TIME",
"TEST_MODE",
"PRODUCT_NAMES",
]
def _reload_env_config(monkeypatch, env):
for key in ENV_KEYS:
monkeypatch.delenv(key, raising=False)
for key, value in env.items():
monkeypatch.setenv(key, value)
sys.modules.pop(MODULE_NAME, None)
return importlib.import_module(MODULE_NAME)
def test_missing_webhook_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(monkeypatch, {"PRODUCT_NAMES": "RTX 5090"})
def test_missing_product_names_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(monkeypatch, {"DISCORD_WEBHOOK_URL": VALID_WEBHOOK})
def test_default_role_map_is_everyone(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090, RTX 5080",
},
)
assert cfg.DISCORD_ROLE_MAP == {"RTX 5090": "@everyone", "RTX 5080": "@everyone"}
def test_role_count_mismatch_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090, RTX 5080",
"DISCORD_ROLES": "<@&123456789012345678>",
},
)
def test_invalid_role_format_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"DISCORD_ROLES": "not-a-role",
},
)
def test_valid_role_format_accepted(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"DISCORD_ROLES": "<@&123456789012345678>",
},
)
assert cfg.DISCORD_ROLE_MAP["RTX 5090"] == "<@&123456789012345678>"
def test_unknown_country_falls_back_to_us(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"COUNTRY": "ZZ",
},
)
assert cfg.currency == "$"
def test_known_country_currency(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"COUNTRY": "GB",
},
)
assert cfg.currency == "£"
def test_refresh_time_invalid_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(
monkeypatch,
{
"DISCORD_WEBHOOK_URL": VALID_WEBHOOK,
"PRODUCT_NAMES": "RTX 5090",
"REFRESH_TIME": "not-a-number",
},
)
+162
View File
@@ -0,0 +1,162 @@
import importlib
import sys
VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef"
PRODUCT_NAME = "RTX 5090 Founders Edition"
SKU_PAYLOAD = {
"searchedProducts": {
"productDetails": [{"gpu": PRODUCT_NAME, "productSKU": "SKU-1", "productUPC": "ABC123"}]
}
}
class FakeResponse:
def __init__(self, payload, status_code=200):
self._payload = payload
self.status_code = status_code
def raise_for_status(self):
if self.status_code >= 400:
raise Exception(f"HTTP {self.status_code}")
def json(self):
return self._payload
def _stock_payload(in_stock, price="1999"):
return {
"listMap": [
{"fe_sku": "ABC123", "is_active": "true" if in_stock else "false", "price": price}
]
}
def _import_gpu_checker(monkeypatch):
monkeypatch.setenv("DISCORD_WEBHOOK_URL", VALID_WEBHOOK)
monkeypatch.setenv("PRODUCT_NAMES", PRODUCT_NAME)
monkeypatch.setenv("TEST_MODE", "True")
monkeypatch.delenv("DISCORD_ROLES", raising=False)
for mod in ("env_config", "notifier", "gpu_checker"):
sys.modules.pop(mod, None)
return importlib.import_module("gpu_checker")
def _queue_responses(monkeypatch, checker, *payloads):
responses = [FakeResponse(p) for p in payloads]
monkeypatch.setattr(checker.session, "get", lambda *a, **k: responses.pop(0))
def test_transition_to_in_stock_sends_notification(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(
checker, "send_discord_notification", lambda *a: calls.append(("in_stock", a))
)
monkeypatch.setattr(
checker, "send_out_of_stock_notification", lambda *a: calls.append(("out_of_stock", a))
)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: calls.append(("sku_change", a))
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
assert len(calls) == 1
assert calls[0][0] == "in_stock"
assert calls[0][1][0] == PRODUCT_NAME
def test_transition_to_out_of_stock_sends_notification(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(
checker, "send_discord_notification", lambda *a: calls.append(("in_stock", a))
)
monkeypatch.setattr(
checker, "send_out_of_stock_notification", lambda *a: calls.append(("out_of_stock", a))
)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: calls.append(("sku_change", a))
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(False))
checker.check_rtx_50_founders()
assert calls[-1][0] == "out_of_stock"
assert calls[-1][1][0] == PRODUCT_NAME
def test_no_duplicate_notification_while_still_in_stock(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(
checker, "send_discord_notification", lambda *a: calls.append(("in_stock", a))
)
monkeypatch.setattr(
checker, "send_out_of_stock_notification", lambda *a: calls.append(("out_of_stock", a))
)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: calls.append(("sku_change", a))
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(True))
checker.check_rtx_50_founders()
assert len(calls) == 1
def test_sku_change_triggers_notification_after_first_run(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
sku_change_calls = []
monkeypatch.setattr(checker, "send_discord_notification", lambda *a: None)
monkeypatch.setattr(checker, "send_out_of_stock_notification", lambda *a: None)
monkeypatch.setattr(
checker, "send_sku_change_notification", lambda *a: sku_change_calls.append(a)
)
_queue_responses(monkeypatch, checker, SKU_PAYLOAD, _stock_payload(False))
checker.check_rtx_50_founders()
assert sku_change_calls == [] # first run must never fire a "change" notification
changed_payload = {
"searchedProducts": {
"productDetails": [{"gpu": PRODUCT_NAME, "productSKU": "SKU-2", "productUPC": "ABC123"}]
}
}
_queue_responses(monkeypatch, checker, changed_payload, _stock_payload(False))
checker.check_rtx_50_founders()
assert len(sku_change_calls) == 1
assert sku_change_calls[0][1] == "SKU-1"
assert sku_change_calls[0][2] == "SKU-2"
def test_missing_product_in_api_is_skipped_gracefully(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
calls = []
monkeypatch.setattr(checker, "send_discord_notification", lambda *a: calls.append(a))
empty_payload = {"searchedProducts": {"productDetails": []}}
monkeypatch.setattr(checker.session, "get", lambda *a, **k: FakeResponse(empty_payload))
checker.check_rtx_50_founders() # must not raise, just log a warning and skip
assert calls == []
def test_sku_api_error_is_handled_without_raising(monkeypatch):
checker = _import_gpu_checker(monkeypatch)
def raise_error(*a, **k):
raise checker.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(checker.session, "get", raise_error)
checker.check_rtx_50_founders() # must not propagate the network error
+187
View File
@@ -0,0 +1,187 @@
import importlib
import sys
VALID_WEBHOOK = "https://discord.com/api/webhooks/123456789012345678/abcdef"
def _import_notifier(monkeypatch, test_mode="False", discord_roles=None):
monkeypatch.setenv("DISCORD_WEBHOOK_URL", VALID_WEBHOOK)
monkeypatch.setenv("PRODUCT_NAMES", "RTX 5090 Founders Edition")
monkeypatch.setenv("TEST_MODE", test_mode)
if discord_roles is not None:
monkeypatch.setenv("DISCORD_ROLES", discord_roles)
else:
monkeypatch.delenv("DISCORD_ROLES", raising=False)
for mod in ("env_config", "notifier"):
sys.modules.pop(mod, None)
return importlib.import_module("notifier")
class FakeResponse:
def __init__(self, status_code=204, text=""):
self.status_code = status_code
self.text = text
def test_test_mode_skips_network_call(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="True")
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append((a, k)))
notifier.send_discord_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
assert calls == []
def test_in_stock_notification_posts_expected_payload(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
captured = {}
def fake_post(url, json=None, **kwargs):
captured["url"] = url
captured["json"] = json
return FakeResponse()
monkeypatch.setattr(notifier.requests, "post", fake_post)
notifier.send_discord_notification(
"RTX 5090 Founders Edition", "https://example.com/buy", "1999"
)
assert captured["url"] == notifier.DISCORD_WEBHOOK_URL
assert captured["json"]["content"] == "@everyone"
embed = captured["json"]["embeds"][0]
assert "RTX 5090 Founders Edition" in embed["title"]
def test_discord_notification_survives_http_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
monkeypatch.setattr(
notifier.requests, "post", lambda *a, **k: FakeResponse(status_code=500, text="boom")
)
notifier.send_discord_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
def test_discord_notification_survives_connection_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
def raise_error(*a, **k):
raise notifier.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(notifier.requests, "post", raise_error)
# Should not raise even though the request itself blew up (network down, DNS, etc.)
notifier.send_discord_notification("RTX 5090 Founders Edition", "https://example.com", "1999")
def test_out_of_stock_test_mode_skips_network_call(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="True")
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append((a, k)))
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com", "1999"
)
assert calls == []
def test_out_of_stock_notification_posts_on_success(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
captured = {}
def fake_post(url, json=None, **kwargs):
captured["json"] = json
return FakeResponse(status_code=204)
monkeypatch.setattr(notifier.requests, "post", fake_post)
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com/buy", "1999"
)
assert captured["json"]["embeds"][0]["url"] == "https://example.com/buy"
def test_out_of_stock_notification_survives_http_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
monkeypatch.setattr(
notifier.requests, "post", lambda *a, **k: FakeResponse(status_code=500, text="boom")
)
# Should not raise even though the webhook call "fails"
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com", "1999"
)
def test_out_of_stock_notification_survives_connection_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
def raise_error(*a, **k):
raise notifier.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(notifier.requests, "post", raise_error)
notifier.send_out_of_stock_notification(
"RTX 5090 Founders Edition", "https://example.com", "1999"
)
def test_sku_change_test_mode_skips_network_call(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="True")
calls = []
monkeypatch.setattr(notifier.requests, "post", lambda *a, **k: calls.append((a, k)))
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku", "new-sku", "https://example.com"
)
assert calls == []
def test_sku_change_notification_survives_http_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
monkeypatch.setattr(
notifier.requests, "post", lambda *a, **k: FakeResponse(status_code=500, text="boom")
)
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku", "new-sku", "https://example.com"
)
def test_sku_change_notification_survives_connection_error(monkeypatch):
notifier = _import_notifier(monkeypatch, test_mode="False")
def raise_error(*a, **k):
raise notifier.requests.exceptions.ConnectionError("boom")
monkeypatch.setattr(notifier.requests, "post", raise_error)
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku", "new-sku", "https://example.com"
)
def test_sku_change_notification_mentions_role_and_skus(monkeypatch):
notifier = _import_notifier(
monkeypatch, test_mode="False", discord_roles="<@&123456789012345678>"
)
captured = {}
def fake_post(url, json=None, **kwargs):
captured["json"] = json
return FakeResponse()
monkeypatch.setattr(notifier.requests, "post", fake_post)
notifier.send_sku_change_notification(
"RTX 5090 Founders Edition", "old-sku-123", "new-sku-456", "https://example.com"
)
assert "<@&123456789012345678>" in captured["json"]["content"]
description = captured["json"]["embeds"][0]["description"]
assert "old-sku-123" in description
assert "new-sku-456" in description