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
7 changes: 6 additions & 1 deletion generate_tooltips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ const src = fs.readFileSync(process.env.RUNEWAGER_APP || 'index.js', 'utf8');
// Execute just the DEFAULT_TIPS_LIST block and print it as JSON
const m = src.match(/const DEFAULT_TIPS_LIST\s*=\s*(\[[\s\S]+?\]);/);
if (!m) { process.stderr.write('DEFAULT_TIPS_LIST not found\n'); process.exit(1); }
// Sanity-check the matched literal before evaluating (must look like an array)
if (m[1].length > 500000 || !/^\s*\[/.test(m[1])) {
process.stderr.write('Unexpected DEFAULT_TIPS_LIST shape — aborting\n');
Comment on lines +44 to +45

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: Consider making the size guard more intentional and visible rather than a hard‑coded magic number.

The 500000 byte limit works as a safeguard, but as a bare literal it’s hard to understand and adjust later. Consider extracting it to a named constant (e.g. MAX_TIPS_LITERAL_LENGTH) or basing it on src.length so future tuning and debugging of “shape” failures is clearer.

process.exit(1);
}
try {
// Use Function constructor for safe eval of the array literal
// Use Function constructor to evaluate the array literal in an isolated scope
const list = (new Function('return ' + m[1]))();
console.log(JSON.stringify(list, null, 2));
} catch (e) { process.stderr.write('Parse error: ' + e.message + '\n'); process.exit(1); }
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4576,7 +4576,7 @@ function onboardingProgressBar(step) {
* Prepends a progress bar header before the step-specific prompt.
* @param {object} ctx - Telegraf context
* @param {object} user - user state object
* @param {number} step - current onboarding step (1–4)
* @param {number} step - current onboarding step (1–5)
*/
async function showOnboardingPrompt(ctx, user, step) {
// Send progress indicator (auto-deletes after 8s to keep chat clean)
Expand Down