(sock, message, args, context)
| 8 | description: 'Generate an animated sticker from text', |
| 9 | usage: '.attp <text>', |
| 10 | async handler(sock, message, args, context) { |
| 11 | const chatId = context.chatId || message.key.remoteJid; |
| 12 | const text = args.join(' '); |
| 13 | if (!text) { |
| 14 | return await sock.sendMessage(chatId, { text: 'Please provide text after the .attp command.' }, { quoted: message }); |
| 15 | } |
| 16 | try { |
| 17 | const mp4Buffer = await renderBlinkingVideoWithFfmpeg(text); |
| 18 | const webpPath = await writeExifVid(mp4Buffer, { packname: 'Mega Md', author: 'MEGA-MD' }); |
| 19 | const webpBuffer = fs.readFileSync(webpPath); |
| 20 | try { |
| 21 | fs.unlinkSync(webpPath); |
| 22 | } |
| 23 | catch { } |
| 24 | await sock.sendMessage(chatId, { sticker: webpBuffer }, { quoted: message }); |
| 25 | } |
| 26 | catch { |
| 27 | await sock.sendMessage(chatId, { text: '❌ Failed to generate the sticker locally.' }, { quoted: message }); |
| 28 | } |
| 29 | } |
| 30 | }; |
| 31 | function _renderTextToPngWithFfmpeg(text) { |
| 32 | return new Promise((resolve, reject) => { |
nothing calls this directly
no test coverage detected