Listening to media & download
import { IContext } from 'degreet-telegram/src/types'
import * as path from 'path'
bot.on(['photo', 'video', 'document'], async (ctx: IContext): Promise<void> => {
try {
await ctx.answer.send(ctx.photoParts, ctx.photo) // ctx.video, ctx.document
await ctx.answer.downloadMedia(path.resolve(__dirname, 'res.jpg')) // .mp4, .txt and more
} catch (e: any) {
console.error(e)
}
})
const path = require('path')
bot.on(['photo', 'video', 'document'], async (ctx) => {
try {
await ctx.answer.send(ctx.photoParts, ctx.photo) // ctx.video, ctx.document
await ctx.answer.downloadMedia(path.resolve(__dirname, 'res.jpg')) // .mp4, .txt and more
} catch (e) {
console.error(e)
}
})
Last updated