tgapi
Version:
Actual Telegram bot API JS implementation
1,643 lines (1,465 loc) • 77.4 kB
JavaScript
/* @flow */
/* ::
import * as t from '../types'
import * as a from './apiTypes'
import * as r from '../returnTypes'
*/
import { callMethod } from '../callMethod'
export class BotCore {
/**
* getUpdates
*
* Use this method to receive incoming updates using long polling (wiki). An
* Array of Update objects is returned.
*/
getUpdates(
props: {
/**
* Identifier of the first update to be returned. Must be greater by one
* than the highest among the identifiers of previously received updates.
* By default, updates starting with the earliest unconfirmed update are
* returned. An update is considered confirmed as soon as getUpdates is
* called with an offset higher than its update_id. The negative offset can
* be specified to retrieve updates starting from -offset update from the
* end of the updates queue. All previous updates will forgotten.
*/
offset?: number,
/**
* Limits the number of updates to be retrieved. Values between 1—100 are
* accepted. Defaults to 100.
*/
limit?: number,
/**
* Timeout in seconds for long polling. Defaults to 0, i.e. usual short
* polling. Should be positive, short polling should be used for testing
* purposes only.
*/
timeout?: number,
/**
* List the types of updates you want your bot to receive. For example,
* specify [“message”, “edited_channel_post”, “callback_query”] to only
* receive updates of these types. See Update for a complete list of
* available update types. Specify an empty list to receive all updates
* regardless of type (default). If not specified, the previous setting
* will be used.Please note that this parameter doesn't affect updates
* created before the call to the getUpdates, so unwanted updates may be
* received for a short period of time.
*/
allowed_updates?: $ReadOnlyArray<string>,
} = {},
): Promise<t.Result<r.GetUpdatesResult>> {
return callMethod(this, 'getUpdates', props)
}
/**
* setWebhook
*
* Use this method to specify a url and receive incoming updates via an
* outgoing webhook. Whenever there is an update for the bot, we will send an
* HTTPS POST request to the specified url, containing a JSON-serialized
* Update. In case of an unsuccessful request, we will give up after a
* reasonable amount of attempts. Returns True on success.
*
* If you'd like to make sure that the Webhook request comes from Telegram,
* we recommend using a secret path in the URL, e.g.
* https://www.example.com/<token>. Since nobody else knows your bot‘s token,
* you can be pretty sure it’s us.
*/
setWebhook(props: {
/**
* HTTPS url to send updates to. Use an empty string to remove webhook
* integration
*/
url: string,
/**
* Upload your public key certificate so that the root certificate in use
* can be checked. See our self-signed guide for details.
*/
certificate?: a.InputFile,
/**
* Maximum allowed number of simultaneous HTTPS connections to the webhook
* for update delivery, 1-100. Defaults to 40. Use lower values to limit
* the load on your bot‘s server, and higher values to increase your bot’s
* throughput.
*/
max_connections?: number,
/**
* List the types of updates you want your bot to receive. For example,
* specify [“message”, “edited_channel_post”, “callback_query”] to only
* receive updates of these types. See Update for a complete list of
* available update types. Specify an empty list to receive all updates
* regardless of type (default). If not specified, the previous setting
* will be used.Please note that this parameter doesn't affect updates
* created before the call to the setWebhook, so unwanted updates may be
* received for a short period of time.
*/
allowed_updates?: $ReadOnlyArray<string>,
}): Promise<t.Result<r.SetWebhookResult>> {
return callMethod(this, 'setWebhook', props)
}
/**
* deleteWebhook
*
* Use this method to remove webhook integration if you decide to switch back
* to getUpdates. Returns True on success. Requires no parameters.
*/
deleteWebhook(): Promise<t.Result<r.DeleteWebhookResult>> {
return callMethod(this, 'deleteWebhook')
}
/**
* getWebhookInfo
*
* Use this method to get current webhook status. Requires no parameters. On
* success, returns a WebhookInfo object. If the bot is using getUpdates,
* will return an object with the url field empty.
*/
getWebhookInfo(): Promise<t.Result<r.GetWebhookInfoResult>> {
return callMethod(this, 'getWebhookInfo')
}
/**
* getMe
*
* A simple method for testing your bot's auth token. Requires no parameters.
* Returns basic information about the bot in form of a User object.
*/
getMe(): Promise<t.Result<r.GetMeResult>> {
return callMethod(this, 'getMe')
}
/**
* sendMessage
*
* Use this method to send text messages. On success, the sent Message is
* returned.
*/
sendMessage(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Text of the message to be sent
*/
text: string,
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in your bot's message.
*/
parse_mode?: string,
/**
* Disables link previews for links in this message
*/
disable_web_page_preview?: boolean,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendMessageResult>> {
return callMethod(this, 'sendMessage', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* forwardMessage
*
* Use this method to forward messages of any kind. On success, the sent
* Message is returned.
*/
forwardMessage(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Unique identifier for the chat where the original message was sent (or
* channel username in the format @channelusername)
*/
from_chat_id: number | string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* Message identifier in the chat specified in from_chat_id
*/
message_id: number,
}): Promise<t.Result<r.ForwardMessageResult>> {
return callMethod(this, 'forwardMessage', props)
}
/**
* sendPhoto
*
* Use this method to send photos. On success, the sent Message is returned.
*/
sendPhoto(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* 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. More info on Sending Files »
*/
photo: a.InputFile | string,
/**
* Photo caption (may also be used when resending photos by file_id),
* 0-1024 characters
*/
caption?: string,
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in the media caption.
*/
parse_mode?: string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendPhotoResult>> {
return callMethod(this, 'sendPhoto', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendAudio
*
* Use this method to send audio files, if you want Telegram clients to
* display them in the music player. Your audio must be in the .mp3 format.
* On success, the sent Message is returned. Bots can currently send audio
* files of up to 50 MB in size, this limit may be changed in the future.
*
* For sending voice messages, use the sendVoice method instead.
*/
sendAudio(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Audio file to send. Pass a file_id as String to send an audio file that
* exists on the Telegram servers (recommended), pass an HTTP URL as a
* String for Telegram to get an audio file from the Internet, or upload a
* new one using multipart/form-data. More info on Sending Files »
*/
audio: a.InputFile | string,
/**
* Audio caption, 0-1024 characters
*/
caption?: string,
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in the media caption.
*/
parse_mode?: string,
/**
* Duration of the audio in seconds
*/
duration?: number,
/**
* Performer
*/
performer?: string,
/**
* Track name
*/
title?: string,
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for
* the file is supported server-side. The thumbnail should be in JPEG
* format and less than 200 kB in size. A thumbnail‘s width and height
* should not exceed 90. Ignored if the file is not uploaded using
* multipart/form-data. Thumbnails can’t be reused and can be only uploaded
* as a new file, so you can pass “attach://<file_attach_name>” if the
* thumbnail was uploaded using multipart/form-data under
* <file_attach_name>. More info on Sending Files »
*/
thumb?: a.InputFile | string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendAudioResult>> {
return callMethod(this, 'sendAudio', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendDocument
*
* Use this method to send general files. On success, the sent Message is
* returned. Bots can currently send files of any type of up to 50 MB in
* size, this limit may be changed in the future.
*/
sendDocument(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* 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. More info on Sending Files »
*/
document: a.InputFile | string,
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for
* the file is supported server-side. The thumbnail should be in JPEG
* format and less than 200 kB in size. A thumbnail‘s width and height
* should not exceed 90. Ignored if the file is not uploaded using
* multipart/form-data. Thumbnails can’t be reused and can be only uploaded
* as a new file, so you can pass “attach://<file_attach_name>” if the
* thumbnail was uploaded using multipart/form-data under
* <file_attach_name>. More info on Sending Files »
*/
thumb?: a.InputFile | string,
/**
* Document caption (may also be used when resending documents by file_id),
* 0-1024 characters
*/
caption?: string,
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in the media caption.
*/
parse_mode?: string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendDocumentResult>> {
return callMethod(this, 'sendDocument', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendVideo
*
* Use this method to send video files, Telegram clients support mp4 videos
* (other formats may be sent as Document). On success, the sent Message is
* returned. Bots can currently send video files of up to 50 MB in size, this
* limit may be changed in the future.
*/
sendVideo(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Video to send. Pass a file_id as String to send a video that exists on
* the Telegram servers (recommended), pass an HTTP URL as a String for
* Telegram to get a video from the Internet, or upload a new video using
* multipart/form-data. More info on Sending Files »
*/
video: a.InputFile | string,
/**
* Duration of sent video in seconds
*/
duration?: number,
/**
* Video width
*/
width?: number,
/**
* Video height
*/
height?: number,
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for
* the file is supported server-side. The thumbnail should be in JPEG
* format and less than 200 kB in size. A thumbnail‘s width and height
* should not exceed 90. Ignored if the file is not uploaded using
* multipart/form-data. Thumbnails can’t be reused and can be only uploaded
* as a new file, so you can pass “attach://<file_attach_name>” if the
* thumbnail was uploaded using multipart/form-data under
* <file_attach_name>. More info on Sending Files »
*/
thumb?: a.InputFile | string,
/**
* Video caption (may also be used when resending videos by file_id),
* 0-1024 characters
*/
caption?: string,
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in the media caption.
*/
parse_mode?: string,
/**
* Pass True, if the uploaded video is suitable for streaming
*/
supports_streaming?: boolean,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendVideoResult>> {
return callMethod(this, 'sendVideo', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendAnimation
*
* Use this method to send animation files (GIF or H.264/MPEG-4 AVC video
* without sound). On success, the sent Message is returned. Bots can
* currently send animation files of up to 50 MB in size, this limit may be
* changed in the future.
*/
sendAnimation(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Animation to send. Pass a file_id as String to send an animation that
* exists on the Telegram servers (recommended), pass an HTTP URL as a
* String for Telegram to get an animation from the Internet, or upload a
* new animation using multipart/form-data. More info on Sending Files »
*/
animation: a.InputFile | string,
/**
* Duration of sent animation in seconds
*/
duration?: number,
/**
* Animation width
*/
width?: number,
/**
* Animation height
*/
height?: number,
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for
* the file is supported server-side. The thumbnail should be in JPEG
* format and less than 200 kB in size. A thumbnail‘s width and height
* should not exceed 90. Ignored if the file is not uploaded using
* multipart/form-data. Thumbnails can’t be reused and can be only uploaded
* as a new file, so you can pass “attach://<file_attach_name>” if the
* thumbnail was uploaded using multipart/form-data under
* <file_attach_name>. More info on Sending Files »
*/
thumb?: a.InputFile | string,
/**
* Animation caption (may also be used when resending animation by
* file_id), 0-1024 characters
*/
caption?: string,
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in the media caption.
*/
parse_mode?: string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendAnimationResult>> {
return callMethod(this, 'sendAnimation', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendVoice
*
* 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.
*/
sendVoice(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* 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. More info on Sending Files »
*/
voice: a.InputFile | string,
/**
* Voice message caption, 0-1024 characters
*/
caption?: string,
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in the media caption.
*/
parse_mode?: string,
/**
* Duration of the voice message in seconds
*/
duration?: number,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendVoiceResult>> {
return callMethod(this, 'sendVoice', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendVideoNote
*
* As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1
* minute long. Use this method to send video messages. On success, the sent
* Message is returned.
*/
sendVideoNote(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* 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. More info on Sending Files ». Sending video notes
* by a URL is currently unsupported
*/
video_note: a.InputFile | string,
/**
* Duration of sent video in seconds
*/
duration?: number,
/**
* Video width and height, i.e. diameter of the video message
*/
length?: number,
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for
* the file is supported server-side. The thumbnail should be in JPEG
* format and less than 200 kB in size. A thumbnail‘s width and height
* should not exceed 90. Ignored if the file is not uploaded using
* multipart/form-data. Thumbnails can’t be reused and can be only uploaded
* as a new file, so you can pass “attach://<file_attach_name>” if the
* thumbnail was uploaded using multipart/form-data under
* <file_attach_name>. More info on Sending Files »
*/
thumb?: a.InputFile | string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendVideoNoteResult>> {
return callMethod(this, 'sendVideoNote', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendMediaGroup
*
* Use this method to send a group of photos or videos as an album. On
* success, an array of the sent Messages is returned.
*/
sendMediaGroup(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* A JSON-serialized array describing photos and videos to be sent, must
* include 2–10 items
*/
media: $ReadOnlyArray<a.InputMediaPhoto | a.InputMediaVideo>,
/**
* Sends the messages silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the messages are a reply, ID of the original message
*/
reply_to_message_id?: number,
}): Promise<t.Result<r.SendMediaGroupResult>> {
return callMethod(this, 'sendMediaGroup', {
...props,
media: props.media && JSON.stringify(props.media),
})
}
/**
* sendLocation
*
* Use this method to send point on the map. On success, the sent Message is
* returned.
*/
sendLocation(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Latitude of the location
*/
latitude: number,
/**
* Longitude of the location
*/
longitude: number,
/**
* Period in seconds for which the location will be updated (see Live
* Locations, should be between 60 and 86400.
*/
live_period?: number,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendLocationResult>> {
return callMethod(this, 'sendLocation', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* editMessageLiveLocation
*
* Use this method to edit live location messages sent by the bot or via the
* bot (for inline bots). A location can be edited until its live_period
* expires or editing is explicitly disabled by a call to
* stopMessageLiveLocation. On success, if the edited message was sent by the
* bot, the edited Message is returned, otherwise True is returned.
*/
editMessageLiveLocation(props: {
/**
* Required if inline_message_id is not specified. Unique identifier for
* the target chat or username of the target channel (in the format
* @channelusername)
*/
chat_id?: number | string,
/**
* Required if inline_message_id is not specified. Identifier of the sent
* message
*/
message_id?: number,
/**
* Required if chat_id and message_id are not specified. Identifier of the
* inline message
*/
inline_message_id?: string,
/**
* Latitude of new location
*/
latitude: number,
/**
* Longitude of new location
*/
longitude: number,
/**
* A JSON-serialized object for a new inline keyboard.
*/
reply_markup?: a.InlineKeyboardMarkup,
}): Promise<t.Result<r.EditMessageLiveLocationResult>> {
return callMethod(this, 'editMessageLiveLocation', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* stopMessageLiveLocation
*
* Use this method to stop updating a live location message sent by the bot
* or via the bot (for inline bots) before live_period expires. On success,
* if the message was sent by the bot, the sent Message is returned,
* otherwise True is returned.
*/
stopMessageLiveLocation(
props: {
/**
* Required if inline_message_id is not specified. Unique identifier for
* the target chat or username of the target channel (in the format
* @channelusername)
*/
chat_id?: number | string,
/**
* Required if inline_message_id is not specified. Identifier of the sent
* message
*/
message_id?: number,
/**
* Required if chat_id and message_id are not specified. Identifier of the
* inline message
*/
inline_message_id?: string,
/**
* A JSON-serialized object for a new inline keyboard.
*/
reply_markup?: a.InlineKeyboardMarkup,
} = {},
): Promise<t.Result<r.StopMessageLiveLocationResult>> {
return callMethod(this, 'stopMessageLiveLocation', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendVenue
*
* Use this method to send information about a venue. On success, the sent
* Message is returned.
*/
sendVenue(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Latitude of the venue
*/
latitude: number,
/**
* Longitude of the venue
*/
longitude: number,
/**
* Name of the venue
*/
title: string,
/**
* Address of the venue
*/
address: string,
/**
* Foursquare identifier of the venue
*/
foursquare_id?: string,
/**
* Foursquare type of the venue, if known. (For example,
* “arts_entertainment/default”, “arts_entertainment/aquarium” or
* “food/icecream”.)
*/
foursquare_type?: string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove reply keyboard
* or to force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendVenueResult>> {
return callMethod(this, 'sendVenue', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendContact
*
* Use this method to send phone contacts. On success, the sent Message is
* returned.
*/
sendContact(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Contact's phone number
*/
phone_number: string,
/**
* Contact's first name
*/
first_name: string,
/**
* Contact's last name
*/
last_name?: string,
/**
* Additional data about the contact in the form of a vCard, 0-2048 bytes
*/
vcard?: string,
/**
* Sends the message silently. Users will receive a notification with no
* sound.
*/
disable_notification?: boolean,
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number,
/**
* Additional interface options. A JSON-serialized object for an inline
* keyboard, custom reply keyboard, instructions to remove keyboard or to
* force a reply from the user.
*/
reply_markup?:
| a.InlineKeyboardMarkup
| a.ReplyKeyboardMarkup
| a.ReplyKeyboardRemove
| a.ForceReply,
}): Promise<t.Result<r.SendContactResult>> {
return callMethod(this, 'sendContact', {
...props,
reply_markup: props.reply_markup && JSON.stringify(props.reply_markup),
})
}
/**
* sendChatAction
*
* Use this method when you need to tell the user that something is happening
* on the bot's side. The status is set for 5 seconds or less (when a message
* arrives from your bot, Telegram clients clear its typing status). Returns
* True on success.
*
* We only recommend using this method when a response from the bot will take
* a noticeable amount of time to arrive.
*/
sendChatAction(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Type of action to broadcast. Choose one, depending on what the user is
* about to receive: typing for text messages, upload_photo for photos,
* record_video or upload_video for videos, record_audio or upload_audio
* for audio files, upload_document for general files, find_location for
* location data, record_video_note or upload_video_note for video notes.
*/
action: string,
}): Promise<t.Result<r.SendChatActionResult>> {
return callMethod(this, 'sendChatAction', props)
}
/**
* getUserProfilePhotos
*
* Use this method to get a list of profile pictures for a user. Returns a
* UserProfilePhotos object.
*/
getUserProfilePhotos(props: {
/**
* Unique identifier of the target user
*/
user_id: number,
/**
* Sequential number of the first photo to be returned. By default, all
* photos are returned.
*/
offset?: number,
/**
* Limits the number of photos to be retrieved. Values between 1—100 are
* accepted. Defaults to 100.
*/
limit?: number,
}): Promise<t.Result<r.GetUserProfilePhotosResult>> {
return callMethod(this, 'getUserProfilePhotos', props)
}
/**
* getFile
*
* Use this method to get basic info about a file and prepare it for
* downloading. For the moment, bots can download files of up to 20MB in
* size. On success, a File object is returned. The file can then be
* downloaded via the link
* https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is
* taken from the response. It is guaranteed that the link will be valid for
* at least 1 hour. When the link expires, a new one can be requested by
* calling getFile again.
*/
getFile(props: {
/**
* File identifier to get info about
*/
file_id: string,
}): Promise<t.Result<r.GetFileResult>> {
return callMethod(this, 'getFile', props)
}
/**
* kickChatMember
*
* Use this method to kick a user from a group, a supergroup or a channel. In
* the case of supergroups and channels, the user will not be able to return
* to the group on their own using invite links, etc., unless unbanned first.
* The bot must be an administrator in the chat for this to work and must
* have the appropriate admin rights. Returns True on success.
*/
kickChatMember(props: {
/**
* Unique identifier for the target group or username of the target
* supergroup or channel (in the format @channelusername)
*/
chat_id: number | string,
/**
* Unique identifier of the target user
*/
user_id: number,
/**
* Date when the user will be unbanned, unix time. If user is banned for
* more than 366 days or less than 30 seconds from the current time they
* are considered to be banned forever
*/
until_date?: number,
}): Promise<t.Result<r.KickChatMemberResult>> {
return callMethod(this, 'kickChatMember', props)
}
/**
* unbanChatMember
*
* Use this method to unban a previously kicked user in a supergroup or
* channel. The user will not return to the group or channel automatically,
* but will be able to join via link, etc. The bot must be an administrator
* for this to work. Returns True on success.
*/
unbanChatMember(props: {
/**
* Unique identifier for the target group or username of the target
* supergroup or channel (in the format @username)
*/
chat_id: number | string,
/**
* Unique identifier of the target user
*/
user_id: number,
}): Promise<t.Result<r.UnbanChatMemberResult>> {
return callMethod(this, 'unbanChatMember', props)
}
/**
* restrictChatMember
*
* 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.
*/
restrictChatMember(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup (in the format @supergroupusername)
*/
chat_id: number | string,
/**
* Unique identifier of the target user
*/
user_id: number,
/**
* Date when restrictions will be lifted for the user, unix time. If user
* is restricted for more than 366 days or less than 30 seconds from the
* current time, they are considered to be restricted forever
*/
until_date?: number,
/**
* Pass True, if the user can send text messages, contacts, locations and
* venues
*/
can_send_messages?: boolean,
/**
* Pass True, if the user can send audios, documents, photos, videos, video
* notes and voice notes, implies can_send_messages
*/
can_send_media_messages?: boolean,
/**
* Pass True, if the user can send animations, games, stickers and use
* inline bots, implies can_send_media_messages
*/
can_send_other_messages?: boolean,
/**
* Pass True, if the user may add web page previews to their messages,
* implies can_send_media_messages
*/
can_add_web_page_previews?: boolean,
}): Promise<t.Result<r.RestrictChatMemberResult>> {
return callMethod(this, 'restrictChatMember', props)
}
/**
* promoteChatMember
*
* 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. Returns True on success.
*/
promoteChatMember(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Unique identifier of the target user
*/
user_id: number,
/**
* Pass True, if the administrator can change chat title, photo and other
* settings
*/
can_change_info?: boolean,
/**
* Pass True, if the administrator can create channel posts, channels only
*/
can_post_messages?: boolean,
/**
* Pass True, if the administrator can edit messages of other users and can
* pin messages, channels only
*/
can_edit_messages?: boolean,
/**
* Pass True, if the administrator can delete messages of other users
*/
can_delete_messages?: boolean,
/**
* Pass True, if the administrator can invite new users to the chat
*/
can_invite_users?: boolean,
/**
* Pass True, if the administrator can restrict, ban or unban chat members
*/
can_restrict_members?: boolean,
/**
* Pass True, if the administrator can pin messages, supergroups only
*/
can_pin_messages?: boolean,
/**
* Pass True, if the administrator can add new administrators with a subset
* of his own privileges or demote administrators that he has promoted,
* directly or indirectly (promoted by administrators that were appointed
* by him)
*/
can_promote_members?: boolean,
}): Promise<t.Result<r.PromoteChatMemberResult>> {
return callMethod(this, 'promoteChatMember', props)
}
/**
* exportChatInviteLink
*
* Use this method to generate a new invite link for a chat; any previously
* generated link is revoked. The bot must be an administrator in the chat
* for this to work and must have the appropriate admin rights. Returns the
* new invite link as String on success.
*/
exportChatInviteLink(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.ExportChatInviteLinkResult>> {
return callMethod(this, 'exportChatInviteLink', props)
}
/**
* setChatPhoto
*
* 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. Returns True
* on success.
*/
setChatPhoto(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* New chat photo, uploaded using multipart/form-data
*/
photo: a.InputFile,
}): Promise<t.Result<r.SetChatPhotoResult>> {
return callMethod(this, 'setChatPhoto', props)
}
/**
* deleteChatPhoto
*
* 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. Returns True on success.
*/
deleteChatPhoto(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.DeleteChatPhotoResult>> {
return callMethod(this, 'deleteChatPhoto', props)
}
/**
* setChatTitle
*
* 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. Returns True on success.
*/
setChatTitle(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* New chat title, 1-255 characters
*/
title: string,
}): Promise<t.Result<r.SetChatTitleResult>> {
return callMethod(this, 'setChatTitle', props)
}
/**
* setChatDescription
*
* Use this method to change the description of 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. Returns True on success.
*/
setChatDescription(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* New chat description, 0-255 characters
*/
description?: string,
}): Promise<t.Result<r.SetChatDescriptionResult>> {
return callMethod(this, 'setChatDescription', props)
}
/**
* pinChatMessage
*
* Use this method to pin a message in a supergroup or a channel. The bot
* must be an administrator in the chat for this to work and must have the
* ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’
* admin right in the channel. Returns True on success.
*/
pinChatMessage(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
/**
* Identifier of a message to pin
*/
message_id: number,
/**
* Pass True, if it is not necessary to send a notification to all chat
* members about the new pinned message. Notifications are always disabled
* in channels.
*/
disable_notification?: boolean,
}): Promise<t.Result<r.PinChatMessageResult>> {
return callMethod(this, 'pinChatMessage', props)
}
/**
* unpinChatMessage
*
* Use this method to unpin a message in a supergroup or a channel. The bot
* must be an administrator in the chat for this to work and must have the
* ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’
* admin right in the channel. Returns True on success.
*/
unpinChatMessage(props: {
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.UnpinChatMessageResult>> {
return callMethod(this, 'unpinChatMessage', props)
}
/**
* leaveChat
*
* Use this method for your bot to leave a group, supergroup or channel.
* Returns True on success.
*/
leaveChat(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup or channel (in the format @channelusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.LeaveChatResult>> {
return callMethod(this, 'leaveChat', props)
}
/**
* getChat
*
* Use this method to get up to date information about the chat (current name
* of the user for one-on-one conversations, current username of a user,
* group or channel, etc.). Returns a Chat object on success.
*/
getChat(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup or channel (in the format @channelusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.GetChatResult>> {
return callMethod(this, 'getChat', props)
}
/**
* getChatAdministrators
*
* Use this method to get a list of administrators in a chat. On success,
* returns an Array of ChatMember objects that contains information about all
* chat administrators except other bots. If the chat is a group or a
* supergroup and no administrators were appointed, only the creator will be
* returned.
*/
getChatAdministrators(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup or channel (in the format @channelusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.GetChatAdministratorsResult>> {
return callMethod(this, 'getChatAdministrators', props)
}
/**
* getChatMembersCount
*
* Use this method to get the number of members in a chat. Returns Int on
* success.
*/
getChatMembersCount(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup or channel (in the format @channelusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.GetChatMembersCountResult>> {
return callMethod(this, 'getChatMembersCount', props)
}
/**
* getChatMember
*
* Use this method to get information about a member of a chat. Returns a
* ChatMember object on success.
*/
getChatMember(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup or channel (in the format @channelusername)
*/
chat_id: number | string,
/**
* Unique identifier of the target user
*/
user_id: number,
}): Promise<t.Result<r.GetChatMemberResult>> {
return callMethod(this, 'getChatMember', props)
}
/**
* setChatStickerSet
*
* Use this method to set a new group sticker set for a supergroup. The bot
* must be an administrator in the chat for this to work and must have the
* appropriate admin rights. Use the field can_set_sticker_set optionally
* returned in getChat requests to check if the bot can use this method.
* Returns True on success.
*/
setChatStickerSet(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup (in the format @supergroupusername)
*/
chat_id: number | string,
/**
* Name of the sticker set to be set as the group sticker set
*/
sticker_set_name: string,
}): Promise<t.Result<r.SetChatStickerSetResult>> {
return callMethod(this, 'setChatStickerSet', props)
}
/**
* deleteChatStickerSet
*
* Use this method to delete a group sticker set from a supergroup. The bot
* must be an administrator in the chat for this to work and must have the
* appropriate admin rights. Use the field can_set_sticker_set optionally
* returned in getChat requests to check if the bot can use this method.
* Returns True on success.
*/
deleteChatStickerSet(props: {
/**
* Unique identifier for the target chat or username of the target
* supergroup (in the format @supergroupusername)
*/
chat_id: number | string,
}): Promise<t.Result<r.DeleteChatStickerSetResult>> {
return callMethod(this, 'deleteChatStickerSet', props)
}
/**
* answerCallbackQuery
*
* Use this method to send answers to callback queries sent from inline
* keyboards. The answer will be displayed to the user as a notification at
* the top of the chat screen or as an alert. On success, True is returned.
*/
answerCallba