(sock, chatId, msg)
| 10 | const settings = require('../settings'); |
| 11 | |
| 12 | async function stickerTelegramCommand(sock, chatId, msg) { |
| 13 | try { |
| 14 | // Get the URL from message |
| 15 | const text = msg.message?.conversation?.trim() || |
| 16 | msg.message?.extendedTextMessage?.text?.trim() || ''; |
| 17 | |
| 18 | const args = text.split(' ').slice(1); |
| 19 | |
| 20 | if (!args[0]) { |
| 21 | await sock.sendMessage(chatId, { |
| 22 | text: '⚠️ Please enter the Telegram sticker URL!\n\nExample: .tg https://t.me/addstickers/Porcientoreal' |
| 23 | }); |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | // Validate URL format |
| 28 | if (!args[0].match(/(https:\/\/t.me\/addstickers\/)/gi)) { |
| 29 | await sock.sendMessage(chatId, { |
| 30 | text: '❌ Invalid URL! Make sure it\'s a Telegram sticker URL.' |
| 31 | }); |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | // Get pack name from URL |
| 36 | const packName = args[0].replace("https://t.me/addstickers/", ""); |
| 37 | |
| 38 | // Using working bot token |
| 39 | const botToken = '7801479976:AAGuPL0a7kXXBYz6XUSR_ll2SR5V_W6oHl4'; |
| 40 | |
| 41 | try { |
| 42 | // Fetch sticker pack info |
| 43 | const response = await fetch( |
| 44 | `https://api.telegram.org/bot${botToken}/getStickerSet?name=${encodeURIComponent(packName)}`, |
| 45 | { |
| 46 | method: "GET", |
| 47 | headers: { |
| 48 | "Accept": "application/json", |
| 49 | "User-Agent": "Mozilla/5.0" |
| 50 | } |
| 51 | } |
| 52 | ); |
| 53 | |
| 54 | if (!response.ok) { |
| 55 | throw new Error(`HTTP error! status: ${response.status}`); |
| 56 | } |
| 57 | |
| 58 | const stickerSet = await response.json(); |
| 59 | |
| 60 | if (!stickerSet.ok || !stickerSet.result) { |
| 61 | throw new Error('Invalid sticker pack or API response'); |
| 62 | } |
| 63 | |
| 64 | // Send initial message with sticker count |
| 65 | await sock.sendMessage(chatId, { |
| 66 | text: `📦 Found ${stickerSet.result.stickers.length} stickers\n⏳ Starting download...` |
| 67 | }); |
| 68 | |
| 69 | // Create temp directory if it doesn't exist |
no test coverage detected