Skip to content

Introduce Promo Manager, Content Drops, announce flow, and admin UI refactor - #90

Merged
gamblecodezcom merged 5 commits into
mainfrom
codex/add-new-admin-promo-manager
Feb 26, 2026
Merged

Introduce Promo Manager, Content Drops, announce flow, and admin UI refactor#90
gamblecodezcom merged 5 commits into
mainfrom
codex/add-new-admin-promo-manager

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 26, 2026

Copy link
Copy Markdown
Owner

User description

Motivation

  • Replace legacy single promo-code model with a DB-backed Promo Manager supporting multiple promos, claims, cooldowns, auto-approval and admin approval queue.
  • Evolve "tips" into a richer Content Drops system with target registration, scheduler improvements, and test/send tooling.
  • Improve admin workflows: announcement builder (DM/channel/group toggles), revamped admin menus/keyboards, and safer SSHV/health tooling.

Description

  • Promo manager: added promoManagerStore, promo-manager-db.json persistence, promo normalization (normalizePromoManagerPromo), listing, eligibility evaluation (evaluatePromoEligibility), claim lifecycle, admin approve/deny commands (/pmapprove, /pmdeny), and related UI/keyboard actions.
  • Replaced legacy promoCodeStore flows with the new manager and migrated user claim tracking; removed hard-coded single promo UI in favor of DB-backed promo menu and promo creation/edit wizard (admin-driven).
  • Content Drops (formerly Tips): renamed features and strings, added postTipToConfiguredTarget, improved target resolution and auto-registration from forwarded messages, test-send behavior, scheduler improvements and clearer admin dashboard UI.
  • Announcements: interactive announce builder with toggleable targets (DM/Channel/Group), parse mode toggle, preview/send helpers and consolidated sendAnnouncementTargets routine.
  • Admin UX & menus: reworked persistent user/admin menus, moved many promo/tips actions under new manager dashboards, added Tests & Bugs menu, new helper keyboards, and many callback aliases for backward compatibility.
  • SSHV & health improvements: sandbox restriction hinting, safer editor save with error handling, TLS-aware health checks, GC timer unref for smart-button and SSHV session timers, and extra admin logs for SSHV actions.
  • Persistence & runtime: added broadcastConfigStore to runtime snapshot, saved promo manager DB on persist, various data migrations for user fields, and RUNEWAGER_FUNCTIONALITY_MAP.md as the authoritative functionality map.
  • Repo housekeeping: update .gitignore to allow example env templates and ignore runtime data/backups, update .env.example (document WEBAPP_HMAC_KEY and add TELEGRAM_BOT_TOKEN), and add AI contract notes in CLAUDE.md.
  • Tests & smoke checks: enhanced test/smoke.test.js to perform an index.js syntax check, discover literal callback buttons vs handlers, and ensure REGISTERED_COMMANDS parity with actual bot.command(...) handlers.

Testing

  • Ran the updated smoke test suite (test/smoke.test.js) which includes node --check index.js, callback-to-handler mapping checks, and REGISTERED_COMMANDS parity checks; all smoke tests passed.
  • Performed runtime start smoke (bot initialization path) and verified tips/content-scheduler starts without errors in CI-mode (no live Telegram interaction).
  • No failing automated tests were observed after changes.

Codex Task


CodeAnt-AI Description

Add static smoke tests for menu/button coverage and remove the /language command

What Changed

  • New smoke tests scan all .js files to ensure inline menu callback IDs are handled (either by literal action handlers or regex patterns) and fail the test if any callback buttons are uncovered.
  • New smoke test enforces parity between REGISTERED_COMMANDS and actual bot.command(...) handlers, failing when commands are missing or extra entries exist.
  • Removed the user-facing /language command and its entry from the help booklet (no longer reports detected language).
  • .env.example now includes guidance for generating and using WEBAPP_HMAC_KEY.

Impact

✅ Fewer silent command regressions
✅ Fewer unhandled inline button callbacks
✅ Clearer WEBAPP_HMAC_KEY setup

💡 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

    • Added configuration support for Discord integration links, promotional content images, and analytics event limits.
  • Tests

    • Enhanced test suite with improved validation and static analysis of command registration.
  • Documentation

    • Updated development guidelines and testing documentation.

…l missing functionality + Updated Functionality Map
@codeant-ai

codeant-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d0574a and 6648794.

📒 Files selected for processing (9)
  • .env.example
  • .gitignore
  • CLAUDE.md
  • RUNEWAGER_FUNCTIONALITY_MAP.md
  • index.js
  • promo-message.js
  • test/runtime.test.js
  • test/smoke.test.js
  • test/unit.test.js

📝 Walkthrough

Walkthrough

This PR introduces configuration enhancements, documentation updates, a new promo message management module with getters/setters, and comprehensive test infrastructure improvements including static analysis helpers for command and callback validation.

Changes

Cohort / File(s) Summary
Configuration & Environment
.env.example, .gitignore
Adds new environment variables (INTRO_GIF_URL, PROMO_ENTRY_IMAGE_URL, MAX_ANALYTICS_EVENTS, RW_DISCORD_LINK, RW_DISCORD_SUPPORT), improves WEBAPP_HMAC_KEY documentation, and removes redundant explicit .json entries from .gitignore (already covered by wildcard rule).
Documentation & Policies
CLAUDE.md, RUNEWAGER_FUNCTIONALITY_MAP.md
Adds verification policy statements for missing functionality detection and docstring validation; augments RUNEWAGER_FUNCTIONALITY_MAP with verification controls, command-registry parity notes, and expanded flow documentation.
Promo Message Management
promo-message.js
Introduces new public functions getPromoMessage() and setPromoMessage(message) with fallback resolution logic (file → environment variable → constant) and file persistence with timestamps; exports updated to include new functions.
Test Infrastructure
test/runtime.test.js, test/smoke.test.js, test/unit.test.js
Adds JSDoc documentation blocks; extends smoke tests with static analysis helpers (collectJsFiles, extractRegisteredCommands, parseRegexLiteral) and new validation test for REGISTERED_COMMANDS/bot.command handler parity; adds unit test helpers (escapeMarkdownV2, normalizeRunewagerUsername, getNextOnboardingStep).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #23: Introduces the same promo-message module with getPromoMessage/setPromoMessage functions and DEFAULT_PROMO_MESSAGE configuration.
  • #85: Implements promo manager with announcement/content-drop refactoring and identical .env/.gitignore adjustments.
  • #88: Strengthens smoke tests with callback/command validations and modifies promo-related functionality alongside test infrastructure expansion.

Poem

🐰 Hopping through configs with glee,
New promo functions set us free,
Tests now speak with clarity,
From file to fallback, we verify,
Environment blooms in harmony! 🌿

✨ 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 codex/add-new-admin-promo-manager

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:L This PR changes 100-499 lines, ignoring generated files label Feb 26, 2026
@codeant-ai

codeant-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Regex Extraction
    The code that extracts regex-based action handlers uses a simple capture (/bot.action(/.../flags)) which can mis-handle escaped slashes, nested delimiters or unusual flags and therefore miss matches or produce incorrect RegExp construction attempts. This may yield false negatives when matching dynamic handlers.

  • REGISTERED_COMMANDS parsing
    The test searches for the REGISTERED_COMMANDS block and command strings using fragile regexes that assume a specific formatting and single-quote usage. Different formatting (double quotes, extra whitespace, trailing comments, or different declaration style) could break this check and produce spurious failures.

@codeant-ai

codeant-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@gamblecodezcom
gamblecodezcom merged commit 8907380 into main Feb 26, 2026
0 of 3 checks passed
@gamblecodezcom
gamblecodezcom deleted the codex/add-new-admin-promo-manager branch February 26, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant