edisonchee / slimbot

Telegram Bot API for Node.js
MIT License
223 stars 37 forks source link

sendMediaGroup returns error #53

Open fatshotty opened 3 years ago

fatshotty commented 3 years ago

Hi, i'm trying to use sendMediaGroup functionality but it returns an error:

let opts = {
    parse_mode: "html",
    disable_web_page_preview: false,
    disable_notification: false,
    caption: [firstPage.subtitle, '---', secondPage.subtitle].join('\n')
  };

  await Telegram.sendMediaGroup(CHAT_ID, [article.thumb, firstPage.image, secondPage.image], opts);

( .thumb and .image are http url )

this code returns: Error: 400: {"ok":false,"error_code":400,"description":"Bad Request: parameter \"media\" is required"}

did I do something wrong?

tuleyko commented 1 year ago

A little bit late, but anyway.

Here is the proper way of calling that method:

bot
  .sendMediaGroup(
    process.env.TELEGRAM_USER_ID,
    JSON.stringify([
      {
        media: "https://realt.by/uploads/pics/nemiga-8.png.jpg",
        type: "photo",
        caption: "test",
      },
    ]),
  )
  .then();