UNPKG

32.1 kBTypeScriptView Raw
1import * as tg from './core/types/typegram';
2import * as tt from './telegram-types';
3import { Deunionize, PropOr, UnionKeys } from './core/helpers/deunionize';
4import ApiClient from './core/network/client';
5import { Guard, Guarded, Keyed, MaybeArray } from './core/helpers/util';
6import Telegram from './telegram';
7import { FmtString } from './format';
8import { Digit, MessageReactions } from './reactions';
9type Tail<T> = T extends [unknown, ...infer U] ? U : never;
10type Shorthand<FName extends Exclude<keyof Telegram, keyof ApiClient>> = Tail<Parameters<Telegram[FName]>>;
11/**
12 * Narrows down `C['update']` (and derived getters)
13 * to specific update type `U`.
14 *
15 * Used by [[`Composer`]],
16 * possibly useful for splitting a bot into multiple files.
17 */
18export type NarrowedContext<C extends Context, U extends tg.Update> = Context<U> & Omit<C, keyof Context>;
19export type FilteredContext<Ctx extends Context, Filter extends tt.UpdateType | Guard<Ctx['update']>> = Filter extends tt.UpdateType ? NarrowedContext<Ctx, Extract<tg.Update, Record<Filter, object>>> : NarrowedContext<Ctx, Guarded<Filter>>;
20export declare class Context<U extends Deunionize<tg.Update> = tg.Update> {
21 readonly update: U;
22 readonly telegram: Telegram;
23 readonly botInfo: tg.UserFromGetMe;
24 readonly state: Record<string | symbol, any>;
25 constructor(update: U, telegram: Telegram, botInfo: tg.UserFromGetMe);
26 get updateType(): Extract<UnionKeys<U>, tt.UpdateType>;
27 get me(): string;
28 /**
29 * @deprecated Use ctx.telegram instead
30 */
31 get tg(): Telegram;
32 get message(): PropOr<U, "message">;
33 get editedMessage(): PropOr<U, "edited_message">;
34 get inlineQuery(): PropOr<U, "inline_query">;
35 get shippingQuery(): PropOr<U, "shipping_query">;
36 get preCheckoutQuery(): PropOr<U, "pre_checkout_query">;
37 get chosenInlineResult(): PropOr<U, "chosen_inline_result">;
38 get channelPost(): PropOr<U, "channel_post">;
39 get editedChannelPost(): PropOr<U, "edited_channel_post">;
40 get messageReaction(): PropOr<U, "message_reaction">;
41 get messageReactionCount(): PropOr<U, "message_reaction_count">;
42 get callbackQuery(): PropOr<U, "callback_query">;
43 get poll(): PropOr<U, "poll">;
44 get pollAnswer(): PropOr<U, "poll_answer">;
45 get myChatMember(): PropOr<U, "my_chat_member">;
46 get chatMember(): PropOr<U, "chat_member">;
47 get chatJoinRequest(): PropOr<U, "chat_join_request">;
48 get chatBoost(): PropOr<U, "chat_boost">;
49 get removedChatBoost(): PropOr<U, "removed_chat_boost">;
50 /** Shorthand for any `message` object present in the current update. One of
51 * `message`, `edited_message`, `channel_post`, `edited_channel_post` or
52 * `callback_query.message`
53 */
54 get msg(): GetMsg<U> & Msg;
55 /** Shorthand for any message_id present in the current update. */
56 get msgId(): GetMsgId<U>;
57 get chat(): Getter<U, 'chat'>;
58 get senderChat(): PropOr<GetUpdateContent<U>, "sender_chat", undefined>;
59 get from(): GetUserFromAnySource<U>;
60 get inlineMessageId(): string | undefined;
61 get passportData(): tg.PassportData | undefined;
62 get webAppData(): {
63 data: {
64 json<T>(): T;
65 text(): string;
66 };
67 button_text: string;
68 } | undefined;
69 /**
70 * @deprecated use {@link Telegram.webhookReply}
71 */
72 get webhookReply(): boolean;
73 set webhookReply(enable: boolean);
74 get reactions(): MessageReactions;
75 has<Filter extends tt.UpdateType | Guard<Context['update']>>(filters: MaybeArray<Filter>): this is FilteredContext<Context, Filter>;
76 get text(): GetText<U>;
77 entities<EntityTypes extends tg.MessageEntity['type'][]>(...types: EntityTypes): (tg.MessageEntity & {
78 type: EntityTypes extends [] ? "mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "blockquote" | "italic" | "underline" | "strikethrough" | "spoiler" | "code" | "custom_emoji" | "pre" | "text_link" | "text_mention" : EntityTypes[number];
79 fragment: string;
80 })[];
81 /**
82 * @see https://core.telegram.org/bots/api#answerinlinequery
83 */
84 answerInlineQuery(...args: Shorthand<'answerInlineQuery'>): Promise<true>;
85 /**
86 * @see https://core.telegram.org/bots/api#answercallbackquery
87 */
88 answerCbQuery(...args: Shorthand<'answerCbQuery'>): Promise<true>;
89 /**
90 * @see https://core.telegram.org/bots/api#answercallbackquery
91 */
92 answerGameQuery(...args: Shorthand<'answerGameQuery'>): Promise<true>;
93 /**
94 * Shorthand for {@link Telegram.getUserChatBoosts}
95 */
96 getUserChatBoosts(): Promise<tg.UserChatBoosts[]>;
97 /**
98 * @see https://core.telegram.org/bots/api#answershippingquery
99 */
100 answerShippingQuery(...args: Shorthand<'answerShippingQuery'>): Promise<true>;
101 /**
102 * @see https://core.telegram.org/bots/api#answerprecheckoutquery
103 */
104 answerPreCheckoutQuery(...args: Shorthand<'answerPreCheckoutQuery'>): Promise<true>;
105 /**
106 * @see https://core.telegram.org/bots/api#editmessagetext
107 */
108 editMessageText(text: string | FmtString, extra?: tt.ExtraEditMessageText): Promise<true | (tg.Update.Edited & tg.Message.TextMessage)>;
109 /**
110 * @see https://core.telegram.org/bots/api#editmessagecaption
111 */
112 editMessageCaption(caption: string | FmtString | undefined, extra?: tt.ExtraEditMessageCaption): Promise<true | (tg.Update.Edited & tg.Message.CaptionableMessage)>;
113 /**
114 * @see https://core.telegram.org/bots/api#editmessagemedia
115 */
116 editMessageMedia(media: tt.WrapCaption<tg.InputMedia>, extra?: tt.ExtraEditMessageMedia): Promise<true | (tg.Update.Edited & tg.Message)>;
117 /**
118 * @see https://core.telegram.org/bots/api#editmessagereplymarkup
119 */
120 editMessageReplyMarkup(markup: tg.InlineKeyboardMarkup | undefined): Promise<true | (tg.Update.Edited & tg.Message)>;
121 /**
122 * @see https://core.telegram.org/bots/api#editmessagelivelocation
123 */
124 editMessageLiveLocation(latitude: number, longitude: number, extra?: tt.ExtraEditMessageLiveLocation): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
125 /**
126 * @see https://core.telegram.org/bots/api#stopmessagelivelocation
127 */
128 stopMessageLiveLocation(markup?: tg.InlineKeyboardMarkup): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
129 /**
130 * @see https://core.telegram.org/bots/api#sendmessage
131 */
132 sendMessage(text: string | FmtString, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
133 /**
134 * @see https://core.telegram.org/bots/api#sendmessage
135 */
136 reply(...args: Shorthand<'sendMessage'>): Promise<tg.Message.TextMessage>;
137 /**
138 * @see https://core.telegram.org/bots/api#getchat
139 */
140 getChat(...args: Shorthand<'getChat'>): Promise<tg.ChatFromGetChat>;
141 /**
142 * @see https://core.telegram.org/bots/api#exportchatinvitelink
143 */
144 exportChatInviteLink(...args: Shorthand<'exportChatInviteLink'>): Promise<string>;
145 /**
146 * @see https://core.telegram.org/bots/api#createchatinvitelink
147 */
148 createChatInviteLink(...args: Shorthand<'createChatInviteLink'>): Promise<tg.ChatInviteLink>;
149 /**
150 * @see https://core.telegram.org/bots/api#editchatinvitelink
151 */
152 editChatInviteLink(...args: Shorthand<'editChatInviteLink'>): Promise<tg.ChatInviteLink>;
153 /**
154 * @see https://core.telegram.org/bots/api#revokechatinvitelink
155 */
156 revokeChatInviteLink(...args: Shorthand<'revokeChatInviteLink'>): Promise<tg.ChatInviteLink>;
157 /**
158 * @see https://core.telegram.org/bots/api#banchatmember
159 */
160 banChatMember(...args: Shorthand<'banChatMember'>): Promise<true>;
161 /**
162 * @see https://core.telegram.org/bots/api#banchatmember
163 * @deprecated since API 5.3. Use {@link Context.banChatMember}
164 */
165 get kickChatMember(): (userId: number, untilDate?: number | undefined, extra?: Omit<{
166 chat_id: string | number;
167 user_id: number;
168 until_date?: number | undefined;
169 revoke_messages?: boolean | undefined;
170 }, "chat_id" | "user_id" | "until_date"> | undefined) => Promise<true>;
171 /**
172 * @see https://core.telegram.org/bots/api#unbanchatmember
173 */
174 unbanChatMember(...args: Shorthand<'unbanChatMember'>): Promise<true>;
175 /**
176 * @see https://core.telegram.org/bots/api#restrictchatmember
177 */
178 restrictChatMember(...args: Shorthand<'restrictChatMember'>): Promise<true>;
179 /**
180 * @see https://core.telegram.org/bots/api#promotechatmember
181 */
182 promoteChatMember(...args: Shorthand<'promoteChatMember'>): Promise<true>;
183 /**
184 * @see https://core.telegram.org/bots/api#setchatadministratorcustomtitle
185 */
186 setChatAdministratorCustomTitle(...args: Shorthand<'setChatAdministratorCustomTitle'>): Promise<true>;
187 /**
188 * @see https://core.telegram.org/bots/api#setchatphoto
189 */
190 setChatPhoto(...args: Shorthand<'setChatPhoto'>): Promise<true>;
191 /**
192 * @see https://core.telegram.org/bots/api#deletechatphoto
193 */
194 deleteChatPhoto(...args: Shorthand<'deleteChatPhoto'>): Promise<true>;
195 /**
196 * @see https://core.telegram.org/bots/api#setchattitle
197 */
198 setChatTitle(...args: Shorthand<'setChatTitle'>): Promise<true>;
199 /**
200 * @see https://core.telegram.org/bots/api#setchatdescription
201 */
202 setChatDescription(...args: Shorthand<'setChatDescription'>): Promise<true>;
203 /**
204 * @see https://core.telegram.org/bots/api#pinchatmessage
205 */
206 pinChatMessage(...args: Shorthand<'pinChatMessage'>): Promise<true>;
207 /**
208 * @see https://core.telegram.org/bots/api#unpinchatmessage
209 */
210 unpinChatMessage(...args: Shorthand<'unpinChatMessage'>): Promise<true>;
211 /**
212 * @see https://core.telegram.org/bots/api#unpinallchatmessages
213 */
214 unpinAllChatMessages(...args: Shorthand<'unpinAllChatMessages'>): Promise<true>;
215 /**
216 * @see https://core.telegram.org/bots/api#leavechat
217 */
218 leaveChat(...args: Shorthand<'leaveChat'>): Promise<true>;
219 /**
220 * @see https://core.telegram.org/bots/api#setchatpermissions
221 */
222 setChatPermissions(...args: Shorthand<'setChatPermissions'>): Promise<true>;
223 /**
224 * @see https://core.telegram.org/bots/api#getchatadministrators
225 */
226 getChatAdministrators(...args: Shorthand<'getChatAdministrators'>): Promise<(tg.ChatMemberOwner | tg.ChatMemberAdministrator)[]>;
227 /**
228 * @see https://core.telegram.org/bots/api#getchatmember
229 */
230 getChatMember(...args: Shorthand<'getChatMember'>): Promise<tg.ChatMember>;
231 /**
232 * @see https://core.telegram.org/bots/api#getchatmembercount
233 */
234 getChatMembersCount(...args: Shorthand<'getChatMembersCount'>): Promise<number>;
235 /**
236 * @see https://core.telegram.org/bots/api#setpassportdataerrors
237 */
238 setPassportDataErrors(errors: readonly tg.PassportElementError[]): Promise<true>;
239 /**
240 * @see https://core.telegram.org/bots/api#sendphoto
241 */
242 sendPhoto(photo: string | tg.InputFile, extra?: tt.ExtraPhoto): Promise<tg.Message.PhotoMessage>;
243 /**
244 * @see https://core.telegram.org/bots/api#sendphoto
245 */
246 replyWithPhoto(...args: Shorthand<'sendPhoto'>): Promise<tg.Message.PhotoMessage>;
247 /**
248 * @see https://core.telegram.org/bots/api#sendmediagroup
249 */
250 sendMediaGroup(media: tt.MediaGroup, extra?: tt.ExtraMediaGroup): Promise<(tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage)[]>;
251 /**
252 * @see https://core.telegram.org/bots/api#sendmediagroup
253 */
254 replyWithMediaGroup(...args: Shorthand<'sendMediaGroup'>): Promise<(tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage)[]>;
255 /**
256 * @see https://core.telegram.org/bots/api#sendaudio
257 */
258 sendAudio(audio: string | tg.InputFile, extra?: tt.ExtraAudio): Promise<tg.Message.AudioMessage>;
259 /**
260 * @see https://core.telegram.org/bots/api#sendaudio
261 */
262 replyWithAudio(...args: Shorthand<'sendAudio'>): Promise<tg.Message.AudioMessage>;
263 /**
264 * @see https://core.telegram.org/bots/api#senddice
265 */
266 sendDice(extra?: tt.ExtraDice): Promise<tg.Message.DiceMessage>;
267 /**
268 * @see https://core.telegram.org/bots/api#senddice
269 */
270 replyWithDice(...args: Shorthand<'sendDice'>): Promise<tg.Message.DiceMessage>;
271 /**
272 * @see https://core.telegram.org/bots/api#senddocument
273 */
274 sendDocument(document: string | tg.InputFile, extra?: tt.ExtraDocument): Promise<tg.Message.DocumentMessage>;
275 /**
276 * @see https://core.telegram.org/bots/api#senddocument
277 */
278 replyWithDocument(...args: Shorthand<'sendDocument'>): Promise<tg.Message.DocumentMessage>;
279 /**
280 * @see https://core.telegram.org/bots/api#sendsticker
281 */
282 sendSticker(sticker: string | tg.InputFile, extra?: tt.ExtraSticker): Promise<tg.Message.StickerMessage>;
283 /**
284 * @see https://core.telegram.org/bots/api#sendsticker
285 */
286 replyWithSticker(...args: Shorthand<'sendSticker'>): Promise<tg.Message.StickerMessage>;
287 /**
288 * @see https://core.telegram.org/bots/api#sendvideo
289 */
290 sendVideo(video: string | tg.InputFile, extra?: tt.ExtraVideo): Promise<tg.Message.VideoMessage>;
291 /**
292 * @see https://core.telegram.org/bots/api#sendvideo
293 */
294 replyWithVideo(...args: Shorthand<'sendVideo'>): Promise<tg.Message.VideoMessage>;
295 /**
296 * @see https://core.telegram.org/bots/api#sendanimation
297 */
298 sendAnimation(animation: string | tg.InputFile, extra?: tt.ExtraAnimation): Promise<tg.Message.AnimationMessage>;
299 /**
300 * @see https://core.telegram.org/bots/api#sendanimation
301 */
302 replyWithAnimation(...args: Shorthand<'sendAnimation'>): Promise<tg.Message.AnimationMessage>;
303 /**
304 * @see https://core.telegram.org/bots/api#sendvideonote
305 */
306 sendVideoNote(videoNote: string | tg.InputFileVideoNote, extra?: tt.ExtraVideoNote): Promise<tg.Message.VideoNoteMessage>;
307 /**
308 * @see https://core.telegram.org/bots/api#sendvideonote
309 */
310 replyWithVideoNote(...args: Shorthand<'sendVideoNote'>): Promise<tg.Message.VideoNoteMessage>;
311 /**
312 * @see https://core.telegram.org/bots/api#sendinvoice
313 */
314 sendInvoice(invoice: tt.NewInvoiceParameters, extra?: tt.ExtraInvoice): Promise<tg.Message.InvoiceMessage>;
315 /**
316 * @see https://core.telegram.org/bots/api#sendinvoice
317 */
318 replyWithInvoice(...args: Shorthand<'sendInvoice'>): Promise<tg.Message.InvoiceMessage>;
319 /**
320 * @see https://core.telegram.org/bots/api#sendgame
321 */
322 sendGame(game: string, extra?: tt.ExtraGame): Promise<tg.Message.GameMessage>;
323 /**
324 * @see https://core.telegram.org/bots/api#sendgame
325 */
326 replyWithGame(...args: Shorthand<'sendGame'>): Promise<tg.Message.GameMessage>;
327 /**
328 * @see https://core.telegram.org/bots/api#sendvoice
329 */
330 sendVoice(voice: string | tg.InputFile, extra?: tt.ExtraVoice): Promise<tg.Message.VoiceMessage>;
331 /**
332 * @see https://core.telegram.org/bots/api#sendvoice
333 */
334 replyWithVoice(...args: Shorthand<'sendVoice'>): Promise<tg.Message.VoiceMessage>;
335 /**
336 * @see https://core.telegram.org/bots/api#sendpoll
337 */
338 sendPoll(poll: string, options: readonly string[], extra?: tt.ExtraPoll): Promise<tg.Message.PollMessage>;
339 /**
340 * @see https://core.telegram.org/bots/api#sendpoll
341 */
342 replyWithPoll(...args: Shorthand<'sendPoll'>): Promise<tg.Message.PollMessage>;
343 /**
344 * @see https://core.telegram.org/bots/api#sendpoll
345 */
346 sendQuiz(quiz: string, options: readonly string[], extra?: tt.ExtraPoll): Promise<tg.Message.PollMessage>;
347 /**
348 * @see https://core.telegram.org/bots/api#sendpoll
349 */
350 replyWithQuiz(...args: Shorthand<'sendQuiz'>): Promise<tg.Message.PollMessage>;
351 /**
352 * @see https://core.telegram.org/bots/api#stoppoll
353 */
354 stopPoll(...args: Shorthand<'stopPoll'>): Promise<tg.Poll>;
355 /**
356 * @see https://core.telegram.org/bots/api#sendchataction
357 */
358 sendChatAction(action: Shorthand<'sendChatAction'>[0], extra?: tt.ExtraSendChatAction): Promise<true>;
359 /**
360 * @see https://core.telegram.org/bots/api#sendchataction
361 *
362 * Sends the sendChatAction request repeatedly, with a delay between requests,
363 * as long as the provided callback function is being processed.
364 *
365 * The sendChatAction errors should be ignored, because the goal is the actual long process completing and performing an action.
366 *
367 * @param action - chat action type.
368 * @param callback - a function to run along with the chat action.
369 * @param extra - extra parameters for sendChatAction.
370 * @param {number} [extra.intervalDuration=8000] - The duration (in milliseconds) between subsequent sendChatAction requests.
371 */
372 persistentChatAction(action: Shorthand<'sendChatAction'>[0], callback: () => Promise<void>, { intervalDuration, ...extra }?: tt.ExtraSendChatAction & {
373 intervalDuration?: number;
374 }): Promise<void>;
375 /**
376 * @deprecated use {@link Context.sendChatAction} instead
377 * @see https://core.telegram.org/bots/api#sendchataction
378 */
379 replyWithChatAction(...args: Shorthand<'sendChatAction'>): Promise<true>;
380 /**
381 * Shorthand for {@link Telegram.setMessageReaction}
382 * @param reaction An emoji or custom_emoji_id to set as reaction to current message. Leave empty to remove reactions.
383 * @param is_big Pass True to set the reaction with a big animation
384 */
385 react(reaction?: MaybeArray<tg.TelegramEmoji | `${Digit}${string}` | tg.ReactionType>, is_big?: boolean): Promise<true>;
386 /**
387 * @see https://core.telegram.org/bots/api#sendlocation
388 */
389 sendLocation(latitude: number, longitude: number, extra?: tt.ExtraLocation): Promise<tg.Message.LocationMessage>;
390 /**
391 * @see https://core.telegram.org/bots/api#sendlocation
392 */
393 replyWithLocation(...args: Shorthand<'sendLocation'>): Promise<tg.Message.LocationMessage>;
394 /**
395 * @see https://core.telegram.org/bots/api#sendvenue
396 */
397 sendVenue(latitude: number, longitude: number, title: string, address: string, extra?: tt.ExtraVenue): Promise<tg.Message.VenueMessage>;
398 /**
399 * @see https://core.telegram.org/bots/api#sendvenue
400 */
401 replyWithVenue(...args: Shorthand<'sendVenue'>): Promise<tg.Message.VenueMessage>;
402 /**
403 * @see https://core.telegram.org/bots/api#sendcontact
404 */
405 sendContact(phoneNumber: string, firstName: string, extra?: tt.ExtraContact): Promise<tg.Message.ContactMessage>;
406 /**
407 * @see https://core.telegram.org/bots/api#sendcontact
408 */
409 replyWithContact(...args: Shorthand<'sendContact'>): Promise<tg.Message.ContactMessage>;
410 /**
411 * @deprecated use {@link Telegram.getStickerSet}
412 * @see https://core.telegram.org/bots/api#getstickerset
413 */
414 getStickerSet(setName: string): Promise<tg.StickerSet>;
415 /**
416 * @see https://core.telegram.org/bots/api#setchatstickerset
417 */
418 setChatStickerSet(setName: string): Promise<true>;
419 /**
420 * @see https://core.telegram.org/bots/api#deletechatstickerset
421 */
422 deleteChatStickerSet(): Promise<true>;
423 /**
424 * Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this
425 * to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a
426 * ForumTopic object.
427 *
428 * @see https://core.telegram.org/bots/api#createforumtopic
429 */
430 createForumTopic(...args: Shorthand<'createForumTopic'>): Promise<tg.ForumTopic>;
431 /**
432 * Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in
433 * the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the
434 * topic. Returns True on success.
435 *
436 * @see https://core.telegram.org/bots/api#editforumtopic
437 */
438 editForumTopic(extra: tt.ExtraEditForumTopic): Promise<true>;
439 /**
440 * Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat
441 * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
442 * Returns True on success.
443 *
444 * @see https://core.telegram.org/bots/api#closeforumtopic
445 */
446 closeForumTopic(): Promise<true>;
447 /**
448 * Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat
449 * for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
450 * Returns True on success.
451 *
452 * @see https://core.telegram.org/bots/api#reopenforumtopic
453 */
454 reopenForumTopic(): Promise<true>;
455 /**
456 * Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an
457 * administrator in the chat for this to work and must have the can_delete_messages administrator rights.
458 * Returns True on success.
459 *
460 * @see https://core.telegram.org/bots/api#deleteforumtopic
461 */
462 deleteForumTopic(): Promise<true>;
463 /**
464 * Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat
465 * for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
466 *
467 * @see https://core.telegram.org/bots/api#unpinallforumtopicmessages
468 */
469 unpinAllForumTopicMessages(): Promise<true>;
470 /**
471 * Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator
472 * in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
473 *
474 * @see https://core.telegram.org/bots/api#editgeneralforumtopic
475 */
476 editGeneralForumTopic(name: string): Promise<true>;
477 /**
478 * Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the
479 * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
480 *
481 * @see https://core.telegram.org/bots/api#closegeneralforumtopic
482 */
483 closeGeneralForumTopic(): Promise<true>;
484 /**
485 * Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in
486 * the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically
487 * unhidden if it was hidden. Returns True on success.
488 *
489 * @see https://core.telegram.org/bots/api#reopengeneralforumtopic
490 */
491 reopenGeneralForumTopic(): Promise<true>;
492 /**
493 * Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat
494 * for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed
495 * if it was open. Returns True on success.
496 *
497 * @see https://core.telegram.org/bots/api#hidegeneralforumtopic
498 */
499 hideGeneralForumTopic(): Promise<true>;
500 /**
501 * Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the
502 * chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
503 *
504 * @see https://core.telegram.org/bots/api#unhidegeneralforumtopic
505 */
506 unhideGeneralForumTopic(): Promise<true>;
507 /**
508 * Use this method to clear the list of pinned messages in a General forum topic.
509 * The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator
510 * right in the supergroup.
511 *
512 * @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
513 *
514 * @see https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages
515 */
516 unpinAllGeneralForumTopicMessages(): Promise<true>;
517 /**
518 * @deprecated use {@link Telegram.setStickerPositionInSet}
519 * @see https://core.telegram.org/bots/api#setstickerpositioninset
520 */
521 setStickerPositionInSet(sticker: string, position: number): Promise<true>;
522 /**
523 * @deprecated use {@link Telegram.setStickerSetThumbnail}
524 * @see https://core.telegram.org/bots/api#setstickersetthumbnail
525 */
526 setStickerSetThumb(...args: Parameters<Telegram['setStickerSetThumbnail']>): Promise<true>;
527 setStickerSetThumbnail(...args: Parameters<Telegram['setStickerSetThumbnail']>): Promise<true>;
528 setStickerMaskPosition(...args: Parameters<Telegram['setStickerMaskPosition']>): Promise<true>;
529 setStickerKeywords(...args: Parameters<Telegram['setStickerKeywords']>): Promise<true>;
530 setStickerEmojiList(...args: Parameters<Telegram['setStickerEmojiList']>): Promise<true>;
531 deleteStickerSet(...args: Parameters<Telegram['deleteStickerSet']>): Promise<true>;
532 setStickerSetTitle(...args: Parameters<Telegram['setStickerSetTitle']>): Promise<true>;
533 setCustomEmojiStickerSetThumbnail(...args: Parameters<Telegram['setCustomEmojiStickerSetThumbnail']>): Promise<true>;
534 /**
535 * @deprecated use {@link Telegram.deleteStickerFromSet}
536 * @see https://core.telegram.org/bots/api#deletestickerfromset
537 */
538 deleteStickerFromSet(sticker: string): Promise<true>;
539 /**
540 * @see https://core.telegram.org/bots/api#uploadstickerfile
541 */
542 uploadStickerFile(...args: Shorthand<'uploadStickerFile'>): Promise<tg.File>;
543 /**
544 * @see https://core.telegram.org/bots/api#createnewstickerset
545 */
546 createNewStickerSet(...args: Shorthand<'createNewStickerSet'>): Promise<true>;
547 /**
548 * @see https://core.telegram.org/bots/api#addstickertoset
549 */
550 addStickerToSet(...args: Shorthand<'addStickerToSet'>): Promise<true>;
551 /**
552 * @deprecated use {@link Telegram.getMyCommands}
553 * @see https://core.telegram.org/bots/api#getmycommands
554 */
555 getMyCommands(): Promise<tg.BotCommand[]>;
556 /**
557 * @deprecated use {@link Telegram.setMyCommands}
558 * @see https://core.telegram.org/bots/api#setmycommands
559 */
560 setMyCommands(commands: readonly tg.BotCommand[]): Promise<true>;
561 /**
562 * @deprecated use {@link Context.replyWithMarkdownV2}
563 * @see https://core.telegram.org/bots/api#sendmessage
564 */
565 replyWithMarkdown(markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
566 /**
567 * @see https://core.telegram.org/bots/api#sendmessage
568 */
569 replyWithMarkdownV2(markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
570 /**
571 * @see https://core.telegram.org/bots/api#sendmessage
572 */
573 replyWithHTML(html: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
574 /**
575 * @see https://core.telegram.org/bots/api#deletemessage
576 */
577 deleteMessage(messageId?: number): Promise<true>;
578 /**
579 * Context-aware shorthand for {@link Telegram.deleteMessages}
580 * @param messageIds Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
581 */
582 deleteMessages(messageIds: number[]): Promise<true>;
583 /**
584 * @see https://core.telegram.org/bots/api#forwardmessage
585 */
586 forwardMessage(chatId: string | number, extra?: Shorthand<'forwardMessage'>[2]): Promise<tg.Message>;
587 /**
588 * Shorthand for {@link Telegram.forwardMessages}
589 * @see https://core.telegram.org/bots/api#forwardmessages
590 */
591 forwardMessages(chatId: string | number, messageIds: number[], extra?: Shorthand<'forwardMessages'>[2]): Promise<tg.MessageId[]>;
592 /**
593 * @see https://core.telegram.org/bots/api#copymessage
594 */
595 copyMessage(chatId: string | number, extra?: tt.ExtraCopyMessage): Promise<tg.MessageId>;
596 /**
597 * Context-aware shorthand for {@link Telegram.copyMessages}
598 * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
599 * @param messageIds Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
600 */
601 copyMessages(chatId: number | string, messageIds: number[], extra?: tt.ExtraCopyMessages): Promise<tg.MessageId[]>;
602 /**
603 * @see https://core.telegram.org/bots/api#approvechatjoinrequest
604 */
605 approveChatJoinRequest(userId: number): Promise<true>;
606 /**
607 * @see https://core.telegram.org/bots/api#declinechatjoinrequest
608 */
609 declineChatJoinRequest(userId: number): Promise<true>;
610 /**
611 * @see https://core.telegram.org/bots/api#banchatsenderchat
612 */
613 banChatSenderChat(senderChatId: number): Promise<true>;
614 /**
615 * @see https://core.telegram.org/bots/api#unbanchatsenderchat
616 */
617 unbanChatSenderChat(senderChatId: number): Promise<true>;
618 /**
619 * Use this method to change the bot's menu button in the current private chat. Returns true on success.
620 * @see https://core.telegram.org/bots/api#setchatmenubutton
621 */
622 setChatMenuButton(menuButton?: tg.MenuButton): Promise<true>;
623 /**
624 * Use this method to get the current value of the bot's menu button in the current private chat. Returns MenuButton on success.
625 * @see https://core.telegram.org/bots/api#getchatmenubutton
626 */
627 getChatMenuButton(): Promise<tg.MenuButton>;
628 /**
629 * @see https://core.telegram.org/bots/api#setmydefaultadministratorrights
630 */
631 setMyDefaultAdministratorRights(extra?: Parameters<Telegram['setMyDefaultAdministratorRights']>[0]): Promise<true>;
632 /**
633 * @see https://core.telegram.org/bots/api#getmydefaultadministratorrights
634 */
635 getMyDefaultAdministratorRights(extra?: Parameters<Telegram['getMyDefaultAdministratorRights']>[0]): Promise<tg.ChatAdministratorRights>;
636}
637export default Context;
638type UpdateTypes<U extends Deunionize<tg.Update>> = Extract<UnionKeys<U>, tt.UpdateType>;
639export type GetUpdateContent<U extends tg.Update> = U extends tg.Update.CallbackQueryUpdate ? U['callback_query']['message'] : U[UpdateTypes<U>];
640type Getter<U extends Deunionize<tg.Update>, P extends string> = PropOr<GetUpdateContent<U>, P>;
641interface Msg {
642 isAccessible(): this is MaybeMessage<tg.Message>;
643 has<Ks extends UnionKeys<tg.Message>[]>(...keys: Ks): this is MaybeMessage<Keyed<tg.Message, Ks[number]>>;
644}
645declare const Msg: Msg;
646export type MaybeMessage<M extends tg.MaybeInaccessibleMessage = tg.MaybeInaccessibleMessage> = M & Msg;
647type GetMsg<U extends tg.Update> = U extends tg.Update.MessageUpdate ? U['message'] : U extends tg.Update.ChannelPostUpdate ? U['channel_post'] : U extends tg.Update.EditedChannelPostUpdate ? U['edited_channel_post'] : U extends tg.Update.EditedMessageUpdate ? U['edited_message'] : U extends tg.Update.CallbackQueryUpdate ? U['callback_query']['message'] : undefined;
648type GetUserFromAnySource<U extends tg.Update> = GetMsg<U> extends {
649 from: tg.User;
650} ? tg.User : U extends tg.Update.CallbackQueryUpdate | tg.Update.InlineQueryUpdate | tg.Update.ShippingQueryUpdate | tg.Update.PreCheckoutQueryUpdate | tg.Update.ChosenInlineResultUpdate | tg.Update.ChatMemberUpdate | tg.Update.MyChatMemberUpdate | tg.Update.ChatJoinRequestUpdate | tg.Update.MessageReactionUpdate | tg.Update.PollAnswerUpdate | tg.Update.ChatBoostUpdate ? tg.User : undefined;
651type GetMsgId<U extends tg.Update> = GetMsg<U> extends {
652 message_id: number;
653} ? number : U extends tg.Update.MessageReactionUpdate ? number : U extends tg.Update.MessageReactionCountUpdate ? number : undefined;
654type GetText<U extends tg.Update> = GetMsg<U> extends tg.Message.TextMessage ? string : GetMsg<U> extends tg.Message ? string | undefined : U extends tg.Update.PollUpdate ? string | undefined : undefined;
655//# sourceMappingURL=context.d.ts.map
\No newline at end of file