Skip to content

Claude/update prod runner script lq2g s - #61

Merged
gamblecodezcom merged 2 commits into
mainfrom
claude/update-prod-runner-script-Lq2gS
Feb 23, 2026
Merged

Claude/update prod runner script lq2g s#61
gamblecodezcom merged 2 commits into
mainfrom
claude/update-prod-runner-script-Lq2gS

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 23, 2026

Copy link
Copy Markdown
Owner

User description

Summary by CodeRabbit

  • New Features

    • Introduced a rotating tips system with admin commands for managing, scheduling, and testing tip messages.
    • Added VPS deployment infrastructure for direct service deployment on the server.
  • Chores

    • Updated environment configuration and disabled GitHub Actions deployment workflow.

CodeAnt-AI Description

Add rotating silent group tips with admin management and VPS-only deploy flow

What Changed

  • Bot now posts a random, silent tip to a configurable group every few hours and persists tips between restarts
  • Admins can manage tips from the bot: view list, add, edit, remove, enable/disable individual tips, toggle the whole system, change the posting interval, and preview a random tip
  • Tips scheduler restarts when interval is changed; default interval and target group are configurable via env
  • Startup now only launches the runtime on a VPS (DEVICE=vps) or CI guard; GitHub Actions deploy job is disabled to avoid remote restarts
  • Added a VPS deployment script (deploy.sh) that fetches origin/main, installs production deps, restarts the service, and reports status; .env example now documents DEVICE=vps

Impact

✅ Automated, silent group tips every X hours
✅ Admins can manage and preview tips without redeploy
✅ Prevents accidental bot restarts from GitHub Actions; clearer VPS deploy process

💡 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.

- Add tipsStore with 15 default sweepstakes-safe tips (id, text, enabled)
- Add TIPS_GROUP constant (@GambleCodezPrizeHub, overridable via env)
- Persist tipsStore in runtime-state.json (snapshot + load)
- Start tips scheduler on bot launch: posts one random enabled tip
  silently every 4 hours to @GambleCodezPrizeHub (disable_notification)
- Scheduler is re-armable when admin changes the interval

Admin commands:
  /tips  /t  /tp    — Tips Manager dashboard with inline buttons
  /tiplist          — Show all tips with IDs and preview
  /tipadd           — Prompt for new tip text (state: await_tip_add_text)
  /tipremove        — Select tip by button to delete
  /tipedit          — Select tip by button then prompt for new text
  /tiptoggle        — Toggle entire tips system on/off
  /tiptest          — Send one random tip preview to admin in DM
  /tipsettings      — Show settings and update interval (hours)

Inline button actions:
  tips_cmd_{add,edit,remove,toggle,list,test,settings}
  tip_remove_<id>       — remove a specific tip
  tip_edit_select_<id>  — prompt to edit a specific tip
  tip_toggle_<id>       — enable/disable individual tip

pendingAction state machine:
  await_tip_add_text       → save new tip, reply "Added as Tip #X"
  await_tip_edit_text      → update tip text, reply "Tip #X updated"
  await_tip_settings_interval → update interval + restart scheduler

https://claude.ai/code/session_01X3PxGFF5zzKptQwVkjYzzN
GitHub CI:
- deploy.yml: disable `deploy` job with `if: false` — GitHub Actions
  must NEVER restart or launch the bot; it is code storage only.
  Quality-gates job (syntax, tests, audit) continues to run on push.
- ci.yml: unchanged — already runs tests without touching Telegram.

index.js runtime guards (layered):
- CI / smoke-test layer: if CI=true or DISABLE_RUNTIME=1 → log and
  skip all runtime startup without calling process.exit() so that
  `require('./index.js')` in smoke tests completes cleanly.
- VPS-only layer: if DEVICE !== "vps" → print warning and exit(0).
  Set DEVICE=vps in the VPS .env to allow the bot to start.

/deploy admin command:
- Restart logic is systemctl-only (no PM2); unchanged from original.

deploy.sh (new, VPS-only):
- git fetch --all && git reset --hard origin/main
- npm ci --omit=dev
- systemctl restart runewager
- systemctl is-active confirmation

.env.example:
- Added DEVICE=vps entry so prod-run.sh copies it correctly.

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

codeant-ai Bot commented Feb 23, 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.

@coderabbitai

coderabbitai Bot commented Feb 23, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes introduce a Tips System to the bot with automated scheduling and admin management commands. A new VPS deployment script is added alongside configuration changes, and GitHub Actions deployment is disabled in favor of direct VPS execution via deploy.sh.

Changes

Cohort / File(s) Summary
Deployment Configuration
.env.example, .github/workflows/deploy.yml, deploy.sh
Added DEVICE environment variable; disabled GitHub Actions VPS deployment job with explanatory comments; introduced new Bash script for direct VPS deployment with git reset, npm installation, and systemctl service restart/validation.
Tips System Implementation
index.js
Introduced a rotating Tips System with scheduler, public store (tips, systemEnabled, intervalHours, targetGroup, nextTipId), admin commands (/tips, /tiplist, /tipadd, /tipremove, /tipedit, /tiptoggle, /tiptest, /tipsettings), inline action handlers, and integration with runtime state persistence and restoration.

Sequence Diagram

sequenceDiagram
    participant Admin as Admin User
    participant Bot as Bot Handler
    participant Scheduler as Tips Scheduler
    participant State as Runtime State
    
    Admin->>Bot: /tips command
    Bot->>Bot: handleTipsCommand()
    Bot->>Admin: sendTipsDashboard (show UI)
    
    Admin->>Bot: Select action (add/edit/remove/toggle)
    Bot->>State: Update tipsStore
    State->>State: Persist tips data
    Bot->>Admin: Acknowledge & refresh dashboard
    
    Note over Scheduler: On startup / interval
    Scheduler->>State: Read intervalHours
    Scheduler->>Scheduler: Calculate next tip
    Scheduler->>Bot: Send tip to targetGroup
    Scheduler->>Scheduler: Re-arm timer
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Tips hop and dance in rotation's way,
A scheduler keeps them bright each day!
Deploy on VPS, no Actions in sight,
Admins now manage these wisdoms just right! 🌱✨


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@gamblecodezcom
gamblecodezcom merged commit 632b819 into main Feb 23, 2026
3 of 5 checks passed
@gamblecodezcom
gamblecodezcom deleted the claude/update-prod-runner-script-Lq2gS branch February 23, 2026 00:56
@gamblecodezcom
gamblecodezcom restored the claude/update-prod-runner-script-Lq2gS branch February 23, 2026 00:56
@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Feb 23, 2026
@codeant-ai

codeant-ai Bot commented Feb 23, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Destructive Reset
    The script runs git reset --hard origin/main, which will discard any local commits or uncommitted changes. On a VPS this may remove debugging or hotfix changes and will fail silently if the repository is in a different branch. Consider adding safety checks (uncommitted changes, current branch) and a deliberate confirmation or a non-destructive deployment strategy.

  • Privilege Requirement
    systemctl restart "${APP_NAME}.service" requires elevated privileges. If the script runs as a non-root user, the restart will fail. The script currently checks for the presence of systemctl but does not handle privilege escalation (sudo) or detect whether the user can restart services.

  • Dependency install assumptions
    The script assumes npm is present and that package-lock.json indicates a compatible workflow. Projects using yarn, pnpm, or relying on different lockfiles will not be handled. Also --omit=dev requires newer npm; consider checking npm version or providing a fallback.

@codeant-ai

codeant-ai Bot commented Feb 23, 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:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants