(sock: any, message: any, args: any, context: BotContext)
| 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 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected