import { Context } from './context'; import { MaybePromise } from './composer'; import { MiddlewareFn } from './middleware'; export interface SessionStore { get: (name: string) => MaybePromise; set: (name: string, value: T) => MaybePromise; delete: (name: string) => MaybePromise; } interface SessionOptions { getSessionKey?: (ctx: Context) => Promise; store?: SessionStore; } export interface SessionContext extends Context { session?: S; } /** * Returns middleware that adds `ctx.session` for storing arbitrary state per session key. * * The default `getSessionKey` is \`${ctx.from.id}:${ctx.chat.id}\`. * If either `ctx.from` or `ctx.chat` is `undefined`, default session key and thus `ctx.session` are also `undefined`. * * Session data is kept only in memory by default, * which means that all data will be lost when the process is terminated. * If you want to store data across restarts, or share it among workers, * you can [install persistent session middleware from npm](https://www.npmjs.com/search?q=telegraf-session), * or pass custom `storage`. * * @example https://github.com/telegraf/telegraf/blob/develop/docs/examples/session-bot.ts * @deprecated https://github.com/telegraf/telegraf/issues/1372#issuecomment-782668499 */ export declare function session(options?: SessionOptions): MiddlewareFn>; /** @deprecated https://github.com/telegraf/telegraf/issues/1372#issuecomment-782668499 */ export declare class MemorySessionStore implements SessionStore { private readonly ttl; private readonly store; constructor(ttl?: number); get(name: string): T | undefined; set(name: string, value: T): void; delete(name: string): void; } export declare function isSessionContext(ctx: Context): ctx is SessionContext; export {}; //# sourceMappingURL=session.d.ts.map