bot.on(['photo'], (ctx) => {
if (ctx.message.media_group_id) {
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
// need send photos to user
ctx.telegram.sendMediaGroup(user_tg_id,[
{
type: 'photo',
media: // url for first photo
},
{
type: 'photo',
media: // url for second photo
},
])
} else {
// works well
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
return ctx.telegram.sendPhoto(user_tg_id, {url})
}
})
bot.on(['photo'], (ctx) => {
if (ctx.message.media_group_id) {
const file_id = ctx.message.photo[0].file_id
const key = ctx.message.media_group_id;
if (ctx.session.albom && ctx.session.albom[key]) {
const mg = ctx.session.albom[key];
clearTimeout(mg.sendTimeout);
mg.messages.push(
{
type: 'photo',
media: file_id
}
);
mg.sendTimeout = setTimeout(async () => {
await ctx.telegram.sendMediaGroup(user_tg_id, mg.messages)
ctx.session.albom[key] = undefined;
}, 1000);
} else {
ctx.session.albom = []
ctx.session.albom[key] = {
messages: [{
type: 'photo',
media: file_id
}],
};
}
} else {
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
return ctx.telegram.sendPhoto(user_tg_id, {url})
}
})
bot.on(['photo'], (ctx) => {
if (ctx.message.photo.length > 1) return;
if (ctx.message.media_group_id) {
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
// need send photos to user
ctx.telegram.sendMediaGroup(user_tg_id,[
{
type: 'photo',
media: // url for first photo
},
{
type: 'photo',
media: // url for second photo
},
])
} else {
// works well
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
return ctx.telegram.sendPhoto(user_tg_id, {url})
}
})