telebot-ts API Documentation - v1.0.0
    Preparing search index...

    Class MemoryPersistence

    Default in-memory persistence implementation.

    Stores user, chat, bot data, and conversation states in memory Maps. Data is reset when the process terminates.

    import { ApplicationBuilder, MemoryPersistence } from "telebot-ts";

    const app = new ApplicationBuilder()
    .token("BOT_TOKEN")
    .persistence(new MemoryPersistence())
    .build();

    Implements

    Index
    • Deletes chat data for a specific chat ID from memory.

      Parameters

      • chatId: string | number

        Telegram chat ID.

      Returns Promise<void>

    • Deletes conversation state for the given key from memory.

      Parameters

      • key: string

        Conversation composite key.

      Returns Promise<void>

    • Deletes user data for a specific user ID from memory.

      Parameters

      • userId: number

        Telegram user ID.

      Returns Promise<void>

    • Retrieves bot data from memory.

      Returns Promise<Record<string, unknown>>

      Global bot data record.

    • Retrieves chat data from memory.

      Parameters

      • chatId: string | number

        Telegram chat ID.

      Returns Promise<Record<string, unknown>>

      The chat data record for chatId.

    • Retrieves a snapshot copy of all active conversation states.

      Returns Promise<Map<string, string | number>>

      A Map clone of conversation states.

    • Retrieves user data from memory.

      Parameters

      • userId: number

        Telegram user ID.

      Returns Promise<Record<string, unknown>>

      The user data record for userId.

    • Stores bot data in memory.

      Parameters

      • data: Record<string, unknown>

        Global bot data record to store.

      Returns Promise<void>

      Resolves when saved in memory.

    • Stores chat data in memory.

      Parameters

      • chatId: string | number

        Telegram chat ID.

      • data: Record<string, unknown>

        Chat data record to store.

      Returns Promise<void>

      Resolves when saved in memory.

    • Overwrites the persisted jobs in memory.

      Parameters

      Returns Promise<void>

      Resolves when updated.

    • Stores user data in memory.

      Parameters

      • userId: number

        Telegram user ID.

      • data: Record<string, unknown>

        User data record to store.

      Returns Promise<void>

      Resolves when saved in memory.

    • Updates conversation state for the given key in memory.

      Parameters

      • key: string

        Conversation composite key.

      • state: string | number

        Current conversation state.

      Returns Promise<void>

      Resolves when updated in memory.