Function session

  • 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 persist data across process restarts, or share it among multiple instances, you should use @telegraf/session, or pass custom storage.

    Type Parameters

    • S extends {}

    • C extends Context<Update> & {
          [key in string]?: C[P]
      }

    • P extends string = "session"

    Parameters

    • Optional options: SessionOptions<S, C, P>
      Optional

    Returns MiddlewareFn<C>

Generated using TypeDoc