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

Function handler

plugins/techImg.ts:11–29  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

9 usage: '.tech',
10
11 async handler(sock: any, message: any, args: any, context: BotContext) {
12 const chatId = context.chatId || message.key.remoteJid;
13
14 try {
15 const res = await axios.get('https://raw.githubusercontent.com/GlobalTechInfo/Database/main/images/tech.json');
16
17 if (!res.data || !Array.isArray(res.data) || res.data.length === 0) {
18 return await sock.sendMessage(chatId, { text: '❌ Failed to fetch image.' }, { quoted: message });
19 }
20
21 const randomImage = res.data[Math.floor(Math.random() * res.data.length)];
22
23 await sock.sendMessage(chatId, { image: { url: randomImage }, caption: '💻 Tech Image' }, { quoted: message });
24
25 } catch(err: any) {
26 console.error('Tech image plugin error:', err);
27 await sock.sendMessage(chatId, { text: '❌ Error while fetching image.' }, { quoted: message });
28 }
29 }
30};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected