This repository was archived by the owner on Oct 13, 2023. It is now read-only.
fix(deps): update dependency telegraf to v4#70
Closed
renovate[bot] wants to merge 1 commit into
Closed
Conversation
c750139 to
1d7f422
Compare
1d7f422 to
dc28f01
Compare
dc28f01 to
117e978
Compare
117e978 to
a67c889
Compare
a67c889 to
7bdb8e6
Compare
7bdb8e6 to
6c42d80
Compare
6c42d80 to
2569878
Compare
2569878 to
b14d2d5
Compare
b14d2d5 to
d677544
Compare
d677544 to
009446d
Compare
009446d to
4c3d64c
Compare
4c3d64c to
56465ae
Compare
Author
Renovate Ignore NotificationBecause you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 4.x releases. But if you manually upgrade to 4.x then Renovate will re-enable If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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:
^3.38.0->^4.14.0Release Notes
telegraf/telegraf (telegraf)
v4.14.0Compare Source
Markup.keyboard([]).persistent()methodv4.13.1Compare Source
v4.13.0Compare 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
propertyin 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.argsare available for this usecase. It's only available inbot.commandhandlers.ctx.commandis 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.payloadis the unparsed text part excluding the command.ctx.argsis a parsed list of arguments passed to it. Have a look at the example:ctx.argsis still considered unstable, and the parser is subject to fine-tuning and improvements based on user feedback.The more generic
ctx.payloadfor all commands causesctx.startPayloadinbot.startto be redundant, and hence the latter is now deprecated.bot.start(ctx => { - console.log(ctx.startPayload); + console.log(ctx.payload); });You can also play with this feature by importing the parser directly:
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 ontypegramfor any reason, you might want to consider switching that over.typegramwill 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,setStickerMaskPositionsetStickerSetThumb->setStickerSetThumbnailAPI 6.7
setMyName,getMyNameAPI 6.8
unpinAllGeneralForumTopicMessagesMore exciting updates coming soon!
v4.12.2Compare Source
v4.12.1Compare Source
bot.commanddid not match bot usernames if the registered username was not lowercased (#1809)v4.12.0Compare 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 astoreimplementation, 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
defaultSessionparameter. You no longer need a hacky middleware to doctx.session ??= { count }.🔺 Bot API 6.5 support
Markup.button.userRequestMarkup.button.botRequestMarkup.button.groupRequestMarkup.button.channelRequestTelegram::setChatPermissionsandContext::setChatPermissionsaccept a new parameter for{ use_independent_chat_permissions?: boolean }as documented in the API.🔺 Bot API 6.4 support
TelegramandContext:editGeneralForumTopiccloseGeneralForumTopicreopenGeneralForumTopichideGeneralForumTopicunhideGeneralForumTopicContext::sendChatActionwill automatically infermessage_thread_idfor 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
joinfmt helper to combine dynamic arrays into a single FmtString.bold(italic("telegraf"))will now work as expected.🌀 Persistent chat actions
ctx.sendChatActionis 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.2Compare Source
sendMediaGroupto acceptStreamFile.message_thread_idifis_topic_messageis true.Telegram sends
message_thread_idfor reply messages, even if the group doesn't have topics. This caused the bot to throw whenctx.replywas used against reply messages in non-forums.v4.11.1Compare Source
"telegraf/filters". Top-levelfilters.{js|d.ts}were missing in package.json "files" array.v4.11.0Compare Source
🔺 Bot API 6.3 support
Telegramclass:createForumTopiceditForumTopiccloseForumTopicreopenForumTopicdeleteForumTopicunpinAllForumTopicMessagesgetForumTopicIconStickersContext; addmessage_thread_idimplicitly 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.hasalso 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.textexisted). 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.launchis now catchable (#1657)Polling errors were previously uncatchable in Telegraf. They are now. Simply attach a
catchtobot.launch:Three things to remember:
bot.launchin webhook mode, it will immediately resolve aftersetWebhookcompletes.bot.launchin 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.0Compare 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.sendChatActioninstead.bot.launch()'s webhook options now acceptscertificatefor self-signed certs.Fix bot crashes if
updateHandlerthrows (#1709)v4.9.2Compare Source
ctx.replyWithVideo(#1687)v4.9.1Compare Source
v4.9.0Compare Source
You can now follow Telegraf releases on Telegram
Telegraf::createWebhookwhich callssetWebhook, and returns Express-style middleware. [Example]Extra*types) now found as:import type { Convenience } from "telegraf/types"(#1659)import { useNewReplies } from telegraf/futurethat changes the behaviour ofContext::reply*methods to actually reply to the context message. This will be the default in v5.Context::sendMessageandContext:sendWith*methods to replace the oldContext::replyandContext::replyWith*methods.--methodand--datato call API methods from the command-line.v4.8.6Compare Source
v4.8.5Compare Source
v4.8.4Compare Source
exports: { types, require }for TypeScript's"module": "Node16". Fixes: #1629, Ref: Handbookv4.8.3Compare Source
ctx.tg; usectx.telegraminsteadtype MiddlewareObjv4.8.2Compare Source
testEnvas an option to Telegraf / Clientv4.8.1Compare Source
types.jsso importing"telegraf/types"does not cause an eslint import resolution errorv4.8.0Compare Source
Markup.button.webApphelperctx.webAppDatashorthand to retrieveweb_app_datamore ergonomicallytelegraf/typesto 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.0Compare Source
Features:
Fixes:
ctx.approveChatJoinRequestandctx.declineChatJoinRequestnow implicitly usectx.chat.idinstead of expectingchatIdas first parameter.v4.6.0Compare Source
Composer.spoilerandComposer#spoilermethods.v4.5.2Compare Source
banChatSenderChatandunbanChatSenderChatnow inferthis.chat.idinstead of taking it as first parameter.v4.5.1Compare Source
v4.4.2Compare Source
v4.4.1Compare Source
v4.4.0: v4.4Compare Source
ff33055Update to Bot API 5.3ab10989Reuse body parsed byexpress(#1477)5588e05ExportTypes.Markupclass; fixes #1414e34c4d7Throw nice error on 5xx responses1ab6563Improve URL buildinge85a21dRedact token secrets containing hyphens1a9aeedMake defaulthookPathdeterministic (#1386)9584cf6Fix and exportMountMapv4.3.0: v4.3Compare Source
src/telegram-types.tsasTypes(#1380)Triggersin someComposermethods (#1404)Contextgeneric,NarrowedContext,Composer::startrequire at least one middleware (https://github.com/telegraf/telegraf/issues/1292#issuecomment-759454750).I have no more features planned, except #1267 for v5.0.
v4.2.1Compare Source
v4.2.0Compare Source
v4.1.2Compare Source
v4.1.1Compare Source
v4.1.0: v4.1Compare Source
session(#1373)dropPendingUpdatestoTelegraf::launch(#1366)apiModeoption (#1334)deunionize,NarrowedContext,Telegram,TelegramErrorv4.0.3Compare Source
v4.0.2Compare Source
v4.0.1Compare Source
v4.0.0: v4.0Compare Source
Changelog Telegraf 4.0
General
ScenesAbortControllerattachmentAgentoption to provide an agent that is used for fetching files from the web before they are sent to Telegram (previously done through the sameagentas used to connect to Telegram itself)Apart from updating Telegraf to full Telegram Bot API 5.0 support, the most significant improvement is that we now have a code base that is written 100 % in TypeScript, which more or less required a rewrite of the complete library.
Previously, the library was written in JavaScript and had a few type annotations to the side, but they were often incorrect or missing.
In working on the 4.0 release, we created type coverage of the complete Telegram Bot API.
The benefit is that your editor can now autocomplete accross every single field in every single method or entity.
Those who ever tried it out can confirm that this improves the development experience by an order of magnitude.
Note that this update brings 9 months worth of improvements, so while we did our best to summarise all important changes, it's possible that we forgot some!
Composer
Composer.guardstatic Composer.mount, preferstatic Composer.onComposer.entityandComposer.matchprivateComposer.catchAllandComposer.safePassThruComposer.forkon('forward_date'), no longeron('forward')Context
ctx.botInforequired, i.e. is is always availablectx.statereadonlyctx.senderChat,ctx.unpinAllChatMessages, andctx.copyMessagectx.deleteMessageno longer works for edited messages, channel posts, or edited channel postsctx.updateSubTypesExtra
Extrais removed entirely, see #1076.You can now just specify any options directly, without having to create an
Extrainstance before.Markup
Markupis largely reworked.Please check out the new documentation about
Markup, this is much easier than trying to understand the differences between the old and the new version.The TypeScript autocompletion should help you a lot in case you have to change something about your code.
The main thing to watch out for is that all buttons (keyboard buttons and inline buttons) are now created via
Markup.button.urland its siblings, no longer viaMarkup.urlButton.The integration with
Extrais removed.Session
Remove the ability to specify a custom property on the context object under which the session lives, in other words, the session data can only be available under
ctx.session.Note that this also applies to scene sessions, they now exclusively live under
ctx.scene.session.When no session data is stored,
ctx.sessionis nowundefinedinstead of{}.Telegraf
Bots should now always be started using
bot.launchwith the corresponding configuration for either long polling (default) or webhooks.startPollingandstartWebhookare now privateTimeoutErroris now thrown if update takes longer thanhandlerTimeoutto processhandlerTimeoutdefaults to 90 secondsstopreturnsvoidand takesreasoninstead of callback as as an argumentchannelModeis removedPolling
retryAfteroption (used in an error case), always using 5 seconds nowtimeoutoption, always using 50 seconds nowlimitoption, always fetching 100 updates nowstopCallbackoptionCommon typing issues
Naturally, if your editor validates your code against the TypeScript types, you may find a few bugs here and there that you were not aware of.
Here are a few things you might come across and that we'd like to explain.
Property X is not availablefor messages, callback queries, etcThis happens in various different forms, one example is this:
We are listening for
messages here, but not all messages are text messages!As a result, the text property might be absent, for example for photo messages.
Here is how you solve it:
Remember that you can always just do this instead:
Cannot access
ctx.sessionorctx.sceneorctx.wizardtypeIf you are using sessions, scenes, wizards, or even yet another of the many modules that work with Telegraf, you have to define your own context object.
This context object must specify which types your middleware registers on the context.
We cannot infer this automatically.
This is best explained by an example bot.
Here is one that's relevant: https://github.com/telegraf/telegraf/blob/develop/docs/examples/example-bot.ts
Scenes have various examples here: https://github.com/telegraf/telegraf/tree/develop/docs/examples/scenes
I see a really complicated type error message!
Middleware in Telegraf is very flexible, so we have to do some really fancy stuff under the hood when we infer the types for you.
Whenever you type
bot.on(['callback_query', 'text'], (ctx) => ctx.|, and autocomplete shows up, we have to look at the first argument ofbot.on, iterate through the array, look at each string in it, and then do a type transformation on the complete Bot API surface to filter out which options are even available on the relevant context objects at this point.All of this computation happens on the type level.
(Fun fact: in the first iteration of this feature it took up to 20 seconds for autocomplete to show up.)
The point is: types are hard.
It was our main priority to make the types correct, and then we focused on making the type inference fast.
We would love to make TypeScript print more readable type errors, and we are actively looking trying a few things to do this without too much black magic.
Until then, don't give up!
Here's what you can do:
Double check this first, the problem may be simpler than you thought.
Look out for these parts, they often help to fix the problem.
Don't hesitate to share a code snippet in the Telegram group.
You are probably not the only one with this problem.
v3.40.0Compare Source
v3.39.0Compare 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 has been generated by Mend Renovate. View repository job log here.