MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MDX / handler

Function handler

plugins/echo.ts:9–26  ·  view source on GitHub ↗
(sock: any, message: any, args: any)

Source from the content-addressed store, hash-verified

7 isPrefixless: true,
8
9 async handler(sock: any, message: any, args: any) {
10 const chatId = message.key.remoteJid;
11
12 if (args.length < 2) {
13 return await sock.sendMessage(chatId, { text: 'Usage: .echo <text> <count>' }, { quoted: message });
14 }
15
16 const count = parseInt(args[args.length - 1], 10);
17 if (isNaN(count) || count <= 0) {
18 return await sock.sendMessage(chatId, { text: 'Count must be a positive number.' }, { quoted: message });
19 }
20
21 args.pop();
22 const text = args.join(' ').trim();
23
24 const repeated = Array(count).fill(text).join('\n');
25 await sock.sendMessage(chatId, { text: repeated }, { quoted: message });
26 }
27};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected