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

Function handler

plugins/attp.js:10–29  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

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};
31function _renderTextToPngWithFfmpeg(text) {
32 return new Promise((resolve, reject) => {

Callers

nothing calls this directly

Calls 2

writeExifVidFunction · 0.90

Tested by

no test coverage detected