(sock: any, message: any, args: any, context: BotContext)
| 7 | usage: '.base64 <text> OR reply to a message', |
| 8 | |
| 9 | async handler(sock: any, message: any, args: any, context: BotContext) { |
| 10 | const chatId = context.chatId || message.key.remoteJid; |
| 11 | try { |
| 12 | let txt = args?.join(' ') || ""; |
| 13 | |
| 14 | const quoted = message.message?.extendedTextMessage?.contextInfo?.quotedMessage; |
| 15 | if (quoted) { |
| 16 | txt = quoted.conversation || |
| 17 | quoted.extendedTextMessage?.text || |
| 18 | quoted.imageMessage?.caption || |
| 19 | quoted.videoMessage?.caption || |
| 20 | txt; |
| 21 | } |
| 22 | |
| 23 | txt = txt.replace(/^\.\w+\s*/, '').trim(); |
| 24 | |
| 25 | if (!txt) { |
| 26 | return await sock.sendMessage(chatId, { text: '*Please provide text to encode or reply to a message.*\nExample: .base64 Hello World' }, { quoted: message }); |
| 27 | } |
| 28 | |
| 29 | const encoded = Buffer.from(txt, 'utf-8').toString('base64'); |
| 30 | |
| 31 | const response = `*🔗 Base64 Encoded:*\n\n${encoded}`; |
| 32 | await sock.sendMessage(chatId, { text: response }, { quoted: message }); |
| 33 | |
| 34 | } catch(err: any) { |
| 35 | console.error('Base64 plugin error:', err); |
| 36 | await sock.sendMessage(chatId, { text: '❌ Failed to encode text.' }, { quoted: message }); |
| 37 | } |
| 38 | } |
| 39 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected