(sock, message, args, context)
| 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 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected