import { type SessionOptions } from "https://dotland.deno.dev/x/grammy@v1.22.4/convenience/session.ts";
Options for session middleware.
Properties
Recommended to use.
A function that produces an initial value for ctx.session
. This
function will be called every time the storage solution returns undefined
for a given session key. Make sure to create a new value every time, such
that different context objects do that accidentally share the same
session data.
This option lets you generate your own session keys per context object. The session key determines how to map the different session objects to your chats and users. Check out the documentation on the website about how to use session middleware to know how session keys are used.
The default implementation will store sessions per chat, as determined by
ctx.chat?.id
.
A storage adapter to your storage solution. Provides read, write, and delete access to the session middleware.
Consider using a known storage adapter instead of rolling your own implementation of this.
The default implementation will store session in memory. The data will be lost whenever your bot restarts.