Home / Docs / Examples
On this page

Ejemplos Completos

Bot de Descargas

const Zerogram = require('zerogramjs');
const path = require('path');

const bot = new Zerogram(apiId, apiHash, token);
await bot.init();

bot.command('download', async (ctx) => {
    const msg = await ctx.getReplyMessage();
    if (!msg?.media) return ctx.reply('Responde a un archivo');

    const file = await ctx.downloadMedia(msg, {
        filePath: path.join('./downloads', `file_${Date.now()}`'),
        onProgress: (p) => log(`${p.percent}%`)
    });

    await ctx.reply('Descargado');
});