///
///
import * as http from 'http';
import { Opts, Telegram } from '../types/typegram';
import { URL } from 'url';
interface FetchResponse {
status: number;
statusText: string;
body?: unknown;
json: () => Promise;
}
type Fetch = (url: URL | string, init?: globalThis.RequestInit) => Promise;
export interface NetworkOptions {
proxy: string;
FetchClient: new (config: {
proxy: string;
}) => {
fetch: Fetch;
};
}
declare namespace ApiClient {
interface Options {
apiRoot: string;
/**
* @default 'bot'
* @see https://github.com/tdlight-team/tdlight-telegram-bot-api#user-mode
*/
apiMode: 'bot' | 'user';
webhookReply: boolean;
testEnv: boolean;
/**
* Fetch implementation used for Bot API calls and URL attachments.
* The default is `globalThis.fetch`.
*
* Provide a custom fetch implementation for proxy agents, custom TLS,
* custom compression, or other non-standard network behavior.
*/
fetch: Fetch;
/**
* Request timeout in milliseconds. Use 0 or Infinity to disable it.
*/
requestTimeout: number;
}
interface CallApiOptions {
signal?: AbortSignal;
}
}
type Response = http.ServerResponse;
declare class ApiClient {
readonly token: string;
private readonly response?;
readonly options: ApiClient.Options;
constructor(token: string, options?: Partial, response?: Response | undefined);
/**
* If set to `true`, first _eligible_ call will avoid performing a POST request.
* Note that such a call:
* 1. cannot report errors or return meaningful values,
* 2. resolves before bot API has a chance to process it,
* 3. prematurely confirms the update as processed.
*
* https://core.telegram.org/bots/faq#how-can-i-make-requests-in-response-to-updates
* https://github.com/telegraf/telegraf/pull/1250
*/
set webhookReply(enable: boolean);
get webhookReply(): boolean;
callApi(method: M, payload: Opts, { signal }?: ApiClient.CallApiOptions): Promise>;
}
export default ApiClient;
//# sourceMappingURL=client.d.ts.map