npm telegraf 4.10.0
v4.10.0

latest releases: 4.16.3, 4.16.2, 4.16.1...
2 years ago
  • Brand new formatting helpers! No more awkward escaping.

    import { fmt, bold, italics, mention } from "telegraf/format";
    
    ctx.reply(fmt`
    Ground control to ${mention("Major Tom", 10000000)}
    ${bold`Lock your Soyuz hatch`} and ${italic`put your helmet on`}
    ${link("David Bowie", "https://en.wikipedia.org/wiki/David_Bowie")}
    `);

    This also just works with captions!

    ctx.replyWithPhoto(
      file.id,
      { caption: fmt`${bold`File name:`} ${file.name}` },
    );
  • Added Input helpers to create the InputFile object.

    import { Telegraf, Input } from "telegraf";
    const bot = new Telegraf(token);
    
    bot.telegram.sendVideo(chatId, Input.fromLocalFile("../assets/cats.mp4"));
    
    bot.telegram.sendDocument(chatId, Input.fromBuffer(buf));
    
    bot.command("cat", ctx => {
      ctx.sendPhoto(Input.fromURL("https://funny-cats.example/cats.jpg"))
    });

    This helps clear the confusion many users have about InputFile.

  • Deprecated ctx.replyWithMarkdown; prefer MarkdownV2 as Telegram recommends.

  • Deprecated ctx.replyWithChatAction; use identical method ctx.sendChatAction instead.

  • bot.launch()'s webhook options now accepts certificate for self-signed certs.

  • Fix bot crashes if updateHandler throws (#1709)

Don't miss a new telegraf release

NewReleases is sending notifications on new releases.