class BaseCommand {
/**
* Tests message
*
* @param {Scope} scope
* @returns {boolean}
*/
test(scope) {
throw 'Not implemented'
}
/**
* Returns handler method name in controller
*
* @returns {string}
*/
get handlerName() { throw 'Not implemented' }
}
n/a
class BaseLogger {
/**
* Any log
*
* @param {Object} data
*/
log(data) { throw 'Not implemented' }
/**
* Warning log
*
* @param {Object} data
*/
warn(data) { throw 'Not implemented' }
/**
* Error log
*
* @param {Object} data
*/
error(data) { throw 'Not implemented' }
}
n/a
class BaseScopeExtension {
/**
*
* @param {Scope} scope
*/
constructor(scope) { }
/**
* This method will be called by your extension user ( $.yourExtension(args...) )
* @param {...*}
*/
process() { throw 'Not implemented' }
/**
* You should return your extension name here. That name will be in scope. ( $.yourExtensionName )
* @returns {string}
*/
get name() { throw 'Not implemented' }
}
n/a
class BaseStorage {
/**
* @param {string} storage
* @param {string} key
* @returns {Promise<Object>}
*/
get(storage, key) { throw 'Not implemented' }
/**
* @param {string} storage
* @param {string} key
* @param {Object} data
* @returns {Promise<>}
*/
set(storage, key, data) { throw 'Not implemented' }
/**
* @param {string} storage
* @param {string} key
* @returns {Promise<>}
*/
remove(storage, key) { throw 'Not implemented' }
}
n/a
class BaseUpdateFetcher {
/**
* @param {TelegramApi} api
* @param {BaseLogger} logger
*/
constructor(api, logger) {
this._api = api
this._logger = logger
}
/**
* @callback fetchUpdatesCallback
* @param {Update[]} updates
*/
/**
* @param {fetchUpdatesCallback} callback
*/
fetch(callback) { throw 'Not implemented' }
}
n/a
class InlineScope {
/**
*
* @param {Update} update
* @param {TelegramApi} api
*/
constructor(update, api, waitingChosenResults, waitingQueries) {
this._update = update
this._api = api
this._waitingChosenResults = waitingChosenResults
this._waitingQueries = waitingQueries
this._inlineQuery = update.inlineQuery
this._userId = update.inlineQuery.from.id
}
/**
*
* @returns {Update}
*/
get update() {
return this._update
}
/**
*
* @returns {TelegramApi}
*/
get api() {
return this._api
}
/**
*
* @returns {InlineQuery}
*/
get inlineQuery() {
return this._inlineQuery
}
/**
*
* @returns {number}
*/
get userId() {
return this._userId
}
/**
*
* @callback answerCallback
* @param {InlineQueryResult} chosenResult
*/
/**
*
* @param {InlineQueryResult[]} results
* @param {Object} [options]
* @param {answerCallback} [callback]
* @returns Promise<boolean>
*/
answer(results, options, callback) {
results = results.map(result => {
if (!result.id)
result._id = Math.random().toString(36).substring(7)
return result
})
this._api.answerInlineQuery(this._inlineQuery.id, results, options)
.then(() => {
results.forEach(result => {
this._waitingChosenResults[result.id] = () => {
callback(result)
}
})
})
}
/**
*
* @param {InlineQueryResult[]} results
* @param {number} answersPerPage
* @param {answerCallback} callback
*/
answerPaginated(results, answersPerPage, callback) {
let slicedData = results.slice(0, answersPerPage)
this.answer(slicedData, { next_offset: results.length.toString() }, callback)
this._waitingQueries[this._inlineQuery.query + ':' + this._inlineQuery.from.id] = ($) => {
$.answerPaginated(results.slice(answersPerPage), answersPerPage, callback)
}
}
//api methods starts here
/**
*
* @param {string} text
* @param {Object} [options]
* @returns {Promise<Message>}
*/
sendMessage(text, options) {
return this._api.sendMessage(this.userId, text, options)
}
/**
*
* @param {number} fromChatId
* @param {number} messageId
* @param {Object} [options]
* @returns {Promise<Message>}
*/
forwardMessage(fromChatId, messageId, options) {
return this._api.forwardMessage(this.userId, fromChatId, messageId, options)
}
/**
*
* @param {InputFile|Object} photo
* @param {Object} [options]
* @returns {Promise<Message>}
*/
sendPhoto(photo, options) {
return this._api.sendPhoto(this.userId, photo, options)
}
/**
*
* @param {InputFile|Object} audio
* @param {Object} [options]
* @returns {Promise<Message>}
*/
sendAudio(audio, options) {
return this._api.sendAudio(this.userId, audio, options)
}
/**
*
* @param {InputFile|Object} document
* @param {Object} [options]
* @returns {Promise<Message>}
*/
sendDocument(document, options) {
return this._api.sendDocument(this.userId, document, options)
}
/**
*
* @param {InputFile|Object} sticker
* @param {Object} [options]
* @returns {Promise<Message>}
*/
sendSticker(sticker, options) {
return this._api.sendSticker(this.userId, sticker, options)
}
/**
*
* @param {InputFile|Object} video
* @param {Object} [options]
* @returns {Promise<Message>}
*/
sendVideo(video, options) {
return this._api.sendVideo(this.userId, video, options)
}
/**
*
* @param {InputFile|Object} voice
* @param {Object} [options]
* @returns {Promise<Message> ...
n/a
class InputFile {
/**
* @param {string|null} fileId
* @param {string|null} filePath
* @param {string|null} fileUrl
* @param {string|null} fileName
* @private
*/
constructor(fileId, filePath, fileUrl, fileName) {
this._fileId = fileId
this._filePath = filePath
this._fileUrl = fileUrl
this._fileName = fileName
}
/**
*
* @param {string} type
* @param {Object} params
* @returns {Promise<Object>}
*/
prepareRequest(type, params) {
return new Promise((resolve) => {
if (this._fileId) {
params[type] = this._fileId
resolve({ params: params, multipart: null })
}
if (this._fileUrl) {
const filePath = __dirname + '/temp/' + Math.random().toString(36).substring(7) + '.dat'
const wstream = fs.createWriteStream(filePath)
const sendedCallback = () => {
fs.unlink(filePath)
}
wstream.on('finish', () => {
const multipart = { }
multipart[type] = {
value: fs.createReadStream(filePath),
filename: this._fileName || STANDARD_TYPES[type].filename,
contentType: STANDARD_TYPES[type].type
}
resolve({ params: params, multipart: multipart, callback: sendedCallback})
})
req.get({
url: this._fileUrl,
pipe: wstream
})
}
if (this._filePath) {
const multipart = { }
multipart[type] = {
value: fs.createReadStream(this._filePath),
filename: path.basename(this._filePath) || STANDARD_TYPES[type].filename,
contentType: STANDARD_TYPES[type].type
}
resolve({ params: params, multipart: multipart })
}
})
}
/**
* Creates InputFile from plain Object
*
* @param {Object|string} raw
* @returns {InputFile}
*/
static deserialize(raw) {
if (typeof raw == 'string') {
return InputFile.byId(raw)
}
if (raw.url) {
return InputFile.byUrl(raw.url, raw.filename)
}
if (raw.path) {
return InputFile.byFilePath(raw.path)
}
}
/**
* Creates InputFile by file id
*
* @param {string} id
* @returns {InputFile}
*/
static byId(id) {
return new InputFile(id, null, null, null)
}
/**
* Creates InputFile by file path
*
* @param {string} path
* @returns {InputFile}
*/
static byFilePath(path) {
return new InputFile(null, path, null, null)
}
/**
* Creates InputFile by url
*
* @param {string} url
* @param {string} [fileName]
* @returns {InputFile}
*/
static byUrl(url, fileName) {
return new InputFile(null, null, url, fileName)
}
}
n/a
class RegexpCommand extends BaseCommand {
/**
* @param {RegExp} regexp
* @param {string} [handler]
*/
constructor(regexp, handler) {
super()
this._regexp = regexp
this._handler = handler
}
/**
* @param {Scope} scope
* @returns {boolean}
*/
test(scope) {
return scope.message.text && this._regexp.test(scope.message.text)
}
/**
* @returns {string}
*/
get handlerName() {
return this._handler
}
}
n/a
class Scope {
/**
*
* @param {Update} update
* @param {TelegramApi} api
* @param {BaseScopeExtension[]} extensions
* @param {Function[]} waitingRequests
* @param {Object} waitingCallbackQueries
* @param {BaseLogger} logger
* @param {Function} processUpdate
* @param {TelegramSessionStorage} sessionStorage
* @param {Function} waitForUpdate
* @param {Function} waitForCallback
*/
constructor( update, api, extensions, waitingRequests, waitingCallbackQueries, logger, sessionStorage, waitForUpdate, waitForCallback ) {
this._api = api
this._update = update
/**
*
* @type {BaseScopeExtension[]}
* @private
*/
this._extensions = extensions
this._waitingRequests = waitingRequests
this._waitingCallbackQueries = waitingCallbackQueries
this._isEditedMessage = update.editedMessage ? true : false
this._message = update.message || update.editedMessage
this._chatId = this._message.chat.id
this._userId = this._message.from.id
this._fromGroupChat = !(this._userId === this._chatId)
this._logger = logger
this._sessionStorage = sessionStorage
this._waitForUpdate = waitForUpdate
this._waitForCallback = waitForCallback
this._extensions.forEach(extension => {
const extensionInstance = new extension(this)
this[extensionInstance.name] = extensionInstance.process
})
}
/**
* @returns {TelegramSessionStorage}
*/
get sessionStorage() {
return this._sessionStorage
}
/**
* @returns {BaseStorage}
*/
get storage() {
return this._sessionStorage
}
/**
*
* @returns {Update}
*/
get update() {
return this._update
}
/**
*
* @returns {Message}
*/
get message() {
return this._message
}
/**
*
* @returns {number}
*/
get chatId() {
return this._chatId
}
/**
*
* @returns {number}
*/
get userId() {
return this._userId
}
/**
*
* @returns {boolean}
*/
get idFromGroupChat() {
return this._fromGroupChat
}
/**
*
* @returns {TelegramApi}
*/
get api() {
return this._api
}
/**
* @param {string} key
* @returns {Promise.<*>}
*/
getUserSession(key) {
return this._sessionStorage.getUserSession(this.userId, key)
}
/**
* @param {string} key
* @param {*} value
* @returns {Promise}
*/
setUserSession(key, value) {
return this._sessionStorage.setUserSession(this.userId, key, value)
}
/**
* @param {string} key
* @returns {Promise.<*>}
*/
getChatSession(key) {
return this._sessionStorage.getChatSession(this.chatId, key)
}
/**
* @param {string} key
* @param {*} value
* @returns {Promise}
*/
setChatSession(key, value) {
return this._sessionStorage.setChatSession(this.chatId, key, value)
}
/**
*
* @returns {BaseLogger}
*/
get logger() {
return this._logger
}
/**
*
* @returns {boolean}
*/
get isEditedMessage() {
return this._isEditedMessage
}
/**
* After calling this the next update
* from current user will be passed to promise
*
* @returns {Promise<Scope>}
*/
get waitForRequest() {
return new Promise(resolve => {
this._waitingRequests[this.chatId] = resolve
this._waitForUpdate(this.chatId)
})
}
/**
* @callback waitForCallbackQueryCallback
* @param {CallbackQuery} query
*/
/**
* If you send some inline keyboard after that you can call this method,
* pass to it string callback data or array of string or your InlineKeyboardMarkup
* and then whe ...
n/a
class Telegram {
/**
*
* @param {string} token
* @param {{
* logger: BaseLogger,
* storage: BaseStorage,
* localization: Object[],
* workers: number,
* webhook: {url: string, port: number, host: string }
* updateFetcher: BaseUpdateFetcher
* webAdmin: {port: number, host: string}
* }} options
*/
constructor(token, options) {
options = options || {}
this._token = token
this._logger = options.logger || new WebAdminLogger()
this._storage = options.storage || new InMemoryStorage()
this._sharedStorage = new SharedStorage(this._storage)
this._localization = new Ivan(this._sharedStorage, (options.localization || []))
this._webAdminPort = options.webAdmin ? options.webAdmin.port : 7777
this._webAdminHost = options.webAdmin ? options.webAdmin.host : 'localhost'
this._cpus = os.cpus()
this._workersCount = options.workers || this._cpus.length
this._ipc = new TelegramIPC()
this._telegramDataSource = new TelegramDataSource(
new TelegramApi(token, this._logger),
new TelegramRouter(),
this._logger,
new TelegramSessionStorage(this._sharedStorage),
this._localization,
this._ipc
)
this._beforeUpdateFunction = null
this._checkNodeVersion()
this._updatesFetcher = null
if (options.updateFetcher)
this._updatesFetcher = options.updateFetcher
else if (options.webhook) {
this._updatesFetcher = new WebhookUpdateFetcher(
this._telegramDataSource.api,
this._logger,
options.webhook.url,
options.webhook.host,
options.webhook.port,
token
)
}
else {
this._updatesFetcher = new LongPoolingUpdateFetcher(
this._telegramDataSource.api,
this._logger
)
}
this._setup()
}
_checkNodeVersion() {
if (process.version.replace('v', '').split('.')[0] < 6) {
this._logger.error({
'Fatal error': 'Node version must be 6 or greater, please update your Node.js'
})
process.exit()
}
}
_setup() {
if (cluster.isMaster)
this._master()
if (cluster.isWorker)
this._worker()
}
_master() {
this._logger.log({
'Telegram': `Master started, ${this._cpus.length} CPUs found, ${this._workersCount} workers will start`
})
this._waitingUpdates = {} // each worker can ask master to send him next update from specific chat
this._waitingCallbacks = {}
this._workers = {}
this.statistics = new Statistics()
new WebAdmin(
this._webAdminHost,
this._webAdminPort,
__dirname + '/webAdmin/client',
this._logger,
this
)
this._runWorkers()
this._updatesFetcher.fetch(updates => {
this._processUpdates(updates)
})
}
_worker() {
this._updateProcessor = new UpdateProcessorsManager(this._telegramDataSource)
process.on('message', msg => {
if (msg.type == 'update') {
this._processUpdates([Update.deserialize(msg.update)])
return
}
this._sharedStorage.handleMessageFromMaster(msg)
})
}
_fork() {
return cluster.fork()
}
restartWorkers() {
this._logger.log({ 'Telegram': 'restarting workers' })
for (const pid in this._workers) {
if (this._workers[pid])
this._workers[pid].kill()
}
}
/**
* This callback will be called from master process
*
* @param {Function} callback
*/
onMaster(callback) {
if (cluster.isMaster)
callback()
}
_runWorkers() {
for(var i = 0; ...
...
```js
'use strict'
const Telegram = require('telegram-node-bot')
const TelegramBaseController = Telegram.TelegramBaseController
const TextCommand = Telegram.TextCommand
const tg = new Telegram.Telegram('YOUR_TOKEN')
class PingController extends TelegramBaseController {
/**
* @param {Scope} $
*/
pingHandler($) {
$.sendMessage('pong')
...
class TelegramApi {
/**
*
* @param {string} token
* @param {BaseLogger} logger
*/
constructor(token, logger) {
this._token = token
this._url = `https://api.telegram.org/bot${this._token}/`
this._queue = new CallbackQueue(REQUESTS_PER_SECOND)
this._logger = logger
}
/**
*
* @param {string} method
* @returns {string}
* @private
*/
_urlForMethod(method) {
return this._url + method
}
/**
*
* @param {string} method
* @param {object} params
* @param {object} [multipart]
* @returns {Promise<Object>}
*/
call(method, params, multipart) {
return new Promise((resolve, reject) => {
const request = new TelegramApiRequest(method, params, multipart)
this._queue.push(() => {
this._handleRequest(request, resolve, reject)
})
})
}
/**
*
* @param {string} method
* @param {Object} params
* @param {function} type
* @param {object} [multipart]
* @returns {Promise}
* @private
*/
_callWithReturnType(method, params, type, multipart) {
return this.call(method, params, multipart)
.then(response => {
return type.deserialize(response.result)
})
}
/**
*
* @param {TelegramApiRequest }request
* @param {function} resolve
* @param {function} reject
* @private
*/
_handleRequest(request, resolve, reject) {
req.post({
url: this._urlForMethod(request.method),
form: request.multipart ? null : request.params,
query: request.multipart ? request.params : null,
multipart: request.multipart,
json: true
}, (body, response, err) => {
if (!err && response.statusCode == 200 && body) {
resolve(body)
return
}
if (err && err.code) {
this._logger.error({'Network error:': err, 'request': request })
this._retryRequest(request, resolve, reject)
return
}
if (body && body.error_code) {
const error = TelegramApiError.fromResponse(body)
if (error.code == 500) {
this._logger.warn({ 'Got Internal server error from Telegram. Body:': body })
this._retryRequest(request, resolve, reject)
return
}
reject(error)
this._logger.warn({ 'Api error: Body:': body })
return
}
if (err.message === 'Unexpected token < in JSON at position 0') {
this._logger.error({
'api request error: Telegram returned some html instead of json. Body:': body,
'Error:': err
})
this._retryRequest(request, resolve, reject)
return
}
this._logger.error({'api request error: Body:': body, 'Error:': err })
reject(err)
})
}
/**
*
* @param {TelegramApiRequest }request
* @param {function} resolve
* @param {function} reject
* @private
*/
_retryRequest(request, resolve, reject) {
setTimeout(() => {
this._queue.push(() => {
this._logger.log({ 'Retry request': request })
this._handleRequest(request, resolve, reject)
})
}, REQUEST_RETRY_TIMEOUT)
}
/**
*
* @param {string} method
* @param {InputFile|Object} inputFile
* @param {string} type
* @param {Object} params
* @returns {Promise}
* @private
*/
_callWithInputFile(method, inputFile, type, params) {
const file = inputFile instanceof InputFile ? inputFile : InputFile.deserialize(inputFile)
let sentCallback = Function()
return file.prepareRequest(type, params)
.then(prepared => { ...
n/a
class TelegramBaseCallbackQueryController {
/**
* This method of your controller will be called to handle callbackQuery.
*
* @param {CallbackQuery} query
*/
handle(query) { throw 'Not implemented' }
}
n/a
class TelegramBaseController {
constructor() {
this._api = null
this._localization = null
}
/**
* This method of your controller will be called to handle command.
*
* @param {Scope} scope
*/
handle(scope) { throw 'Not implemented' }
/**
* If you want a specific methods of your controller be called for specific commands,
* you should return here an plain object where key is a route and value is name of your method.
* In that case handle method will not be called and scope will be passed to your method.
* Return example: { '/start': 'startMethod' }
*
* @returns {Object}
*/
get routes() { return {} }
/**
* This method will be called before any command handler or handle method.
* You can modify incoming scope and must return it.
* Your modified scope will be passed to controller.
*
* @param {Scope} scope
* @returns {Scope}
*/
before(scope) { return scope }
/**
*
* @param {TelegramApi} api
*/
set api(api) {
this._api = api
}
/**
*
* @param {Ivan} localization
*/
set localization(localization) {
this._localization = localization
}
}
n/a
class TelegramBaseInlineQueryController {
constructor() {
this._api = null
this._localization = null
}
/**
* This method of your controller will be called to handle inline query.
*
* @param {InlineScope} scope
*/
handle(scope) { throw 'Not implemented' }
/**
*
* @param {ChosenInlineResult} result
*/
chosenResult(result) { }
/**
*
* @param {TelegramApi} api
*/
set api(api) {
this._api = api
}
/**
*
* @param {Ivan} localization
*/
set localization(localization) {
this._localization = localization
}
}
n/a
class TextCommand extends BaseCommand {
/**
* @param {string} textPattern
* @param {string} [handler]
*/
constructor(textPattern, handler) {
super()
this._textPattern = textPattern
this._handler = handler
}
/**
* @param {Scope} scope
* @returns {boolean}
*/
test(scope) {
return scope.message.text &&
scope.message.text.indexOf(this._textPattern) > -1
}
/**
* @returns {string}
*/
get handlerName() {
return this._handler
}
}
n/a
class Animation {
/**
*
* @param {string} fileId
* @param {PhotoSize|null} [thumb]
* @param {string|null} [fileName]
* @param {string|null} [mimeType]
* @param {number|null} [fileSize]
*/
constructor(fileId, thumb, fileName, mimeType, fileSize) {
this._fileId = fileId
this._thumb = thumb
this._fileName = fileName
this._mimeType = mimeType
this._fileSize = fileSize
}
/**
* Unique file identifier
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* Animation thumbnail as defined by sender
* @returns {PhotoSize|null}
*/
get thumb() {
return this._thumb
}
/**
* Original animation filename as defined by sender
* @returns {string|null}
*/
get fileName() {
return this._fileName
}
/**
* MIME type of the file as defined by sender
* @returns {string|null}
*/
get mimeType() {
return this._mimeType
}
/**
* File size
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
*
* @param {Object} raw
* @returns {Animation}
*/
static deserialize(raw) {
return new Animation(
raw['file_id'],
raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null,
raw['file_name'] ? raw['file_name'] : null,
raw['mime_type'] ? raw['mime_type'] : null,
raw['file_size'] ? raw['file_size'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
thumb: this.thumb ? this.thumb.serialize() : undefined,
file_name: this.fileName ? this.fileName : undefined,
mime_type: this.mimeType ? this.mimeType : undefined,
file_size: this.fileSize ? this.fileSize : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Audio {
/**
*
* @param {string} fileId
* @param {number} duration
* @param {string|null} [performer]
* @param {string|null} [title]
* @param {string|null} [mimeType]
* @param {number|null} [fileSize]
*/
constructor(fileId, duration, performer, title, mimeType, fileSize) {
this._fileId = fileId
this._duration = duration
this._performer = performer
this._title = title
this._mimeType = mimeType
this._fileSize = fileSize
}
/**
* Unique identifier for this file
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* Duration of the audio in seconds as defined by sender
* @returns {number}
*/
get duration() {
return this._duration
}
/**
* Performer of the audio as defined by sender or by audio tags
* @returns {string|null}
*/
get performer() {
return this._performer
}
/**
* Title of the audio as defined by sender or by audio tags
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* MIME type of the file as defined by sender
* @returns {string|null}
*/
get mimeType() {
return this._mimeType
}
/**
* File size
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
*
* @param {Object} raw
* @returns {Audio}
*/
static deserialize(raw) {
return new Audio(
raw['file_id'],
raw['duration'],
raw['performer'] ? raw['performer'] : null,
raw['title'] ? raw['title'] : null,
raw['mime_type'] ? raw['mime_type'] : null,
raw['file_size'] ? raw['file_size'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
duration: this.duration ? this.duration : undefined,
performer: this.performer ? this.performer : undefined,
title: this.title ? this.title : undefined,
mime_type: this.mimeType ? this.mimeType : undefined,
file_size: this.fileSize ? this.fileSize : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class CallbackQuery {
/**
*
* @param {string} id
* @param {User} from
* @param {Message|null} [message]
* @param {string|null} [inlineMessageId]
* @param {string} chatInstance
* @param {string|null} [data]
* @param {string|null} [gameShortName]
*/
constructor( id, from, message, inlineMessageId, chatInstance, data, gameShortName ) {
this._id = id
this._from = from
this._message = message
this._inlineMessageId = inlineMessageId
this._chatInstance = chatInstance
this._data = data
this._gameShortName = gameShortName
}
/**
* Unique identifier for this query
* @returns {string}
*/
get id() {
return this._id
}
/**
* Sender
* @returns {User}
*/
get from() {
return this._from
}
/**
* Message with the callback button that originated the query. Note that message content and message date will not be available
if the message is too old
* @returns {Message|null}
*/
get message() {
return this._message
}
/**
* Identifier of the message sent via the bot in inline mode, that originated the query.
* @returns {string|null}
*/
get inlineMessageId() {
return this._inlineMessageId
}
/**
* Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high
scores in games.
* @returns {string}
*/
get chatInstance() {
return this._chatInstance
}
/**
* Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field.
* @returns {string|null}
*/
get data() {
return this._data
}
/**
* Short name of a Game to be returned, serves as the unique identifier for the game
* @returns {string|null}
*/
get gameShortName() {
return this._gameShortName
}
/**
*
* @param {Object} raw
* @returns {CallbackQuery}
*/
static deserialize(raw) {
return new CallbackQuery(
raw['id'],
raw['from'] ? User.deserialize(raw['from']) : null,
raw['message'] ? Message.deserialize(raw['message']) : null,
raw['inline_message_id'] ? raw['inline_message_id'] : null,
raw['chat_instance'],
raw['data'] ? raw['data'] : null,
raw['game_short_name'] ? raw['game_short_name'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
id: this.id ? this.id : undefined,
from: this.from ? this.from.serialize() : undefined,
message: this.message ? this.message.serialize() : undefined,
inline_message_id: this.inlineMessageId ? this.inlineMessageId : undefined,
chat_instance: this.chatInstance ? this.chatInstance : undefined,
data: this.data ? this.data : undefined,
game_short_name: this.gameShortName ? this.gameShortName : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Chat {
/**
*
* @param {number} id
* @param {string} type
* @param {string|null} [title]
* @param {string|null} [username]
* @param {string|null} [firstName]
* @param {string|null} [lastName]
* @param {boolean|null} [allMembersAreAdministrators]
*/
constructor( id, type, title, username, firstName, lastName, allMembersAreAdministrators ) {
this._id = id
this._type = type
this._title = title
this._username = username
this._firstName = firstName
this._lastName = lastName
this._allMembersAreAdministrators = allMembersAreAdministrators
}
/**
* 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 smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe
for storing this identifier.
* @returns {number}
*/
get id() {
return this._id
}
/**
* Type of chat, can be either “private”, “group”, “supergroup” or “channel”
* @returns {string}
*/
get type() {
return this._type
}
/**
* Title, for supergroups, channels and group chats
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* Username, for private chats, supergroups and channels if available
* @returns {string|null}
*/
get username() {
return this._username
}
/**
* First name of the other party in a private chat
* @returns {string|null}
*/
get firstName() {
return this._firstName
}
/**
* Last name of the other party in a private chat
* @returns {string|null}
*/
get lastName() {
return this._lastName
}
/**
* True if a group has ‘All Members Are Admins’ enabled.
* @returns {boolean|null}
*/
get allMembersAreAdministrators() {
return this._allMembersAreAdministrators
}
/**
*
* @param {Object} raw
* @returns {Chat}
*/
static deserialize(raw) {
return new Chat(
raw['id'],
raw['type'],
raw['title'] ? raw['title'] : null,
raw['username'] ? raw['username'] : null,
raw['first_name'] ? raw['first_name'] : null,
raw['last_name'] ? raw['last_name'] : null,
raw['all_members_are_administrators'] ? raw['all_members_are_administrators'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
id: this.id ? this.id : undefined,
type: this.type ? this.type : undefined,
title: this.title ? this.title : undefined,
username: this.username ? this.username : undefined,
first_name: this.firstName ? this.firstName : undefined,
last_name: this.lastName ? this.lastName : undefined,
all_members_are_administrators: this.allMembersAreAdministrators ? this.allMembersAreAdministrators : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class ChatMember {
/**
*
* @param {User} user
* @param {string} status
*/
constructor(user, status) {
this._user = user
this._status = status
}
/**
* Information about the user
* @returns {User}
*/
get user() {
return this._user
}
/**
* The member's status in the chat. Can be “creator”, “administrator”, “member”, “left” or “kicked”
* @returns {string}
*/
get status() {
return this._status
}
/**
*
* @param {Object} raw
* @returns {ChatMember}
*/
static deserialize(raw) {
return new ChatMember(raw['user'] ? User.deserialize(raw['user']) : null, raw['status'])
}
/**
*
* @returns {Object}
*/
serialize() {
return {
user: this.user ? this.user.serialize() : undefined,
status: this.status ? this.status : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class ChosenInlineResult {
/**
*
* @param {string} resultId
* @param {User} from
* @param {Location|null} [location]
* @param {string|null} [inlineMessageId]
* @param {string} query
*/
constructor(resultId, from, location, inlineMessageId, query) {
this._resultId = resultId
this._from = from
this._location = location
this._inlineMessageId = inlineMessageId
this._query = query
}
/**
* The unique identifier for the result that was chosen
* @returns {string}
*/
get resultId() {
return this._resultId
}
/**
* The user that chose the result
* @returns {User}
*/
get from() {
return this._from
}
/**
* Sender location, only for bots that require user location
* @returns {Location|null}
*/
get location() {
return this._location
}
/**
* Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also
received in callback queries and can be used to edit the message.
* @returns {string|null}
*/
get inlineMessageId() {
return this._inlineMessageId
}
/**
* The query that was used to obtain the result
* @returns {string}
*/
get query() {
return this._query
}
/**
*
* @param {Object} raw
* @returns {ChosenInlineResult}
*/
static deserialize(raw) {
return new ChosenInlineResult(
raw['result_id'],
raw['from'] ? User.deserialize(raw['from']) : null,
raw['location'] ? Location.deserialize(raw['location']) : null,
raw['inline_message_id'] ? raw['inline_message_id'] : null,
raw['query']
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
result_id: this.resultId ? this.resultId : undefined,
from: this.from ? this.from.serialize() : undefined,
location: this.location ? this.location.serialize() : undefined,
inline_message_id: this.inlineMessageId ? this.inlineMessageId : undefined,
query: this.query ? this.query : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Contact {
/**
*
* @param {string} phoneNumber
* @param {string} firstName
* @param {string|null} [lastName]
* @param {number|null} [userId]
*/
constructor(phoneNumber, firstName, lastName, userId) {
this._phoneNumber = phoneNumber
this._firstName = firstName
this._lastName = lastName
this._userId = userId
}
/**
* Contact's phone number
* @returns {string}
*/
get phoneNumber() {
return this._phoneNumber
}
/**
* Contact's first name
* @returns {string}
*/
get firstName() {
return this._firstName
}
/**
* Contact's last name
* @returns {string|null}
*/
get lastName() {
return this._lastName
}
/**
* Contact's user identifier in Telegram
* @returns {number|null}
*/
get userId() {
return this._userId
}
/**
*
* @param {Object} raw
* @returns {Contact}
*/
static deserialize(raw) {
return new Contact(raw['phone_number'], raw['first_name'], raw['last_name'] ? raw['last_name'] : null, raw['user_id'] ? raw
['user_id'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
phone_number: this.phoneNumber ? this.phoneNumber : undefined,
first_name: this.firstName ? this.firstName : undefined,
last_name: this.lastName ? this.lastName : undefined,
user_id: this.userId ? this.userId : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Document {
/**
*
* @param {string} fileId
* @param {PhotoSize|null} [thumb]
* @param {string|null} [fileName]
* @param {string|null} [mimeType]
* @param {number|null} [fileSize]
*/
constructor(fileId, thumb, fileName, mimeType, fileSize) {
this._fileId = fileId
this._thumb = thumb
this._fileName = fileName
this._mimeType = mimeType
this._fileSize = fileSize
}
/**
* Unique file identifier
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* Document thumbnail as defined by sender
* @returns {PhotoSize|null}
*/
get thumb() {
return this._thumb
}
/**
* Original filename as defined by sender
* @returns {string|null}
*/
get fileName() {
return this._fileName
}
/**
* MIME type of the file as defined by sender
* @returns {string|null}
*/
get mimeType() {
return this._mimeType
}
/**
* File size
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
*
* @param {Object} raw
* @returns {Document}
*/
static deserialize(raw) {
return new Document(
raw['file_id'],
raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null,
raw['file_name'] ? raw['file_name'] : null,
raw['mime_type'] ? raw['mime_type'] : null,
raw['file_size'] ? raw['file_size'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
thumb: this.thumb ? this.thumb.serialize() : undefined,
file_name: this.fileName ? this.fileName : undefined,
mime_type: this.mimeType ? this.mimeType : undefined,
file_size: this.fileSize ? this.fileSize : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class File {
/**
*
* @param {string} fileId
* @param {number|null} [fileSize]
* @param {string|null} [filePath]
*/
constructor(fileId, fileSize, filePath) {
this._fileId = fileId
this._fileSize = fileSize
this._filePath = filePath
}
/**
* Unique identifier for this file
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* File size, if known
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
* File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
* @returns {string|null}
*/
get filePath() {
return this._filePath
}
/**
*
* @param {Object} raw
* @returns {File}
*/
static deserialize(raw) {
return new File(raw['file_id'], raw['file_size'] ? raw['file_size'] : null, raw['file_path'] ? raw['file_path'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
file_size: this.fileSize ? this.fileSize : undefined,
file_path: this.filePath ? this.filePath : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class ForceReply {
/**
*
* @param {boolean} forceReply
* @param {boolean|null} [selective]
*/
constructor(forceReply, selective) {
this._forceReply = forceReply
this._selective = selective
}
/**
* Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'
* @returns {boolean}
*/
get forceReply() {
return this._forceReply
}
/**
* Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text
of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
* @returns {boolean|null}
*/
get selective() {
return this._selective
}
/**
*
* @param {Object} raw
* @returns {ForceReply}
*/
static deserialize(raw) {
return new ForceReply(raw['force_reply'], raw['selective'] ? raw['selective'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
force_reply: this.forceReply ? this.forceReply : undefined,
selective: this.selective ? this.selective : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Game {
/**
*
* @param {string} title
* @param {string} description
* @param {PhotoSize[]} photo
* @param {string|null} [text]
* @param {MessageEntity[]|null} [textEntities]
* @param {Animation|null} [animation]
*/
constructor(title, description, photo, text, textEntities, animation) {
this._title = title
this._description = description
this._photo = photo
this._text = text
this._textEntities = textEntities
this._animation = animation
}
/**
* Title of the game
* @returns {string}
*/
get title() {
return this._title
}
/**
* Description of the game
* @returns {string}
*/
get description() {
return this._description
}
/**
* Photo that will be displayed in the game message in chats.
* @returns {PhotoSize[]}
*/
get photo() {
return this._photo
}
/**
* 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.
* @returns {string|null}
*/
get text() {
return this._text
}
/**
* Special entities that appear in text, such as usernames, URLs, bot commands, etc.
* @returns {MessageEntity[]|null}
*/
get textEntities() {
return this._textEntities
}
/**
* Animation that will be displayed in the game message in chats. Upload via BotFather
* @returns {Animation|null}
*/
get animation() {
return this._animation
}
/**
*
* @param {Object} raw
* @returns {Game}
*/
static deserialize(raw) {
return new Game(
raw['title'],
raw['description'],
raw['photo'] ? raw['photo'].map(item => PhotoSize.deserialize(item)) : null,
raw['text'] ? raw['text'] : null,
raw['text_entities'] ? raw['text_entities'].map(item => MessageEntity.deserialize(item)) : null,
raw['animation'] ? Animation.deserialize(raw['animation']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
title: this.title ? this.title : undefined,
description: this.description ? this.description : undefined,
photo: this.photo ? this.photo.map(item => item.serialize()) : undefined,
text: this.text ? this.text : undefined,
text_entities: this.textEntities ? this.textEntities.map(item => item.serialize()) : undefined,
animation: this.animation ? this.animation.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class GameHighScore {
/**
*
* @param {number} position
* @param {User} user
* @param {number} score
*/
constructor(position, user, score) {
this._position = position
this._user = user
this._score = score
}
/**
* Position in high score table for the game
* @returns {number}
*/
get position() {
return this._position
}
/**
* User
* @returns {User}
*/
get user() {
return this._user
}
/**
* Score
* @returns {number}
*/
get score() {
return this._score
}
/**
*
* @param {Object} raw
* @returns {GameHighScore}
*/
static deserialize(raw) {
return new GameHighScore(raw['position'], raw['user'] ? User.deserialize(raw['user']) : null, raw['score'])
}
/**
*
* @returns {Object}
*/
serialize() {
return {
position: this.position ? this.position : undefined,
user: this.user ? this.user.serialize() : undefined,
score: this.score ? this.score : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineKeyboardButton {
/**
*
* @param {string} text
* @param {string|null} [url]
* @param {string|null} [callbackData]
* @param {string|null} [switchInlineQuery]
* @param {string|null} [switchInlineQueryCurrentChat]
* @param {CallbackGame|null} [callbackGame]
*/
constructor(text, url, callbackData, switchInlineQuery, switchInlineQueryCurrentChat, callbackGame) {
this._text = text
this._url = url
this._callbackData = callbackData
this._switchInlineQuery = switchInlineQuery
this._switchInlineQueryCurrentChat = switchInlineQueryCurrentChat
this._callbackGame = callbackGame
}
/**
* Label text on the button
* @returns {string}
*/
get text() {
return this._text
}
/**
* HTTP url to be opened when button is pressed
* @returns {string|null}
*/
get url() {
return this._url
}
/**
* Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes
* @returns {string|null}
*/
get callbackData() {
return this._callbackData
}
/**
* If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username
and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.Note: This
offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially
useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from
, skipping the chat selection screen.
* @returns {string|null}
*/
get switchInlineQuery() {
return this._switchInlineQuery
}
/**
* If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field
. Can be empty, in which case only the bot’s username will be inserted.This offers a quick way for the user to open your bot in
inline mode in the same chat – good for selecting something from multiple options.
* @returns {string|null}
*/
get switchInlineQueryCurrentChat() {
return this._switchInlineQueryCurrentChat
}
/**
* Description of the game that will be launched when the user presses the button.NOTE: This type of button must always be the
first button in the first row.
* @returns {CallbackGame|null}
*/
get callbackGame() {
return this._callbackGame
}
/**
*
* @param {Object} raw
* @returns {InlineKeyboardButton}
*/
static deserialize(raw) {
return new InlineKeyboardButton(
raw['text'],
raw['url'] ? raw['url'] : null,
raw['callback_data'] ? raw['callback_data'] : null,
raw['switch_inline_query'] ? raw['switch_inline_query'] : null,
raw['switch_inline_query_current_chat'] ? raw['switch_inline_query_current_chat'] : null,
raw['callback_game'] ? CallbackGame.deserialize(raw['callback_game']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
text: this.text ? this.text : undefined,
url: this.url ? this.url : undefined,
callback_data: this.callbackData ? this.callbackData : undefined,
switch_inline_query: this.switchInlineQuery ? this.switchInlineQuery : undefined,
switch_inline_query_current_chat: this.switchInlineQueryCurrentChat ? this.switchInlineQueryCurrentChat : undefined,
callback_game: this.callbackGame ? this.callbackGame.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineKeyboardMarkup {
/**
*
* @param {InlineKeyboardButton[][]} inlineKeyboard
*/
constructor(inlineKeyboard) {
this._inlineKeyboard = inlineKeyboard
}
/**
* Array of button rows, each represented by an Array of InlineKeyboardButton objects
* @returns {InlineKeyboardButton[][]}
*/
get inlineKeyboard() {
return this._inlineKeyboard
}
/**
*
* @param {Object} raw
* @returns {InlineKeyboardMarkup}
*/
static deserialize(raw) {
return new InlineKeyboardMarkup(raw['inline_keyboard'] ? raw['inline_keyboard'].map(arr => arr.map(item => InlineKeyboardButton
.deserialize(item))) : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
inline_keyboard: this.inlineKeyboard ? this.inlineKeyboard.map(arr => arr.map(item => item.serialize())) : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQuery {
/**
*
* @param {string} id
* @param {User} from
* @param {Location|null} [location]
* @param {string} query
* @param {string} offset
*/
constructor(id, from, location, query, offset) {
this._id = id
this._from = from
this._location = location
this._query = query
this._offset = offset
}
/**
* Unique identifier for this query
* @returns {string}
*/
get id() {
return this._id
}
/**
* Sender
* @returns {User}
*/
get from() {
return this._from
}
/**
* Sender location, only for bots that request user location
* @returns {Location|null}
*/
get location() {
return this._location
}
/**
* Text of the query (up to 512 characters)
* @returns {string}
*/
get query() {
return this._query
}
/**
* Offset of the results to be returned, can be controlled by the bot
* @returns {string}
*/
get offset() {
return this._offset
}
/**
*
* @param {Object} raw
* @returns {InlineQuery}
*/
static deserialize(raw) {
return new InlineQuery(
raw['id'],
raw['from'] ? User.deserialize(raw['from']) : null,
raw['location'] ? Location.deserialize(raw['location']) : null,
raw['query'],
raw['offset']
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
id: this.id ? this.id : undefined,
from: this.from ? this.from.serialize() : undefined,
location: this.location ? this.location.serialize() : undefined,
query: this.query ? this.query : undefined,
offset: this.offset ? this.offset : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResult { toJSON() { } get id() { } }
n/a
class InlineQueryResultArticle extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} title
* @param {InputMessageContent} inputMessageContent
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {string|null} [url]
* @param {boolean|null} [hideUrl]
* @param {string|null} [description]
* @param {string|null} [thumbUrl]
* @param {number|null} [thumbWidth]
* @param {number|null} [thumbHeight]
*/
constructor( type, id, title, inputMessageContent, replyMarkup, url, hideUrl, description, thumbUrl, thumbWidth, thumbHeight ) {
super()
this._type = type
this._id = id
this._title = title
this._inputMessageContent = inputMessageContent
this._replyMarkup = replyMarkup
this._url = url
this._hideUrl = hideUrl
this._description = description
this._thumbUrl = thumbUrl
this._thumbWidth = thumbWidth
this._thumbHeight = thumbHeight
}
/**
* Type of the result, must be article
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 Bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* Title of the result
* @returns {string}
*/
get title() {
return this._title
}
/**
* Content of the message to be sent
* @returns {InputMessageContent}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* URL of the result
* @returns {string|null}
*/
get url() {
return this._url
}
/**
* Pass True, if you don't want the URL to be shown in the message
* @returns {boolean|null}
*/
get hideUrl() {
return this._hideUrl
}
/**
* Short description of the result
* @returns {string|null}
*/
get description() {
return this._description
}
/**
* Url of the thumbnail for the result
* @returns {string|null}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Thumbnail width
* @returns {number|null}
*/
get thumbWidth() {
return this._thumbWidth
}
/**
* Thumbnail height
* @returns {number|null}
*/
get thumbHeight() {
return this._thumbHeight
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultArticle}
*/
static deserialize(raw) {
return new InlineQueryResultArticle(
raw['type'],
raw['id'],
raw['title'],
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['url'] ? raw['url'] : null,
raw['hide_url'] ? raw['hide_url'] : null,
raw['description'] ? raw['description'] : null,
raw['thumb_url'] ? raw['thumb_url'] : null,
raw['thumb_width'] ? raw['thumb_width'] : null,
raw['thumb_height'] ? raw['thumb_height'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
title: this.title ? this.title : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
url: this.url ? this.url : undefined,
hide_url: this.hideUrl ? this.hideUrl : undefined,
description: this.description ? this.description : undefined,
thumb_url: this.thumbUrl ? this.thumbUrl : undefined,
thumb_width: this.thumbWidth ? this ...
n/a
class InlineQueryResultAudio extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} audioUrl
* @param {string} title
* @param {string|null} [caption]
* @param {string|null} [performer]
* @param {number|null} [audioDuration]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, audioUrl, title, caption, performer, audioDuration, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._audioUrl = audioUrl
this._title = title
this._caption = caption
this._performer = performer
this._audioDuration = audioDuration
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be audio
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid URL for the audio file
* @returns {string}
*/
get audioUrl() {
return this._audioUrl
}
/**
* Title
* @returns {string}
*/
get title() {
return this._title
}
/**
* Caption, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Performer
* @returns {string|null}
*/
get performer() {
return this._performer
}
/**
* Audio duration in seconds
* @returns {number|null}
*/
get audioDuration() {
return this._audioDuration
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the audio
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultAudio}
*/
static deserialize(raw) {
return new InlineQueryResultAudio(
raw['type'],
raw['id'],
raw['audio_url'],
raw['title'],
raw['caption'] ? raw['caption'] : null,
raw['performer'] ? raw['performer'] : null,
raw['audio_duration'] ? raw['audio_duration'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
audio_url: this.audioUrl ? this.audioUrl : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
performer: this.performer ? this.performer : undefined,
audio_duration: this.audioDuration ? this.audioDuration : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedAudio extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} audioFileId
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor(type, id, audioFileId, caption, replyMarkup, inputMessageContent) {
super()
this._type = type
this._id = id
this._audioFileId = audioFileId
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be audio
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid file identifier for the audio file
* @returns {string}
*/
get audioFileId() {
return this._audioFileId
}
/**
* Caption, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the audio
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedAudio}
*/
static deserialize(raw) {
return new InlineQueryResultCachedAudio(
raw['type'],
raw['id'],
raw['audio_file_id'],
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
audio_file_id: this.audioFileId ? this.audioFileId : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedDocument extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} title
* @param {string} documentFileId
* @param {string|null} [description]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, title, documentFileId, description, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._title = title
this._documentFileId = documentFileId
this._description = description
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be document
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* Title for the result
* @returns {string}
*/
get title() {
return this._title
}
/**
* A valid file identifier for the file
* @returns {string}
*/
get documentFileId() {
return this._documentFileId
}
/**
* Short description of the result
* @returns {string|null}
*/
get description() {
return this._description
}
/**
* Caption of the document to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the file
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedDocument}
*/
static deserialize(raw) {
return new InlineQueryResultCachedDocument(
raw['type'],
raw['id'],
raw['title'],
raw['document_file_id'],
raw['description'] ? raw['description'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
title: this.title ? this.title : undefined,
document_file_id: this.documentFileId ? this.documentFileId : undefined,
description: this.description ? this.description : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedGif extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} gifFileId
* @param {string|null} [title]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, gifFileId, title, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._gifFileId = gifFileId
this._title = title
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be gif
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid file identifier for the GIF file
* @returns {string}
*/
get gifFileId() {
return this._gifFileId
}
/**
* Title for the result
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* Caption of the GIF file to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the GIF animation
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedGif}
*/
static deserialize(raw) {
return new InlineQueryResultCachedGif(
raw['type'],
raw['id'],
raw['gif_file_id'],
raw['title'] ? raw['title'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
gif_file_id: this.gifFileId ? this.gifFileId : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} mpeg4FileId
* @param {string|null} [title]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, mpeg4FileId, title, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._mpeg4FileId = mpeg4FileId
this._title = title
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be mpeg4_gif
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid file identifier for the MP4 file
* @returns {string}
*/
get mpeg4FileId() {
return this._mpeg4FileId
}
/**
* Title for the result
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* Caption of the MPEG-4 file to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the video animation
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedMpeg4Gif}
*/
static deserialize(raw) {
return new InlineQueryResultCachedMpeg4Gif(
raw['type'],
raw['id'],
raw['mpeg4_file_id'],
raw['title'] ? raw['title'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
mpeg4_file_id: this.mpeg4FileId ? this.mpeg4FileId : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedPhoto extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} photoFileId
* @param {string|null} [title]
* @param {string|null} [description]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, photoFileId, title, description, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._photoFileId = photoFileId
this._title = title
this._description = description
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be photo
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid file identifier of the photo
* @returns {string}
*/
get photoFileId() {
return this._photoFileId
}
/**
* Title for the result
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* Short description of the result
* @returns {string|null}
*/
get description() {
return this._description
}
/**
* Caption of the photo to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the photo
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedPhoto}
*/
static deserialize(raw) {
return new InlineQueryResultCachedPhoto(
raw['type'],
raw['id'],
raw['photo_file_id'],
raw['title'] ? raw['title'] : null,
raw['description'] ? raw['description'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
photo_file_id: this.photoFileId ? this.photoFileId : undefined,
title: this.title ? this.title : undefined,
description: this.description ? this.description : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedSticker extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} stickerFileId
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor(type, id, stickerFileId, replyMarkup, inputMessageContent) {
super()
this._type = type
this._id = id
this._stickerFileId = stickerFileId
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be sticker
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid file identifier of the sticker
* @returns {string}
*/
get stickerFileId() {
return this._stickerFileId
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the sticker
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedSticker}
*/
static deserialize(raw) {
return new InlineQueryResultCachedSticker(
raw['type'],
raw['id'],
raw['sticker_file_id'],
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
sticker_file_id: this.stickerFileId ? this.stickerFileId : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedVideo extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} videoFileId
* @param {string} title
* @param {string|null} [description]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, videoFileId, title, description, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._videoFileId = videoFileId
this._title = title
this._description = description
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be video
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid file identifier for the video file
* @returns {string}
*/
get videoFileId() {
return this._videoFileId
}
/**
* Title for the result
* @returns {string}
*/
get title() {
return this._title
}
/**
* Short description of the result
* @returns {string|null}
*/
get description() {
return this._description
}
/**
* Caption of the video to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the video
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedVideo}
*/
static deserialize(raw) {
return new InlineQueryResultCachedVideo(
raw['type'],
raw['id'],
raw['video_file_id'],
raw['title'],
raw['description'] ? raw['description'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
video_file_id: this.videoFileId ? this.videoFileId : undefined,
title: this.title ? this.title : undefined,
description: this.description ? this.description : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultCachedVoice extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} voiceFileId
* @param {string} title
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, voiceFileId, title, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._voiceFileId = voiceFileId
this._title = title
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be voice
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid file identifier for the voice message
* @returns {string}
*/
get voiceFileId() {
return this._voiceFileId
}
/**
* Voice message title
* @returns {string}
*/
get title() {
return this._title
}
/**
* Caption, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the voice message
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultCachedVoice}
*/
static deserialize(raw) {
return new InlineQueryResultCachedVoice(
raw['type'],
raw['id'],
raw['voice_file_id'],
raw['title'],
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
voice_file_id: this.voiceFileId ? this.voiceFileId : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultContact extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} phoneNumber
* @param {string} firstName
* @param {string|null} [lastName]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
* @param {string|null} [thumbUrl]
* @param {number|null} [thumbWidth]
* @param {number|null} [thumbHeight]
*/
constructor( type, id, phoneNumber, firstName, lastName, replyMarkup, inputMessageContent, thumbUrl, thumbWidth, thumbHeight ) {
super()
this._type = type
this._id = id
this._phoneNumber = phoneNumber
this._firstName = firstName
this._lastName = lastName
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
this._thumbUrl = thumbUrl
this._thumbWidth = thumbWidth
this._thumbHeight = thumbHeight
}
/**
* Type of the result, must be contact
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 Bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* Contact's phone number
* @returns {string}
*/
get phoneNumber() {
return this._phoneNumber
}
/**
* Contact's first name
* @returns {string}
*/
get firstName() {
return this._firstName
}
/**
* Contact's last name
* @returns {string|null}
*/
get lastName() {
return this._lastName
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the contact
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
* Url of the thumbnail for the result
* @returns {string|null}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Thumbnail width
* @returns {number|null}
*/
get thumbWidth() {
return this._thumbWidth
}
/**
* Thumbnail height
* @returns {number|null}
*/
get thumbHeight() {
return this._thumbHeight
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultContact}
*/
static deserialize(raw) {
return new InlineQueryResultContact(
raw['type'],
raw['id'],
raw['phone_number'],
raw['first_name'],
raw['last_name'] ? raw['last_name'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null,
raw['thumb_url'] ? raw['thumb_url'] : null,
raw['thumb_width'] ? raw['thumb_width'] : null,
raw['thumb_height'] ? raw['thumb_height'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
phone_number: this.phoneNumber ? this.phoneNumber : undefined,
first_name: this.firstName ? this.firstName : undefined,
last_name: this.lastName ? this.lastName : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined,
thumb_url: this.thumbUrl ? this.thumbUrl : undefined,
thumb_width: this.thumbWidth ? this.thumbWidth : undefined,
thumb_height: this.thumbHeight ? this.thumbHeight : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultDocument extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} title
* @param {string|null} [caption]
* @param {string} documentUrl
* @param {string} mimeType
* @param {string|null} [description]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
* @param {string|null} [thumbUrl]
* @param {number|null} [thumbWidth]
* @param {number|null} [thumbHeight]
*/
constructor( type, id, title, caption, documentUrl, mimeType, description, replyMarkup, inputMessageContent, thumbUrl, thumbWidth, thumbHeight ) {
super()
this._type = type
this._id = id
this._title = title
this._caption = caption
this._documentUrl = documentUrl
this._mimeType = mimeType
this._description = description
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
this._thumbUrl = thumbUrl
this._thumbWidth = thumbWidth
this._thumbHeight = thumbHeight
}
/**
* Type of the result, must be document
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* Title for the result
* @returns {string}
*/
get title() {
return this._title
}
/**
* Caption of the document to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* A valid URL for the file
* @returns {string}
*/
get documentUrl() {
return this._documentUrl
}
/**
* Mime type of the content of the file, either “application/pdf” or “application/zip”
* @returns {string}
*/
get mimeType() {
return this._mimeType
}
/**
* Short description of the result
* @returns {string|null}
*/
get description() {
return this._description
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the file
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
* URL of the thumbnail (jpeg only) for the file
* @returns {string|null}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Thumbnail width
* @returns {number|null}
*/
get thumbWidth() {
return this._thumbWidth
}
/**
* Thumbnail height
* @returns {number|null}
*/
get thumbHeight() {
return this._thumbHeight
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultDocument}
*/
static deserialize(raw) {
return new InlineQueryResultDocument(
raw['type'],
raw['id'],
raw['title'],
raw['caption'] ? raw['caption'] : null,
raw['document_url'],
raw['mime_type'],
raw['description'] ? raw['description'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null,
raw['thumb_url'] ? raw['thumb_url'] : null,
raw['thumb_width'] ? raw['thumb_width'] : null,
raw['thumb_height'] ? raw['thumb_height'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
document_url: this.documentUrl ? this.documentUrl : undefined, ...
n/a
class InlineQueryResultGame extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} gameShortName
* @param {InlineKeyboardMarkup|null} [replyMarkup]
*/
constructor(type, id, gameShortName, replyMarkup) {
super()
this._type = type
this._id = id
this._gameShortName = gameShortName
this._replyMarkup = replyMarkup
}
/**
* Type of the result, must be game
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* Short name of the game
* @returns {string}
*/
get gameShortName() {
return this._gameShortName
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultGame}
*/
static deserialize(raw) {
return new InlineQueryResultGame(raw['type'], raw['id'], raw['game_short_name'], raw['reply_markup'] ? InlineKeyboardMarkup
.deserialize(raw['reply_markup']) : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
game_short_name: this.gameShortName ? this.gameShortName : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultGif extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} gifUrl
* @param {number|null} [gifWidth]
* @param {number|null} [gifHeight]
* @param {string} thumbUrl
* @param {string|null} [title]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, gifUrl, gifWidth, gifHeight, thumbUrl, title, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._gifUrl = gifUrl
this._gifWidth = gifWidth
this._gifHeight = gifHeight
this._thumbUrl = thumbUrl
this._title = title
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be gif
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid URL for the GIF file. File size must not exceed 1MB
* @returns {string}
*/
get gifUrl() {
return this._gifUrl
}
/**
* Width of the GIF
* @returns {number|null}
*/
get gifWidth() {
return this._gifWidth
}
/**
* Height of the GIF
* @returns {number|null}
*/
get gifHeight() {
return this._gifHeight
}
/**
* URL of the static thumbnail for the result (jpeg or gif)
* @returns {string}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Title for the result
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* Caption of the GIF file to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the GIF animation
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultGif}
*/
static deserialize(raw) {
return new InlineQueryResultGif(
raw['type'],
raw['id'],
raw['gif_url'],
raw['gif_width'] ? raw['gif_width'] : null,
raw['gif_height'] ? raw['gif_height'] : null,
raw['thumb_url'],
raw['title'] ? raw['title'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
gif_url: this.gifUrl ? this.gifUrl : undefined,
gif_width: this.gifWidth ? this.gifWidth : undefined,
gif_height: this.gifHeight ? this.gifHeight : undefined,
thumb_url: this.thumbUrl ? this.thumbUrl : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultLocation extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {number} latitude
* @param {number} longitude
* @param {string} title
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
* @param {string|null} [thumbUrl]
* @param {number|null} [thumbWidth]
* @param {number|null} [thumbHeight]
*/
constructor( type, id, latitude, longitude, title, replyMarkup, inputMessageContent, thumbUrl, thumbWidth, thumbHeight ) {
super()
this._type = type
this._id = id
this._latitude = latitude
this._longitude = longitude
this._title = title
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
this._thumbUrl = thumbUrl
this._thumbWidth = thumbWidth
this._thumbHeight = thumbHeight
}
/**
* Type of the result, must be location
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 Bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* Location latitude in degrees
* @returns {number}
*/
get latitude() {
return this._latitude
}
/**
* Location longitude in degrees
* @returns {number}
*/
get longitude() {
return this._longitude
}
/**
* Location title
* @returns {string}
*/
get title() {
return this._title
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the location
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
* Url of the thumbnail for the result
* @returns {string|null}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Thumbnail width
* @returns {number|null}
*/
get thumbWidth() {
return this._thumbWidth
}
/**
* Thumbnail height
* @returns {number|null}
*/
get thumbHeight() {
return this._thumbHeight
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultLocation}
*/
static deserialize(raw) {
return new InlineQueryResultLocation(
raw['type'],
raw['id'],
raw['latitude'],
raw['longitude'],
raw['title'],
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null,
raw['thumb_url'] ? raw['thumb_url'] : null,
raw['thumb_width'] ? raw['thumb_width'] : null,
raw['thumb_height'] ? raw['thumb_height'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
latitude: this.latitude ? this.latitude : undefined,
longitude: this.longitude ? this.longitude : undefined,
title: this.title ? this.title : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined,
thumb_url: this.thumbUrl ? this.thumbUrl : undefined,
thumb_width: this.thumbWidth ? this.thumbWidth : undefined,
thumb_height: this.thumbHeight ? this.thumbHeight : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultMpeg4Gif extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} mpeg4Url
* @param {number|null} [mpeg4Width]
* @param {number|null} [mpeg4Height]
* @param {string} thumbUrl
* @param {string|null} [title]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, mpeg4Url, mpeg4Width, mpeg4Height, thumbUrl, title, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._mpeg4Url = mpeg4Url
this._mpeg4Width = mpeg4Width
this._mpeg4Height = mpeg4Height
this._thumbUrl = thumbUrl
this._title = title
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be mpeg4_gif
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid URL for the MP4 file. File size must not exceed 1MB
* @returns {string}
*/
get mpeg4Url() {
return this._mpeg4Url
}
/**
* Video width
* @returns {number|null}
*/
get mpeg4Width() {
return this._mpeg4Width
}
/**
* Video height
* @returns {number|null}
*/
get mpeg4Height() {
return this._mpeg4Height
}
/**
* URL of the static thumbnail (jpeg or gif) for the result
* @returns {string}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Title for the result
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* Caption of the MPEG-4 file to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the video animation
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultMpeg4Gif}
*/
static deserialize(raw) {
return new InlineQueryResultMpeg4Gif(
raw['type'],
raw['id'],
raw['mpeg4_url'],
raw['mpeg4_width'] ? raw['mpeg4_width'] : null,
raw['mpeg4_height'] ? raw['mpeg4_height'] : null,
raw['thumb_url'],
raw['title'] ? raw['title'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
mpeg4_url: this.mpeg4Url ? this.mpeg4Url : undefined,
mpeg4_width: this.mpeg4Width ? this.mpeg4Width : undefined,
mpeg4_height: this.mpeg4Height ? this.mpeg4Height : undefined,
thumb_url: this.thumbUrl ? this.thumbUrl : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InlineQueryResultPhoto extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} photoUrl
* @param {string} thumbUrl
* @param {number|null} [photoWidth]
* @param {number|null} [photoHeight]
* @param {string|null} [title]
* @param {string|null} [description]
* @param {string|null} [caption]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, photoUrl, thumbUrl, photoWidth, photoHeight, title, description, caption, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._photoUrl = photoUrl
this._thumbUrl = thumbUrl
this._photoWidth = photoWidth
this._photoHeight = photoHeight
this._title = title
this._description = description
this._caption = caption
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be photo
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid URL of the photo. Photo must be in jpeg format. Photo size must not exceed 5MB
* @returns {string}
*/
get photoUrl() {
return this._photoUrl
}
/**
* URL of the thumbnail for the photo
* @returns {string}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Width of the photo
* @returns {number|null}
*/
get photoWidth() {
return this._photoWidth
}
/**
* Height of the photo
* @returns {number|null}
*/
get photoHeight() {
return this._photoHeight
}
/**
* Title for the result
* @returns {string|null}
*/
get title() {
return this._title
}
/**
* Short description of the result
* @returns {string|null}
*/
get description() {
return this._description
}
/**
* Caption of the photo to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the photo
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultPhoto}
*/
static deserialize(raw) {
return new InlineQueryResultPhoto(
raw['type'],
raw['id'],
raw['photo_url'],
raw['thumb_url'],
raw['photo_width'] ? raw['photo_width'] : null,
raw['photo_height'] ? raw['photo_height'] : null,
raw['title'] ? raw['title'] : null,
raw['description'] ? raw['description'] : null,
raw['caption'] ? raw['caption'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
photo_url: this.photoUrl ? this.photoUrl : undefined,
thumb_url: this.thumbUrl ? this.thumbUrl : undefined,
photo_width: this.photoWidth ? this.photoWidth : undefined,
photo_height: this.photoHeight ? this.photoHeight : undefined,
title: this.title ? this.title : undefined,
description: this.description ? this.description : undefined,
caption: this.caption ? this.caption : undefined, ...
n/a
class InlineQueryResultVenue extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {number} latitude
* @param {number} longitude
* @param {string} title
* @param {string} address
* @param {string|null} [foursquareId]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
* @param {string|null} [thumbUrl]
* @param {number|null} [thumbWidth]
* @param {number|null} [thumbHeight]
*/
constructor( type, id, latitude, longitude, title, address, foursquareId, replyMarkup, inputMessageContent, thumbUrl, thumbWidth, thumbHeight ) {
super()
this._type = type
this._id = id
this._latitude = latitude
this._longitude = longitude
this._title = title
this._address = address
this._foursquareId = foursquareId
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
this._thumbUrl = thumbUrl
this._thumbWidth = thumbWidth
this._thumbHeight = thumbHeight
}
/**
* Type of the result, must be venue
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 Bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* Latitude of the venue location in degrees
* @returns {number}
*/
get latitude() {
return this._latitude
}
/**
* Longitude of the venue location in degrees
* @returns {number}
*/
get longitude() {
return this._longitude
}
/**
* Title of the venue
* @returns {string}
*/
get title() {
return this._title
}
/**
* Address of the venue
* @returns {string}
*/
get address() {
return this._address
}
/**
* Foursquare identifier of the venue if known
* @returns {string|null}
*/
get foursquareId() {
return this._foursquareId
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the venue
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
* Url of the thumbnail for the result
* @returns {string|null}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Thumbnail width
* @returns {number|null}
*/
get thumbWidth() {
return this._thumbWidth
}
/**
* Thumbnail height
* @returns {number|null}
*/
get thumbHeight() {
return this._thumbHeight
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultVenue}
*/
static deserialize(raw) {
return new InlineQueryResultVenue(
raw['type'],
raw['id'],
raw['latitude'],
raw['longitude'],
raw['title'],
raw['address'],
raw['foursquare_id'] ? raw['foursquare_id'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null,
raw['thumb_url'] ? raw['thumb_url'] : null,
raw['thumb_width'] ? raw['thumb_width'] : null,
raw['thumb_height'] ? raw['thumb_height'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
latitude: this.latitude ? this.latitude : undefined,
longitude: this.longitude ? this.longitude : undefined,
title: this.title ? this.title : undefined,
address: this.address ? this.address : undefined,
foursquare_id: this.foursquareId ? this.fou ...
n/a
class InlineQueryResultVideo extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} videoUrl
* @param {string} mimeType
* @param {string} thumbUrl
* @param {string} title
* @param {string|null} [caption]
* @param {number|null} [videoWidth]
* @param {number|null} [videoHeight]
* @param {number|null} [videoDuration]
* @param {string|null} [description]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, videoUrl, mimeType, thumbUrl, title, caption, videoWidth, videoHeight, videoDuration, description, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._videoUrl = videoUrl
this._mimeType = mimeType
this._thumbUrl = thumbUrl
this._title = title
this._caption = caption
this._videoWidth = videoWidth
this._videoHeight = videoHeight
this._videoDuration = videoDuration
this._description = description
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be video
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid URL for the embedded video player or video file
* @returns {string}
*/
get videoUrl() {
return this._videoUrl
}
/**
* Mime type of the content of video url, “text/html” or “video/mp4”
* @returns {string}
*/
get mimeType() {
return this._mimeType
}
/**
* URL of the thumbnail (jpeg only) for the video
* @returns {string}
*/
get thumbUrl() {
return this._thumbUrl
}
/**
* Title for the result
* @returns {string}
*/
get title() {
return this._title
}
/**
* Caption of the video to be sent, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Video width
* @returns {number|null}
*/
get videoWidth() {
return this._videoWidth
}
/**
* Video height
* @returns {number|null}
*/
get videoHeight() {
return this._videoHeight
}
/**
* Video duration in seconds
* @returns {number|null}
*/
get videoDuration() {
return this._videoDuration
}
/**
* Short description of the result
* @returns {string|null}
*/
get description() {
return this._description
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the video
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultVideo}
*/
static deserialize(raw) {
return new InlineQueryResultVideo(
raw['type'],
raw['id'],
raw['video_url'],
raw['mime_type'],
raw['thumb_url'],
raw['title'],
raw['caption'] ? raw['caption'] : null,
raw['video_width'] ? raw['video_width'] : null,
raw['video_height'] ? raw['video_height'] : null,
raw['video_duration'] ? raw['video_duration'] : null,
raw['description'] ? raw['description'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undef ...
n/a
class InlineQueryResultVoice extends InlineQueryResult {
/**
*
* @param {string} type
* @param {string} id
* @param {string} voiceUrl
* @param {string} title
* @param {string|null} [caption]
* @param {number|null} [voiceDuration]
* @param {InlineKeyboardMarkup|null} [replyMarkup]
* @param {InputMessageContent|null} [inputMessageContent]
*/
constructor( type, id, voiceUrl, title, caption, voiceDuration, replyMarkup, inputMessageContent ) {
super()
this._type = type
this._id = id
this._voiceUrl = voiceUrl
this._title = title
this._caption = caption
this._voiceDuration = voiceDuration
this._replyMarkup = replyMarkup
this._inputMessageContent = inputMessageContent
}
/**
* Type of the result, must be voice
* @returns {string}
*/
get type() {
return this._type
}
/**
* Unique identifier for this result, 1-64 bytes
* @returns {string}
*/
get id() {
return this._id
}
/**
* A valid URL for the voice recording
* @returns {string}
*/
get voiceUrl() {
return this._voiceUrl
}
/**
* Recording title
* @returns {string}
*/
get title() {
return this._title
}
/**
* Caption, 0-200 characters
* @returns {string|null}
*/
get caption() {
return this._caption
}
/**
* Recording duration in seconds
* @returns {number|null}
*/
get voiceDuration() {
return this._voiceDuration
}
/**
* Inline keyboard attached to the message
* @returns {InlineKeyboardMarkup|null}
*/
get replyMarkup() {
return this._replyMarkup
}
/**
* Content of the message to be sent instead of the voice recording
* @returns {InputMessageContent|null}
*/
get inputMessageContent() {
return this._inputMessageContent
}
/**
*
* @param {Object} raw
* @returns {InlineQueryResultVoice}
*/
static deserialize(raw) {
return new InlineQueryResultVoice(
raw['type'],
raw['id'],
raw['voice_url'],
raw['title'],
raw['caption'] ? raw['caption'] : null,
raw['voice_duration'] ? raw['voice_duration'] : null,
raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null,
raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
id: this.id ? this.id : undefined,
voice_url: this.voiceUrl ? this.voiceUrl : undefined,
title: this.title ? this.title : undefined,
caption: this.caption ? this.caption : undefined,
voice_duration: this.voiceDuration ? this.voiceDuration : undefined,
reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined,
input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InputContactMessageContent extends InputMessageContent {
/**
*
* @param {string} phoneNumber
* @param {string} firstName
* @param {string|null} [lastName]
*/
constructor(phoneNumber, firstName, lastName) {
super()
this._phoneNumber = phoneNumber
this._firstName = firstName
this._lastName = lastName
}
/**
* Contact's phone number
* @returns {string}
*/
get phoneNumber() {
return this._phoneNumber
}
/**
* Contact's first name
* @returns {string}
*/
get firstName() {
return this._firstName
}
/**
* Contact's last name
* @returns {string|null}
*/
get lastName() {
return this._lastName
}
/**
*
* @param {Object} raw
* @returns {InputContactMessageContent}
*/
static deserialize(raw) {
return new InputContactMessageContent(raw['phone_number'], raw['first_name'], raw['last_name'] ? raw['last_name'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
phone_number: this.phoneNumber ? this.phoneNumber : undefined,
first_name: this.firstName ? this.firstName : undefined,
last_name: this.lastName ? this.lastName : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InputLocationMessageContent extends InputMessageContent {
/**
*
* @param {number} latitude
* @param {number} longitude
*/
constructor(latitude, longitude) {
super()
this._latitude = latitude
this._longitude = longitude
}
/**
* Latitude of the location in degrees
* @returns {number}
*/
get latitude() {
return this._latitude
}
/**
* Longitude of the location in degrees
* @returns {number}
*/
get longitude() {
return this._longitude
}
/**
*
* @param {Object} raw
* @returns {InputLocationMessageContent}
*/
static deserialize(raw) {
return new InputLocationMessageContent(raw['latitude'], raw['longitude'])
}
/**
*
* @returns {Object}
*/
serialize() {
return {
latitude: this.latitude ? this.latitude : undefined,
longitude: this.longitude ? this.longitude : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InputMessageContent {
/**
*
* @param {Object} raw
* @returns {InputTextMessageContent|InputVenueMessageContent|InputContactMessageContent|InputLocationMessageContent}
*/
static deserialize(raw) {
switch (raw) {
case raw.message_text:
return require('./InputTextMessageContent').deserialize(raw)
case raw.latitude && raw.title:
return require('./InputVenueMessageContent').deserialize(raw)
case raw.phone_number:
return require('./InputContactMessageContent').deserialize(raw)
case raw.latitude:
return require('./InputLocationMessageContent').deserialize(raw)
}
}
}
n/a
class InputTextMessageContent extends InputMessageContent {
/**
*
* @param {string} messageText
* @param {string|null} [parseMode]
* @param {boolean|null} [disableWebPagePreview]
*/
constructor(messageText, parseMode, disableWebPagePreview) {
super()
this._messageText = messageText
this._parseMode = parseMode
this._disableWebPagePreview = disableWebPagePreview
}
/**
* Text of the message to be sent, 1-4096 characters
* @returns {string}
*/
get messageText() {
return this._messageText
}
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message
.
* @returns {string|null}
*/
get parseMode() {
return this._parseMode
}
/**
* Disables link previews for links in the sent message
* @returns {boolean|null}
*/
get disableWebPagePreview() {
return this._disableWebPagePreview
}
/**
*
* @param {Object} raw
* @returns {InputTextMessageContent}
*/
static deserialize(raw) {
return new InputTextMessageContent(raw['message_text'], raw['parse_mode'] ? raw['parse_mode'] : null, raw['disable_web_page_preview
'] ? raw['disable_web_page_preview'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
message_text: this.messageText ? this.messageText : undefined,
parse_mode: this.parseMode ? this.parseMode : undefined,
disable_web_page_preview: this.disableWebPagePreview ? this.disableWebPagePreview : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class InputVenueMessageContent extends InputMessageContent {
/**
*
* @param {number} latitude
* @param {number} longitude
* @param {string} title
* @param {string} address
* @param {string|null} [foursquareId]
*/
constructor(latitude, longitude, title, address, foursquareId) {
super()
this._latitude = latitude
this._longitude = longitude
this._title = title
this._address = address
this._foursquareId = foursquareId
}
/**
* Latitude of the venue in degrees
* @returns {number}
*/
get latitude() {
return this._latitude
}
/**
* Longitude of the venue in degrees
* @returns {number}
*/
get longitude() {
return this._longitude
}
/**
* Name of the venue
* @returns {string}
*/
get title() {
return this._title
}
/**
* Address of the venue
* @returns {string}
*/
get address() {
return this._address
}
/**
* Foursquare identifier of the venue, if known
* @returns {string|null}
*/
get foursquareId() {
return this._foursquareId
}
/**
*
* @param {Object} raw
* @returns {InputVenueMessageContent}
*/
static deserialize(raw) {
return new InputVenueMessageContent(
raw['latitude'],
raw['longitude'],
raw['title'],
raw['address'],
raw['foursquare_id'] ? raw['foursquare_id'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
latitude: this.latitude ? this.latitude : undefined,
longitude: this.longitude ? this.longitude : undefined,
title: this.title ? this.title : undefined,
address: this.address ? this.address : undefined,
foursquare_id: this.foursquareId ? this.foursquareId : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class KeyboardButton {
/**
*
* @param {string} text
* @param {boolean|null} [requestContact]
* @param {boolean|null} [requestLocation]
*/
constructor(text, requestContact, requestLocation) {
this._text = text
this._requestContact = requestContact
this._requestLocation = requestLocation
}
/**
* Text of the button. If none of the optional fields are used, it will be sent to the bot as a message when the button is pressed
* @returns {string}
*/
get text() {
return this._text
}
/**
* If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only
* @returns {boolean|null}
*/
get requestContact() {
return this._requestContact
}
/**
* If True, the user's current location will be sent when the button is pressed. Available in private chats only
* @returns {boolean|null}
*/
get requestLocation() {
return this._requestLocation
}
/**
*
* @param {Object} raw
* @returns {KeyboardButton}
*/
static deserialize(raw) {
return new KeyboardButton(raw['text'], raw['request_contact'] ? raw['request_contact'] : null, raw['request_location'] ? raw
['request_location'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
text: this.text ? this.text : undefined,
request_contact: this.requestContact ? this.requestContact : undefined,
request_location: this.requestLocation ? this.requestLocation : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Location {
/**
*
* @param {number} longitude
* @param {number} latitude
*/
constructor(longitude, latitude) {
this._longitude = longitude
this._latitude = latitude
}
/**
* Longitude as defined by sender
* @returns {number}
*/
get longitude() {
return this._longitude
}
/**
* Latitude as defined by sender
* @returns {number}
*/
get latitude() {
return this._latitude
}
/**
*
* @param {Object} raw
* @returns {Location}
*/
static deserialize(raw) {
return new Location(raw['longitude'], raw['latitude'])
}
/**
*
* @returns {Object}
*/
serialize() {
return {
longitude: this.longitude ? this.longitude : undefined,
latitude: this.latitude ? this.latitude : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Message {
/**
*
* @param {number} messageId
* @param {User|null} [from]
* @param {number} date
* @param {Chat} chat
* @param {User|null} [forwardFrom]
* @param {Chat|null} [forwardFromChat]
* @param {number|null} [forwardFromMessageId]
* @param {number|null} [forwardDate]
* @param {Message|null} [replyToMessage]
* @param {number|null} [editDate]
* @param {string|null} [text]
* @param {MessageEntity[]|null} [entities]
* @param {Audio|null} [audio]
* @param {Document|null} [document]
* @param {Game|null} [game]
* @param {PhotoSize[]|null} [photo]
* @param {Sticker|null} [sticker]
* @param {Video|null} [video]
* @param {Voice|null} [voice]
* @param {string|null} [caption]
* @param {Contact|null} [contact]
* @param {Location|null} [location]
* @param {Venue|null} [venue]
* @param {User|null} [newChatMember]
* @param {User|null} [leftChatMember]
* @param {string|null} [newChatTitle]
* @param {PhotoSize[]|null} [newChatPhoto]
* @param {boolean|null} [deleteChatPhoto]
* @param {boolean|null} [groupChatCreated]
* @param {boolean|null} [supergroupChatCreated]
* @param {boolean|null} [channelChatCreated]
* @param {number|null} [migrateToChatId]
* @param {number|null} [migrateFromChatId]
* @param {Message|null} [pinnedMessage]
*/
constructor( messageId, from, date, chat, forwardFrom, forwardFromChat, forwardFromMessageId, forwardDate, replyToMessage, editDate, text, entities, audio, document, game, photo, sticker, video, voice, caption, contact, location, venue, newChatMember, leftChatMember, newChatTitle, newChatPhoto, deleteChatPhoto, groupChatCreated, supergroupChatCreated, channelChatCreated, migrateToChatId, migrateFromChatId, pinnedMessage ) {
this._messageId = messageId
this._from = from
this._date = date
this._chat = chat
this._forwardFrom = forwardFrom
this._forwardFromChat = forwardFromChat
this._forwardFromMessageId = forwardFromMessageId
this._forwardDate = forwardDate
this._replyToMessage = replyToMessage
this._editDate = editDate
this._text = text
this._entities = entities
this._audio = audio
this._document = document
this._game = game
this._photo = photo
this._sticker = sticker
this._video = video
this._voice = voice
this._caption = caption
this._contact = contact
this._location = location
this._venue = venue
this._newChatMember = newChatMember
this._leftChatMember = leftChatMember
this._newChatTitle = newChatTitle
this._newChatPhoto = newChatPhoto
this._deleteChatPhoto = deleteChatPhoto
this._groupChatCreated = groupChatCreated
this._supergroupChatCreated = supergroupChatCreated
this._channelChatCreated = channelChatCreated
this._migrateToChatId = migrateToChatId
this._migrateFromChatId = migrateFromChatId
this._pinnedMessage = pinnedMessage
}
/**
* Unique message identifier inside this chat
* @returns {number}
*/
get messageId() {
return this._messageId
}
/**
* Sender, can be empty for messages sent to channels
* @returns {User|null}
*/
get from() {
return this._from
}
/**
* Date the message was sent in Unix time
* @returns {number}
*/
get date() {
return this._date
}
/**
* Conversation the message belongs to
* @returns {Chat}
*/
get chat() {
return this._chat
}
/**
* For forwarded messages, sender of the original message
* @returns {User|null}
*/
get forwardFrom() {
return this._forwardFrom
}
/**
* For messages forwarded from a channel, information about the original channel ...
n/a
class MessageEntity {
/**
*
* @param {string} type
* @param {number} offset
* @param {number} length
* @param {string|null} [url]
* @param {User|null} [user]
*/
constructor(type, offset, length, url, user) {
this._type = type
this._offset = offset
this._length = length
this._url = url
this._user = user
}
/**
* Type of the entity. Can be mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text),
code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), text_mention (for users without usernames)
* @returns {string}
*/
get type() {
return this._type
}
/**
* Offset in UTF-16 code units to the start of the entity
* @returns {number}
*/
get offset() {
return this._offset
}
/**
* Length of the entity in UTF-16 code units
* @returns {number}
*/
get length() {
return this._length
}
/**
* For “text_link” only, url that will be opened after user taps on the text
* @returns {string|null}
*/
get url() {
return this._url
}
/**
* For “text_mention” only, the mentioned user
* @returns {User|null}
*/
get user() {
return this._user
}
/**
*
* @param {Object} raw
* @returns {MessageEntity}
*/
static deserialize(raw) {
return new MessageEntity(
raw['type'],
raw['offset'],
raw['length'],
raw['url'] ? raw['url'] : null,
raw['user'] ? User.deserialize(raw['user']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
type: this.type ? this.type : undefined,
offset: this.offset ? this.offset : undefined,
length: this.length ? this.length : undefined,
url: this.url ? this.url : undefined,
user: this.user ? this.user.serialize() : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class PhotoSize {
/**
*
* @param {string} fileId
* @param {number} width
* @param {number} height
* @param {number|null} [fileSize]
*/
constructor(fileId, width, height, fileSize) {
this._fileId = fileId
this._width = width
this._height = height
this._fileSize = fileSize
}
/**
* Unique identifier for this file
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* Photo width
* @returns {number}
*/
get width() {
return this._width
}
/**
* Photo height
* @returns {number}
*/
get height() {
return this._height
}
/**
* File size
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
*
* @param {Object} raw
* @returns {PhotoSize}
*/
static deserialize(raw) {
return new PhotoSize(raw['file_id'], raw['width'], raw['height'], raw['file_size'] ? raw['file_size'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
width: this.width ? this.width : undefined,
height: this.height ? this.height : undefined,
file_size: this.fileSize ? this.fileSize : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class ReplyKeyboardMarkup {
/**
*
* @param {KeyboardButton[][]} keyboard
* @param {boolean|null} [resizeKeyboard]
* @param {boolean|null} [oneTimeKeyboard]
* @param {boolean|null} [selective]
*/
constructor(keyboard, resizeKeyboard, oneTimeKeyboard, selective) {
this._keyboard = keyboard
this._resizeKeyboard = resizeKeyboard
this._oneTimeKeyboard = oneTimeKeyboard
this._selective = selective
}
/**
* Array of button rows, each represented by an Array of KeyboardButton objects
* @returns {KeyboardButton[][]}
*/
get keyboard() {
return this._keyboard
}
/**
* Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two
rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard
.
* @returns {boolean|null}
*/
get resizeKeyboard() {
return this._resizeKeyboard
}
/**
* Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically
display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard
again. Defaults to false.
* @returns {boolean|null}
*/
get oneTimeKeyboard() {
return this._oneTimeKeyboard
}
/**
* Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text
of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.Example: A
user requests to change the bot‘s language, bot replies to the request with a keyboard to select the new language. Other users in
the group don’t see the keyboard.
* @returns {boolean|null}
*/
get selective() {
return this._selective
}
/**
*
* @param {Object} raw
* @returns {ReplyKeyboardMarkup}
*/
static deserialize(raw) {
return new ReplyKeyboardMarkup(raw['keyboard'] ? raw['keyboard'].map(arr => arr.map(item => KeyboardButton.deserialize(item
))) : null, raw['resize_keyboard'] ? raw['resize_keyboard'] : null, raw['one_time_keyboard'] ? raw['one_time_keyboard'] : null,
raw['selective'] ? raw['selective'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
keyboard: this.keyboard ? this.keyboard.map(arr => arr.map(item => item.serialize())) : undefined,
resize_keyboard: this.resizeKeyboard ? this.resizeKeyboard : undefined,
one_time_keyboard: this.oneTimeKeyboard ? this.oneTimeKeyboard : undefined,
selective: this.selective ? this.selective : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class ReplyKeyboardRemove {
/**
*
* @param {boolean} removeKeyboard
* @param {boolean|null} [selective]
*/
constructor(removeKeyboard, selective) {
this._removeKeyboard = removeKeyboard
this._selective = selective
}
/**
* Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard
from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)
* @returns {boolean}
*/
get removeKeyboard() {
return this._removeKeyboard
}
/**
* Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the
text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.Example
: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still
showing the keyboard with poll options to users who haven't voted yet.
* @returns {boolean|null}
*/
get selective() {
return this._selective
}
/**
*
* @param {Object} raw
* @returns {ReplyKeyboardRemove}
*/
static deserialize(raw) {
return new ReplyKeyboardRemove(raw['remove_keyboard'], raw['selective'] ? raw['selective'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
remove_keyboard: this.removeKeyboard ? this.removeKeyboard : undefined,
selective: this.selective ? this.selective : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class ResponseParameters {
/**
*
* @param {number|null} [migrateToChatId]
* @param {number|null} [retryAfter]
*/
constructor(migrateToChatId, retryAfter) {
this._migrateToChatId = migrateToChatId
this._retryAfter = retryAfter
}
/**
* The group has been migrated to a supergroup with the specified identifier. 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.
* @returns {number|null}
*/
get migrateToChatId() {
return this._migrateToChatId
}
/**
* In case of exceeding flood control, the number of seconds left to wait before the request can be repeated
* @returns {number|null}
*/
get retryAfter() {
return this._retryAfter
}
/**
*
* @param {Object} raw
* @returns {ResponseParameters}
*/
static deserialize(raw) {
return new ResponseParameters(raw['migrate_to_chat_id'] ? raw['migrate_to_chat_id'] : null, raw['retry_after'] ? raw['retry_after
'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
migrate_to_chat_id: this.migrateToChatId ? this.migrateToChatId : undefined,
retry_after: this.retryAfter ? this.retryAfter : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Sticker {
/**
*
* @param {string} fileId
* @param {number} width
* @param {number} height
* @param {PhotoSize|null} [thumb]
* @param {string|null} [emoji]
* @param {number|null} [fileSize]
*/
constructor(fileId, width, height, thumb, emoji, fileSize) {
this._fileId = fileId
this._width = width
this._height = height
this._thumb = thumb
this._emoji = emoji
this._fileSize = fileSize
}
/**
* Unique identifier for this file
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* Sticker width
* @returns {number}
*/
get width() {
return this._width
}
/**
* Sticker height
* @returns {number}
*/
get height() {
return this._height
}
/**
* Sticker thumbnail in .webp or .jpg format
* @returns {PhotoSize|null}
*/
get thumb() {
return this._thumb
}
/**
* Emoji associated with the sticker
* @returns {string|null}
*/
get emoji() {
return this._emoji
}
/**
* File size
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
*
* @param {Object} raw
* @returns {Sticker}
*/
static deserialize(raw) {
return new Sticker(
raw['file_id'],
raw['width'],
raw['height'],
raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null,
raw['emoji'] ? raw['emoji'] : null,
raw['file_size'] ? raw['file_size'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
width: this.width ? this.width : undefined,
height: this.height ? this.height : undefined,
thumb: this.thumb ? this.thumb.serialize() : undefined,
emoji: this.emoji ? this.emoji : undefined,
file_size: this.fileSize ? this.fileSize : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Update {
/**
*
* @param {number} updateId
* @param {Message|null} [message]
* @param {Message|null} [editedMessage]
* @param {Message|null} [channelPost]
* @param {Message|null} [editedChannelPost]
* @param {InlineQuery|null} [inlineQuery]
* @param {ChosenInlineResult|null} [chosenInlineResult]
* @param {CallbackQuery|null} [callbackQuery]
*/
constructor( updateId, message, editedMessage, channelPost, editedChannelPost, inlineQuery, chosenInlineResult, callbackQuery ) {
this._updateId = updateId
this._message = message
this._editedMessage = editedMessage
this._channelPost = channelPost
this._editedChannelPost = editedChannelPost
this._inlineQuery = inlineQuery
this._chosenInlineResult = chosenInlineResult
this._callbackQuery = callbackQuery
}
/**
* 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.
* @returns {number}
*/
get updateId() {
return this._updateId
}
/**
* New incoming message of any kind — text, photo, sticker, etc.
* @returns {Message|null}
*/
get message() {
return this._message
}
/**
* New version of a message that is known to the bot and was edited
* @returns {Message|null}
*/
get editedMessage() {
return this._editedMessage
}
/**
* New incoming channel post of any kind — text, photo, sticker, etc.
* @returns {Message|null}
*/
get channelPost() {
return this._channelPost
}
/**
* New version of a channel post that is known to the bot and was edited
* @returns {Message|null}
*/
get editedChannelPost() {
return this._editedChannelPost
}
/**
* New incoming inline query
* @returns {InlineQuery|null}
*/
get inlineQuery() {
return this._inlineQuery
}
/**
* The result of an inline query that was chosen by a user and sent to their chat partner.
* @returns {ChosenInlineResult|null}
*/
get chosenInlineResult() {
return this._chosenInlineResult
}
/**
* New incoming callback query
* @returns {CallbackQuery|null}
*/
get callbackQuery() {
return this._callbackQuery
}
/**
*
* @param {Object} raw
* @returns {Update}
*/
static deserialize(raw) {
return new Update(
raw['update_id'],
raw['message'] ? Message.deserialize(raw['message']) : null,
raw['edited_message'] ? Message.deserialize(raw['edited_message']) : null,
raw['channel_post'] ? Message.deserialize(raw['channel_post']) : null,
raw['edited_channel_post'] ? Message.deserialize(raw['edited_channel_post']) : null,
raw['inline_query'] ? InlineQuery.deserialize(raw['inline_query']) : null,
raw['chosen_inline_result'] ? ChosenInlineResult.deserialize(raw['chosen_inline_result']) : null,
raw['callback_query'] ? CallbackQuery.deserialize(raw['callback_query']) : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
update_id: this.updateId ? this.updateId : undefined,
message: this.message ? this.message.serialize() : undefined,
edited_message: this.editedMessage ? this.editedMessage.serialize() : undefined,
channel_post: this.channelPost ? this.channelPost.serialize() : undefined,
edited_channel_post: this.editedChannelPost ? this.editedChannelPost.serialize() : undefined,
inline_query: this.inlineQuery ? this.inlineQuery.serialize() : undefined,
chosen_inline_result: this.chosenInlineResult ? this.chosenInlineResult.serialize() : undefined,
callback_query: this.callbackQuery ? this.callbackQuery.serialize() : undef ...
n/a
class User {
/**
*
* @param {number} id
* @param {string} firstName
* @param {string|null} [lastName]
* @param {string|null} [username]
*/
constructor(id, firstName, lastName, username) {
this._id = id
this._firstName = firstName
this._lastName = lastName
this._username = username
}
/**
* Unique identifier for this user or bot
* @returns {number}
*/
get id() {
return this._id
}
/**
* User‘s or bot’s first name
* @returns {string}
*/
get firstName() {
return this._firstName
}
/**
* User‘s or bot’s last name
* @returns {string|null}
*/
get lastName() {
return this._lastName
}
/**
* User‘s or bot’s username
* @returns {string|null}
*/
get username() {
return this._username
}
/**
*
* @param {Object} raw
* @returns {User}
*/
static deserialize(raw) {
return new User(raw['id'], raw['first_name'], raw['last_name'] ? raw['last_name'] : null, raw['username'] ? raw['username'] :
null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
id: this.id ? this.id : undefined,
first_name: this.firstName ? this.firstName : undefined,
last_name: this.lastName ? this.lastName : undefined,
username: this.username ? this.username : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class UserProfilePhotos {
/**
*
* @param {number} totalCount
* @param {PhotoSize[][]} photos
*/
constructor(totalCount, photos) {
this._totalCount = totalCount
this._photos = photos
}
/**
* Total number of profile pictures the target user has
* @returns {number}
*/
get totalCount() {
return this._totalCount
}
/**
* Requested profile pictures (in up to 4 sizes each)
* @returns {PhotoSize[][]}
*/
get photos() {
return this._photos
}
/**
*
* @param {Object} raw
* @returns {UserProfilePhotos}
*/
static deserialize(raw) {
return new UserProfilePhotos(raw['total_count'], raw['photos'] ? raw['photos'].map(arr => arr.map(item => PhotoSize.deserialize
(item))) : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
total_count: this.totalCount ? this.totalCount : undefined,
photos: this.photos ? this.photos.map(arr => arr.map(item => item.serialize())) : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Venue {
/**
*
* @param {Location} location
* @param {string} title
* @param {string} address
* @param {string|null} [foursquareId]
*/
constructor(location, title, address, foursquareId) {
this._location = location
this._title = title
this._address = address
this._foursquareId = foursquareId
}
/**
* Venue location
* @returns {Location}
*/
get location() {
return this._location
}
/**
* Name of the venue
* @returns {string}
*/
get title() {
return this._title
}
/**
* Address of the venue
* @returns {string}
*/
get address() {
return this._address
}
/**
* Foursquare identifier of the venue
* @returns {string|null}
*/
get foursquareId() {
return this._foursquareId
}
/**
*
* @param {Object} raw
* @returns {Venue}
*/
static deserialize(raw) {
return new Venue(raw['location'] ? Location.deserialize(raw['location']) : null, raw['title'], raw['address'], raw['foursquare_id
'] ? raw['foursquare_id'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
location: this.location ? this.location.serialize() : undefined,
title: this.title ? this.title : undefined,
address: this.address ? this.address : undefined,
foursquare_id: this.foursquareId ? this.foursquareId : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Video {
/**
*
* @param {string} fileId
* @param {number} width
* @param {number} height
* @param {number} duration
* @param {PhotoSize|null} [thumb]
* @param {string|null} [mimeType]
* @param {number|null} [fileSize]
*/
constructor( fileId, width, height, duration, thumb, mimeType, fileSize ) {
this._fileId = fileId
this._width = width
this._height = height
this._duration = duration
this._thumb = thumb
this._mimeType = mimeType
this._fileSize = fileSize
}
/**
* Unique identifier for this file
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* Video width as defined by sender
* @returns {number}
*/
get width() {
return this._width
}
/**
* Video height as defined by sender
* @returns {number}
*/
get height() {
return this._height
}
/**
* Duration of the video in seconds as defined by sender
* @returns {number}
*/
get duration() {
return this._duration
}
/**
* Video thumbnail
* @returns {PhotoSize|null}
*/
get thumb() {
return this._thumb
}
/**
* Mime type of a file as defined by sender
* @returns {string|null}
*/
get mimeType() {
return this._mimeType
}
/**
* File size
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
*
* @param {Object} raw
* @returns {Video}
*/
static deserialize(raw) {
return new Video(
raw['file_id'],
raw['width'],
raw['height'],
raw['duration'],
raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null,
raw['mime_type'] ? raw['mime_type'] : null,
raw['file_size'] ? raw['file_size'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
width: this.width ? this.width : undefined,
height: this.height ? this.height : undefined,
duration: this.duration ? this.duration : undefined,
thumb: this.thumb ? this.thumb.serialize() : undefined,
mime_type: this.mimeType ? this.mimeType : undefined,
file_size: this.fileSize ? this.fileSize : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class Voice {
/**
*
* @param {string} fileId
* @param {number} duration
* @param {string|null} [mimeType]
* @param {number|null} [fileSize]
*/
constructor(fileId, duration, mimeType, fileSize) {
this._fileId = fileId
this._duration = duration
this._mimeType = mimeType
this._fileSize = fileSize
}
/**
* Unique identifier for this file
* @returns {string}
*/
get fileId() {
return this._fileId
}
/**
* Duration of the audio in seconds as defined by sender
* @returns {number}
*/
get duration() {
return this._duration
}
/**
* MIME type of the file as defined by sender
* @returns {string|null}
*/
get mimeType() {
return this._mimeType
}
/**
* File size
* @returns {number|null}
*/
get fileSize() {
return this._fileSize
}
/**
*
* @param {Object} raw
* @returns {Voice}
*/
static deserialize(raw) {
return new Voice(raw['file_id'], raw['duration'], raw['mime_type'] ? raw['mime_type'] : null, raw['file_size'] ? raw['file_size
'] : null)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
file_id: this.fileId ? this.fileId : undefined,
duration: this.duration ? this.duration : undefined,
mime_type: this.mimeType ? this.mimeType : undefined,
file_size: this.fileSize ? this.fileSize : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a
class WebhookInfo {
/**
*
* @param {string} url
* @param {boolean} hasCustomCertificate
* @param {number} pendingUpdateCount
* @param {number|null} [lastErrorDate]
* @param {string|null} [lastErrorMessage]
* @param {number|null} [maxConnections]
* @param {string[]|null} [allowedUpdates]
*/
constructor( url, hasCustomCertificate, pendingUpdateCount, lastErrorDate, lastErrorMessage, maxConnections, allowedUpdates ) {
this._url = url
this._hasCustomCertificate = hasCustomCertificate
this._pendingUpdateCount = pendingUpdateCount
this._lastErrorDate = lastErrorDate
this._lastErrorMessage = lastErrorMessage
this._maxConnections = maxConnections
this._allowedUpdates = allowedUpdates
}
/**
* Webhook URL, may be empty if webhook is not set up
* @returns {string}
*/
get url() {
return this._url
}
/**
* True, if a custom certificate was provided for webhook certificate checks
* @returns {boolean}
*/
get hasCustomCertificate() {
return this._hasCustomCertificate
}
/**
* Number of updates awaiting delivery
* @returns {number}
*/
get pendingUpdateCount() {
return this._pendingUpdateCount
}
/**
* Unix time for the most recent error that happened when trying to deliver an update via webhook
* @returns {number|null}
*/
get lastErrorDate() {
return this._lastErrorDate
}
/**
* Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
* @returns {string|null}
*/
get lastErrorMessage() {
return this._lastErrorMessage
}
/**
* Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
* @returns {number|null}
*/
get maxConnections() {
return this._maxConnections
}
/**
* A list of update types the bot is subscribed to. Defaults to all update types
* @returns {string[]|null}
*/
get allowedUpdates() {
return this._allowedUpdates
}
/**
*
* @param {Object} raw
* @returns {WebhookInfo}
*/
static deserialize(raw) {
return new WebhookInfo(
raw['url'],
raw['has_custom_certificate'],
raw['pending_update_count'],
raw['last_error_date'] ? raw['last_error_date'] : null,
raw['last_error_message'] ? raw['last_error_message'] : null,
raw['max_connections'] ? raw['max_connections'] : null,
raw['allowed_updates'] ? raw['allowed_updates'] : null
)
}
/**
*
* @returns {Object}
*/
serialize() {
return {
url: this.url ? this.url : undefined,
has_custom_certificate: this.hasCustomCertificate ? this.hasCustomCertificate : undefined,
pending_update_count: this.pendingUpdateCount ? this.pendingUpdateCount : undefined,
last_error_date: this.lastErrorDate ? this.lastErrorDate : undefined,
last_error_message: this.lastErrorMessage ? this.lastErrorMessage : undefined,
max_connections: this.maxConnections ? this.maxConnections : undefined,
allowed_updates: this.allowedUpdates ? this.allowedUpdates : undefined
}
}
/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}
n/a