telegramsjs
    Preparing search index...

    Class WebhookClient

    Represents a client for handling Telegram updates using webhooks.

    Index

    Constructors

    Properties

    isClosed: boolean

    Indicates whether the webhook client is closed.

    offset: number

    The offset used to keep track of the latest updates.

    webhookFilter: (
        request: IncomingMessage & { body?: Update },
        options: { path: string; secretToken?: string; token: string },
    ) => boolean

    Filters incoming webhook requests to verify their authenticity.

    Type Declaration

      • (
            request: IncomingMessage & { body?: Update },
            options: { path: string; secretToken?: string; token: string },
        ): boolean
      • Parameters

        • request: IncomingMessage & { body?: Update }

          The incoming request.

        • options: { path: string; secretToken?: string; token: string }

          The options for filtering the request.

        Returns boolean

        Whether the request is valid.

    webhookServer:
        | Server<typeof IncomingMessage, typeof ServerResponse>
        | Server<typeof IncomingMessage, typeof ServerResponse>
        | null

    The HTTP or HTTPS server for handling webhook requests.

    Methods

    • Closes the webhook server.

      Returns Promise<boolean>

      The closed state of the webhook client.

    • Creates a callback function for handling webhook requests.

      Parameters

      • OptionalrequestCallback: RequestListener

        The callback function to handle requests.

      • Optionaloptions: { path?: string; secretToken?: string }

        The options for creating the webhook callback.

      Returns Promise<
          | RequestListener
          | (
              (
                  request: IncomingMessage & { body?: Update },
                  response: ServerResponse,
              ) => void
          ),
      >

      The created callback function.

    • Starts the webhook server to receive updates from Telegram.

      Parameters

      • Optionalpath: string

        The path for the webhook endpoint.

      • OptionalsecretToken: string

        The secret token for verifying webhook requests.

      • Optionaloptions: {
            host?: string;
            port?: number;
            requestCallback?: RequestListener;
            tlsOptions?: TlsOptions;
        }

        The options for the webhook server.

      Returns Promise<void>