Skip to content

Claude/apply onboarding fixes r rf6 k - #32

Merged
gamblecodezcom merged 4 commits into
mainfrom
claude/apply-onboarding-fixes-rRf6K
Feb 20, 2026
Merged

Claude/apply onboarding fixes r rf6 k#32
gamblecodezcom merged 4 commits into
mainfrom
claude/apply-onboarding-fixes-rRf6K

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 20, 2026

Copy link
Copy Markdown
Owner

CodeAnt-AI Description

Use HTTP health endpoint, require Node 20, non-root Docker user, and update start scripts/docs

What Changed

  • Health checks now call the bot's HTTP /health endpoint (curl or wget) and fail fast if unhealthy; a health script and Docker HEALTHCHECK use that endpoint
  • Production run script now launches the bot directly and uses a robust shell setup; container runs as a non-root user (uid 10001)
  • README and .env.example rewritten with concise startup instructions, required env vars (BOT_TOKEN, ADMIN_IDS), runtime requirement (Node.js 20+), and a clear list of user-facing commands
  • package.json updated (name, version, Node engine constraint) and new npm scripts for prod and health checks

Impact

✅ Clearer setup and startup instructions
✅ Health checks work reliably inside containers
✅ Lower privilege container runtime (non-root user)

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Summary by CodeRabbit

  • New Features

    • Enhanced health check mechanism with automatic retry and timeout support.
    • Improved Docker production configuration with optimized health verification.
  • Documentation

    • Streamlined README with Quick Start guide and Docker deployment instructions.
  • Chores

    • Version bump to 2.1.0 and project rebranding to "runewager-bot".
    • Updated Node.js engine requirements (>=20 <22).
    • Environment configuration reorganization and dependency updates.

gamblecodezcom and others added 4 commits February 20, 2026 04:34
Update Environment_and_links.md
…n Node.js runtime, apply latest logic

- Unified index.js from codex/main-m22psu (2174 lines) + all branch features merged
- 2295-line final: 35-step walkthrough, full giveaway engine, 30SC wager bonus system,
  analytics, referral boosts, Mini App deep links, inline queries, WebApp sync
- NEW commands: /play, /signup, /affiliate, /discord, /promo, /setpromo, /join
- setMyCommands auto-registration with scoped admin/private/group commands
- Fixed link routing: Mini App buttons (t.me/RuneWager_bot/Play|profile|claim),
  browser buttons for runewager.com and Discord — no user preference toggle
- LINKS updated: miniAppPlay, miniAppProfile, miniAppClaim, discordSupport, runewagerProfile
- promoStore now uses env vars: PROMO_CODE, PROMO_AMOUNT_SC, PROMO_CLAIM_LIMIT
- BONUS_CONTACT_DISCORD env var replaces all hardcoded Discord admin IDs
- Dockerfile: node:20-slim, non-root user (uid 10001), wget health check
- prod-run.sh: exec node index.js only
- health-check.sh: curl/wget /health endpoint, no Python
- package.json: version 2.1.0, node >=20 <22
- Removed: make_gif.py, promoStore.js (state now inline)
- Updated: README.md (Node.js only, full command reference)
- Updated: .env.example (all env vars documented)

https://claude.ai/code/session_01DuwDCiNJva2tbdiM3sBycU
@codeant-ai

codeant-ai Bot commented Feb 20, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gamblecodezcom
gamblecodezcom merged commit 194877f into main Feb 20, 2026
1 check was pending
@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR updates the project's deployment configuration, Docker setup, and documentation. Changes include reorganizing environment variables in .env.example, refining Dockerfile for production (user isolation, robust health checks), bumping package version to 2.1.0 with Node.js engine constraints, simplifying initialization scripts (health-check.sh, prod-run.sh), and condensing README to focus on essentials.

Changes

Cohort / File(s) Summary
Configuration and Package
.env.example, package.json
Reorganized environment variable sections with new defaults; updated package name to "runewager-bot" (v2.1.0), added Node.js engine constraints (>=20 <22), explicit module type, and new "prod" and "health" scripts. Upgraded dotenv dependency.
Deployment
Dockerfile
Enhanced production setup: replaced curl with NODE_ENV=production, changed user from uid 1001 to system user uid 10001, switched to package\*.json glob copy, reworked HEALTHCHECK with start-period/retries, and improved health verification via wget to 127.0.0.1:PORT.
Scripts
health-check.sh, prod-run.sh
Stripped initialization logic from startup and health-check routines. Both scripts now use stricter error handling; health-check simplified to basic curl/wget health endpoint verification; prod-run reduced to environment setup and node execution.
Documentation
README.md
Drastically condensed from comprehensive multi-section format to streamlined overview. Removed detailed walkthroughs, links, and screenshots; added compact Quick Start, Docker guidance, command reference, and feature summary.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

codex, size:XL

Poem

🐰 A Runewager bot hops into v2.1,
Docker's trim, scripts run clean,
Node.js ≥20, health checks so keen,
Docs now concise, deployments pristine! 🚀

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/apply-onboarding-fixes-rRf6K

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Feb 20, 2026
@codeant-ai

codeant-ai Bot commented Feb 20, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • WebApp verification mismatch
    verifyWebAppInitData computes the HMAC secret in a non-standard way (HMAC over BOT_TOKEN with key 'WebAppData'). Telegram webapp verification expects the secret derived from the bot token via SHA256 then an HMAC over the data string with that secret. The current approach may accept invalid payloads or reject valid ones — review and align with Telegram docs.

  • Smart-button state leak
    The Set used by consumeSmartButton stores tokens indefinitely. Some smart-buttons are created with long-lived keys (e.g. 'promo_confirm_claimed') and others include time buckets, but nothing evicts entries. Over time this will grow unbounded and can cause memory pressure or unexpected refusal of valid button actions. Consider adding TTLs or periodic cleanup.

  • Broadcast throttling / spam risk
    The admin broadcast loop sends messages in a tight sequential loop to all users (no rate limiting or backoff). For large user counts this may hit Telegram rate limits or cause partial failures and heavy API load. Consider batching, delays, or worker queue to avoid hitting API limits.

  • Missing env validation
    The new script no longer checks for a .env file or validates required environment variables before starting the Node process. This can cause the app to run with missing configuration or fail at runtime. Reintroduce a presence check or explicit validation of required env vars (or fail fast with a clear error).

  • Healthcheck dependency
    The HEALTHCHECK uses wget directly but the base image (node:20-slim) does not include wget/curl by default. The healthcheck will fail unless one of these tools is installed or the HEALTHCHECK is changed to use the included health-check script or another mechanism.

Comment thread Dockerfile
COPY . .
RUN chown -R runewager:runewager /app

RUN useradd --system --create-home --uid 10001 runewager \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The container healthcheck and health-check.sh rely on wget (and previously relied on curl), but the new Dockerfile no longer installs any HTTP client; on a node:20-slim base image that does not include wget by default, the healthcheck will consistently fail with wget: not found even when the app is healthy. Reintroducing package installation for an HTTP client (e.g., wget) in the Docker image before dropping privileges fixes this. [possible bug]

Severity Level: Critical 🚨
- ❌ Container healthcheck fails; Docker marks service as unhealthy.
- ⚠️ Orchestrators may restart healthy containers unnecessarily.
- ⚠️ `npm run health` script uses wget/curl, also broken.
Suggested change
RUN useradd --system --create-home --uid 10001 runewager \
RUN apt-get update \
&& apt-get install -y --no-install-recommends wget \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --system --create-home --uid 10001 runewager \
Steps of Reproduction ✅
1. Build the Docker image using `/workspace/Runewager/Dockerfile` (lines 1–20), which
defines a `HEALTHCHECK` at lines 17–18 using `wget` but has no `apt-get install` for
`wget` or `curl`.

2. Run a container from this image; the container starts `node index.js` via `CMD ["node",
"index.js"]` at `Dockerfile:20` and the app exposes `GET /health` (checked by
`health-check.sh` at `/workspace/Runewager/health-check.sh:4–8` and by the Dockerfile
healthcheck URL).

3. Docker periodically executes the healthcheck command defined at `Dockerfile:17–18`:
`CMD sh -c 'wget -qO- "http://127.0.0.1:${PORT:-3000}/health" >/dev/null || exit 1'`
inside the running container.

4. Inside the container, `wget` is not installed on the `node:20-slim` base image (no
installation step in the Dockerfile), so the healthcheck command fails with `sh: 1: wget:
not found`, causing the healthcheck to exit non‑zero and the container to be marked
unhealthy even when the Node.js app is responding correctly.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** Dockerfile
**Line:** 12:12
**Comment:**
	*Possible Bug: The container healthcheck and `health-check.sh` rely on `wget` (and previously relied on `curl`), but the new Dockerfile no longer installs any HTTP client; on a `node:20-slim` base image that does not include `wget` by default, the healthcheck will consistently fail with `wget: not found` even when the app is healthy. Reintroducing package installation for an HTTP client (e.g., `wget`) in the Docker image before dropping privileges fixes this.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

Comment thread index.js
Comment on lines +11 to +18
const BOT_TOKEN = process.env.BOT_TOKEN;
const ADMIN_IDS = (process.env.ADMIN_IDS || '')
.split(',')
.map((id) => id.trim())
.filter(Boolean)
.map((id) => Number(id));

if (!BOT_TOKEN) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The bot now only reads BOT_TOKEN and no longer falls back to TELEGRAM_BOT_TOKEN as before, so existing deployments that still provide only TELEGRAM_BOT_TOKEN will crash at startup with "Missing BOT_TOKEN" even though a valid token is configured. [possible bug]

Severity Level: Critical 🚨
- ❌ Bot fails to start in TELEGRAM_BOT_TOKEN-only setups.
- ❌ All Telegram onboarding and giveaway features unavailable.
Suggested change
const BOT_TOKEN = process.env.BOT_TOKEN;
const ADMIN_IDS = (process.env.ADMIN_IDS || '')
.split(',')
.map((id) => id.trim())
.filter(Boolean)
.map((id) => Number(id));
if (!BOT_TOKEN) {
const BOT_TOKEN = process.env.BOT_TOKEN || process.env.TELEGRAM_BOT_TOKEN;
const ADMIN_IDS = (process.env.ADMIN_IDS || '')
.split(',')
.map((id) => id.trim())
.filter(Boolean)
.map((id) => Number(id));
if (!BOT_TOKEN) {
throw new Error('Missing BOT_TOKEN (or TELEGRAM_BOT_TOKEN) in environment variables.');
Steps of Reproduction ✅
1. Configure an environment where only `TELEGRAM_BOT_TOKEN` is set (and not `BOT_TOKEN`),
matching the legacy configuration expected by the pre-PR code (see old code in the diff
where `BOT_TOKEN` was derived from `process.env.BOT_TOKEN ||
process.env.TELEGRAM_BOT_TOKEN`).

2. Start the Node.js process that runs `index.js`; on load, the config block at
`index.js:11-20` executes `const BOT_TOKEN = process.env.BOT_TOKEN;` which resolves to
`undefined` because `BOT_TOKEN` is not set.

3. The subsequent guard at `index.js:18-20` (`if (!BOT_TOKEN) { throw new Error('Missing
BOT_TOKEN in environment variables.'); }`) evaluates to true and throws, causing the
process to terminate before `new Telegraf(BOT_TOKEN)` at `index.js:55` or `startBot()` at
`index.js:2047+` can run.

4. Observe that the Telegram bot never launches (no polling/webhook setup, no health log
messages), and all Telegram commands and callbacks defined throughout `index.js` remain
unreachable because the process exits during configuration.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** index.js
**Line:** 11:18
**Comment:**
	*Possible Bug: The bot now only reads `BOT_TOKEN` and no longer falls back to `TELEGRAM_BOT_TOKEN` as before, so existing deployments that still provide only `TELEGRAM_BOT_TOKEN` will crash at startup with "Missing BOT_TOKEN" even though a valid token is configured.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

Comment thread index.js
Comment on lines +66 to +67
remainingClaims: Number(process.env.PROMO_CLAIM_LIMIT) || 600,
get bonusRule() { return `Wager 3,000 SC in any rolling 7-day period → 30 SC bonus (once per account). Contact ${process.env.BONUS_CONTACT_DISCORD || 'the GambleCodez Discord admin'}.`; },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The promo bonus description is defined as a read-only getter (get bonusRule() { ... }) but later updated via assignment (promoStore.bonusRule = text in the admin flow), so the admin /setpromo path will silently fail to change the displayed bonus rule and users will still see the old text. [logic error]

Severity Level: Major ⚠️
- ⚠️ /promo output ignores admin-updated bonus rule text.
- ⚠️ Claim flow shows outdated wagering/bonus instructions.
Suggested change
remainingClaims: Number(process.env.PROMO_CLAIM_LIMIT) || 600,
get bonusRule() { return `Wager 3,000 SC in any rolling 7-day period → 30 SC bonus (once per account). Contact ${process.env.BONUS_CONTACT_DISCORD || 'the GambleCodez Discord admin'}.`; },
bonusRule: process.env.PROMO_BONUS_RULE
|| `Wager 3,000 SC in any rolling 7-day period → 30 SC bonus (once per account). Contact ${process.env.BONUS_CONTACT_DISCORD || 'the GambleCodez Discord admin'}.`,
Steps of Reproduction ✅
1. Start the bot with the current PR code (`index.js`), ensuring an admin Telegram ID is
configured in `ADMIN_IDS` so `/setpromo` is available (see admin commands setup at
`index.js:453-496` and `bot.command('setpromo', ...)` at `index.js:712-718`).

2. As an admin user in a private chat with the bot, send the `/setpromo` command; this is
handled at `index.js:712-718`, which sets `user.pendingAction = { type:
'admin_set_bonus_rule' }`.

3. Reply in the same chat with a new promo bonus description text (for example, changing
the contact handle or wagering conditions); the text handler at `index.js:1485-1500`
matches `action.type === 'admin_set_bonus_rule'` and executes `promoStore.bonusRule =
text`.

4. Trigger the user-facing promo view by issuing `/promo` (handled at `index.js:704-710`)
or using the "How to Claim" button, which calls `promoText()` at `index.js:228-230`;
`promoText()` still reads `promoStore.bonusRule` from the getter defined at
`index.js:60-70`, so the displayed bonus rule remains the original hard-coded string and
ignores the admin-provided text.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** index.js
**Line:** 66:67
**Comment:**
	*Logic Error: The promo bonus description is defined as a read-only getter (`get bonusRule() { ... }`) but later updated via assignment (`promoStore.bonusRule = text` in the admin flow), so the admin `/setpromo` path will silently fail to change the displayed bonus rule and users will still see the old text.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

@codeant-ai

codeant-ai Bot commented Feb 20, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants