telegraf-media-albums

1.3.3 • Public • Published

telegraf-media-albums

Handle media groups (aka albums) easily with telegraf!

Usage

Telegraf v3

const Telegraf = require("telegraf")
const mediaGroup = require("telegraf-media-albums")

const bot = new Telegraf(process.env.BOT_TOKEN)

bot.use(mediaGroup())

bot.on("media_group", (ctx) => {
  // ctx.mediaGroup — an array of album messages (including the last one)
  for (const message of ctx.mediaGroup) {
    console.log(message)
  }
  return ctx.reply(`total: ${ctx.mediaGroup.length}`)
})

Telegraf v4

const { Telegraf } = require("telegraf")
const mediaGroup = require("telegraf-media-albums")

const bot = new Telegraf(process.env.BOT_TOKEN)

bot.use(mediaGroup())

bot.on("media_group", (ctx) => {
  // ctx.mediaGroup — an array of album messages (including the last one)
  for (const message of ctx.mediaGroup) {
    console.log(message)
  }
  return ctx.reply(`total: ${ctx.mediaGroup.length}`)
})

Package Sidebar

Install

npm i telegraf-media-albums

Weekly Downloads

2

Version

1.3.3

License

MIT

Unpacked Size

3 kB

Total Files

3

Last publish

Collaborators

  • dakomun