logo

Opengram media group

The media-group plugin lets you handle & copy media-groups (albums) with ease.

CIcodecovnpmdownloadsjavascript style guideCodacy BadgeLicense: MITFOSSA Status

Features

  • video, audio, photo, document support
  • Supports sends copy of a media group

Docs

You can find documentation here and examples here and try now here

Installation

NPM

npm i @opengram/media-group

Yarn

yarn add @opengram/media-group

PNPM

pnpm add @opengram/media-group

Quick start

const { Opengram } = require('opengram')
const { MediaGroup } = require('@opengram/media-group')
const bot = new Opengram(process.env.BOT_TOKEN) // <-- put your bot token here (https://t.me/BotFather)
const mediaGroup = new MediaGroup()
bot.use(mediaGroup)

bot.on('media_group', async ctx => {
  // ctx.mediaGroup - array of messages
  for (const message of ctx.mediaGroup) {
    console.log(JSON.stringify(message, null, 2)) // Pretty-print media group messages to console
  }

  await ctx.copyMediaGroup(ctx.chat.id) // Copy media-group to current chat
})

bot.launch()

// Enable graceful stop
process.once('SIGINT', () => bot.stop())
process.once('SIGTERM', () => bot.stop())

License

FOSSA Status