UNPKG

2.74 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as http from 'http';
3import * as tg from './core/types/typegram';
4import * as tt from './telegram-types';
5import { Composer, MaybePromise } from './composer';
6import ApiClient from './core/network/client';
7import Context from './context';
8import Telegram from './telegram';
9import { TlsOptions } from 'tls';
10export declare namespace Telegraf {
11 interface Options<TContext extends Context> {
12 contextType: new (...args: ConstructorParameters<typeof Context>) => TContext;
13 handlerTimeout: number;
14 telegram?: Partial<ApiClient.Options>;
15 }
16 interface LaunchOptions {
17 dropPendingUpdates?: boolean;
18 /** List the types of updates you want your bot to receive */
19 allowedUpdates?: tt.UpdateType[];
20 /** Configuration options for when the bot is run via webhooks */
21 webhook?: {
22 /** Public domain for webhook. If domain is not specified, hookPath should contain a domain name as well (not only path component). */
23 domain?: string;
24 /** Webhook url path; will be automatically generated if not specified */
25 hookPath?: string;
26 host?: string;
27 port?: number;
28 /** TLS server options. Omit to use http. */
29 tlsOptions?: TlsOptions;
30 cb?: http.RequestListener;
31 };
32 }
33}
34export declare class Telegraf<C extends Context = Context> extends Composer<C> {
35 private readonly options;
36 private webhookServer?;
37 private polling?;
38 /** Set manually to avoid implicit `getMe` call in `launch` or `webhookCallback` */
39 botInfo?: tg.UserFromGetMe;
40 telegram: Telegram;
41 readonly context: Partial<C>;
42 private handleError;
43 constructor(token: string, options?: Partial<Telegraf.Options<C>>);
44 private get token();
45 /** @deprecated use `ctx.telegram.webhookReply` */
46 set webhookReply(webhookReply: boolean);
47 get webhookReply(): boolean;
48 /**
49 * _Override_ error handling
50 */
51 catch(handler: (err: unknown, ctx: C) => MaybePromise<void>): this;
52 webhookCallback(path?: string): (req: http.IncomingMessage & {
53 body?: tg.Update | undefined;
54 }, res: http.ServerResponse, next?: () => void) => Promise<void>;
55 private startPolling;
56 private startWebhook;
57 secretPathComponent(): string;
58 /**
59 * @see https://github.com/telegraf/telegraf/discussions/1344#discussioncomment-335700
60 */
61 launch(config?: Telegraf.LaunchOptions): Promise<void>;
62 stop(reason?: string): void;
63 private handleUpdates;
64 private botInfoCall?;
65 handleUpdate(update: tg.Update, webhookResponse?: http.ServerResponse): Promise<void>;
66}
67//# sourceMappingURL=telegraf.d.ts.map
\No newline at end of file