(sock: any, message: any, args: any, context: BotContext)
| 9 | usage: '.getty <Getty URL>', |
| 10 | |
| 11 | async handler(sock: any, message: any, args: any, context: BotContext) { |
| 12 | const chatId = context.chatId || message.key.remoteJid; |
| 13 | const url = args?.[0]; |
| 14 | |
| 15 | if (!url) { |
| 16 | return await sock.sendMessage(chatId, { text: 'Please provide a Getty URL.\nExample: .getty https://www.gettyimages.com/detail/video/482277170' }, { quoted: message }); |
| 17 | } |
| 18 | |
| 19 | try { |
| 20 | const apiUrl = `https://discardapi.dpdns.org/api/dl/getty?apikey=guru&url=${encodeURIComponent(url)}`; |
| 21 | const { data } = await axios.get(apiUrl, { timeout: 10000 }); |
| 22 | |
| 23 | if (!data?.status || !data.result?.length) { |
| 24 | return await sock.sendMessage(chatId, { text: '❌ No video found for this URL.' }, { quoted: message }); |
| 25 | } |
| 26 | |
| 27 | const videoUrl = data.result[0].video; |
| 28 | const imageUrl = data.result[0].image; |
| 29 | |
| 30 | if (imageUrl) { |
| 31 | await sock.sendMessage(chatId, { image: { url: imageUrl }, caption: '🖼️ Getty Thumbnail' }, { quoted: message }); |
| 32 | } |
| 33 | |
| 34 | if (videoUrl) { |
| 35 | await sock.sendMessage(chatId, { video: { url: videoUrl }, caption: '🎬 Getty Video' }, { quoted: message }); |
| 36 | } |
| 37 | |
| 38 | } catch(error: any) { |
| 39 | console.error('Getty plugin error:', error); |
| 40 | |
| 41 | if (error.code === 'ECONNABORTED') { |
| 42 | await sock.sendMessage(chatId, { text: '❌ Request timed out. The API may be slow or unreachable.' }, { quoted: message }); |
| 43 | } else { |
| 44 | await sock.sendMessage(chatId, { text: '❌ Failed to fetch Getty video.' }, { quoted: message }); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected