Class representing the Telegram API and all it's methods

Constructors

Methods

  • Get the API URL for a given bot API and slug

    Parameters

    • botApi: string

      full URL to the telegram API without slug

    • slug: string

      slug to append to the API URL

    • data: Record<string, string | number | boolean>

      data to append to the request

    Returns Request<unknown, CfProperties<unknown>>

  • Get a file with a given file_id

    Parameters

    • botApi: string

      full URL to the telegram API without slug

    • data: Record<string, string | number | boolean>

      data to append to the request

    • token: string

      bot token

    Returns Promise<Response>

  • Send a message to a given botApi

    Parameters

    • botApi: string

      full URL to the telegram API without slug

    • data: {
          chat_id: string | number;
          parse_mode: string;
          reply_to_message_id: string | number;
          text: string;
      }

      data to append to the request

      • chat_id: string | number
      • parse_mode: string
      • reply_to_message_id: string | number
      • text: string

    Returns Promise<Response>

  • Send a photo message to a given botApi

    Parameters

    • botApi: string

      full URL to the telegram API without slug

    • data: {
          caption: string;
          chat_id: string | number;
          photo: string;
          reply_to_message_id: string | number;
      }

      data to append to the request

      • caption: string
      • chat_id: string | number
      • photo: string
      • reply_to_message_id: string | number

    Returns Promise<Response>

  • Send a video message to a given botApi

    Parameters

    • botApi: string

      full URL to the telegram API without slug

    • data: {
          chat_id: string | number;
          reply_to_message_id: string | number;
          video: string;
      }

      data to append to the request

      • chat_id: string | number
      • reply_to_message_id: string | number
      • video: string

    Returns Promise<Response>