Skip to content

Commit

Permalink
chore: scene update improve
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed Nov 10, 2024
1 parent 261b2bc commit d5e4056
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Binary file modified bun.lockb
Binary file not shown.
12 changes: 6 additions & 6 deletions docs/plugins/official/scenes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ WIP. The API can be changed, but we already use it in production environment.

# Usage

```ts
```ts twoslash
import { Bot } from "gramio";
import { scenes, Scene } from "@gramio/scenes";

const testScene = new Scene("test")
.params<{ test: boolean }>()
.step("message", (context) => {
.step("message", async (context) => {
if (context.scene.step.firstTime || context.text !== "1")
return context.send("1");

if (context.scene.params.test === true) context.send("DEBUG!");
if (context.scene.params.test === true) await context.send("DEBUG!");

return context.scene.step.next();
});
Expand All @@ -42,14 +42,14 @@ const bot = new Bot(process.env.TOKEN as string)
import { Scene } from "@gramio/scenes";

const testScene = new Scene("test")
.step("message", (context) => {
.step("message", async (context) => {
if (context.scene.step.firstTime || context.text !== "1")
return context.send("1");

// u can fine type issues with this when returns non update session data but just ignore it for now
return context.scene.update({ messageId: context.id });
return context.scene.update({ messageId: context.id, some: "hii!" });
})
.step("message", (context) => {
.step("message", async (context) => {
if (context.scene.step.firstTime || context.text !== "2")
return context.send("2");

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"trustedDependencies": ["@biomejs/biome"],
"dependencies": {
"@gramio/scenes": "^0.0.4",
"@gramio/scenes": "^0.0.5",
"ioredis": "^5.4.1",
"jobify": "^0.1.0"
}
Expand Down

0 comments on commit d5e4056

Please sign in to comment.