Skip to content

v1.1.1

Latest

Choose a tag to compare

@yagop yagop released this 22 Jun 20:45
e899b08

Added

  • request.fetch and request.fetchOptions options (on the TelegramBot
    constructor / HttpClient), for per-instance transport customization. Pass a
    custom fetch implementation (e.g. undici's fetch bound to a ProxyAgent),
    or extra fetch init such as an undici dispatcher, scoped to a single bot
    instance - no setGlobalDispatcher, so other clients in the process are
    unaffected. This restores the per-instance proxy capability that the legacy
    request.agent provided before the move to the built-in fetch. (#1319)

    import TelegramBot from "node-telegram-bot-api";
    import { ProxyAgent } from "undici";
    
    const bot = new TelegramBot(token, {
      polling: true,
      request: { fetchOptions: { dispatcher: new ProxyAgent("http://127.0.0.1:8080") } },
    });

Fixed

  • editMessageMedia now accepts a Buffer / stream / local file path for the new
    media (and its thumbnail / cover), uploading it via an attach:// part -
    previously only a file_id / URL or the legacy attach://<local-path> form
    worked. Resolved through the same _buildMediaItems pipeline as
    sendMediaGroup; string callers and the old attach://<local-path> form are
    unaffected.
    (#1189)

  • Breaking: createNewStickerSet and addStickerToSet were still sending the
    long-removed png_sticker / emojis fields, which Telegram rejects with
    400 Bad Request: invalid sticker emojis. They now use the current Bot API
    shape - a single options object carrying stickers: InputSticker[] (or a single
    sticker: InputSticker), where each sticker's file (Buffer / stream / local
    path) is uploaded via an attach:// part, while a file_id / URL string passes
    through unchanged.
    (#1236)

    // Before (broken):
    bot.createNewStickerSet(userId, name, title, pngSticker, "😀");
    
    // After:
    bot.createNewStickerSet({
      user_id: userId,
      name,
      title,
      stickers: [{ sticker: "./a.png", format: "static", emoji_list: ["😀"] }],
    });
    bot.addStickerToSet({
      user_id: userId,
      name,
      sticker: { sticker: "./b.webp", format: "static", emoji_list: ["🎈"] },
    });