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) {
// Mesajın içeriğini tutmak için bir değişken oluşturun
let messageToSend = '';
// 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) {
// İletilecek mesajı alın
messageToSend += msg.text;
// Gömülü bağlantıları metne ekleyin
let urls = [];
for (const entity of msg.entities) {
if (entity.type === 'text_link') {
urls.push(entity.url);
}
}
if (urls.length > 0) {
messageToSend += '\n\n' + urls.join('\n');
}
}
// Metin içerik varsa ve gömülü bağlantılar eklendiyse ilet
if (msg.text && messageToSend) {
bot.sendMessage(targetChannelId, messageToSend);
}
}
});MessageToSend değişkenini tanimlamamisim. Bir de böyle deneyebilir misin?
Hocam ilginiz için çok teşekkür ederim fakat bu şekilde de görsel dahil olunca değişen bir şey olmuyor, fakat görselsiz paylaşınca da gömülü değil de text + bağlantı şeklinde gösteriyor :/