Open sergeysova opened 6 years ago
@valscion @Piterden Can you try?
I don't have time right now to try, sorry
let el = document.getElementById('telegram-passport').parentElement
let code = []
let cls = ''
while (el.nextElementSibling && el.nextElementSibling.tagName !== 'H3') {
if (el.nextElementSibling.tagName === 'H4') {
cls = cls + `class ${el.nextElementSibling.innerText}`
}
if (el.nextElementSibling.tagName === 'P') {
cls = `/**${el.nextElementSibling.innerText.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}
*/\n${cls}`
}
if (el.nextElementSibling.tagName === 'TABLE') {
code.push(cls);
cls = '';
}
el = el.nextElementSibling;
}
console.log(code.join('\n\n'))
It has the WIP status for now...
ЗЫ Серег, добавь меня в контакты в телеге, плиз. Не могу тебе написать... )
Second version
el = document.getElementById('telegram-passport').parentElement
code = []
cls = ''
while (el.nextElementSibling && el.nextElementSibling.tagName !== 'H3') {
if (el.nextElementSibling.tagName === 'H4') {
cls = cls + `class ${el.nextElementSibling.innerText}`
}
if (el.nextElementSibling.tagName === 'P') {
cls = `/**${el.nextElementSibling.innerText.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}
*/\n` + cls
}
if (el.nextElementSibling.tagName === 'TABLE') {
code.push(`${cls}\n{`)
cls = ''
const keys = Array.from(el.nextElementSibling.querySelectorAll('tr:first-child td'))
.map((td) => td.innerText)
const values = Array.from(el.nextElementSibling.querySelectorAll('tr:not(:first-child) td'))
.map((td, idx) => [keys[idx % keys.length].toLowerCase(), td.innerText])
.reduce((acc, cur, idx) => {
acc[parseInt(idx / keys.length)] = acc[parseInt(idx / keys.length)] || {}
acc[parseInt(idx / keys.length)] = Object.assign(acc[parseInt(idx / keys.length)], { [cur[0]]: cur[1] })
return acc
}, [])
console.log(values)
}
el = el.nextElementSibling
}
// console.log(code.join('\n'))
Version 3. Sova, please finish this shit...
el = document.getElementById('telegram-passport').parentElement
code = []
cls = ''
while (el.nextElementSibling && el.nextElementSibling.tagName !== 'H3') {
if (el.nextElementSibling.tagName === 'H4') {
cls = cls + `interface ${el.nextElementSibling.innerText}`
}
if (el.nextElementSibling.tagName === 'P') {
cls = `/**${el.nextElementSibling.innerText.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}\n */\n` + cls
cls = el.previousElementSibling.tagName === 'H3' || el.tagName === 'H3' || el.previousElementSibling.previousElementSibling.tagName === 'H3'
? cls.replace(/\n \*\/\n\/\*\*/g, '\n */\n\n/**')
: cls.replace(/\n \*\/\n\/\*\*/g, '\n *')
}
if (el.nextElementSibling.tagName === 'TABLE') {
const keys = Array.from(el.nextElementSibling.querySelectorAll('tr:first-child td'))
.map((td) => td.innerText)
const values = Array.from(el.nextElementSibling.querySelectorAll('tr:not(:first-child) td'))
.map((td, idx) => [keys[idx % keys.length].toLowerCase(), td.innerText])
.reduce((acc, cur, idx) => {
acc[parseInt(idx / keys.length)] = acc[parseInt(idx / keys.length)] || {}
acc[parseInt(idx / keys.length)][cur[0]] = cur[1]
return acc
}, [])
cls += '\n{\n\n' + values.map((prop) => ` /**${prop.description.replace(/“|”/g, '`').replace(/(.{1,72}\s)\s*?/g, '\n * $1')}\n */\n ${prop.parameters || prop.field}: ${prop.type.replace(/Array of (\w+)/, '$1[]')};\n`).join('\n')
code.push(`${cls}\n}\n`)
cls = ''
}
el = el.nextElementSibling
}
console.log(code.join('\n'))
Output:
/**
* Contains information about Telegram Passport data shared with the bot by
* the user.
*/
/**
* Telegram Passport is a unified authorization method for services that
* require personal identification. Users can upload their documents once,
* then instantly share their data with services that require real-world ID
* (finance, ICOs, etc.). Please see the manual for details.
*/
interface PassportData
{
/**
* Array with information about documents and other Telegram Passport
* elements that was shared with the bot
*/
data: EncryptedPassportElement[];
/**
* Encrypted credentials required to decrypt the data
*/
credentials: EncryptedCredentials;
}
/**
* This object represents a file uploaded to Telegram Passport. Currently
* all Telegram Passport files are in JPEG format when decrypted and don't
* exceed 10MB.
*/
interface PassportFile
{
/**
* Unique identifier for this file
*/
file_id: String;
/**
* File size
*/
file_size: Integer;
/**
* Unix time when the file was uploaded
*/
file_date: Integer;
}
/**
* Contains information about documents or other Telegram Passport elements
* shared with the bot by the user.
*/
interface EncryptedPassportElement
{
/**
* Element type. One of `personal_details`, `passport`, `driver_license`,
* `identity_card`, `internal_passport`, `address`, `utility_bill`,
* `bank_statement`, `rental_agreement`, `passport_registration`,
* `temporary_registration`, `phone_number`, `email`.
*/
type: String;
/**
* Optional. Base64-encoded encrypted Telegram Passport element data
* provided by the user, available for `personal_details`, `passport`,
* `driver_license`, `identity_card`, `internal_passport` and `address`
* types. Can be decrypted and verified using the accompanying EncryptedCredentials.
*/
data: String;
/**
* Optional. User's verified phone number, available only for
* `phone_number` type
*/
phone_number: String;
/**
* Optional. User's verified email address, available only for `email` type
*/
email: String;
/**
* Optional. Array of encrypted files with documents provided by the user,
* available for `utility_bill`, `bank_statement`, `rental_agreement`,
* `passport_registration` and `temporary_registration` types. Files can be
* decrypted and verified using the accompanying EncryptedCredentials.
*/
files: PassportFile[];
/**
* Optional. Encrypted file with the front side of the document, provided
* by the user. Available for `passport`, `driver_license`, `identity_card`
* and `internal_passport`. The file can be decrypted and verified using
* the accompanying EncryptedCredentials.
*/
front_side: PassportFile;
/**
* Optional. Encrypted file with the reverse side of the document, provided
* by the user. Available for `driver_license` and `identity_card`. The
* file can be decrypted and verified using the accompanying EncryptedCredentials.
*/
reverse_side: PassportFile;
/**
* Optional. Encrypted file with the selfie of the user holding a document,
* provided by the user; available for `passport`, `driver_license`,
* `identity_card` and `internal_passport`. The file can be decrypted and
* verified using the accompanying EncryptedCredentials.
*/
selfie: PassportFile;
}
/**
* Contains data required for decrypting and authenticating
* EncryptedPassportElement. See the Telegram Passport Documentation for a
* complete description of the data decryption and authentication processes.
*/
interface EncryptedCredentials
{
/**
* Base64-encoded encrypted JSON-serialized data with unique user's
* payload, data hashes and secrets required for EncryptedPassportElement
* decryption and authentication
*/
data: String;
/**
* Base64-encoded data hash for data authentication
*/
hash: String;
/**
* Base64-encoded secret, encrypted with the bot's public RSA key, required
* for data decryption
*/
secret: String;
}
/**
* Use this if the data submitted by the user doesn't satisfy the standards
* your service requires for any reason. For example, if a birthday date
* seems invalid, a submitted document is blurry, a scan shows evidence of
* tampering, etc. Supply some details in the error message to make sure
* the user knows how to correct the issues.
*
* Informs a user that some of the Telegram Passport elements they provided
* contains errors. 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). Returns True on success.
*/
interface setPassportDataErrors
{
/**
* User identifier
*/
user_id: Integer;
/**
* A JSON-serialized array describing the errors
*/
errors: PassportElementError[];
}
/**
* Represents an issue in one of the data fields that was provided by the
* user. The error is considered resolved when the field's value changes.
*
* This object represents an error in the Telegram Passport element which
* was submitted that should be resolved by the user. It should be one of:
*/
interface PassportElementErrorinterface PassportElementErrorDataField
{
/**
* Error source, must be data
*/
source: String;
/**
* The section of the user's Telegram Passport which has the error, one of
* `personal_details`, `passport`, `driver_license`, `identity_card`,
* `internal_passport`, `address`
*/
type: String;
/**
* Name of the data field which has the error
*/
field_name: String;
/**
* Base64-encoded data hash
*/
data_hash: String;
/**
* Error message
*/
message: String;
}
/**
* Represents an issue with the front side of a document. The error is
* considered resolved when the file with the front side of the document changes.
*/
interface PassportElementErrorFrontSide
{
/**
* Error source, must be front_side
*/
source: String;
/**
* The section of the user's Telegram Passport which has the issue, one of
* `passport`, `driver_license`, `identity_card`, `internal_passport`
*/
type: String;
/**
* Base64-encoded hash of the file with the front side of the document
*/
file_hash: String;
/**
* Error message
*/
message: String;
}
/**
* Represents an issue with the reverse side of a document. The error is
* considered resolved when the file with reverse side of the document changes.
*/
interface PassportElementErrorReverseSide
{
/**
* Error source, must be reverse_side
*/
source: String;
/**
* The section of the user's Telegram Passport which has the issue, one of
* `driver_license`, `identity_card`
*/
type: String;
/**
* Base64-encoded hash of the file with the reverse side of the document
*/
file_hash: String;
/**
* Error message
*/
message: String;
}
/**
* Represents an issue with the selfie with a document. The error is
* considered resolved when the file with the selfie changes.
*/
interface PassportElementErrorSelfie
{
/**
* Error source, must be selfie
*/
source: String;
/**
* The section of the user's Telegram Passport which has the issue, one of
* `passport`, `driver_license`, `identity_card`, `internal_passport`
*/
type: String;
/**
* Base64-encoded hash of the file with the selfie
*/
file_hash: String;
/**
* Error message
*/
message: String;
}
/**
* Represents an issue with a document scan. The error is considered
* resolved when the file with the document scan changes.
*/
interface PassportElementErrorFile
{
/**
* Error source, must be file
*/
source: String;
/**
* The section of the user's Telegram Passport which has the issue, one of
* `utility_bill`, `bank_statement`, `rental_agreement`,
* `passport_registration`, `temporary_registration`
*/
type: String;
/**
* Base64-encoded file hash
*/
file_hash: String;
/**
* Error message
*/
message: String;
}
/**
* Represents an issue with a list of scans. The error is considered
* resolved when the list of files containing the scans changes.
*/
interface PassportElementErrorFiles
{
/**
* Error source, must be files
*/
source: String;
/**
* The section of the user's Telegram Passport which has the issue, one of
* `utility_bill`, `bank_statement`, `rental_agreement`,
* `passport_registration`, `temporary_registration`
*/
type: String;
/**
* List of base64-encoded file hashes
*/
file_hashes: String[];
/**
* Error message
*/
message: String;
}
Could you imagine this?
document.querySelectorAll('h3').forEach((el) => {
const code = []
let cls = ''
let comment = []
while (el.nextElementSibling) {
if (el.nextElementSibling.tagName === 'H4') {
cls = `${cls}export type ${el.nextElementSibling.innerText}`
}
if (el.nextElementSibling.tagName === 'P') {
comment = comment + `/**${el.nextElementSibling.innerText.replace(/(.{1,72}\s)\s*?/g, '\n * $1')}\n */\n`
comment = comment.replace(/\n \*\/\n\/\*\*/g, '\n *')
}
if (el.nextElementSibling.tagName === 'TABLE') {
const keys = Array.from(el.nextElementSibling.querySelectorAll('tr:first-child td'))
.map((td) => td.innerText)
const values = Array.from(el.nextElementSibling.querySelectorAll('tr:not(:first-child) td'))
.map((td, idx) => [keys[idx % keys.length].toLowerCase(), td.innerText])
.reduce((acc, cur, idx) => {
acc[parseInt(idx / keys.length)] = acc[parseInt(idx / keys.length)] || {}
acc[parseInt(idx / keys.length)][cur[0]] = cur[1]
return acc
}, [])
cls += '\n{\n\n' + values.map((prop) => ` /**${prop.description.replace(/“|”/g, '`').replace(/(.{1,72}\s)\s*?/g, '\n * $1')}\n */\n ${prop.parameters || prop.field}: ${prop.type.replace(/Array of (\w+)/, '$1[]')};\n`).join('\n')
code.push(`${comment}${cls}\n}\n`)
cls = ''
comment = ''
}
el = el.nextElementSibling
}
console.log(code.join('\n'))
})
It is parsing all shit almost correct.
/**
* Bot API 4.0.
*
* Bot API 3.6.
*
* See earlier changes »
*
* Each bot is given a unique authentication token when it is created. The
* token looks something like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11,
* but we'll use simply <token> in this document instead. You can learn
* about obtaining tokens and generating new ones in this document.
*
* All queries to the Telegram Bot API must be served over HTTPS and need
* to be presented in this form:
* https://api.telegram.org/bot<token>/METHOD_NAME. Like this for example:
*
* We support GET and POST HTTP methods. We support four ways of passing
* parameters in Bot API requests:
*
* The response contains a JSON object, which always has a Boolean field
* ‘ok’ and may have an optional String field ‘description’ with a
* human-readable description of the result. If ‘ok’ equals true, the
* request was successful and the result of the query can be found in the
* ‘result’ field. In case of an unsuccessful request, ‘ok’ equals false
* and the error is explained in the ‘description’. An Integer ‘error_code’
* field is also returned, but its contents are subject to change in the
* future. Some errors may also have an optional field ‘parameters’ of the
* type ResponseParameters, which can help to automatically handle the error.
*
* If you're using webhooks, you can perform a request to the Bot API while
* sending an answer to the webhook. Use either application/json or
* application/x-www-form-urlencoded or multipart/form-data response
* content type for passing parameters. Specify the method to be invoked in
* the method parameter of the request. It's not possible to know that such
* a request was successful or get its result.
*
* There are two mutually exclusive ways of receiving updates for your bot
* — the getUpdates method on one hand and Webhooks on the other. Incoming
* updates are stored on the server until the bot receives them either way,
* but they will not be kept longer than 24 hours.
*
* Regardless of which option you choose, you will receive JSON-serialized
* Update objects as a result.
*
* This object represents an incoming update.
* At most one of the optional parameters can be present in any given update.
*/
export type July 26, 2018export type February 13, 2018export type Making requests when getting updatesexport type Update
{
/**
* The update‘s unique identifier. Update identifiers start from a certain
* positive number and increase sequentially. This ID becomes especially
* handy if you’re using Webhooks, since it allows you to ignore repeated
* updates or to restore the correct update sequence, should they get out
* of order. If there are no new updates for at least a week, then
* identifier of the next update will be chosen randomly instead of sequentially.
*/
update_id: Integer;
/**
* Optional. New incoming message of any kind — text, photo, sticker, etc.
*/
message: Message;
/**
* Optional. New version of a message that is known to the bot and was edited
*/
edited_message: Message;
/**
* Optional. New incoming channel post of any kind — text, photo, sticker, etc.
*/
channel_post: Message;
/**
* Optional. New version of a channel post that is known to the bot and was edited
*/
edited_channel_post: Message;
/**
* Optional. New incoming inline query
*/
inline_query: InlineQuery;
/**
* Optional. The result of an inline query that was chosen by a user and
* sent to their chat partner. Please see our documentation on the feedback
* collecting for details on how to enable these updates for your bot.
*/
chosen_inline_result: ChosenInlineResult;
/**
* Optional. New incoming callback query
*/
callback_query: CallbackQuery;
/**
* Optional. New incoming shipping query. Only for invoices with flexible price
*/
shipping_query: ShippingQuery;
/**
* Optional. New incoming pre-checkout query. Contains full information
* about checkout
*/
pre_checkout_query: PreCheckoutQuery;
}
/**
* Use this method to receive incoming updates using long polling (wiki).
* An Array of Update objects is returned.
*/
export type getUpdates
{
/**
* 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: Integer;
/**
* Limits the number of updates to be retrieved. Values between 1—100 are
* accepted. Defaults to 100.
*/
limit: Integer;
/**
* Timeout in seconds for lo
VM258:38 /**
* Each bot is given a unique authentication token when it is created. The
* token looks something like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11,
* but we'll use simply <token> in this document instead. You can learn
* about obtaining tokens and generating new ones in this document.
*
* All queries to the Telegram Bot API must be served over HTTPS and need
* to be presented in this form:
* https://api.telegram.org/bot<token>/METHOD_NAME. Like this for example:
*
* We support GET and POST HTTP methods. We support four ways of passing
* parameters in Bot API requests:
*
* The response contains a JSON object, which always has a Boolean field
* ‘ok’ and may have an optional String field ‘description’ with a
* human-readable description of the result. If ‘ok’ equals true, the
* request was successful and the result of the query can be found in the
* ‘result’ field. In case of an unsuccessful request, ‘ok’ equals false
* and the error is explained in the ‘description’. An Integer ‘error_code’
* field is also returned, but its contents are subject to change in the
* future. Some errors may also have an optional field ‘parameters’ of the
* type ResponseParameters, which can help to automatically handle the error.
*
* If you're using webhooks, you can perform a request to the Bot API while
* sending an answer to the webhook. Use either application/json or
* application/x-www-form-urlencoded or multipart/form-data response
* content type for passing parameters. Specify the method to be invoked in
* the method parameter of the request. It's not possible to know that such
* a request was successful or get its result.
*
* There are two mutually exclusive ways of receiving updates for your bot
* — the getUpdates method on one hand and Webhooks on the other. Incoming
* updates are stored on the server until the bot receives them either way,
* but they will not be kept longer than 24 hours.
*
* Regardless of which option you choose, you will receive JSON-serialized
* Update objects as a result.
*
* This object represents an incoming update.
* At most one of the optional parameters can be present in any given update.
*/
export type Making requests when getting updatesexport type Update
{
/**
* The update‘s unique identifier. Update identifiers start from a certain
* positive number and increase sequentially. This ID becomes especially
* handy if you’re using Webhooks, since it allows you to ignore repeated
* updates or to restore the correct update sequence, should they get out
* of order. If there are no new updates for at least a week, then
* identifier of the next update will be chosen randomly instead of sequentially.
*/
update_id: Integer;
/**
* Optional. New incoming message of any kind — text, photo, sticker, etc.
*/
message: Message;
/**
* Optional. New version of a message that is known to the bot and was edited
*/
edited_message: Message;
/**
* Optional. New incoming channel post of any kind — text, photo, sticker, etc.
*/
channel_post: Message;
/**
* Optional. New version of a channel post that is known to the bot and was edited
*/
edited_channel_post: Message;
/**
* Optional. New incoming inline query
*/
inline_query: InlineQuery;
/**
* Optional. The result of an inline query that was chosen by a user and
* sent to their chat partner. Please see our documentation on the feedback
* collecting for details on how to enable these updates for your bot.
*/
chosen_inline_result: ChosenInlineResult;
/**
* Optional. New incoming callback query
*/
callback_query: CallbackQuery;
/**
* Optional. New incoming shipping query. Only for invoices with flexible price
*/
shipping_query: ShippingQuery;
/**
* Optional. New incoming pre-checkout query. Contains full information
* about checkout
*/
pre_checkout_query: PreCheckoutQuery;
}
/**
* Use this method to receive incoming updates using long polling (wiki).
* An Array of Update objects is returned.
*/
export type getUpdates
{
/**
* 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: Integer;
/**
* Limits the number of updates to be retrieved. Values between 1—100 are
* accepted. Defaults to 100.
*/
limit: Integer;
/**
* Timeout in seconds for long polling. Defaults to 0, i.e. usual short
* polling. Should be positive, short polling should be used for testing
VM258:38 /**
* All queries to the Telegram Bot API must be served over HTTPS and need
* to be presented in this form:
* https://api.telegram.org/bot<token>/METHOD_NAME. Like this for example:
*
* We support GET and POST HTTP methods. We support four ways of passing
* parameters in Bot API requests:
*
* The response contains a JSON object, which always has a Boolean field
* ‘ok’ and may have an optional String field ‘description’ with a
* human-readable description of the result. If ‘ok’ equals true, the
* request was successful and the result of the query can be found in the
* ‘result’ field. In case of an unsuccessful request, ‘ok’ equals false
* and the error is explained in the ‘description’. An Integer ‘error_code’
* field is also returned, but its contents are subject to change in the
* future. Some errors may also have an optional field ‘parameters’ of the
* type ResponseParameters, which can help to automatically handle the error.
*
* If you're using webhooks, you can perform a request to the Bot API while
* sending an answer to the webhook. Use either application/json or
* application/x-www-form-urlencoded or multipart/form-data response
* content type for passing parameters. Specify the method to be invoked in
* the method parameter of the request. It's not possible to know that such
* a request was successful or get its result.
*
* There are two mutually exclusive ways of receiving updates for your bot
* — the getUpdates method on one hand and Webhooks on the other. Incoming
* updates are stored on the server until the bot receives them either way,
* but they will not be kept longer than 24 hours.
*
* Regardless of which option you choose, you will receive JSON-serialized
* Update objects as a result.
*
* This object represents an incoming update.
* At most one of the optional parameters can be present in any given update.
*/
export type Making requests when getting updatesexport type Update
{
/**
* The update‘s unique identifier. Update identifiers start from a certain
* positive number and increase sequentially. This ID becomes especially
* handy if you’re using Webhooks, since it allows you to ignore repeated
* updates or to restore the correct update sequence, should they get out
* of order. If there are no new updates for at least a week, then
* identifier of the next update will be chosen randomly instead of sequentially.
*/
update_id: Integer;
/**
* Optional. New incoming message of any kind — text, photo, sticker, etc.
*/
message: Message;
/**
* Optional. New version of a message that is known to the bot and was edited
*/
edited_message: Message;
/**
* Optional. New incoming channel post of any kind — text, photo, sticker, etc.
*/
channel_post: Message;
/**
* Optional. New version of a channel post that is known to the bot and was edited
*/
edited_channel_post: Message;
/**
* Optional. New incoming inline query
*/
inline_query: InlineQuery;
/**
* Optional. The result of an inline query that was chosen by a user and
* sent to their chat partner. Please see our documentation on the feedback
* collecting for details on how to enable these updates for your bot.
*/
chosen_inline_result: ChosenInlineResult;
/**
* Optional. New incoming callback query
*/
callback_query: CallbackQuery;
/**
* Optional. New incoming shipping query. Only for invoices with flexible price
*/
shipping_query: ShippingQuery;
/**
* Optional. New incoming pre-checkout query. Contains full information
* about checkout
*/
pre_checkout_query: PreCheckoutQuery;
}
/**
* Use this method to receive incoming updates using long polling (wiki).
* An Array of Update objects is returned.
*/
export type getUpdates
{
/**
* 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: Integer;
/**
* Limits the number of updates to be retrieved. Values between 1—100 are
* accepted. Defaults to 100.
*/
limit: Integer;
/**
* 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: Integer;
/**
* 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 upd
VM258:38 /**
* There are two mutually exclusive ways of receiving updates for your bot
* — the getUpdates method on one hand and Webhooks on the other. Incoming
* updates are stored on the server until the bot receives them either way,
* but they will not be kept longer than 24 hours.
*
* Regardless of which option you choose, you will receive JSON-serialized
* Update objects as a result.
*
* This object represents an incoming update.
* At most one of the optional parameters can be present in any given update.
*/
export type Update
{
/**
* The update‘s unique identifier. Update identifiers start from a certain
* positive number and increase sequentially. This ID becomes especially
* handy if you’re using Webhooks, since it allows you to ignore repeated
* updates or to restore the correct update sequence, should they get out
* of order. If there are no new updates for at least a week, then
* identifier of the next update will be chosen randomly instead of sequentially.
*/
update_id: Integer;
/**
* Optional. New incoming message of any kind — text, photo, sticker, etc.
*/
message: Message;
/**
* Optional. New version of a message that is known to the bot and was edited
*/
edited_message: Message;
/**
* Optional. New incoming channel post of any kind — text, photo, sticker, etc.
*/
channel_post: Message;
/**
* Optional. New version of a channel post that is known to the bot and was edited
*/
edited_channel_post: Message;
/**
* Optional. New incoming inline query
*/
inline_query: InlineQuery;
/**
* Optional. The result of an inline query that was chosen by a user and
* sent to their chat partner. Please see our documentation on the feedback
* collecting for details on how to enable these updates for your bot.
*/
chosen_inline_result: ChosenInlineResult;
/**
* Optional. New incoming callback query
*/
callback_query: CallbackQuery;
/**
* Optional. New incoming shipping query. Only for invoices with flexible price
*/
shipping_query: ShippingQuery;
/**
* Optional. New incoming pre-checkout query. Contains full information
* about checkout
*/
pre_checkout_query: PreCheckoutQuery;
}
/**
* Use this method to receive incoming updates using long polling (wiki).
* An Array of Update objects is returned.
*/
export type getUpdates
{
/**
* 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: Integer;
/**
* Limits the number of updates to be retrieved. Values between 1—100 are
* accepted. Defaults to 100.
*/
limit: Integer;
/**
* 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: Integer;
/**
* 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: String[];
}
/**
* 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.
*/
export type setWebhook
{
/**
* 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: InputFile;
/**
* Maximum allowed number of simultaneous HTTPS connections to the webhook
* for update delivery, 1-100. Defaults to 40. Use l
VM258:38 /**
* All types used in the Bot API responses are represented as JSON-objects.
*
* It is safe to use 32-bit signed integers for storing all Integer fields
* unless otherwise noted.
*
* This object represents a Telegram user or bot.
*/
export type User
{
/**
* Unique identifier for this user or bot
*/
id: Integer;
/**
* True, if this user is a bot
*/
is_bot: Boolean;
/**
* User‘s or bot’s first name
*/
first_name: String;
/**
* Optional. User‘s or bot’s last name
*/
last_name: String;
/**
* Optional. User‘s or bot’s username
*/
username: String;
/**
* Optional. IETF language tag of the user's language
*/
language_code: String;
}
/**
* This object represents a chat.
*/
export type Chat
{
/**
* Unique identifier for this chat. This number may be greater than 32 bits
* and some programming languages may have difficulty/silent defects in
* interpreting it. But it is smaller than 52 bits, so a signed 64 bit
* integer or double-precision float type are safe for storing this identifier.
*/
id: Integer;
/**
* Type of chat, can be either `private`, `group`, `supergroup` or `channel`
*/
type: String;
/**
* Optional. Title, for supergroups, channels and group chats
*/
title: String;
/**
* Optional. Username, for private chats, supergroups and channels if available
*/
username: String;
/**
* Optional. First name of the other party in a private chat
*/
first_name: String;
/**
* Optional. Last name of the other party in a private chat
*/
last_name: String;
/**
* Optional. True if a group has ‘All Members Are Admins’ enabled.
*/
all_members_are_administrators: Boolean;
/**
* Optional. Chat photo. Returned only in getChat.
*/
photo: ChatPhoto;
/**
* Optional. Description, for supergroups and channel chats. Returned only
* in getChat.
*/
description: String;
/**
* Optional. Chat invite link, for supergroups and channel chats. Returned
* only in getChat.
*/
invite_link: String;
/**
* Optional. Pinned message, for supergroups and channel chats. Returned
* only in getChat.
*/
pinned_message: Message;
/**
* Optional. For supergroups, name of group sticker set. Returned only in getChat.
*/
sticker_set_name: String;
/**
* Optional. True, if the bot can change the group sticker set. Returned
* only in getChat.
*/
can_set_sticker_set: Boolean;
}
/**
* This object represents a message.
*/
export type Message
{
/**
* Unique message identifier inside this chat
*/
message_id: Integer;
/**
* Optional. Sender, empty for messages sent to channels
*/
from: User;
/**
* Date the message was sent in Unix time
*/
date: Integer;
/**
* Conversation the message belongs to
*/
chat: Chat;
/**
* Optional. For forwarded messages, sender of the original message
*/
forward_from: User;
/**
* Optional. For messages forwarded from channels, information about the
* original channel
*/
forward_from_chat: Chat;
/**
* Optional. For messages forwarded from channels, identifier of the
* original message in the channel
*/
forward_from_message_id: Integer;
/**
* Optional. For messages forwarded from channels, signature of the post
* author if present
*/
forward_signature: String;
/**
* Optional. For forwarded messages, date the original message was sent in
* Unix time
*/
forward_date: Integer;
/**
* Optional. For replies, the original message. Note that the Message
* object in this field will not contain further reply_to_message fields
* even if it itself is a reply.
*/
reply_to_message: Message;
/**
* Optional. Date the message was last edited in Unix time
*/
edit_date: Integer;
/**
* Optional. The unique identifier of a media message group this message
* belongs to
*/
media_group_id: String;
/**
* Optional. Signature of the post author for messages in channels
*/
author_signature: String;
/**
* Optional. For text messages, the actual UTF-8 text of the message,
* 0-4096 characters.
*/
text: String;
/**
* Optional. For text messages, special entities like usernames, URLs, bot
* commands, etc. that appear in the text
*/
entities: MessageEntity[];
/**
* Optional. For messages with a caption, special entities like usernames,
* URLs, bot commands, etc. that appear in the caption
*/
caption_entities: MessageEntity[];
/**
* Optional. Message is an audio file, information about the file
*/
audio: Audio;
/**
* Optional. Message is a general file, information about the file
*/
document: Document;
/**
* Optional. Message is an animation, information about the animation. For
* backward compatibility, when this field is set, the document field will
* also be set
*/
animation:
VM258:38 /**
* 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.
*
* Use this method to send text messages. On success, the sent Message is returned.
*/
export type getMeexport type sendMessage
{
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: Integer or 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: Integer;
/**
* 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: InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply;
}
/**
* The Bot API supports basic formatting for messages. You can use bold and
* italic text, as well as inline links and pre-formatted code in your
* bots' messages. Telegram clients will render them accordingly. You can
* use either markdown-style or HTML-style formatting.
*
* Note that Telegram clients will display an alert to the user before
* opening an inline link (‘Open this link?’ together with the full URL).
*
* Links tg://user?id=<user_id> can be used to mention a user by their id
* without using a username. Please note:
*
* To use this mode, pass Markdown in the parse_mode field when using
* sendMessage. Use the following syntax in your message:
*
* To use this mode, pass HTML in the parse_mode field when using
* sendMessage. The following tags are currently supported:
*
* Please note:
*
* Use this method to forward messages of any kind. On success, the sent
* Message is returned.
*/
export type Formatting optionsexport type forwardMessage
{
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: Integer or String;
/**
* Unique identifier for the chat where the original message was sent (or
* channel username in the format @channelusername)
*/
from_chat_id: Integer or 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: Integer;
}
/**
* Use this method to send photos. On success, the sent Message is returned.
*/
export type sendPhoto
{
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: Integer or 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: InputFile or String;
/**
* Photo caption (may also be used when resending photos by file_id), 0-200 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: Integer;
/**
* 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: InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply;
}
/**
* 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.
*/
export type sendAudio
{
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: Integer or String;
/**
* Audio file to send. Pass a file_id as String to send an audio file that
* exists on the Telegram servers (rec
VM258:38 /**
* The following methods allow you to change an existing message in the
* message history instead of sending a new one with a result of an action.
* This is most useful for messages with inline keyboards using callback
* queries, but can also help reduce clutter in conversations with regular
* chat bots.
*
* Please note, that it is currently only possible to edit messages without
* reply_markup or with inline keyboards.
*
* Use this method to edit text and game messages sent by the bot or via
* the bot (for inline bots). On success, if edited message is sent by the
* bot, the edited Message is returned, otherwise True is returned.
*/
export type editMessageText
{
/**
* 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: Integer or String;
/**
* Required if inline_message_id is not specified. Identifier of the sent message
*/
message_id: Integer;
/**
* Required if chat_id and message_id are not specified. Identifier of the
* inline message
*/
inline_message_id: String;
/**
* New text of the message
*/
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;
/**
* A JSON-serialized object for an inline keyboard.
*/
reply_markup: InlineKeyboardMarkup;
}
/**
* Use this method to edit captions of messages sent by the bot or via the
* bot (for inline bots). On success, if edited message is sent by the bot,
* the edited Message is returned, otherwise True is returned.
*/
export type editMessageCaption
{
/**
* 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: Integer or String;
/**
* Required if inline_message_id is not specified. Identifier of the sent message
*/
message_id: Integer;
/**
* Required if chat_id and message_id are not specified. Identifier of the
* inline message
*/
inline_message_id: String;
/**
* New caption of the message
*/
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;
/**
* A JSON-serialized object for an inline keyboard.
*/
reply_markup: InlineKeyboardMarkup;
}
/**
* Use this method to edit audio, document, photo, or video messages. If a
* message is a part of a message album, then it can be edited only to a
* photo or a video. Otherwise, message type can be changed arbitrarily.
* When inline message is edited, new file can't be uploaded. Use
* previously uploaded file via its file_id or specify a URL. On success,
* if the edited message was sent by the bot, the edited Message is
* returned, otherwise True is returned.
*/
export type editMessageMedia
{
/**
* 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: Integer or String;
/**
* Required if inline_message_id is not specified. Identifier of the sent message
*/
message_id: Integer;
/**
* 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 media content of the message
*/
media: InputMedia;
/**
* A JSON-serialized object for a new inline keyboard.
*/
reply_markup: InlineKeyboardMarkup;
}
/**
* Use this method to edit only the reply markup of messages sent by the
* bot or via the bot (for inline bots). On success, if edited message is
* sent by the bot, the edited Message is returned, otherwise True is returned.
*/
export type editMessageReplyMarkup
{
/**
* 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: Integer or String;
/**
* Required if inline_message_id is not specified. Identifier of the sent message
*/
message_id: Integer;
/**
* Required if chat_id and message_id are not specified. Identifier of the
* inline message
*/
inline_message_id: String;
/**
* A JSON-serialized object for an inline keyboard.
*/
reply_markup: InlineKeyboardMarkup;
}
/**
* Use this method to delete a message, including service messages, with
* the following limitations:
* - A message can only be deleted if it was sent less than 48 hours ago.
* - Bots can delete outgoing messages in groups and supergroups.
* - Bots granted can_post_me
VM258:38 /**
* The following methods and objects allow your bot to handle stickers and
* sticker sets.
*
* This object represents a sticker.
*/
export type Sticker
{
/**
* Unique identifier for this file
*/
file_id: String;
/**
* Sticker width
*/
width: Integer;
/**
* Sticker height
*/
height: Integer;
/**
* Optional. Sticker thumbnail in the .webp or .jpg format
*/
thumb: PhotoSize;
/**
* Optional. Emoji associated with the sticker
*/
emoji: String;
/**
* Optional. Name of the sticker set to which the sticker belongs
*/
set_name: String;
/**
* Optional. For mask stickers, the position where the mask should be placed
*/
mask_position: MaskPosition;
/**
* Optional. File size
*/
file_size: Integer;
}
/**
* This object represents a sticker set.
*/
export type StickerSet
{
/**
* Sticker set name
*/
name: String;
/**
* Sticker set title
*/
title: String;
/**
* True, if the sticker set contains masks
*/
contains_masks: Boolean;
/**
* List of all set stickers
*/
stickers: Sticker[];
}
/**
* This object describes the position on faces where a mask should be
* placed by default.
*/
export type MaskPosition
{
/**
* The part of the face relative to which the mask should be placed. One of
* `forehead`, `eyes`, `mouth`, or `chin`.
*/
point: String;
/**
* Shift by X-axis measured in widths of the mask scaled to the face size,
* from left to right. For example, choosing -1.0 will place mask just to
* the left of the default mask position.
*/
x_shift: Float number;
/**
* Shift by Y-axis measured in heights of the mask scaled to the face size,
* from top to bottom. For example, 1.0 will place the mask just below the
* default mask position.
*/
y_shift: Float number;
/**
* Mask scaling coefficient. For example, 2.0 means double size.
*/
scale: Float number;
}
/**
* Use this method to send .webp stickers. On success, the sent Message is returned.
*/
export type sendSticker
{
/**
* Unique identifier for the target chat or username of the target channel
* (in the format @channelusername)
*/
chat_id: Integer or String;
/**
* Sticker 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 .webp file from the Internet, or upload a new one
* using multipart/form-data. More info on Sending Files »
*/
sticker: InputFile or 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: Integer;
/**
* 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: InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply;
}
/**
* Use this method to get a sticker set. On success, a StickerSet object is returned.
*/
export type getStickerSet
{
/**
* Name of the sticker set
*/
name: String;
}
/**
* Use this method to upload a .png file with a sticker for later use in
* createNewStickerSet and addStickerToSet methods (can be used multiple
* times). Returns the uploaded File on success.
*/
export type uploadStickerFile
{
/**
* User identifier of sticker file owner
*/
user_id: Integer;
/**
* Png image with the sticker, must be up to 512 kilobytes in size,
* dimensions must not exceed 512px, and either width or height must be
* exactly 512px. More info on Sending Files »
*/
png_sticker: InputFile;
}
/**
* Use this method to create new sticker set owned by a user. The bot will
* be able to edit the created sticker set. Returns True on success.
*/
export type createNewStickerSet
{
/**
* User identifier of created sticker set owner
*/
user_id: Integer;
/**
* Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g.,
* animals). Can contain only english letters, digits and underscores. Must
* begin with a letter, can't contain consecutive underscores and must end
* in `_by_<bot username>`. <bot_username> is case insensitive. 1-64 characters.
*/
name: String;
/**
* Sticker set title, 1-64 characters
*/
title: String;
/**
* Png image with the sticker, must be up to 512 kilobytes in size,
* dimensions must not exceed 512px, and either width or height must be
* exactly 512px. Pass a file_id as a String to send a file that already
* exists on the Telegram servers, 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 »
*/
png_sticker: In
VM258:38 /**
* The following methods and objects allow your bot to work in inline mode.
* Please see our Introduction to Inline bots for more details.
*
* To enable this option, send the /setinline command to @BotFather and
* provide the placeholder text that the user will see in the input field
* after typing your bot’s name.
*
* This object represents an incoming inline query. When the user sends an
* empty query, your bot could return some default or trending results.
*/
export type InlineQuery
{
/**
* Unique identifier for this query
*/
id: String;
/**Sender
*/
from: User;
/**
* Optional. Sender location, only for bots that request user location
*/
location: Location;
/**
* Text of the query (up to 512 characters)
*/
query: String;
/**
* Offset of the results to be returned, can be controlled by the bot
*/
offset: String;
}
/**
* Use this method to send answers to an inline query. On success, True is
* returned.
* No more than 50 results per query are allowed.
*/
export type answerInlineQuery
{
/**
* Unique identifier for the answered query
*/
inline_query_id: String;
/**
* A JSON-serialized array of results for the inline query
*/
results: InlineQueryResult[];
/**
* The maximum amount of time in seconds that the result of the inline
* query may be cached on the server. Defaults to 300.
*/
cache_time: Integer;
/**
* Pass True, if results may be cached on the server side only for the user
* that sent the query. By default, results may be returned to any user who
* sends the same query
*/
is_personal: Boolean;
/**
* Pass the offset that a client should send in the next query with the
* same text to receive more results. Pass an empty string if there are no
* more results or if you don‘t support pagination. Offset length can’t
* exceed 64 bytes.
*/
next_offset: String;
/**
* If passed, clients will display a button with specified text that
* switches the user to a private chat with the bot and sends the bot a
* start message with the parameter switch_pm_parameter
*/
switch_pm_text: String;
/**
* Deep-linking parameter for the /start message sent to the bot when user
* presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and -
* are allowed.
* Example: An inline bot that sends YouTube videos can ask the user to
* connect the bot to their YouTube account to adapt search results
* accordingly. To do this, it displays a ‘Connect your YouTube account’
* button above the results, or even before showing any. The user presses
* the button, switches to a private chat with the bot and, in doing so,
* passes a start parameter that instructs the bot to return an oauth link.
* Once done, the bot can offer a switch_inline button so that the user can
* easily return to the chat where they wanted to use the bot's inline capabilities.
*/
switch_pm_parameter: String;
}
/**
* This object represents one result of an inline query. Telegram clients
* currently support results of the following 20 types:
*
* Represents a link to an article or web page.
*/
export type InlineQueryResultexport type InlineQueryResultArticle
{
/**
* Type of the result, must be article
*/
type: String;
/**
* Unique identifier for this result, 1-64 Bytes
*/
id: String;
/**
* Title of the result
*/
title: String;
/**
* Content of the message to be sent
*/
input_message_content: InputMessageContent;
/**
* Optional. Inline keyboard attached to the message
*/
reply_markup: InlineKeyboardMarkup;
/**
* Optional. URL of the result
*/
url: String;
/**
* Optional. Pass True, if you don't want the URL to be shown in the message
*/
hide_url: Boolean;
/**
* Optional. Short description of the result
*/
description: String;
/**
* Optional. Url of the thumbnail for the result
*/
thumb_url: String;
/**
* Optional. Thumbnail width
*/
thumb_width: Integer;
/**
* Optional. Thumbnail height
*/
thumb_height: Integer;
}
/**
* Represents a link to a photo. By default, this photo will be sent by the
* user with optional caption. Alternatively, you can use
* input_message_content to send a message with the specified content
* instead of the photo.
*/
export type InlineQueryResultPhoto
{
/**
* Type of the result, must be photo
*/
type: String;
/**
* Unique identifier for this result, 1-64 bytes
*/
id: String;
/**
* A valid URL of the photo. Photo must be in jpeg format. Photo size must
* not exceed 5MB
*/
photo_url: String;
/**
* URL of the thumbnail for the photo
*/
thumb_url: String;
/**
* Optional. Width of the photo
*/
photo_width: Integer;
/**
* Optional. Height of the photo
*/
photo_height: Integer;
/**
* Optional. Title for the result
VM258:38 /**
* Your bot can accept payments from Telegram users. Please see the
* introduction to payments for more details on the process and how to set
* up payments for your bot. Please note that users will need Telegram
* v.4.0 or higher to use payments (released on May 18, 2017).
*
* Use this method to send invoices. On success, the sent Message is returned.
*/
export type sendInvoice
{
/**
* Unique identifier for the target private chat
*/
chat_id: Integer;
/**
* Product name, 1-32 characters
*/
title: String;
/**
* Product description, 1-255 characters
*/
description: String;
/**
* Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
* the user, use for your internal processes.
*/
payload: String;
/**
* Payments provider token, obtained via Botfather
*/
provider_token: String;
/**
* Unique deep-linking parameter that can be used to generate this invoice
* when used as a start parameter
*/
start_parameter: String;
/**
* Three-letter ISO 4217 currency code, see more on currencies
*/
currency: String;
/**
* Price breakdown, a list of components (e.g. product price, tax,
* discount, delivery cost, delivery tax, bonus, etc.)
*/
prices: LabeledPrice[];
/**
* JSON-encoded data about the invoice, which will be shared with the
* payment provider. A detailed description of required fields should be
* provided by the payment provider.
*/
provider_data: String;
/**
* URL of the product photo for the invoice. Can be a photo of the goods or
* a marketing image for a service. People like it better when they see
* what they are paying for.
*/
photo_url: String;
/**
* Photo size
*/
photo_size: Integer;
/**
* Photo width
*/
photo_width: Integer;
/**
* Photo height
*/
photo_height: Integer;
/**
* Pass True, if you require the user's full name to complete the order
*/
need_name: Boolean;
/**
* Pass True, if you require the user's phone number to complete the order
*/
need_phone_number: Boolean;
/**
* Pass True, if you require the user's email address to complete the order
*/
need_email: Boolean;
/**
* Pass True, if you require the user's shipping address to complete the order
*/
need_shipping_address: Boolean;
/**
* Pass True, if user's phone number should be sent to provider
*/
send_phone_number_to_provider: Boolean;
/**
* Pass True, if user's email address should be sent to provider
*/
send_email_to_provider: Boolean;
/**
* Pass True, if the final price depends on the shipping method
*/
is_flexible: 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: Integer;
/**
* A JSON-serialized object for an inline keyboard. If empty, one 'Pay
* total price' button will be shown. If not empty, the first button must
* be a Pay button.
*/
reply_markup: InlineKeyboardMarkup;
}
/**
* If you sent an invoice requesting a shipping address and the parameter
* is_flexible was specified, the Bot API will send an Update with a
* shipping_query field to the bot. Use this method to reply to shipping
* queries. On success, True is returned.
*/
export type answerShippingQuery
{
/**
* Unique identifier for the query to be answered
*/
shipping_query_id: String;
/**
* Specify True if delivery to the specified address is possible and False
* if there are any problems (for example, if delivery to the specified
* address is not possible)
*/
ok: Boolean;
/**
* Required if ok is True. A JSON-serialized array of available shipping options.
*/
shipping_options: ShippingOption[];
/**
* Required if ok is False. Error message in human readable form that
* explains why it is impossible to complete the order (e.g. "Sorry,
* delivery to your desired address is unavailable'). Telegram will display
* this message to the user.
*/
error_message: String;
}
/**
* Once the user has confirmed their payment and shipping details, the Bot
* API sends the final confirmation in the form of an Update with the field
* pre_checkout_query. Use this method to respond to such pre-checkout
* queries. On success, True is returned. Note: The Bot API must receive an
* answer within 10 seconds after the pre-checkout query was sent.
*/
export type answerPreCheckoutQuery
{
/**
* Unique identifier for the query to be answered
*/
pre_checkout_query_id: String;
/**
* Specify True if everything is alright (goods are available, etc.) and
* the bot is ready to proceed with the order. Use False if there are any problems.
*/
ok: Boolean;
/**
* Required if ok is False. Error message in human readable form that
* expl
VM258:38 /**
* Telegram Passport is a unified authorization method for services that
* require personal identification. Users can upload their documents once,
* then instantly share their data with services that require real-world ID
* (finance, ICOs, etc.). Please see the manual for details.
*
* Contains information about Telegram Passport data shared with the bot by
* the user.
*/
export type PassportData
{
/**
* Array with information about documents and other Telegram Passport
* elements that was shared with the bot
*/
data: EncryptedPassportElement[];
/**
* Encrypted credentials required to decrypt the data
*/
credentials: EncryptedCredentials;
}
/**
* This object represents a file uploaded to Telegram Passport. Currently
* all Telegram Passport files are in JPEG format when decrypted and don't
* exceed 10MB.
*/
export type PassportFile
{
/**
* Unique identifier for this file
*/
file_id: String;
/**
* File size
*/
file_size: Integer;
/**
* Unix time when the file was uploaded
*/
file_date: Integer;
}
/**
* Contains information about documents or other Telegram Passport elements
* shared with the bot by the user.
*/
export type EncryptedPassportElement
{
/**
* Element type. One of `personal_details`, `passport`, `driver_license`,
* `identity_card`, `internal_passport`, `address`, `utility_bill`,
* `bank_statement`, `rental_agreement`, `passport_registration`,
* `temporary_registration`, `phone_number`, `email`.
*/
type: String;
/**
* Optional. Base64-encoded encrypted Telegram Passport element data
* provided by the user, available for `personal_details`, `passport`,
* `driver_license`, `identity_card`, `internal_passport` and `address`
* types. Can be decrypted and verified using the accompanying EncryptedCredentials.
*/
data: String;
/**
* Optional. User's verified phone number, available only for
* `phone_number` type
*/
phone_number: String;
/**
* Optional. User's verified email address, available only for `email` type
*/
email: String;
/**
* Optional. Array of encrypted files with documents provided by the user,
* available for `utility_bill`, `bank_statement`, `rental_agreement`,
* `passport_registration` and `temporary_registration` types. Files can be
* decrypted and verified using the accompanying EncryptedCredentials.
*/
files: PassportFile[];
/**
* Optional. Encrypted file with the front side of the document, provided
* by the user. Available for `passport`, `driver_license`, `identity_card`
* and `internal_passport`. The file can be decrypted and verified using
* the accompanying EncryptedCredentials.
*/
front_side: PassportFile;
/**
* Optional. Encrypted file with the reverse side of the document, provided
* by the user. Available for `driver_license` and `identity_card`. The
* file can be decrypted and verified using the accompanying EncryptedCredentials.
*/
reverse_side: PassportFile;
/**
* Optional. Encrypted file with the selfie of the user holding a document,
* provided by the user; available for `passport`, `driver_license`,
* `identity_card` and `internal_passport`. The file can be decrypted and
* verified using the accompanying EncryptedCredentials.
*/
selfie: PassportFile;
}
/**
* Contains data required for decrypting and authenticating
* EncryptedPassportElement. See the Telegram Passport Documentation for a
* complete description of the data decryption and authentication processes.
*/
export type EncryptedCredentials
{
/**
* Base64-encoded encrypted JSON-serialized data with unique user's
* payload, data hashes and secrets required for EncryptedPassportElement
* decryption and authentication
*/
data: String;
/**
* Base64-encoded data hash for data authentication
*/
hash: String;
/**
* Base64-encoded secret, encrypted with the bot's public RSA key, required
* for data decryption
*/
secret: String;
}
/**
* Informs a user that some of the Telegram Passport elements they provided
* contains errors. 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). Returns True on success.
*
* Use this if the data submitted by the user doesn't satisfy the standards
* your service requires for any reason. For example, if a birthday date
* seems invalid, a submitted document is blurry, a scan shows evidence of
* tampering, etc. Supply some details in the error message to make sure
* the user knows how to correct the issues.
*/
export type setPassportDataErrors
{
/**
* User identifier
*/
user_id: Integer;
/**
* A JSON-serialized array describing the errors
*/
errors: PassportElementError[];
}
/**
* This object represents an error in the Telegram Passport element
VM258:38 /**
* Your bot can offer users HTML5 games to play solo or to compete against
* each other in groups and one-on-one chats. Create games via @BotFather
* using the /newgame command. Please note that this kind of power requires
* responsibility: you will need to accept the terms for each game that
* your bots will be offering.
*
* Use this method to send a game. On success, the sent Message is returned.
*/
export type sendGame
{
/**
* Unique identifier for the target chat
*/
chat_id: Integer;
/**
* Short name of the game, serves as the unique identifier for the game.
* Set up your games via Botfather.
*/
game_short_name: 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: Integer;
/**
* A JSON-serialized object for an inline keyboard. If empty, one ‘Play
* game_title’ button will be shown. If not empty, the first button must
* launch the game.
*/
reply_markup: InlineKeyboardMarkup;
}
/**
* This object represents a game. Use BotFather to create and edit games,
* their short names will act as unique identifiers.
*/
export type Game
{
/**
* Title of the game
*/
title: String;
/**
* Description of the game
*/
description: String;
/**
* Photo that will be displayed in the game message in chats.
*/
photo: PhotoSize[];
/**
* Optional. Brief description of the game or high scores included in the
* game message. Can be automatically edited to include current high scores
* for the game when the bot calls setGameScore, or manually edited using
* editMessageText. 0-4096 characters.
*/
text: String;
/**
* Optional. Special entities that appear in text, such as usernames, URLs,
* bot commands, etc.
*/
text_entities: MessageEntity[];
/**
* Optional. Animation that will be displayed in the game message in chats.
* Upload via BotFather
*/
animation: Animation;
}
/**
* A placeholder, currently holds no information. Use BotFather to set up
* your game.
*
* Use this method to set the score of the specified user in a game. On
* success, if the message was sent by the bot, returns the edited Message,
* otherwise returns True. Returns an error, if the new score is not
* greater than the user's current score in the chat and force is False.
*/
export type CallbackGameexport type setGameScore
{
/**
* User identifier
*/
user_id: Integer;
/**
* New score, must be non-negative
*/
score: Integer;
/**
* Pass True, if the high score is allowed to decrease. This can be useful
* when fixing mistakes or banning cheaters
*/
force: Boolean;
/**
* Pass True, if the game message should not be automatically edited to
* include the current scoreboard
*/
disable_edit_message: Boolean;
/**
* Required if inline_message_id is not specified. Unique identifier for
* the target chat
*/
chat_id: Integer;
/**
* Required if inline_message_id is not specified. Identifier of the sent message
*/
message_id: Integer;
/**
* Required if chat_id and message_id are not specified. Identifier of the
* inline message
*/
inline_message_id: String;
}
/**
* Use this method to get data for high score tables. Will return the score
* of the specified user and several of his neighbors in a game. On
* success, returns an Array of GameHighScore objects.
*/
export type getGameHighScores
{
/**
* Target user id
*/
user_id: Integer;
/**
* Required if inline_message_id is not specified. Unique identifier for
* the target chat
*/
chat_id: Integer;
/**
* Required if inline_message_id is not specified. Identifier of the sent message
*/
message_id: Integer;
/**
* Required if chat_id and message_id are not specified. Identifier of the
* inline message
*/
inline_message_id: String;
}
/**
* This object represents one row of the high scores table for a game.
*/
export type GameHighScore
{
/**
* Position in high score table for the game
*/
position: Integer;
/**User
*/
user: User;
/**Score
*/
score: Integer;
}
Interface with parameters header in table.
https://core.telegram.org/bots/api#passportdata