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

Function handler

plugins/exad.ts:9–37  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

7 usage: '.excard Title | Body | ImageURL',
8
9 async handler(sock: any, message: any, args: any, context: BotContext) {
10 const chatId = context.chatId || message.key.remoteJid;
11 const input = args.join(' ');
12
13 if (!input.includes('|')) {
14 return await sock.sendMessage(chatId, {
15 text: '*Usage:* .excard Title | Body | ImageURL\n\n*Example:* .excard Google | Search anything | https://google.com/logo.png'
16 }, { quoted: message });
17 }
18
19 const [title, body, url] = input.split('|').map((t: any) => t.trim());
20
21 const quoted = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
22 const _hasQuotedImage = quoted?.imageMessage;
23
24 await sock.sendMessage(chatId, {
25 text: body || " ",
26 contextInfo: {
27 externalAdReply: {
28 title: title,
29 body: 'Shared via Mega Md',
30 thumbnailUrl: url || 'https://i.ibb.co/3S6f0mS/default.jpg',
31 mediaType: 1,
32 renderLargerThumbnail: true,
33 sourceUrl: url || 'https://github.com'
34 }
35 }
36 }, { quoted: message });
37 }
38};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected