1 |
|
2 |
|
3 | import * as http from 'http';
|
4 | import * as tg from './core/types/typegram';
|
5 | import * as tt from './telegram-types';
|
6 | import { Composer } from './composer';
|
7 | import { MaybePromise } from './core/helpers/util';
|
8 | import ApiClient from './core/network/client';
|
9 | import Context from './context';
|
10 | import Telegram from './telegram';
|
11 | import { TlsOptions } from 'tls';
|
12 | export declare namespace Telegraf {
|
13 | interface Options<TContext extends Context> {
|
14 | contextType: new (...args: ConstructorParameters<typeof Context>) => TContext;
|
15 | handlerTimeout: number;
|
16 | telegram?: Partial<ApiClient.Options>;
|
17 | }
|
18 | interface LaunchOptions {
|
19 | dropPendingUpdates?: boolean;
|
20 |
|
21 | allowedUpdates?: tt.UpdateType[];
|
22 |
|
23 | webhook?: {
|
24 |
|
25 | domain: string;
|
26 | |
27 |
|
28 |
|
29 |
|
30 | hookPath?: string;
|
31 |
|
32 | path?: string;
|
33 | host?: string;
|
34 | port?: number;
|
35 |
|
36 | ipAddress?: string;
|
37 | |
38 |
|
39 |
|
40 |
|
41 | maxConnections?: number;
|
42 |
|
43 | tlsOptions?: TlsOptions;
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 | secretToken?: string;
|
50 | |
51 |
|
52 |
|
53 |
|
54 | certificate?: tg.InputFile;
|
55 | cb?: http.RequestListener;
|
56 | };
|
57 | }
|
58 | }
|
59 | export declare class Telegraf<C extends Context = Context> extends Composer<C> {
|
60 | private readonly options;
|
61 | private webhookServer?;
|
62 | private polling?;
|
63 |
|
64 | botInfo?: tg.UserFromGetMe;
|
65 | telegram: Telegram;
|
66 | readonly context: Partial<C>;
|
67 | |
68 |
|
69 |
|
70 |
|
71 | webhookFilter: (this: {
|
72 |
|
73 | hookPath: string;
|
74 | path: string;
|
75 | secretToken?: string;
|
76 | }, req: http.IncomingMessage) => boolean;
|
77 | private handleError;
|
78 | constructor(token: string, options?: Partial<Telegraf.Options<C>>);
|
79 | private get token();
|
80 | /** @deprecated use `ctx.telegram.webhookReply` */
|
81 | set webhookReply(webhookReply: boolean);
|
82 | /** @deprecated use `ctx.telegram.webhookReply` */
|
83 | get webhookReply(): boolean;
|
84 | /**
|
85 | * _Override_ error handling
|
86 | */
|
87 | catch(handler: (err: unknown, ctx: C) => MaybePromise<void>): this;
|
88 | /**
|
89 | * You must call `bot.telegram.setWebhook` for this to work.
|
90 | * You should probably use {@link Telegraf.createWebhook} instead.
|
91 | */
|
92 | webhookCallback(path?: string, opts?: {
|
93 | secretToken?: string;
|
94 | }): (req: http.IncomingMessage & {
|
95 | body?: tg.Update | undefined;
|
96 | }, res: http.ServerResponse<http.IncomingMessage>, next?: () => void) => Promise<void>;
|
97 | private getDomainOpts;
|
98 | |
99 |
|
100 |
|
101 |
|
102 | createWebhook(opts: {
|
103 | domain: string;
|
104 | path?: string;
|
105 | } & tt.ExtraSetWebhook): Promise<(req: http.IncomingMessage & {
|
106 | body?: tg.Update | undefined;
|
107 | }, res: http.ServerResponse<http.IncomingMessage>, next?: () => void) => Promise<void>>;
|
108 | private startPolling;
|
109 | private startWebhook;
|
110 | secretPathComponent(): string;
|
111 | launch(onLaunch?: () => void): Promise<void>;
|
112 | launch(config: Telegraf.LaunchOptions, onLaunch?: () => void): Promise<void>;
|
113 | stop(reason?: string): void;
|
114 | private botInfoCall?;
|
115 | handleUpdate(update: tg.Update, webhookResponse?: http.ServerResponse): Promise<void>;
|
116 | }
|
117 |
|
\ | No newline at end of file |