Bir telegram botu oluşturdum ve bu bot A kanalında paylaşılan gönderiyi anında B grubuna iletiyor. Fakat bunu yaparken sadece görsel ile text'i iletiyor, yani gömülü bağlantıları iletmiyor. Bunun için ne yapmalıyım? Kodda gömülü bağlantıları da iletmesini sağlayacağını düşündüğüm bi kod ekledim fakat işe yaramadı, gömülü bağlantıyı text olarak iletiyor. Bilen hocalarımız yardımcı olabilirse çok sevinirim, şimdiden çok teşekkürler. Kod:
const TelegramBot = require('node-telegram-bot-api'); const sourceChannelId = CHANNEL_ID; const targetChannelId = CHANNEL_ID; const bot = new TelegramBot('BOT_TOKEN', { polling: true }); bot.on('channel_post', (msg) => { if (msg.chat.id === sourceChannelId) { const chatId = msg.chat.id; // Görsel içerik varsa ilet if (msg.photo) { const photoId = msg.photo[msg.photo.length - 1].file_id; bot.sendPhoto(targetChannelId, photoId, { caption: msg.caption }); } // Video içerik varsa ilet if (msg.video) { const videoId = msg.video.file_id; bot.sendVideo(targetChannelId, videoId, { caption: msg.caption }); } // Ses içerik varsa ilet if (msg.audio) { const audioId = msg.audio.file_id; bot.sendAudio(targetChannelId, audioId, { caption: msg.caption }); } // Belge içerik varsa ilet if (msg.document) { const documentId = msg.document.file_id; bot.sendDocument(targetChannelId, documentId, { caption: msg.caption }); } // Gömülü bağlantı varsa ve metin içeriği boş değilse, bağlantıları metin içeriği ile birleştirerek gönder if (msg.entities && msg.text) { let urls = []; for (const entity of msg.entities) { if (entity.type === 'text_link') { urls.push(entity.url); } } // Gömülü bağlantıları metne ekleyin if (urls.length > 0) { messageToSend += urls.join('\n'); messageToSend += '\n\n'; } } // Metin içerik varsa ilet if (msg.text) { bot.sendMessage(targetChannelId, msg.text); } } });