Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ Every coding session must begin by reading RUNEWAGER_FUNCTIONALITY_MAP.md and mu


Every coding session must begin by reading RUNEWAGER_FUNCTIONALITY_MAP.md and must end with a full docstring verification pass. No work is complete until every function has a complete docstring and the map is fully updated.

All AI agent instruction files in this repo must enforce this baseline workflow: (1) read and understand `RUNEWAGER_FUNCTIONALITY_MAP.md` before changing code, (2) update the map after any code change, (3) run a full verification pass after the map update, and (4) do not consider work complete until docstrings, the map, and agent instruction files are synchronized.
2 changes: 1 addition & 1 deletion RUNEWAGER_FUNCTIONALITY_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ Admin starts wizard (gwiz)
- 2026-02-26: Completed a 50-point verification pass, synchronized command registry coverage, and extended smoke checks for command-registration parity.

- 2026-02-26: Added repo-wide baseline docstrings to named function declarations (runtime, helper, and test modules) and re-verified command/callback coverage.
- 2026-02-26: Re-verified removal of `/language` command/callback surface, reran smoke/full tests, and synchronized agent-contract wording in `CLAUDE.md` with map-first/update-map/verify requirements.

## 25. AI Coder Contract Requirements

Expand All @@ -328,4 +329,3 @@ Mandatory rules for any AI agent touching this repo:
1. **Before writing or modifying any code, the AI must always read and familiarize itself with `RUNEWAGER_FUNCTIONALITY_MAP.md`. This file is the authoritative source of truth for all bot functionality. The AI must keep this file updated with full, easy‑to‑understand descriptions whenever functionality is added, changed, or removed. Updating this file is a required step at the end of every coding session.**

2. **After generating or modifying any functionality, the AI must run a follow-up audit to ensure the `RUNEWAGER_FUNCTIONALITY_MAP.md` file is fully updated and accurate. No coding session is complete until the map is updated and verified.**

97 changes: 69 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7775,33 +7775,6 @@ bot.action('admin_cat_support', async (ctx) => {
*/


function adminTestsToolsKeyboard() {
return Markup.inlineKeyboard([
[Markup.button.callback('🧪 Run TestAll', 'admin_cmd_testall'), Markup.button.callback('🎁 Test Giveaway', 'admin_cmd_testgiveaway')],
[Markup.button.callback('🐛 View Bug Reports', 'admin_cmd_viewbugs'), Markup.button.callback('📤 Export Bugs', 'admin_cmd_exportbugs')],
[Markup.button.callback('✅ Resolve Bug', 'admin_cmd_resolvebug_prompt'), Markup.button.callback('🧪 Test Content Drop', 'admin_cmd_tiptest')],
[Markup.button.callback('📟 Open SSHV Console', 'sshv_open')],
[Markup.button.callback('⬅️ Admin Dashboard', 'open_admin_dashboard')],
]);
}

bot.action('admin_cat_tests', async (ctx) => {
if (!requireAdmin(ctx)) return;
await ctx.answerCbQuery();
await replaceCallbackPanel(ctx,
`🧪 *Tests & Bug Tools*

Use this menu for diagnostics, bug workflows, and test sends.

• TestAll = full sanity check
• Test Giveaway = simulated giveaway flow
• Test Content Drop = sends one random drop to current target
• SSHV = VPS console tools`,
{ parse_mode: 'Markdown', ...adminTestsToolsKeyboard() },
);
});


function adminTestsToolsKeyboard() {
return Markup.inlineKeyboard([
[Markup.button.callback('🧪 Run TestAll', 'admin_cmd_testall'), Markup.button.callback('🎁 Test Giveaway', 'admin_cmd_testgiveaway')],
Expand Down Expand Up @@ -9984,7 +9957,8 @@ bot.action('announce_send_all', async (ctx) => {
await ctx.reply('Legacy "Send All" mapped to the new broadcast flow. Tap "Send Broadcast Now" after reviewing toggles.');
});

bot.action('announce_send_now', async (ctx) => {
// Legacy aliases
bot.action('announce_send_all', async (ctx) => {
if (!requireAdmin(ctx)) return;
const user = getUser(ctx);
const action = user.pendingAction;
Expand Down Expand Up @@ -10095,6 +10069,73 @@ async function postTipToConfiguredTarget(tip, telegram) {
return { ok: false, error: lastErr };
}

/**

* resolveTipTargetChatId executes its scoped Runewager logic and participates in menu/command or utility flow composition.

* Parameters: See the function signature for exact argument names and accepted values.

* Returns: Returns the computed value or a Promise resolving to the operation result; may return void for side-effect handlers.

* Side effects: May mutate runtime stores, pendingAction state, menu state, persistence files, logs, and callback progression.

* Validation/safety: Uses existing guard utilities (admin checks, input checks, path checks, cooldown checks) where applicable.

* Timeouts/fallbacks: Timeout and fallback behavior are controlled by the calling flow and global handler/state machine conventions.

* Errors: Surfaces user-facing error replies and/or logs when inputs, permissions, or dependencies are invalid.

* System fit: This function is part of the Runewager command/callback/state orchestration pipeline.

*/

async function resolveTipTargetChatId(rawTarget) {
const t = String(rawTarget || '').trim();
if (!t) return null;
if (/^-?\d+$/.test(t)) return Number(t);
if (t.startsWith('@')) return t;
return `@${t}`;
}

/**

* postTipToConfiguredTarget executes its scoped Runewager logic and participates in menu/command or utility flow composition.

* Parameters: See the function signature for exact argument names and accepted values.

* Returns: Returns the computed value or a Promise resolving to the operation result; may return void for side-effect handlers.

* Side effects: May mutate runtime stores, pendingAction state, menu state, persistence files, logs, and callback progression.

* Validation/safety: Uses existing guard utilities (admin checks, input checks, path checks, cooldown checks) where applicable.

* Timeouts/fallbacks: Timeout and fallback behavior are controlled by the calling flow and global handler/state machine conventions.

* Errors: Surfaces user-facing error replies and/or logs when inputs, permissions, or dependencies are invalid.

* System fit: This function is part of the Runewager command/callback/state orchestration pipeline.

*/

async function postTipToConfiguredTarget(tip, telegram) {
const primaryTarget = await resolveTipTargetChatId(tipsStore.targetGroup || broadcastConfigStore.targetGroup);
const fallbackTarget = approvedGroupsStore.size ? Array.from(approvedGroupsStore)[0] : null;
const candidates = [primaryTarget, fallbackTarget].filter(Boolean);
let lastErr = null;
for (const target of candidates) {
try {
// eslint-disable-next-line no-await-in-loop
await telegram.sendMessage(target, formatTipForHtml(tip.text), { parse_mode: 'HTML', disable_notification: true });
tipsStore.targetGroup = String(target);
broadcastConfigStore.targetGroup = String(target);
return { ok: true, target };
} catch (e) {
lastErr = e;
}
}
return { ok: false, error: lastErr };
}

/**
* Start (or restart) the tips scheduler.
* Clears any existing timer then arms a fresh one using the current interval.
Expand Down
Loading