Skip to content

Commit d3f203a

Browse files
committed
Update typings for context
1 parent 8e12888 commit d3f203a

1 file changed

Lines changed: 222 additions & 46 deletions

File tree

typings/context.d.ts

Lines changed: 222 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,39 @@ import * as tt from './telegram-types'
55
import { Telegram } from './telegram'
66

77
export declare class TelegrafContext {
8+
tg: Telegram
9+
update: tt.Update
810
updateType: tt.UpdateType
911
updateSubTypes: tt.MessageSubTypes[]
10-
update: tt.Update
11-
tg: Telegram
1212
botInfo?: tt.User
13-
telegram: Telegram
14-
callbackQuery?: tt.CallbackQuery
15-
channelPost?: tt.Message
16-
chat?: tt.Chat
17-
chosenInlineResult?: tt.ChosenInlineResult
18-
editedChannelPost?: tt.Message
19-
editedMessage?: tt.Message
20-
from?: tt.User
21-
inlineQuery?: tt.InlineQuery
2213
match?: RegExpExecArray | null
2314
me?: string
15+
telegram: Telegram
2416
message?: tt.Message
17+
editedMessage?: tt.Message
18+
inlineQuery?: tt.InlineQuery
19+
shippingQuery?: tt.ShippingQuery
20+
preCheckoutQuery?: tt.PreCheckoutQuery
21+
chosenInlineResult?: tt.ChosenInlineResult
22+
channelPost?: tt.Message
23+
editedChannelPost?: tt.Message
24+
callbackQuery?: tt.CallbackQuery
2525
poll?: tt.Poll
2626
pollAnswer?: tt.PollAnswer
27-
preCheckoutQuery?: tt.PreCheckoutQuery
28-
shippingQuery?: tt.ShippingQuery
27+
chat?: tt.Chat
28+
from?: tt.User
29+
inlineMessageId?: string
30+
passportData?: tt.PassportData
31+
state: object
32+
webhookReply: boolean
2933

3034
constructor(
3135
update: tt.Update,
3236
telegram: Telegram,
33-
options?: { username?: string }
37+
options?: {
38+
username?: string,
39+
channelMode?: boolean
40+
}
3441
)
3542

3643
/**
@@ -63,12 +70,6 @@ export declare class TelegrafContext {
6370
stickerData: tt.StickerData
6471
): Promise<boolean>
6572

66-
/**
67-
* Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
68-
* @returns True on success
69-
*/
70-
deleteChatPhoto(): Promise<boolean>
71-
7273
/**
7374
* Use this method to delete a sticker from a set created by the bot.
7475
* @param sticker File identifier of the sticker
@@ -109,7 +110,7 @@ export declare class TelegrafContext {
109110

110111
/**
111112
* Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
112-
* @param user_id Unique identifier of the target user
113+
* @param userId Unique identifier of the target user
113114
* @param extra Additional params for restrict chat member
114115
* @returns True on success
115116
*/
@@ -125,12 +126,41 @@ export declare class TelegrafContext {
125126
*/
126127
getStickerSet(setName: string): Promise<tt.StickerSet>
127128

129+
/**
130+
* Use this method to set a new group sticker set for a supergroup.
131+
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
132+
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method
133+
* @param setName Name of the sticker set to be set as the group sticker set
134+
* @returns True on success.
135+
*/
136+
setChatStickerSet(
137+
setName: string
138+
): Promise<boolean>
139+
140+
/**
141+
* Use this method to delete a group sticker set from a supergroup.
142+
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
143+
* Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method
144+
* @returns True on success.
145+
*/
146+
deleteChatStickerSet(): Promise<boolean>
147+
128148
/**
129149
* Use this method for your bot to leave a group, supergroup or channel
130150
* @returns True on success
131151
*/
132152
leaveChat(): Promise<boolean>
133153

154+
/**
155+
* Use this method to set default chat permissions for all members.
156+
* The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights.
157+
* @param permissions New default chat permissions
158+
* @returns True on success
159+
*/
160+
setChatPermissions(
161+
permissions: tt.ChatPermissions
162+
): Promise<boolean>
163+
134164
/**
135165
* Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
136166
* @param messageId Identifier of a message to pin
@@ -246,6 +276,36 @@ export declare class TelegrafContext {
246276
extra?: tt.ExtraLocation
247277
): Promise<tt.MessageLocation>
248278

279+
/**
280+
* Use this method to send information about a venue
281+
* @param latitude Latitude of location
282+
* @param longitude Longitude of location
283+
* @param title Name of the venue
284+
* @param address Address of the venue
285+
* @param extra Additional params for sendVenue
286+
* @returns a Message on success
287+
*/
288+
replyWithVenue(
289+
latitude: number,
290+
longitude: number,
291+
title: string,
292+
address: string,
293+
extra?: tt.ExtraVenue
294+
): Promise<tt.MessageVenue>
295+
296+
/**
297+
* Use this method to send phone contacts
298+
* @param phoneNumber Contact's phone number
299+
* @param firstName Contact's first name
300+
* @param extra Additional params for sendContact
301+
* @returns a Message on success
302+
*/
303+
replyWithContact(
304+
phoneNumber: string,
305+
firstName: string,
306+
extra?: tt.ExtraContact
307+
): Promise<tt.MessageContact>
308+
249309
/**
250310
* The Bot API supports basic formatting for messages
251311
* @param markdown You can use bold and italic text, as well as inline links and pre-formatted code in your bots' messages.
@@ -257,6 +317,17 @@ export declare class TelegrafContext {
257317
extra?: tt.ExtraSendMessage
258318
): Promise<tt.Message>
259319

320+
/**
321+
* The Bot API supports basic formatting for messages
322+
* @param markdown You can use bold and italic text, as well as inline links and pre-formatted code in your bots' messages.
323+
* @param extra Additional params to send message
324+
* @returns a Message on success
325+
*/
326+
replyWithMarkdownV2(
327+
markdown: string,
328+
extra?: tt.ExtraSendMessage
329+
): Promise<tt.Message>
330+
260331
/**
261332
* Use this method to send photos
262333
* @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data
@@ -336,6 +407,28 @@ export declare class TelegrafContext {
336407
extra?: tt.ExtraVideo
337408
): Promise<tt.MessageVideo>
338409

410+
/**
411+
* Use this method to send .gif animations
412+
* @param animation Animation to send. Pass a file_id as String to send a GIF that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a GIF from the Internet, or upload a new GIF using multipart/form-data
413+
* @param extra Additional params for sendAnimation
414+
* @returns a Message on success
415+
*/
416+
replyWithAnimation(
417+
animation: tt.InputFile,
418+
extra?: tt.ExtraAnimation
419+
): Promise<tt.MessageAnimation>
420+
421+
/**
422+
* Use this method to send .gif animations
423+
* @param videoNote video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported
424+
* @param extra Additional params for sendVideoNote
425+
* @returns a Message on success
426+
*/
427+
replyWithVideoNote(
428+
videoNote: tt.InputFileVideoNote,
429+
extra?: tt.ExtraAnimation
430+
): Promise<tt.MessageVideoNote>
431+
339432
/**
340433
* Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
341434
* @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data
@@ -370,6 +463,18 @@ export declare class TelegrafContext {
370463
// ------------------------------------------------------------------------------------------ //
371464
// ------------------------------------------------------------------------------------------ //
372465

466+
/**
467+
* Use this method to send answers to an inline query.
468+
* No more than 50 results per query are allowed.
469+
* @returns On success, True is returned.
470+
* @param results Array of results for the inline query
471+
* @param extra Extra optional parameters
472+
*/
473+
answerInlineQuery(
474+
results: tt.InlineQueryResult[],
475+
extra?: tt.ExtraAnswerInlineQuery
476+
): Promise<boolean>
477+
373478
answerCbQuery(
374479
text?: string,
375480
showAlert?: boolean,
@@ -401,18 +506,6 @@ export declare class TelegrafContext {
401506
*/
402507
answerPreCheckoutQuery(ok: boolean, errorMessage?: string): Promise<boolean>
403508

404-
/**
405-
* Use this method to send answers to an inline query.
406-
* No more than 50 results per query are allowed.
407-
* @returns On success, True is returned.
408-
* @param results Array of results for the inline query
409-
* @param extra Extra optional parameters
410-
*/
411-
answerInlineQuery(
412-
results: tt.InlineQueryResult[],
413-
extra?: tt.ExtraAnswerInlineQuery
414-
): Promise<boolean>
415-
416509
/**
417510
* Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
418511
* @returns On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
@@ -435,15 +528,6 @@ export declare class TelegrafContext {
435528
extra?: tt.ExtraEditCaption
436529
): Promise<tt.Message | boolean>
437530

438-
/**
439-
* Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
440-
* @returns On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
441-
* @param markup Markup of inline keyboard
442-
*/
443-
editMessageReplyMarkup(
444-
markup?: tt.InlineKeyboardMarkup
445-
): Promise<tt.Message | boolean>
446-
447531
/**
448532
* Use this method to edit animation, audio, document, photo, or video messages.
449533
* @returns On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
@@ -455,6 +539,15 @@ export declare class TelegrafContext {
455539
extra?: tt.ExtraEditMessageMedia
456540
): Promise<tt.Message | boolean>
457541

542+
/**
543+
* Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
544+
* @returns On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
545+
* @param markup Markup of inline keyboard
546+
*/
547+
editMessageReplyMarkup(
548+
markup?: tt.InlineKeyboardMarkup
549+
): Promise<tt.Message | boolean>
550+
458551
/**
459552
* Use this method to edit live location messages
460553
* @returns On success, if the edited message was sent by the bot, the edited message is returned, otherwise True is returned.
@@ -495,15 +588,53 @@ export declare class TelegrafContext {
495588

496589
/**
497590
* Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
498-
* @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
499591
* @param userId Unique identifier of the target user
592+
* @param extra Extra parameters for promoteChatMember
500593
* @returns True on success
501594
*/
502595
promoteChatMember(
503596
userId: number,
504597
extra: tt.ExtraPromoteChatMember
505598
): Promise<boolean>
506599

600+
/**
601+
* Use this method to set a custom title for an administrator in a supergroup promoted by the bot
602+
* @param userId Unique identifier of the target user
603+
* @param title New custom title for the administrator; 0-16 characters, emoji are not allowed
604+
* @returns True on success
605+
*/
606+
setChatAdministratorCustomTitle(
607+
userId: number,
608+
title: string
609+
): Promise<boolean>
610+
611+
/**
612+
* Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
613+
* @param photo New chat photo
614+
* @returns True on success.
615+
*/
616+
setChatPhoto(photo: tt.InputFile): Promise<boolean>
617+
618+
/**
619+
* Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
620+
* @returns True on success
621+
*/
622+
deleteChatPhoto(): Promise<boolean>
623+
624+
/**
625+
* Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
626+
* @param title New chat title, 1-255 characters
627+
* @returns True on success
628+
*/
629+
setChatTitle(title: string): Promise<boolean>
630+
631+
/**
632+
* Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
633+
* @param description New chat description, 0-255 characters
634+
* @returns True on success
635+
*/
636+
setChatDescription(description: string): Promise<boolean>
637+
507638
/**
508639
* Use this method to delete a message, including service messages, with the following limitations:
509640
* - A message can only be deleted if it was sent less than 48 hours ago.
@@ -515,6 +646,17 @@ export declare class TelegrafContext {
515646
*/
516647
deleteMessage(messageId?: number): Promise<boolean>
517648

649+
/**
650+
* Use this method to forward exists message.
651+
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
652+
* @param extra Pass `{ disable_notification: true }`, if it is not necessary to send a notification for forwarded message
653+
* @returns On success, the sent Message is returned.
654+
*/
655+
forwardMessage(
656+
chatId: number | string,
657+
extra?: { disable_notification?: boolean }
658+
): Promise<tt.Message>
659+
518660
/**
519661
* Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times)
520662
* https://core.telegram.org/bots/api#sending-files
@@ -536,9 +678,43 @@ export declare class TelegrafContext {
536678
setStickerPositionInSet(sticker: string, position: number): Promise<boolean>
537679

538680
/**
539-
* Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
540-
* @param title New chat title, 1-255 characters
681+
* Use this method to set the thumbnail of a sticker set.
682+
* Animated thumbnails can be set for animated sticker sets only
683+
* @param name Sticker set name
684+
* @param userId User identifier of the sticker set owner
685+
* @param thumb New thumbnail. See [documentation](https://core.telegram.org/bots/api#setstickersetthumb)
686+
* @returns True on success.
687+
*/
688+
setStickerSetThumb(
689+
name: string,
690+
userId: number,
691+
thumb: tt.InputFile,
692+
): Promise<boolean>
693+
694+
/**
695+
* Informs a user that some of the Telegram Passport elements they provided contains errors.
696+
* The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change).
697+
*
698+
* Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason.
699+
* For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc.
700+
* Supply some details in the error message to make sure the user knows how to correct the issues.
701+
* @param errors An array describing the errors
702+
* @returns True on success.
703+
*/
704+
setPassportDataErrors(
705+
errors: tt.PassportElementError[]
706+
): Promise<boolean>
707+
708+
/**
709+
* Use this method to get the current list of the bot's commands. Requires no parameters.
710+
* @returns Array of BotCommand on success.
711+
*/
712+
getMyCommands(): Promise<tt.BotCommand[]>
713+
714+
/**
715+
* Use this method to change the list of the bot's commands.
716+
* @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
541717
* @returns True on success
542718
*/
543-
setChatTitle(title: string): Promise<boolean>
719+
setMyCommands(commands: tt.BotCommand[]): Promise<boolean>
544720
}

0 commit comments

Comments
 (0)