MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / parseArgs

Function parseArgs

quote/quote.ts:270–302  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

268 const normalized = first.replace(/@\w+$/i, "");
269 if (normalized.toLowerCase() !== command.toLowerCase()) return rest;
270 return rest.slice(first.length).trimStart();
271}
272
273function parseArgs(text: string): QuoteArgs {
274 const args = text.trim().split(/\s+/).filter(Boolean);
275 const out: QuoteArgs = {
276 count: 1,
277 reply: false,
278 png: false,
279 img: false,
280 rate: false,
281 hidden: false,
282 media: false,
283 crop: false,
284 stories: false,
285 scale: 2,
286 backgroundColor: DEFAULT_BACKGROUND,
287 emojiBrand: DEFAULT_EMOJI_BRAND,
288 emojiSuffix: QUOTE_EMOJIS,
289 };
290
291 for (const arg of args) {
292 if (arg === "r" || arg === "reply") {
293 out.reply = true;
294 continue;
295 }
296
297 const n = Number.parseInt(arg, 10);
298 if (!Number.isNaN(n) && /^[-+]?\d+$/.test(arg)) {
299 out.count = Math.max(-MAX_QUOTE_MESSAGES, Math.min(MAX_QUOTE_MESSAGES, n));
300 }
301 }
302
303 out.emojiSuffix = `${QUOTE_EMOJIS}${EMOJI_SUFFIXES[Math.floor(Math.random() * EMOJI_SUFFIXES.length)]}💜`;
304 return out;
305}

Callers 1

handleQuoteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected