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

    Class JsonFilePersistence

    Persists user data, chat data, bot data, conversation states, and jobs to a single JSON file.

    const persistence = new JsonFilePersistence({ filePath: "./data/state.json" });
    

    Implements

    Index
    • Deletes chat data for the given chat ID.

      Parameters

      • chatId: string | number

        Telegram chat ID.

      Returns Promise<void>

    • Deletes state for a conversation key.

      Parameters

      • key: string

        Conversation identifier.

      Returns Promise<void>

    • Deletes user data for the given user ID.

      Parameters

      • userId: number

        Telegram user ID.

      Returns Promise<void>

    • Flushes any pending disk updates.

      Returns Promise<void>

    • Retrieves global bot data.

      Returns Promise<Record<string, unknown>>

      Key-value map of bot data.

    • Retrieves chat data for the given chat ID.

      Parameters

      • chatId: string | number

        Telegram chat ID.

      Returns Promise<Record<string, unknown>>

      Key-value map of chat data.

    • Retrieves all active conversation states.

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

      Map of conversation keys to states.

    • Retrieves user data for the given user ID.

      Parameters

      • userId: number

        Telegram user ID.

      Returns Promise<Record<string, unknown>>

      Key-value map of user data.

    • Stores global bot data.

      Parameters

      • data: Record<string, unknown>

        Key-value map to store.

      Returns Promise<void>

      Resolves when saved.

    • Stores chat data for the given chat ID.

      Parameters

      • chatId: string | number

        Telegram chat ID.

      • data: Record<string, unknown>

        Key-value map to store.

      Returns Promise<void>

      Resolves when saved.

    • Stores user data for the given user ID.

      Parameters

      • userId: number

        Telegram user ID.

      • data: Record<string, unknown>

        Key-value map to store.

      Returns Promise<void>

      Resolves when saved.

    • Updates state for a conversation key.

      Parameters

      • key: string

        Conversation identifier.

      • state: string | number

        Current step/state.

      Returns Promise<void>

      Resolves when saved.