-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# 4.13.0 | ||
|
||
### 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: | ||
|
||
```TS | ||
bot.use(session()); // creates ctx.session backed by an in-memory store | ||
|
||
bot.use(session({ | ||
property: "chatSession", | ||
getSessionKey: ctx => ctx.chat && String(ctx.chat.id), | ||
store: Redis({ url: "redis://127.0.0.1:6379" }); | ||
})); // creates ctx.chatSession backed by a Redis store | ||
``` | ||
|
||
Thanks to @Evertt for making the case for this feature. | ||
|
||
--- | ||
|
||
### Command parser | ||
|
||
It's an often requested feature to be able to parse command arguments. As of this release, `ctx.command` and `ctx.args` are available for this usecase. It's only available in `bot.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.args` is a parsed list of arguments passed to it. Have a look at the example: | ||
|
||
```TS | ||
// User sends /warn --delete "Offtopic chat" | ||
|
||
bot.command("warn", async ctx => { | ||
ctx.command; // [ "warn" ] | ||
ctx.args; // [ "--delete", "Offtopic chat" ] | ||
}); | ||
``` | ||
|
||
`ctx.args` is considered unstable, and the parser is subject to fine-tuning and improvements based on user feedback. | ||
|
||
You can also play with this feature by importing the parser directly: | ||
|
||
```TS | ||
import { argsParser } from "telegraf/utils"; | ||
|
||
// do not include the /command part! | ||
argsParser('--delete "Offtopic chat"'); // [ "--delete", "Offtopic chat" ] | ||
``` | ||
|
||
--- | ||
|
||
### 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 on `typegram` 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: | ||
|
||
```TS | ||
import type { Update } from "telegraf/types"; | ||
``` | ||
|
||
This new package is [`@telegraf/types`](https://github.com/telegraf/types), available on [Deno/x](https://deno.land/x/telegraf_types) and [npm](https://www.npmjs.com/package/@telegraf/types) with our ongoing effort to make Telegraf more platform independent. | ||
|
||
--- | ||
|
||
### 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 | ||
|
||
- New methods `setMyDescription`, `getMyDescription`, `setMyShortDescription`, `getMyShortDescription`, ` setCustomEmojiStickerSetThumbnail`, `setStickerSetTitle`, `deleteStickerSet`, `setStickerEmojiList`, `setStickerKeywords`, `setStickerMaskPosition` | ||
- Renamed `setStickerSetThumb` -> `setStickerSetThumbnail` | ||
- Renamed thumb to thumbnail throughout the API | ||
- Various other minor changes, refer to [Bot API 6.6](https://core.telegram.org/bots/api-changelog#march-9-2023) | ||
|
||
#### API 6.7 | ||
|
||
- New methods `setMyName`, `getMyName` | ||
- Various other minor changes, refer to [Bot API 6.7](https://core.telegram.org/bots/api-changelog#april-21-2023) | ||
|
||
#### API 6.8 | ||
|
||
- New methods `unpinAllGeneralForumTopicMessages` | ||
- Various other minor changes, refer to [Bot API 6.8](https://core.telegram.org/bots/api-changelog#august-18-2023) |