[Snyk] Upgrade telegraf from 4.5.2 to 4.16.3 #255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade telegraf from 4.5.2 to 4.16.3.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 58 versions ahead of your current version.
The recommended version was released 2 years ago.
Issues fixed by the recommended upgrade:
SNYK-JS-MINIMIST-2429795
Release notes
Package name: telegraf
-
4.16.3 - 2024-02-29
- Fix: bug with
- Fix: add
-
4.16.2 - 2024-02-26
-
4.16.1 - 2024-02-25
-
4.16.0 - 2024-02-25
- Support for API 7.0. Highlights are Reactions, Replies 2.0, Link Previews, Blockquotes, and Chat Boosts.
- Support for API 7.1.
- All methods and update types from these API versions are now fully supported.
-
bot.reaction("👍", (ctx) => {
bot.reaction("5368742036629364794", (ctx) => {
-
bot.on("message_reaction", async (ctx) => {
-
-
-
bot.on(message("text"), (ctx) => {
-
-
if (ctx.msg.isAccessible()) {
-
-
- Added
- Stricter types for format helpers. For example, it will now be a type-error to try to nest
- Added
- Fixed thumbnail uploads in media groups (#1947).
- The shorthand
- The shorthand
- The following modules are now directly importable:
- (Breaking)
- (Breaking)
- (Types breaking)
- (Types breaking)
- Bug fixes and security updates will still be released for Telegraf v4.
- The existing documentation for Telegraf v4 will remain available.
- New API updates will only focus on ensuring compatibility with the latest Telegram Bot API. No new convenience features will be added to Telegraf v4.
-
4.16.0-rc.2 - 2024-02-21
-
4.16.0-rc.1 - 2024-02-21
-
4.15.3 - 2023-12-03
- Fix: unable to upload media
- Fix:
-
4.15.2 - 2023-11-30
-
4.15.1 - 2023-11-29
-
-
⚠️ Set the env var
-
4.15.0 - 2023-10-23
import { anyOf, allOf } from "telegraf/filters";
-
4.14.0 - 2023-09-22
- ⬆️ Bot API 6.9 support
- Added missing
-
4.13.1 - 2023-09-02
- Fix README to mention API 6.8
-
4.13.0 - 2023-09-02
-
4.12.3-canary.1 - 2023-04-01
-
4.12.2 - 2023-03-09
-
4.12.1 - 2023-03-07
-
4.12.0 - 2023-03-05
-
4.11.2 - 2022-11-19
-
4.11.1 - 2022-11-19
-
4.11.1-canary.2 - 2022-11-19
-
4.11.1-canary.1 - 2022-11-19
-
4.11.0 - 2022-11-18
-
4.11.0-canary.1 - 2022-11-12
-
4.10.0 - 2022-10-01
-
4.9.2 - 2022-09-13
-
4.9.1 - 2022-08-29
-
4.9.0 - 2022-08-26
-
4.9.0-canary.12 - 2022-08-24
-
4.9.0-canary.11 - 2022-08-24
-
4.9.0-canary.10 - 2022-08-18
-
4.9.0-canary.9 - 2022-05-18
-
4.9.0-canary.8 - 2022-05-18
-
4.9.0-canary.7 - 2022-05-18
-
4.9.0-canary.6 - 2022-05-15
-
4.9.0-canary.5 - 2022-05-15
-
4.9.0-canary.4 - 2022-05-15
-
4.9.0-canary.3 - 2022-05-15
-
4.9.0-canary.2 - 2022-05-15
-
4.9.0-canary.1 - 2022-05-15
-
4.8.6 - 2022-07-25
-
4.8.5 - 2022-06-08
-
4.8.5-canary.1 - 2022-06-08
-
4.8.4 - 2022-06-07
-
4.8.3 - 2022-05-29
-
4.8.2 - 2022-05-13
-
4.8.1 - 2022-04-29
-
4.8.0 - 2022-04-29
-
4.8.0-canary.8 - 2022-04-29
-
4.8.0-canary.7 - 2022-04-29
-
4.8.0-canary.6 - 2022-04-29
-
4.8.0-canary.5 - 2022-04-28
-
4.8.0-canary.4 - 2022-04-28
-
4.8.0-canary.3 - 2022-04-28
-
4.8.0-canary.2 - 2022-04-28
-
4.8.0-canary.1 - 2022-04-28
-
4.7.0 - 2022-02-05
-
4.7.0-canary.1 - 2022-02-04
-
4.6.0 - 2022-01-15
-
4.5.2 - 2021-12-08
from telegraf GitHub release noteslink_preview_options.urlcaused client to try sending it as mediaCommandContextExtntype toComposer::{start|help|settings}(adds ctx.command, payload, args)Fixed
Context::text: was undefined if entities was undefined. Thanks to @ AnotiaWang.Fixed
Context::from: now usescallbackQuery.frominstead ofmsg.fromPhew, what a feature-packed release! 🎉
🆙 Bot API Updates
👍 Working with Reactions
To listen on reaction addition and removal, use
Composer.reaction:// user added a 👍 reaction
});
// prefix with - to listen to reaction removal
bot.reaction("-👍", (ctx) => {
// user removed a 👍 reaction
});
This also just works with custom emoji IDs.
// user added a reaction with the given custom emoji ID
});
bot.reaction("-5368742036629364794", (ctx) => {
// user removed a reaction with the given custom emoji ID
});
You can probe and inspect the reaction list with the
ctx.reactionssmart object:// remember that ctx.reactions is a smart object, but not an array
// message has a 👍 reaction
ctx.reactions.has("👍");
// message has a reaction with the given custom emoji ID
ctx.reactions.has("5368742036629364794");
// number of reactions from this user on the message
ctx.reaction.count;
// indexed access is allowed:
const first = ctx.reactions[0];
// the 👍 emoji was added in this update
if (ctx.reactions.added.has("👍")) {
// user added a 👍 reaction
await User.updateOne({ id: ctx.from.id }, { $inc: { likes: 1 } });
}
// the 👍 emoji was removed in this update
if (ctx.reactions.removed.has("👍")) {
// user removed a 👍 reaction
await User.updateOne({ id: ctx.from.id }, { $inc: { likes: -1 } });
};
// to copy any of these smart objects into an array, call the
toArraymethodconst reactions = ctx.reactions.toArray();
const added = ctx.reactions.added.toArray();
const removed = ctx.reactions.removed.toArray();
});
To react to a message, use
ctx.react:You can also react to a message with a custom emoji ID:
The
bot.telegram.setMessageReactionmethod is also available.💅
Context::textandContext::entities()helpersAdded the
ctx.entities()method to fetch entities in any message.Not only does this method fetch entities from any message, but also works with captions, game text, and poll explanations. In short, if an update has any text and entities, this method will find them.
ctx.textis the companion toctx.entities(). It fetches the text from the update, and works with any message type. This includes message text, media captions, game text, and poll explanations.// fetch the text from the update
const text = ctx.text;
});
bot.on(message("photo"), (ctx) => {
// fetch the caption from the photo
const caption = ctx.text;
});
🎁 Bonus! Every entity in the
ctx.entities()array will have a fragment of the text they represent!📬
Context::msgandContext::msgIdshorthandsContext::msgshorthand to get any message in the update.ctx.msgis decorated with theisAccessibleandhasmethods. Thehasmethod works similarly to themessage()filter inbot.on. It checks if the message has a certain property.// msg is accessible, not deleted or otherwise unavailable
// this is a type-guard based on the runtime check for msg.date === 0
}
if (ctx.msg.has("text")) {
// ctx.msg.text exists
}
Context::msgIdshorthand to get any available message ID in the update. This also includesmessage_idpresent in updates that do not contain a message, such asmessage_reaction, andmessage_reaction_count.🚀
bot.launchtakes an onLaunch callbackbot.launchnow takes an optional callback that is called when the bot is launched.If you pass LaunchOptions, the callback goes after the options.
This is useful for running some code when the bot is launched, such as logging to the console, or sending a message to a channel. Remember that errors thrown in this callback will not be caught by the bot's error handler. You must handle them yourself.
🖍 Format helpers
quoteformat helper for Blockquotes.prewithin another entity.🔧 Other fixes and improvements
ctx.matchforComposer.command(#1938).ctx.chatnow includeschatfromthis.messageReaction ?? this.messageReactionCount ?? this.removedChatBoost.ctx.fromnow includes the fielduserfromctx.messageReaction ?? ctx.pollAnswer ?? ctx.chatBoost?.boost.source, in addition to fetchingfromin other updates.useNewRepliesusesctx.msgIdinstead ofctx.message.message_idto reply to messages, which works for more update types than before.types,scenes,filters,format,future,utils,markup,session. For example, viaimport { WizardScene } from "telegraf/scenes". This was previously available in v3, and was removed in v4.💔 Minor breaking changes
Markup.button.userRequestwill takeextrainstead ofuser_is_premiumas the third parameter.Markup.button.botRequestwill takeextrabeforehideas the third parameter.reply_to_message_idandallow_sending_without_replyreplaced byreply_parameters.disable_web_page_previewandlink_preview_optionsreplaced bylink_preview_options.🎉 BIG announcement 🥳
Telegraf v4 - Last Major Update
This will be the last major update for Telegraf v4.
What to Expect
If you are currently using Telegraf v4, you can continue using it as you have been. Telegraf v4 will be supported until February 2025, with the following commitments:
Introducing Telegraf v5
In the coming weeks, we plan to release Telegraf v5. v5 will bring a revamped API, new functionalities, numerous convenient helpers, an improved approach to handling updates, and enhanced documentation.
One of the key highlights of Telegraf v5 is its platform-agnostic nature, allowing you to run it on any JavaScript runtime environment, including Deno, Bun, edge runtimes (such as Cloudflare Workers and Vercel), browsers, and more.
Smooth Transition to v5
If you have closely followed the development of v4 in the past year and stayed updated with deprecation notices, the transition to v5 will be relatively seamless for you. For those still using v4, we will provide a comprehensive migration guide to assist you in upgrading to v5. Stay tuned for more information on the release of v5!
Thanks for all the love ❤️! Go follow the releases channel on Telegram: t.me/Telegraf_JS.
You can sponsor the maintainer (@ MKRhere) via GitHub Sponsors, Patreon, or Ko-fi.
thumbnailis now respected in all APIs that accept itEXPERIMENTAL_SESSION_CHECKSintroduced in the last minor release had been reporting false positives. This has been fixed; it will now work as intended.🔧 Fixed
sendPhotoand friends irrecoverably erroring if passed an invalid path, such as a directory.EXPERIMENTAL_SESSION_CHECKS=1to catch session bugs in your code.When this is enabled, Telegraf will throw errors if you access/assign to session after Telegraf thinks the middleware chain has exhausted. This can happen if you're missing awaits in async code, and session changes might not get persisted! Previously, these bugs were silently ignored until someone noticed their session was not saved. It's always safe to enable this feature. This behaviour may be default in v5.
This is a rather minor release.
anyOfandallOffilter combinatorsv4.11.0 introduced support for type-guard filters in
Composer::on, which allowed you to filter updates based on their content.This release adds two new combinators to the filter API:
anyOfandallOf. This will play very nicely with custom filters. For example:// must match all filters
bot.on(allOf(message(), isGroup), ctx => {
// ...
});
Deprecating
hookPathThe confusingly named
hookPathinbot.launchwebhook options is now deprecated. It will be removed in the next major release. You can start usingpathinstead, today.Meanwhile, we're working on new modules to add to the Telegraf ecosystem. Look forward to them, and join discussions in the official Telegraf chat!
Markup.keyboard([]).persistent()methodImportant
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: