(sock, chatId, message, args)
| 26 | } |
| 27 | |
| 28 | async function reminiCommand(sock, chatId, message, args) { |
| 29 | try { |
| 30 | let imageUrl = null; |
| 31 | |
| 32 | // Check if args contain a URL |
| 33 | if (args.length > 0) { |
| 34 | const url = args.join(' '); |
| 35 | if (isValidUrl(url)) { |
| 36 | imageUrl = url; |
| 37 | } else { |
| 38 | return sock.sendMessage(chatId, { |
| 39 | text: '❌ Invalid URL provided.\n\nUsage: `.remini https://example.com/image.jpg`' |
| 40 | }, { quoted: message }); |
| 41 | } |
| 42 | } else { |
| 43 | // Try to get image from message or quoted message |
| 44 | imageUrl = await getQuotedOrOwnImageUrl(sock, message); |
| 45 | |
| 46 | if (!imageUrl) { |
| 47 | return sock.sendMessage(chatId, { |
| 48 | text: '📸 *Remini AI Enhancement Command*\n\nUsage:\n• `.remini <image_url>`\n• Reply to an image with `.remini`\n• Send image with `.remini`\n\nExample: `.remini https://example.com/image.jpg`' |
| 49 | }, { quoted: message }); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // Call the Remini API |
| 54 | const apiUrl = `https://api.princetechn.com/api/tools/remini?apikey=prince_tech_api_azfsbshfb&url=${encodeURIComponent(imageUrl)}`; |
| 55 | |
| 56 | const response = await axios.get(apiUrl, { |
| 57 | timeout: 60000, // 60 second timeout (AI processing takes longer) |
| 58 | headers: { |
| 59 | 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' |
| 60 | } |
| 61 | }); |
| 62 | |
| 63 | |
| 64 | if (response.data && response.data.success && response.data.result) { |
| 65 | const result = response.data.result; |
| 66 | |
| 67 | if (result.image_url) { |
| 68 | // Download the enhanced image |
| 69 | const imageResponse = await axios.get(result.image_url, { |
| 70 | responseType: 'arraybuffer', |
| 71 | timeout: 30000 |
| 72 | }); |
| 73 | |
| 74 | if (imageResponse.status === 200 && imageResponse.data) { |
| 75 | // Send the enhanced image |
| 76 | await sock.sendMessage(chatId, { |
| 77 | image: imageResponse.data, |
| 78 | caption: '✨ *Image enhanced successfully!*\n\n𝗘𝗡𝗛𝗔𝗡𝗖𝗘𝗗 𝗕𝗬 𝐙𝐄𝐍𝐈𝐓𝐒𝐔-𝐁𝐎𝐓' |
| 79 | }, { quoted: message }); |
| 80 | } else { |
| 81 | throw new Error('Failed to download enhanced image'); |
| 82 | } |
| 83 | } else { |
| 84 | throw new Error(result.message || 'Failed to enhance image'); |
| 85 | } |
nothing calls this directly
no test coverage detected