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

Function handler

plugins/source.js:22–43  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

20 description: 'Get the raw HTML source of a website',
21 usage: '.getpage <url>',
22 async handler(sock, message, args, context) {
23 const chatId = context.chatId || message.key.remoteJid;
24 const url = args[0];
25 if (!url || !url.startsWith('http')) {
26 return await sock.sendMessage(chatId, { text: 'Provide a valid URL (include http/https).' }, { quoted: message });
27 }
28 try {
29 await sock.sendMessage(chatId, { text: '🌐 *Fetching source code...*' });
30 const res = await axios.get(url);
31 const html = res.data;
32 const buffer = Buffer.from(html, 'utf-8');
33 await sock.sendMessage(chatId, {
34 document: buffer,
35 mimetype: 'text/html',
36 fileName: 'source.html',
37 caption: `*Source code for:* ${url}`
38 }, { quoted: message });
39 }
40 catch (err) {
41 await sock.sendMessage(chatId, { text: '❌ Failed to fetch source. The site might be protected.' });
42 }
43 }
44};
45/*****************************************************************************
46 * *

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected