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

Function handler

plugins/qrcode.js:8–25  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

6 description: 'Generate a QR code from text',
7 usage: '.qrcode <text>',
8 async handler(sock, message, args, context) {
9 const chatId = context.chatId || message.key.remoteJid;
10 const text = args?.join(' ')?.trim();
11 if (!text) {
12 return await sock.sendMessage(chatId, { text: '*Provide text to generate QR*\nExample: .qrcode Hello World' }, { quoted: message });
13 }
14 try {
15 const qr = await QRCode.toDataURL(text.slice(0, 2048), {
16 errorCorrectionLevel: 'H',
17 scale: 8
18 });
19 await sock.sendMessage(chatId, { image: { url: qr }, caption: '✅ QR Code Generated' }, { quoted: message });
20 }
21 catch (err) {
22 console.error('QR plugin error:', err);
23 await sock.sendMessage(chatId, { text: '❌ Failed to generate QR code.' }, { quoted: message });
24 }
25 }
26};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected