ROIBot / src /resolve-bulk.js
Codex
Add bulk resolve command
ec4cf41
raw
history blame contribute delete
782 Bytes
export function parseBetIdList(input) {
const tokens = String(input ?? '')
.split(/[,\s]+/)
.map((token) => token.trim())
.filter(Boolean);
if (tokens.length === 0) {
return { ok: false, error: 'Please provide at least one bet ID.' };
}
const ids = [];
const invalid = [];
for (const token of tokens) {
if (!/^\d+$/.test(token)) {
invalid.push(token);
continue;
}
const value = Number(token);
if (!Number.isSafeInteger(value) || value <= 0) {
invalid.push(token);
continue;
}
if (!ids.includes(value)) {
ids.push(value);
}
}
if (invalid.length > 0) {
return {
ok: false,
error: `Invalid bet ID value(s): ${invalid.join(', ')}`,
};
}
return { ok: true, ids };
}