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

Function handler

plugins/speedtest.js:11–37  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

9 usage: '.speedtest',
10 ownerOnly: true,
11 async handler(sock, message, args, context) {
12 const { chatId, channelInfo } = context;
13 await sock.sendMessage(chatId, {
14 text: '🔄 *Testing internet speed...*\n\nPlease wait, this may take a moment.',
15 ...channelInfo
16 }, { quoted: message });
17 try {
18 const { stdout, stderr } = await execAsync('python3 lib/speed.py', { timeout: 120000 });
19 const result = (stdout || stderr || '').trim();
20 if (!result) {
21 return await sock.sendMessage(chatId, {
22 text: '❌ No output from speed test.',
23 ...channelInfo
24 }, { quoted: message });
25 }
26 await sock.sendMessage(chatId, {
27 text: result,
28 ...channelInfo
29 }, { quoted: message });
30 }
31 catch (error) {
32 await sock.sendMessage(chatId, {
33 text: `❌ Speed test failed: ${error.message}`,
34 ...channelInfo
35 }, { quoted: message });
36 }
37 }
38};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected