chore(deps): update dependency telegraf to ^4.16.3 #124
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.
This PR contains the following updates:
^4.4.2
->^4.16.3
Release Notes
telegraf/telegraf (telegraf)
v4.16.3
Compare Source
link_preview_options.url
caused client to try sending it as mediaCommandContextExtn
type toComposer::{start|help|settings}
(adds ctx.command, payload, args)v4.16.2
Compare Source
Fixed
Context::text
: was undefined if entities was undefined. Thanks to @AnotiaWang.v4.16.1
Compare Source
Fixed
Context::from
: now usescallbackQuery.from
instead ofmsg.from
v4.16.0
Compare Source
Phew, what a feature-packed release! 🎉
🆙 Bot API Updates
👍 Working with Reactions
To listen on reaction addition and removal, use
Composer.reaction
:This also just works with custom emoji IDs.
You can probe and inspect the reaction list with the
ctx.reactions
smart object:To react to a message, use
ctx.react
:You can also react to a message with a custom emoji ID:
The
bot.telegram.setMessageReaction
method is also available.💅
Context::text
andContext::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.text
is 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.🎁 Bonus! Every entity in the
ctx.entities()
array will have a fragment of the text they represent!📬
Context::msg
andContext::msgId
shorthandsContext::msg
shorthand to get any message in the update.ctx.msg
is decorated with theisAccessible
andhas
methods. Thehas
method works similarly to themessage()
filter inbot.on
. It checks if the message has a certain property.Context::msgId
shorthand to get any available message ID in the update. This also includesmessage_id
present in updates that do not contain a message, such asmessage_reaction
, andmessage_reaction_count
.🚀
bot.launch
takes an onLaunch callbackbot.launch
now 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
quote
format helper for Blockquotes.pre
within another entity.🔧 Other fixes and improvements
ctx.match
forComposer.command
(#1938).ctx.chat
now includeschat
fromthis.messageReaction ?? this.messageReactionCount ?? this.removedChatBoost
.ctx.from
now includes the fielduser
fromctx.messageReaction ?? ctx.pollAnswer ?? ctx.chatBoost?.boost.source
, in addition to fetchingfrom
in other updates.useNewReplies
usesctx.msgId
instead ofctx.message.message_id
to 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.userRequest
will takeextra
instead ofuser_is_premium
as the third parameter.Markup.button.botRequest
will takeextra
beforehide
as the third parameter.reply_to_message_id
andallow_sending_without_reply
replaced byreply_parameters
.disable_web_page_preview
andlink_preview_options
replaced 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.
v4.15.3
Compare Source
thumbnail
is now respected in all APIs that accept itv4.15.2
Compare Source
EXPERIMENTAL_SESSION_CHECKS
introduced in the last minor release had been reporting false positives. This has been fixed; it will now work as intended.v4.15.1
Compare Source
🔧 Fixed
sendPhoto
and friends irrecoverably erroring if passed an invalid path, such as a directory.EXPERIMENTAL_SESSION_CHECKS=1
to 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.
v4.15.0
Compare Source
This is a rather minor release.
anyOf
andallOf
filter 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:
anyOf
andallOf
. This will play very nicely with custom filters. For example:Deprecating
hookPath
The confusingly named
hookPath
inbot.launch
webhook options is now deprecated. It will be removed in the next major release. You can start usingpath
instead, 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!
v4.14.0
Compare Source
Markup.keyboard([]).persistent()
methodv4.13.1
Compare Source
v4.13.0
Compare Source
👞👟🥾 Multi-session and custom session property
👞👟🥾 Multi-session and custom session property
This update brings us the ability to have multiple session keys. This is achieved simply by passing
property
in session options:Thanks to @Evertt for making the case for this feature.
📨 Command parser
📨 Command parser
It's an often requested feature to be able to parse command arguments.
As of this release,
ctx.command
,ctx.payload
, andctx.args
are available for this usecase. It's only available inbot.command
handlers.ctx.command
is the matched command (even if you used RegExp), and it does not include the botname if it was included in the user's command.ctx.payload
is the unparsed text part excluding the command.ctx.args
is a parsed list of arguments passed to it. Have a look at the example:ctx.args
is still considered unstable, and the parser is subject to fine-tuning and improvements based on user feedback.The more generic
ctx.payload
for all commands causesctx.startPayload
inbot.start
to be redundant, and hence the latter is now deprecated.You can also play with this feature by importing the parser directly:
New types package
New types package
We have now forked Typegram to maintain types more in line with Telegraf.
Most of you will be unaffected, because Telegraf just switched its internal import to
@telegraf/types
. If you have a direct dependency ontypegram
for any reason, you might want to consider switching that over.typegram
will continue to be maintained as well.Remember that all of these types are available through Telegraf without installing any additional library:
This new package is
@telegraf/types
, available on Deno/x and npm with our ongoing effort to make Telegraf more platform independent.⬆️ Bot API 6.6, 6.7, and 6.8 support
⬆️ Bot API 6.6, 6.7, and 6.8 support
We're a little delayed this time, but we've got them all ready for you now:
API 6.6
setMyDescription
,getMyDescription
,setMyShortDescription
,getMyShortDescription
,setCustomEmojiStickerSetThumbnail
,setStickerSetTitle
,deleteStickerSet
,setStickerEmojiList
,setStickerKeywords
,setStickerMaskPosition
setStickerSetThumb
->setStickerSetThumbnail
API 6.7
setMyName
,getMyName
API 6.8
unpinAllGeneralForumTopicMessages
More exciting updates coming soon!
v4.12.2
Compare Source
v4.12.1
Compare Source
bot.command
did not match bot usernames if the registered username was not lowercased (#1809)v4.12.0
Compare Source
Normally the most exciting features of a new release would be support for the latest Bot API. But in this update, it's session! This has been in the works for many months, and we're happy to bring it to you this release!
🔒 Stable and safe session
Some of you may know that builtin session has been deprecated for quite a while. This was motivated by the fact that session is prone to race-conditions (#1372). This left the community in a grey area where they continued to use session despite the deprecation, since no clear alternative was provided. Added to this was the fact that there were no official database-backed sessions, and all unofficial async session middleware were affected by #1372.
This release finally addresses both of these long-running issues.
🏃🏼 No more race conditions
#1713 provides a reference-counted implementation resistant to race conditions. Session is now no longer deprecated, and can be used safely!
™️ Official database adapters are here!
We're also happy to announce a revamped
@telegraf/session
—this provides official store implementations for database-backed sessions via Redis, MongoDB, MySQL, MariaDB, PostgreSQL, and SQLite. Just install the drivers necessary for your database, and off you go! Since this package now only provides astore
implementation, it's usable with builtin session, and effectively makes all implementations have the same safety as the core package. Check it out!🆗 Default session
Additionally, session now accepts a
defaultSession
parameter. You no longer need a hacky middleware to doctx.session ??= { count }
.🔺 Bot API 6.5 support
Markup.button.userRequest
Markup.button.botRequest
Markup.button.groupRequest
Markup.button.channelRequest
Telegram::setChatPermissions
andContext::setChatPermissions
accept a new parameter for{ use_independent_chat_permissions?: boolean }
as documented in the API.🔺 Bot API 6.4 support
Telegram
andContext
:editGeneralForumTopic
closeGeneralForumTopic
reopenGeneralForumTopic
hideGeneralForumTopic
unhideGeneralForumTopic
Context::sendChatAction
will automatically infermessage_thread_id
for topic messages.'this' Context of type 'NarrowedContext' is not assignable to method's 'this' of type 'Context<Update>'
.⚡️ RegExp support for commands!
Another long-standing problem was the lack of support for RegExp or case-insensitive command matching. This is here now:
✍️ fmt helpers
join
fmt helper to combine dynamic arrays into a single FmtString.bold(italic("telegraf"))
will now work as expected.🌀 Persistent chat actions
ctx.sendChatAction
is used to send a "typing", or "uploading photo" status while your bot is working on something. But this is cleared after 5 seconds. If you have a longer process, you may want to keep calling sendChatAction in a loop. This new feature adds an API to help with this:Thanks to @orimiles5 for raising this pull request (#1804).
Follow Telegraf_JS to receive these updates in Telegram. If you have feedback about this update, please share with us on @TelegrafJSChat!
v4.11.2
Compare Source
sendMediaGroup
to acceptStreamFile
.message_thread_id
ifis_topic_message
is true.Telegram sends
message_thread_id
for reply messages, even if the group doesn't have topics. This caused the bot to throw whenctx.reply
was used against reply messages in non-forums.v4.11.1
Compare Source
"telegraf/filters"
. Top-levelfilters.{js|d.ts}
were missing in package.json "files" array.v4.11.0
Compare Source
🔺 Bot API 6.3 support
Telegram
class:createForumTopic
editForumTopic
closeForumTopic
reopenForumTopic
deleteForumTopic
unpinAllForumTopicMessages
getForumTopicIconStickers
Context
; addmessage_thread_id
implicitly toContext::send*
methods.✨ Filters! ✨
We've added a new powerful feature called filters! Here's how to use them.
This unlocks the ability to filter for very specific update types previously not possible! This is only an initial release, and filters will become even more powerful in future updates.
All filters are also usable from a new method,
ctx.has
. This is very useful if you want to filter within a handler. For example:Like
bot.on
,ctx.has
also supports an array of update types and filters, even mixed:As of this release, filtering by message type using
bot.on()
(for example: "text", "photo", etc.) is deprecated. Don't panic, though! Your existing bots will continue to work, but whenever you can, you must update your message type filters to use the above filters before v5. This is fairly easy to do, like this:The deprecated message type behaviour will be removed in v5.
You might be happy, or fairly upset about this development. But it was important we made this decision. For a long time, Telegraf has supported filtering by both update type and message type.
This meant you could use
bot.on("message")
, orbot.on("text")
(text here is a message type, and not an update type, so this was really making sure thatupdate.message.text
existed). However, when polls were introduced, this caused a conflict.bot.on("poll")
would match bothupdate.poll
(update about stopped polls sent by the bot) andupdate.message.poll
(a message that is a native poll). At type-level, both objects will show as available, which was wrong.Besides, this type of filters really limited how far we could go with Telegraf. That's why we introduced filters, which are way more powerful and flexible!
A few updates back, in 4.9.0, we added
ctx.send*
methods to replacectx.reply*
methods. This is because in v5 the behaviour ofctx.reply*
will be to actually reply to the current message, instead of only sending a message.To start using this behaviour right away, we had also introduced a middleware. We recommend you start using this, so that you're prepared for v5, which is brewing very soon!
Other changes
bot.launch
is now catchable (#1657)Polling errors were previously uncatchable in Telegraf. They are now. Simply attach a
catch
tobot.launch
:Three things to remember:
bot.launch
in webhook mode, it will immediately resolve aftersetWebhook
completes.bot.launch
in polling mode will not resolve immediately. Instead, it will resolve afterbot.stop()
, or reject when there's a polling error.We previously did not want fatal errors to be caught, since it gives the impression that it's a handleable error. However, being able to catch this is useful when you launch multiple bots in the same process, and one of them failing doesn't need to bring down the process.
Use this feature with care. :)
Format helpers (
"telegraf/format"
) now use template string substitution instead of naively using+=
. (Discussion)Follow Telegraf_JS to receive these updates in Telegram. If you have feedback about this update, please share with us on @TelegrafJSChat!
v4.10.0
Compare Source
Brand new formatting helpers! No more awkward escaping.
This also just works with captions!
Added Input helpers to create the InputFile object.
This helps clear the confusion many users have about InputFile.
Deprecated
ctx.replyWithMarkdown
; prefer MarkdownV2 as Telegram recommends.Deprecated
ctx.replyWithChatAction
; use identical methodctx.sendChatAction
instead.bot.launch()
's webhook options now acceptscertificate
for self-signed certs.Fix bot crashes if
updateHandler
throws (#1709)v4.9.2
Compare Source
ctx.replyWithVideo
(#1687)v4.9.1
Compare Source
v4.9.0
Compare Source
You can now follow Telegraf releases on Telegram
Telegraf::createWebhook
which callssetWebhook
, and returns Express-style middleware. [Example]Extra*
types) now found as:import type { Convenience } from "telegraf/types"
(#1659)import { useNewReplies } from telegraf/future
that changes the behaviour ofContext::reply*
methods to actually reply to the context message. This will be the default in v5.Context::sendMessage
andContext:sendWith*
methods to replace the oldContext::reply
andContext::replyWith*
methods.--method
and--data
to call API methods from the command-line.v4.8.6
Compare Source
v4.8.5
Compare Source
v4.8.4
Compare Source
exports: { types, require }
for TypeScript's"module": "Node16"
. Fixes: #1629, Ref: Handbookv4.8.3
Compare Source
ctx.tg
; usectx.telegram
insteadtype MiddlewareObj
v4.8.2
Compare Source
testEnv
as an option to Telegraf / Clientv4.8.1
Compare Source
types.js
so importing"telegraf/types"
does not cause an eslint import resolution errorv4.8.0
Compare Source
Markup.button.webApp
helperctx.webAppData
shorthand to retrieveweb_app_data
more ergonomicallytelegraf/types
to be imported directly without relying on a separate dependency on typegram. The export interface is not stable. It may change at a later date. Feedback welcomev4.7.0
Compare Source
Features:
Fixes:
ctx.approveChatJoinRequest
andctx.declineChatJoinRequest
now implicitly usectx.chat.id
instead of expectingchatId
as first parameter.v4.6.0
Compare Source
Composer.spoiler
andComposer#spoiler
methods.v4.5.2
Compare Source
banChatSenderChat
andunbanChatSenderChat
now inferthis.chat.id
instead of taking it as first parameter.v4.5.1
Compare Source
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.