yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.13k stars 1.49k forks source link

How to send group of photos? I mean to group 2 photos #1147

Closed internetwarrior closed 2 months ago

internetwarrior commented 8 months ago

I can not send 2 pics

image image
internetwarrior commented 8 months ago

How can I group all of them?

PotapIlya commented 3 months ago

const imagesWithCaptions = [ { path: '/path/to/your/image1.jpg', caption: '12' }, { path: '/path/to/your/image2.jpg', caption: '12' }, { path: '/path/to/your/image3.jpg', caption: '13' } ];

const media = imagesWithCaptions.map(({ path, caption }) => ({ type: 'photo', media: { source: path }, caption: caption }));

bot.sendMediaGroup(chatId, media) .then(() => { console.log('success'); }) .catch((error) => { console.error(error); });