1 | import * as tg from './core/types/typegram';
|
2 | import * as tt from './telegram-types';
|
3 | import { Deunionize, PropOr, UnionKeys } from './deunionize';
|
4 | import ApiClient from './core/network/client';
|
5 | import Telegram from './telegram';
|
6 | declare type Tail<T> = T extends [unknown, ...infer U] ? U : never;
|
7 | declare type Shorthand<FName extends Exclude<keyof Telegram, keyof ApiClient>> = Tail<Parameters<Telegram[FName]>>;
|
8 | export declare class Context<U extends Deunionize<tg.Update> = tg.Update> {
|
9 | readonly update: U;
|
10 | readonly tg: Telegram;
|
11 | readonly botInfo: tg.UserFromGetMe;
|
12 | readonly state: Record<string | symbol, any>;
|
13 | constructor(update: U, tg: Telegram, botInfo: tg.UserFromGetMe);
|
14 | get updateType(): Extract<UnionKeys<U>, tt.UpdateType>;
|
15 | get me(): string;
|
16 | get telegram(): Telegram;
|
17 | get message(): PropOr<U, "message", undefined>;
|
18 | get editedMessage(): PropOr<U, "edited_message", undefined>;
|
19 | get inlineQuery(): PropOr<U, "inline_query", undefined>;
|
20 | get shippingQuery(): PropOr<U, "shipping_query", undefined>;
|
21 | get preCheckoutQuery(): PropOr<U, "pre_checkout_query", undefined>;
|
22 | get chosenInlineResult(): PropOr<U, "chosen_inline_result", undefined>;
|
23 | get channelPost(): PropOr<U, "channel_post", undefined>;
|
24 | get editedChannelPost(): PropOr<U, "edited_channel_post", undefined>;
|
25 | get callbackQuery(): PropOr<U, "callback_query", undefined>;
|
26 | get poll(): PropOr<U, "poll", undefined>;
|
27 | get pollAnswer(): PropOr<U, "poll_answer", undefined>;
|
28 | get myChatMember(): PropOr<U, "my_chat_member", undefined>;
|
29 | get chatMember(): PropOr<U, "chat_member", undefined>;
|
30 | get chat(): Getter<U, 'chat'>;
|
31 | get senderChat(): PropOr<GetUpdateContent<U>, "sender_chat", undefined>;
|
32 | get from(): PropOr<GetUpdateContent<U>, "from", undefined>;
|
33 | get inlineMessageId(): string | undefined;
|
34 | get passportData(): tg.PassportData | undefined;
|
35 | /**
|
36 | * @deprecated use {@link Telegram.webhookReply}
|
37 | */
|
38 | get webhookReply(): boolean;
|
39 | set webhookReply(enable: boolean);
|
40 | private assert;
|
41 | |
42 |
|
43 |
|
44 | answerInlineQuery(this: Context, ...args: Shorthand<'answerInlineQuery'>): Promise<true>;
|
45 | |
46 |
|
47 |
|
48 | answerCbQuery(this: Context, ...args: Shorthand<'answerCbQuery'>): Promise<true>;
|
49 | |
50 |
|
51 |
|
52 | answerGameQuery(this: Context, ...args: Shorthand<'answerGameQuery'>): Promise<true>;
|
53 | |
54 |
|
55 |
|
56 | answerShippingQuery(this: Context, ...args: Shorthand<'answerShippingQuery'>): Promise<true>;
|
57 | |
58 |
|
59 |
|
60 | answerPreCheckoutQuery(this: Context, ...args: Shorthand<'answerPreCheckoutQuery'>): Promise<true>;
|
61 | |
62 |
|
63 |
|
64 | editMessageText(this: Context, text: string, extra?: tt.ExtraEditMessageText): Promise<true | (tg.Update.Edited & tg.Message.TextMessage)>;
|
65 | |
66 |
|
67 |
|
68 | editMessageCaption(this: Context, caption: string | undefined, extra?: tt.ExtraEditMessageCaption): Promise<true | (tg.Update.Edited & tg.Message.CaptionableMessage)>;
|
69 | |
70 |
|
71 |
|
72 | editMessageMedia(this: Context, media: tg.InputMedia, extra?: tt.ExtraEditMessageMedia): Promise<true | (tg.Update.Edited & tg.Message.AnimationMessage) | (tg.Update.Edited & tg.Message.DocumentMessage) | (tg.Update.Edited & tg.Message.AudioMessage) | (tg.Update.Edited & tg.Message.PhotoMessage) | (tg.Update.Edited & tg.Message.VideoMessage)>;
|
73 | |
74 |
|
75 |
|
76 | editMessageReplyMarkup(this: Context, markup: tg.InlineKeyboardMarkup | undefined): Promise<true | (tg.Update.Edited & tg.Message)>;
|
77 | |
78 |
|
79 |
|
80 | editMessageLiveLocation(this: Context, latitude: number, longitude: number, extra?: tt.ExtraEditMessageLiveLocation): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
|
81 | |
82 |
|
83 |
|
84 | stopMessageLiveLocation(this: Context, markup?: tg.InlineKeyboardMarkup): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
|
85 | |
86 |
|
87 |
|
88 | reply(this: Context, ...args: Shorthand<'sendMessage'>): Promise<tg.Message.TextMessage>;
|
89 | |
90 |
|
91 |
|
92 | getChat(this: Context, ...args: Shorthand<'getChat'>): Promise<tg.ChatFromGetChat>;
|
93 | |
94 |
|
95 |
|
96 | exportChatInviteLink(this: Context, ...args: Shorthand<'exportChatInviteLink'>): Promise<string>;
|
97 | |
98 |
|
99 |
|
100 | createChatInviteLink(this: Context, ...args: Shorthand<'createChatInviteLink'>): Promise<tg.ChatInviteLink>;
|
101 | |
102 |
|
103 |
|
104 | editChatInviteLink(this: Context, ...args: Shorthand<'editChatInviteLink'>): Promise<tg.ChatInviteLink>;
|
105 | |
106 |
|
107 |
|
108 | revokeChatInviteLink(this: Context, ...args: Shorthand<'revokeChatInviteLink'>): Promise<tg.ChatInviteLink>;
|
109 | |
110 |
|
111 |
|
112 | kickChatMember(this: Context, ...args: Shorthand<'kickChatMember'>): Promise<true>;
|
113 | |
114 |
|
115 |
|
116 | unbanChatMember(this: Context, ...args: Shorthand<'unbanChatMember'>): Promise<true>;
|
117 | |
118 |
|
119 |
|
120 | restrictChatMember(this: Context, ...args: Shorthand<'restrictChatMember'>): Promise<true>;
|
121 | |
122 |
|
123 |
|
124 | promoteChatMember(this: Context, ...args: Shorthand<'promoteChatMember'>): Promise<true>;
|
125 | |
126 |
|
127 |
|
128 | setChatAdministratorCustomTitle(this: Context, ...args: Shorthand<'setChatAdministratorCustomTitle'>): Promise<true>;
|
129 | |
130 |
|
131 |
|
132 | setChatPhoto(this: Context, ...args: Shorthand<'setChatPhoto'>): Promise<true>;
|
133 | |
134 |
|
135 |
|
136 | deleteChatPhoto(this: Context, ...args: Shorthand<'deleteChatPhoto'>): Promise<true>;
|
137 | |
138 |
|
139 |
|
140 | setChatTitle(this: Context, ...args: Shorthand<'setChatTitle'>): Promise<true>;
|
141 | |
142 |
|
143 |
|
144 | setChatDescription(this: Context, ...args: Shorthand<'setChatDescription'>): Promise<true>;
|
145 | |
146 |
|
147 |
|
148 | pinChatMessage(this: Context, ...args: Shorthand<'pinChatMessage'>): Promise<true>;
|
149 | |
150 |
|
151 |
|
152 | unpinChatMessage(this: Context, ...args: Shorthand<'unpinChatMessage'>): Promise<true>;
|
153 | |
154 |
|
155 |
|
156 | unpinAllChatMessages(this: Context, ...args: Shorthand<'unpinAllChatMessages'>): Promise<true>;
|
157 | |
158 |
|
159 |
|
160 | leaveChat(this: Context, ...args: Shorthand<'leaveChat'>): Promise<true>;
|
161 | |
162 |
|
163 |
|
164 | setChatPermissions(this: Context, ...args: Shorthand<'setChatPermissions'>): Promise<true>;
|
165 | |
166 |
|
167 |
|
168 | getChatAdministrators(this: Context, ...args: Shorthand<'getChatAdministrators'>): Promise<tg.ChatMember[]>;
|
169 | |
170 |
|
171 |
|
172 | getChatMember(this: Context, ...args: Shorthand<'getChatMember'>): Promise<tg.ChatMember>;
|
173 | |
174 |
|
175 |
|
176 | getChatMembersCount(this: Context, ...args: Shorthand<'getChatMembersCount'>): Promise<number>;
|
177 | |
178 |
|
179 |
|
180 | setPassportDataErrors(this: Context, errors: readonly tg.PassportElementError[]): Promise<true>;
|
181 | |
182 |
|
183 |
|
184 | replyWithPhoto(this: Context, ...args: Shorthand<'sendPhoto'>): Promise<tg.Message.PhotoMessage>;
|
185 | |
186 |
|
187 |
|
188 | replyWithMediaGroup(this: Context, ...args: Shorthand<'sendMediaGroup'>): Promise<(tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage)[]>;
|
189 | |
190 |
|
191 |
|
192 | replyWithAudio(this: Context, ...args: Shorthand<'sendAudio'>): Promise<tg.Message.AudioMessage>;
|
193 | |
194 |
|
195 |
|
196 | replyWithDice(this: Context, ...args: Shorthand<'sendDice'>): Promise<tg.Message.DiceMessage>;
|
197 | |
198 |
|
199 |
|
200 | replyWithDocument(this: Context, ...args: Shorthand<'sendDocument'>): Promise<tg.Message.DocumentMessage>;
|
201 | |
202 |
|
203 |
|
204 | replyWithSticker(this: Context, ...args: Shorthand<'sendSticker'>): Promise<tg.Message.StickerMessage>;
|
205 | |
206 |
|
207 |
|
208 | replyWithVideo(this: Context, ...args: Shorthand<'sendVideo'>): Promise<tg.Message.VideoMessage>;
|
209 | |
210 |
|
211 |
|
212 | replyWithAnimation(this: Context, ...args: Shorthand<'sendAnimation'>): Promise<tg.Message.AnimationMessage>;
|
213 | |
214 |
|
215 |
|
216 | replyWithVideoNote(this: Context, ...args: Shorthand<'sendVideoNote'>): Promise<tg.Message.VideoNoteMessage>;
|
217 | |
218 |
|
219 |
|
220 | replyWithInvoice(this: Context, ...args: Shorthand<'sendInvoice'>): Promise<tg.Message.InvoiceMessage>;
|
221 | |
222 |
|
223 |
|
224 | replyWithGame(this: Context, ...args: Shorthand<'sendGame'>): Promise<tg.Message.GameMessage>;
|
225 | |
226 |
|
227 |
|
228 | replyWithVoice(this: Context, ...args: Shorthand<'sendVoice'>): Promise<tg.Message.VoiceMessage>;
|
229 | |
230 |
|
231 |
|
232 | replyWithPoll(this: Context, ...args: Shorthand<'sendPoll'>): Promise<tg.Message.PollMessage>;
|
233 | |
234 |
|
235 |
|
236 | replyWithQuiz(this: Context, ...args: Shorthand<'sendQuiz'>): Promise<tg.Message.PollMessage>;
|
237 | |
238 |
|
239 |
|
240 | stopPoll(this: Context, ...args: Shorthand<'stopPoll'>): Promise<tg.Poll>;
|
241 | |
242 |
|
243 |
|
244 | replyWithChatAction(this: Context, ...args: Shorthand<'sendChatAction'>): Promise<true>;
|
245 | |
246 |
|
247 |
|
248 | replyWithLocation(this: Context, ...args: Shorthand<'sendLocation'>): Promise<tg.Message.LocationMessage>;
|
249 | |
250 |
|
251 |
|
252 | replyWithVenue(this: Context, ...args: Shorthand<'sendVenue'>): Promise<tg.Message.VenueMessage>;
|
253 | |
254 |
|
255 |
|
256 | replyWithContact(this: Context, ...args: Shorthand<'sendContact'>): Promise<tg.Message.ContactMessage>;
|
257 | |
258 |
|
259 |
|
260 |
|
261 | getStickerSet(this: Context, setName: string): Promise<tg.StickerSet>;
|
262 | |
263 |
|
264 |
|
265 | setChatStickerSet(this: Context, setName: string): Promise<true>;
|
266 | |
267 |
|
268 |
|
269 | deleteChatStickerSet(this: Context): Promise<true>;
|
270 | |
271 |
|
272 |
|
273 |
|
274 | setStickerPositionInSet(this: Context, sticker: string, position: number): Promise<true>;
|
275 | |
276 |
|
277 |
|
278 |
|
279 | setStickerSetThumb(this: Context, ...args: Parameters<Telegram['setStickerSetThumb']>): Promise<true>;
|
280 | |
281 |
|
282 |
|
283 |
|
284 | deleteStickerFromSet(this: Context, sticker: string): Promise<true>;
|
285 | |
286 |
|
287 |
|
288 | uploadStickerFile(this: Context, ...args: Shorthand<'uploadStickerFile'>): Promise<tg.File>;
|
289 | |
290 |
|
291 |
|
292 | createNewStickerSet(this: Context, ...args: Shorthand<'createNewStickerSet'>): Promise<true>;
|
293 | |
294 |
|
295 |
|
296 | addStickerToSet(this: Context, ...args: Shorthand<'addStickerToSet'>): Promise<true>;
|
297 | |
298 |
|
299 |
|
300 |
|
301 | getMyCommands(this: Context): Promise<tg.BotCommand[]>;
|
302 | |
303 |
|
304 |
|
305 |
|
306 | setMyCommands(this: Context, commands: readonly tg.BotCommand[]): Promise<true>;
|
307 | |
308 |
|
309 |
|
310 | replyWithMarkdown(this: Context, markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
|
311 | |
312 |
|
313 |
|
314 | replyWithMarkdownV2(this: Context, markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
|
315 | |
316 |
|
317 |
|
318 | replyWithHTML(this: Context, html: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
|
319 | |
320 |
|
321 |
|
322 | deleteMessage(this: Context, messageId?: number): Promise<true>;
|
323 | |
324 |
|
325 |
|
326 | forwardMessage(this: Context, chatId: string | number, extra?: {
|
327 | disable_notification?: boolean;
|
328 | }): Promise<tg.Message>;
|
329 | |
330 |
|
331 |
|
332 | copyMessage(this: Context, chatId: string | number, extra?: tt.ExtraCopyMessage): Promise<tg.MessageId>;
|
333 | }
|
334 | export default Context;
|
335 | declare type UpdateTypes<U extends Deunionize<tg.Update>> = Extract<UnionKeys<U>, tt.UpdateType>;
|
336 | export declare type GetUpdateContent<U extends tg.Update> = U extends tg.Update.CallbackQueryUpdate ? U['callback_query']['message'] : U[UpdateTypes<U>];
|
337 | declare type Getter<U extends Deunionize<tg.Update>, P extends string> = PropOr<GetUpdateContent<U>, P>;
|
338 |
|
\ | No newline at end of file |