Skip to content

Commit bc490bd

Browse files
committed
chore: add notice about storage defaults with scenes()
1 parent 2eea95e commit bc490bd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

docs/plugins/official/scenes.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,16 @@ const bot = new Bot(process.env.TOKEN as string)
390390

391391
> [!IMPORTANT]
392392
> The same **storage** and **list of scenes** should be shared across `scenes()` and `scenesDerives()` options.
393+
394+
By default, when registering the `scenes()` plugin, `inMemoryStorage` is used. So if you need to use `scenesDerives()` to manage scenes, you must declare `inMemoryStorage` yourself and explicitly specify it in both `scenesDerives()` and `scenes()` options.
395+
396+
```ts
397+
import { inMemoryStorage } from "@gramio/storage";
398+
399+
const storage = inMemoryStorage(); // Stores in process memory and will be erased on restart
400+
401+
const bot = new Bot(process.env.TOKEN as string)
402+
.extend(scenes([testScene], { storage }))
403+
// ...
404+
.extend(scenesDerives([testScene], { storage }));
405+
```

docs/ru/plugins/official/scenes.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,14 @@ const bot = new Bot(process.env.TOKEN as string)
402402
> Одно и то же **хранилище** и **список сцен** нужно использовать и в `scenes()`, и в опциях `scenesDerives()`.
403403
404404
<!-- TODO: Translate any new or changed sections from docs/plugins/official/scenes.md if missed above. -->
405+
406+
По умолчанию при регистрации плагина `scenes()` используется `inMemoryStorage`. Так что когда вам необходимо использовать `scenesDerives()` для управления сценами, вы должны сами объявить `inMemoryStorage` и явно указать его в опциях `scenesDerives()` и `scenes()`.
407+
408+
```ts
409+
const storage = inMemoryStorage(); // Хранит в памяти процесса и будет стёрто при перезапуске
410+
411+
const bot = new Bot(process.env.TOKEN as string)
412+
.extend(scenes([testScene], { storage }))
413+
// ...
414+
.extend(scenesDerives([testScene], { storage }));
415+
```

0 commit comments

Comments
 (0)