ultra-telegram-framework
    Preparing search index...

    Class NodeApiClient

    Abstract core describing the transport layer.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    Properties

    baseUrl: string

    Accessors

    Methods

    • Request method implemented by each platform.

      Type Parameters

      • T

      Parameters

      • method: string

        Method name

      • payload: Record<string, unknown> = {}

        Parameters object

      Returns Promise<T>

      Promise<T>

    • Retrieve and clear the captured webhook reply payload. Returns null if no payload was captured (e.g., the first call had files, or no API calls were made during this update).

      Returns WebhookReplyPayload | null

    • Enable webhook reply mode. Call this BEFORE handleUpdate() to capture the first text-only API call as a JSON payload instead of sending it via fetch.

      ⚠️ Important trade-off: When a call is captured, the corresponding ctx.reply() / ctx.api.* method returns an empty object {} instead of the real Telegram response. This means you cannot rely on the return value (e.g., msg.message_id will be undefined).

      Use this only when you don't need the return value of the first API call.

      Returns void

      app.post('/webhook', async (req, res) => {
      client.enableWebhookReply();
      await bot.handleUpdate(req.body);

      const reply = client.consumeWebhookReply();
      if (reply) {
      res.json(reply);
      } else {
      res.json({ ok: true });
      }
      });