From b5a048c48cdd0301832fea91cff70fc884ef8b29 Mon Sep 17 00:00:00 2001 From: OmidS Date: Sat, 12 Nov 2016 15:49:39 -0800 Subject: [PATCH 1/6] fixes chatSession key names --- lib/storage/session/TelegramSessionStorage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/storage/session/TelegramSessionStorage.js b/lib/storage/session/TelegramSessionStorage.js index 91ee43c..dbc5e4e 100755 --- a/lib/storage/session/TelegramSessionStorage.js +++ b/lib/storage/session/TelegramSessionStorage.js @@ -47,7 +47,7 @@ class TelegramSessionStorage { getChatSession(chatId, key) { return this._storage.get( CHAT_STORAGE, - this._generateKeyForUserSession(chatId, key) + this._generateKeyForChatSession(chatId, key) ) } @@ -60,7 +60,7 @@ class TelegramSessionStorage { setChatSession(chatId, key, value) { return this._storage.set( CHAT_STORAGE, - this._generateKeyForUserSession(chatId, key), + this._generateKeyForChatSession(chatId, key), value ) } From a3800177ca14d3a95ae9592a3b39f80b3f25fbf8 Mon Sep 17 00:00:00 2001 From: OmidS Date: Sat, 12 Nov 2016 15:52:49 -0800 Subject: [PATCH 2/6] fixes chatSession key names --- lib/storage/session/TelegramSessionStorage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/storage/session/TelegramSessionStorage.js b/lib/storage/session/TelegramSessionStorage.js index 91ee43c..dbc5e4e 100755 --- a/lib/storage/session/TelegramSessionStorage.js +++ b/lib/storage/session/TelegramSessionStorage.js @@ -47,7 +47,7 @@ class TelegramSessionStorage { getChatSession(chatId, key) { return this._storage.get( CHAT_STORAGE, - this._generateKeyForUserSession(chatId, key) + this._generateKeyForChatSession(chatId, key) ) } @@ -60,7 +60,7 @@ class TelegramSessionStorage { setChatSession(chatId, key, value) { return this._storage.set( CHAT_STORAGE, - this._generateKeyForUserSession(chatId, key), + this._generateKeyForChatSession(chatId, key), value ) } From 7c6b25a1a5158068f4aa050cfb822a8442465ec4 Mon Sep 17 00:00:00 2001 From: OmidS Date: Sat, 12 Nov 2016 16:14:03 -0800 Subject: [PATCH 3/6] [TEMP] commits all models for ease of use --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index deac8af..c694d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ .idea/ node_modules docs -lib/models/* -!lib/models/InlineQueryResult.js -!lib/models/InputMessageContent.js -!lib/models/CallbackGame.js ScreenShot.png \ No newline at end of file From 625ec41b119b3fbf0de0eb607949ce3a49ae1df9 Mon Sep 17 00:00:00 2001 From: OmidS Date: Sat, 12 Nov 2016 16:14:09 -0800 Subject: [PATCH 4/6] [TEMP] commits all models for ease of use --- lib/models/Animation.js | 104 ++++ lib/models/Audio.js | 114 ++++ lib/models/CallbackQuery.js | 137 +++++ lib/models/Chat.js | 134 +++++ lib/models/ChatMember.js | 65 +++ lib/models/ChosenInlineResult.js | 105 ++++ lib/models/Contact.js | 85 +++ lib/models/Document.js | 104 ++++ lib/models/File.js | 74 +++ lib/models/ForceReply.js | 63 +++ lib/models/Game.js | 118 +++++ lib/models/GameHighScore.js | 76 +++ lib/models/InlineKeyboardButton.js | 116 +++++ lib/models/InlineKeyboardMarkup.js | 54 ++ lib/models/InlineQuery.js | 105 ++++ lib/models/InlineQueryResultArticle.js | 190 +++++++ lib/models/InlineQueryResultAudio.js | 164 ++++++ lib/models/InlineQueryResultCachedAudio.js | 118 +++++ lib/models/InlineQueryResultCachedDocument.js | 151 ++++++ lib/models/InlineQueryResultCachedGif.js | 138 +++++ lib/models/InlineQueryResultCachedMpeg4Gif.js | 138 +++++ lib/models/InlineQueryResultCachedPhoto.js | 151 ++++++ lib/models/InlineQueryResultCachedSticker.js | 106 ++++ lib/models/InlineQueryResultCachedVideo.js | 151 ++++++ lib/models/InlineQueryResultCachedVoice.js | 138 +++++ lib/models/InlineQueryResultContact.js | 177 +++++++ lib/models/InlineQueryResultDocument.js | 203 ++++++++ lib/models/InlineQueryResultGame.js | 88 ++++ lib/models/InlineQueryResultGif.js | 177 +++++++ lib/models/InlineQueryResultLocation.js | 177 +++++++ lib/models/InlineQueryResultMpeg4Gif.js | 177 +++++++ lib/models/InlineQueryResultPhoto.js | 190 +++++++ lib/models/InlineQueryResultVenue.js | 203 ++++++++ lib/models/InlineQueryResultVideo.js | 216 ++++++++ lib/models/InlineQueryResultVoice.js | 151 ++++++ lib/models/InputContactMessageContent.js | 76 +++ lib/models/InputLocationMessageContent.js | 65 +++ lib/models/InputTextMessageContent.js | 76 +++ lib/models/InputVenueMessageContent.js | 104 ++++ lib/models/KeyboardButton.js | 74 +++ lib/models/Location.js | 63 +++ lib/models/Message.js | 486 ++++++++++++++++++ lib/models/MessageEntity.js | 104 ++++ lib/models/Models.js | 59 +++ lib/models/PhotoSize.js | 85 +++ lib/models/ReplyKeyboardHide.js | 63 +++ lib/models/ReplyKeyboardMarkup.js | 87 ++++ lib/models/ResponseParameters.js | 63 +++ lib/models/Sticker.js | 116 +++++ lib/models/Update.js | 119 +++++ lib/models/User.js | 85 +++ lib/models/UserProfilePhotos.js | 65 +++ lib/models/Venue.js | 87 ++++ lib/models/Video.js | 136 +++++ lib/models/Voice.js | 85 +++ lib/models/WebhookInfo.js | 102 ++++ 56 files changed, 6858 insertions(+) create mode 100644 lib/models/Animation.js create mode 100644 lib/models/Audio.js create mode 100644 lib/models/CallbackQuery.js create mode 100644 lib/models/Chat.js create mode 100644 lib/models/ChatMember.js create mode 100644 lib/models/ChosenInlineResult.js create mode 100644 lib/models/Contact.js create mode 100644 lib/models/Document.js create mode 100644 lib/models/File.js create mode 100644 lib/models/ForceReply.js create mode 100644 lib/models/Game.js create mode 100644 lib/models/GameHighScore.js create mode 100644 lib/models/InlineKeyboardButton.js create mode 100644 lib/models/InlineKeyboardMarkup.js create mode 100644 lib/models/InlineQuery.js create mode 100644 lib/models/InlineQueryResultArticle.js create mode 100644 lib/models/InlineQueryResultAudio.js create mode 100644 lib/models/InlineQueryResultCachedAudio.js create mode 100644 lib/models/InlineQueryResultCachedDocument.js create mode 100644 lib/models/InlineQueryResultCachedGif.js create mode 100644 lib/models/InlineQueryResultCachedMpeg4Gif.js create mode 100644 lib/models/InlineQueryResultCachedPhoto.js create mode 100644 lib/models/InlineQueryResultCachedSticker.js create mode 100644 lib/models/InlineQueryResultCachedVideo.js create mode 100644 lib/models/InlineQueryResultCachedVoice.js create mode 100644 lib/models/InlineQueryResultContact.js create mode 100644 lib/models/InlineQueryResultDocument.js create mode 100644 lib/models/InlineQueryResultGame.js create mode 100644 lib/models/InlineQueryResultGif.js create mode 100644 lib/models/InlineQueryResultLocation.js create mode 100644 lib/models/InlineQueryResultMpeg4Gif.js create mode 100644 lib/models/InlineQueryResultPhoto.js create mode 100644 lib/models/InlineQueryResultVenue.js create mode 100644 lib/models/InlineQueryResultVideo.js create mode 100644 lib/models/InlineQueryResultVoice.js create mode 100644 lib/models/InputContactMessageContent.js create mode 100644 lib/models/InputLocationMessageContent.js create mode 100644 lib/models/InputTextMessageContent.js create mode 100644 lib/models/InputVenueMessageContent.js create mode 100644 lib/models/KeyboardButton.js create mode 100644 lib/models/Location.js create mode 100644 lib/models/Message.js create mode 100644 lib/models/MessageEntity.js create mode 100644 lib/models/Models.js create mode 100644 lib/models/PhotoSize.js create mode 100644 lib/models/ReplyKeyboardHide.js create mode 100644 lib/models/ReplyKeyboardMarkup.js create mode 100644 lib/models/ResponseParameters.js create mode 100644 lib/models/Sticker.js create mode 100644 lib/models/Update.js create mode 100644 lib/models/User.js create mode 100644 lib/models/UserProfilePhotos.js create mode 100644 lib/models/Venue.js create mode 100644 lib/models/Video.js create mode 100644 lib/models/Voice.js create mode 100644 lib/models/WebhookInfo.js diff --git a/lib/models/Animation.js b/lib/models/Animation.js new file mode 100644 index 0000000..2035b36 --- /dev/null +++ b/lib/models/Animation.js @@ -0,0 +1,104 @@ +'use strict' + +const PhotoSize = require('./PhotoSize') + +/** + * You can provide an animation for your game so that it looks stylish in chats (check out Lumberjack for an example). This object represents an animation file to be displayed in the message containing a game. + */ + +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() + } +} + +module.exports = Animation \ No newline at end of file diff --git a/lib/models/Audio.js b/lib/models/Audio.js new file mode 100644 index 0000000..1676b86 --- /dev/null +++ b/lib/models/Audio.js @@ -0,0 +1,114 @@ +'use strict' + +/** + * This object represents an audio file to be treated as music by the Telegram clients. + */ + +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() + } +} + +module.exports = Audio \ No newline at end of file diff --git a/lib/models/CallbackQuery.js b/lib/models/CallbackQuery.js new file mode 100644 index 0000000..7eb401f --- /dev/null +++ b/lib/models/CallbackQuery.js @@ -0,0 +1,137 @@ +'use strict' + +const User = require('./User') +const Message = require('./Message') + +/** + * This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present. + */ + +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 + } + + /** + * 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() + } +} + +module.exports = CallbackQuery \ No newline at end of file diff --git a/lib/models/Chat.js b/lib/models/Chat.js new file mode 100644 index 0000000..6b49bf9 --- /dev/null +++ b/lib/models/Chat.js @@ -0,0 +1,134 @@ +'use strict' + +/** + * This object represents a chat. + */ + +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() + } +} + +module.exports = Chat \ No newline at end of file diff --git a/lib/models/ChatMember.js b/lib/models/ChatMember.js new file mode 100644 index 0000000..84f5219 --- /dev/null +++ b/lib/models/ChatMember.js @@ -0,0 +1,65 @@ +'use strict' + +const User = require('./User') + +/** + * This object contains information about one member of the chat. + */ + +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() + } +} + +module.exports = ChatMember \ No newline at end of file diff --git a/lib/models/ChosenInlineResult.js b/lib/models/ChosenInlineResult.js new file mode 100644 index 0000000..1dfdb61 --- /dev/null +++ b/lib/models/ChosenInlineResult.js @@ -0,0 +1,105 @@ +'use strict' + +const User = require('./User') +const Location = require('./Location') + +/** + * Represents a result of an inline query that was chosen by the user and sent to their chat partner. + */ + +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() + } +} + +module.exports = ChosenInlineResult \ No newline at end of file diff --git a/lib/models/Contact.js b/lib/models/Contact.js new file mode 100644 index 0000000..5c85615 --- /dev/null +++ b/lib/models/Contact.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * This object represents a phone contact. + */ + +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() + } +} + +module.exports = Contact \ No newline at end of file diff --git a/lib/models/Document.js b/lib/models/Document.js new file mode 100644 index 0000000..5f507a5 --- /dev/null +++ b/lib/models/Document.js @@ -0,0 +1,104 @@ +'use strict' + +const PhotoSize = require('./PhotoSize') + +/** + * This object represents a general file (as opposed to photos, voice messages and audio files). + */ + +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() + } +} + +module.exports = Document \ No newline at end of file diff --git a/lib/models/File.js b/lib/models/File.js new file mode 100644 index 0000000..1d435f0 --- /dev/null +++ b/lib/models/File.js @@ -0,0 +1,74 @@ +'use strict' + +/** + * This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot/. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile. + */ + +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/ 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() + } +} + +module.exports = File \ No newline at end of file diff --git a/lib/models/ForceReply.js b/lib/models/ForceReply.js new file mode 100644 index 0000000..db40d19 --- /dev/null +++ b/lib/models/ForceReply.js @@ -0,0 +1,63 @@ +'use strict' + +/** + * Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. + */ + +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() + } +} + +module.exports = ForceReply \ No newline at end of file diff --git a/lib/models/Game.js b/lib/models/Game.js new file mode 100644 index 0000000..7cf8605 --- /dev/null +++ b/lib/models/Game.js @@ -0,0 +1,118 @@ +'use strict' + +const PhotoSize = require('./PhotoSize') +const MessageEntity = require('./MessageEntity') +const Animation = require('./Animation') + +/** + * This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers. + */ + +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() + } +} + +module.exports = Game \ No newline at end of file diff --git a/lib/models/GameHighScore.js b/lib/models/GameHighScore.js new file mode 100644 index 0000000..52a8fdd --- /dev/null +++ b/lib/models/GameHighScore.js @@ -0,0 +1,76 @@ +'use strict' + +const User = require('./User') + +/** + * This object represents one row of the high scores table for a game. + */ + +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() + } +} + +module.exports = GameHighScore \ No newline at end of file diff --git a/lib/models/InlineKeyboardButton.js b/lib/models/InlineKeyboardButton.js new file mode 100644 index 0000000..3420493 --- /dev/null +++ b/lib/models/InlineKeyboardButton.js @@ -0,0 +1,116 @@ +'use strict' + +const CallbackGame = require('./CallbackGame') + +/** + * This object represents one button of an inline keyboard. You must use exactly one of the optional fields. + */ + +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. + * @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() + } +} + +module.exports = InlineKeyboardButton \ No newline at end of file diff --git a/lib/models/InlineKeyboardMarkup.js b/lib/models/InlineKeyboardMarkup.js new file mode 100644 index 0000000..f15dd2d --- /dev/null +++ b/lib/models/InlineKeyboardMarkup.js @@ -0,0 +1,54 @@ +'use strict' + +const InlineKeyboardButton = require('./InlineKeyboardButton') + +/** + * This object represents an inline keyboard that appears right next to the message it belongs to. + */ + +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() + } +} + +module.exports = InlineKeyboardMarkup \ No newline at end of file diff --git a/lib/models/InlineQuery.js b/lib/models/InlineQuery.js new file mode 100644 index 0000000..0978b74 --- /dev/null +++ b/lib/models/InlineQuery.js @@ -0,0 +1,105 @@ +'use strict' + +const User = require('./User') +const Location = require('./Location') + +/** + * This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results. + */ + +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() + } +} + +module.exports = InlineQuery \ No newline at end of file diff --git a/lib/models/InlineQueryResultArticle.js b/lib/models/InlineQueryResultArticle.js new file mode 100644 index 0000000..aedb9c3 --- /dev/null +++ b/lib/models/InlineQueryResultArticle.js @@ -0,0 +1,190 @@ +'use strict' + +const InputMessageContent = require('./InputMessageContent') +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to an article or web page. + */ + +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.thumbWidth : undefined, + thumb_height: this.thumbHeight ? this.thumbHeight : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InlineQueryResultArticle \ No newline at end of file diff --git a/lib/models/InlineQueryResultAudio.js b/lib/models/InlineQueryResultAudio.js new file mode 100644 index 0000000..f0f13b7 --- /dev/null +++ b/lib/models/InlineQueryResultAudio.js @@ -0,0 +1,164 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to an mp3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. + */ + +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() + } +} + +module.exports = InlineQueryResultAudio \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedAudio.js b/lib/models/InlineQueryResultCachedAudio.js new file mode 100644 index 0000000..795fc15 --- /dev/null +++ b/lib/models/InlineQueryResultCachedAudio.js @@ -0,0 +1,118 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to an mp3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedAudio \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedDocument.js b/lib/models/InlineQueryResultCachedDocument.js new file mode 100644 index 0000000..d5d4e69 --- /dev/null +++ b/lib/models/InlineQueryResultCachedDocument.js @@ -0,0 +1,151 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only pdf-files and zip archives can be sent using this method. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedDocument \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedGif.js b/lib/models/InlineQueryResultCachedGif.js new file mode 100644 index 0000000..d6a05f0 --- /dev/null +++ b/lib/models/InlineQueryResultCachedGif.js @@ -0,0 +1,138 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedGif \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedMpeg4Gif.js b/lib/models/InlineQueryResultCachedMpeg4Gif.js new file mode 100644 index 0000000..ae52c6f --- /dev/null +++ b/lib/models/InlineQueryResultCachedMpeg4Gif.js @@ -0,0 +1,138 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedMpeg4Gif \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedPhoto.js b/lib/models/InlineQueryResultCachedPhoto.js new file mode 100644 index 0000000..b17c685 --- /dev/null +++ b/lib/models/InlineQueryResultCachedPhoto.js @@ -0,0 +1,151 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedPhoto \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedSticker.js b/lib/models/InlineQueryResultCachedSticker.js new file mode 100644 index 0000000..e072bd1 --- /dev/null +++ b/lib/models/InlineQueryResultCachedSticker.js @@ -0,0 +1,106 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedSticker \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedVideo.js b/lib/models/InlineQueryResultCachedVideo.js new file mode 100644 index 0000000..ba51800 --- /dev/null +++ b/lib/models/InlineQueryResultCachedVideo.js @@ -0,0 +1,151 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedVideo \ No newline at end of file diff --git a/lib/models/InlineQueryResultCachedVoice.js b/lib/models/InlineQueryResultCachedVoice.js new file mode 100644 index 0000000..2d1f5ef --- /dev/null +++ b/lib/models/InlineQueryResultCachedVoice.js @@ -0,0 +1,138 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message. + */ + +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() + } +} + +module.exports = InlineQueryResultCachedVoice \ No newline at end of file diff --git a/lib/models/InlineQueryResultContact.js b/lib/models/InlineQueryResultContact.js new file mode 100644 index 0000000..41ec19a --- /dev/null +++ b/lib/models/InlineQueryResultContact.js @@ -0,0 +1,177 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact. + */ + +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() + } +} + +module.exports = InlineQueryResultContact \ No newline at end of file diff --git a/lib/models/InlineQueryResultDocument.js b/lib/models/InlineQueryResultDocument.js new file mode 100644 index 0000000..a591d90 --- /dev/null +++ b/lib/models/InlineQueryResultDocument.js @@ -0,0 +1,203 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method. + */ + +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, + mime_type: this.mimeType ? this.mimeType : undefined, + description: this.description ? this.description : 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() + } +} + +module.exports = InlineQueryResultDocument \ No newline at end of file diff --git a/lib/models/InlineQueryResultGame.js b/lib/models/InlineQueryResultGame.js new file mode 100644 index 0000000..32e81b8 --- /dev/null +++ b/lib/models/InlineQueryResultGame.js @@ -0,0 +1,88 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a Game. + */ + +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() + } +} + +module.exports = InlineQueryResultGame \ No newline at end of file diff --git a/lib/models/InlineQueryResultGif.js b/lib/models/InlineQueryResultGif.js new file mode 100644 index 0000000..2a3d317 --- /dev/null +++ b/lib/models/InlineQueryResultGif.js @@ -0,0 +1,177 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. + */ + +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() + } +} + +module.exports = InlineQueryResultGif \ No newline at end of file diff --git a/lib/models/InlineQueryResultLocation.js b/lib/models/InlineQueryResultLocation.js new file mode 100644 index 0000000..349974d --- /dev/null +++ b/lib/models/InlineQueryResultLocation.js @@ -0,0 +1,177 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location. + */ + +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() + } +} + +module.exports = InlineQueryResultLocation \ No newline at end of file diff --git a/lib/models/InlineQueryResultMpeg4Gif.js b/lib/models/InlineQueryResultMpeg4Gif.js new file mode 100644 index 0000000..e6bd408 --- /dev/null +++ b/lib/models/InlineQueryResultMpeg4Gif.js @@ -0,0 +1,177 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation. + */ + +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() + } +} + +module.exports = InlineQueryResultMpeg4Gif \ No newline at end of file diff --git a/lib/models/InlineQueryResultPhoto.js b/lib/models/InlineQueryResultPhoto.js new file mode 100644 index 0000000..8403ea0 --- /dev/null +++ b/lib/models/InlineQueryResultPhoto.js @@ -0,0 +1,190 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo. + */ + +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, + reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, + input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InlineQueryResultPhoto \ No newline at end of file diff --git a/lib/models/InlineQueryResultVenue.js b/lib/models/InlineQueryResultVenue.js new file mode 100644 index 0000000..e9cbb9e --- /dev/null +++ b/lib/models/InlineQueryResultVenue.js @@ -0,0 +1,203 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue. + */ + +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.foursquareId : 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() + } +} + +module.exports = InlineQueryResultVenue \ No newline at end of file diff --git a/lib/models/InlineQueryResultVideo.js b/lib/models/InlineQueryResultVideo.js new file mode 100644 index 0000000..a3a649a --- /dev/null +++ b/lib/models/InlineQueryResultVideo.js @@ -0,0 +1,216 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. + */ + +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 : undefined, + id: this.id ? this.id : undefined, + video_url: this.videoUrl ? this.videoUrl : undefined, + mime_type: this.mimeType ? this.mimeType : undefined, + thumb_url: this.thumbUrl ? this.thumbUrl : undefined, + title: this.title ? this.title : undefined, + caption: this.caption ? this.caption : undefined, + video_width: this.videoWidth ? this.videoWidth : undefined, + video_height: this.videoHeight ? this.videoHeight : undefined, + video_duration: this.videoDuration ? this.videoDuration : undefined, + description: this.description ? this.description : undefined, + reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, + input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InlineQueryResultVideo \ No newline at end of file diff --git a/lib/models/InlineQueryResultVoice.js b/lib/models/InlineQueryResultVoice.js new file mode 100644 index 0000000..4edf8b7 --- /dev/null +++ b/lib/models/InlineQueryResultVoice.js @@ -0,0 +1,151 @@ +'use strict' + +const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') +const InputMessageContent = require('./InputMessageContent') +const InlineQueryResult = require('./InlineQueryResult') +/** + * Represents a link to a voice recording in an .ogg container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. + */ + +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() + } +} + +module.exports = InlineQueryResultVoice \ No newline at end of file diff --git a/lib/models/InputContactMessageContent.js b/lib/models/InputContactMessageContent.js new file mode 100644 index 0000000..e365d29 --- /dev/null +++ b/lib/models/InputContactMessageContent.js @@ -0,0 +1,76 @@ +'use strict' + +const InputMessageContent = require('./InputMessageContent') +/** + * Represents the content of a contact message to be sent as the result of an inline query. + */ + +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() + } +} + +module.exports = InputContactMessageContent \ No newline at end of file diff --git a/lib/models/InputLocationMessageContent.js b/lib/models/InputLocationMessageContent.js new file mode 100644 index 0000000..0ccfb77 --- /dev/null +++ b/lib/models/InputLocationMessageContent.js @@ -0,0 +1,65 @@ +'use strict' + +const InputMessageContent = require('./InputMessageContent') +/** + * Represents the content of a location message to be sent as the result of an inline query. + */ + +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() + } +} + +module.exports = InputLocationMessageContent \ No newline at end of file diff --git a/lib/models/InputTextMessageContent.js b/lib/models/InputTextMessageContent.js new file mode 100644 index 0000000..4f227ec --- /dev/null +++ b/lib/models/InputTextMessageContent.js @@ -0,0 +1,76 @@ +'use strict' + +const InputMessageContent = require('./InputMessageContent') +/** + * Represents the content of a text message to be sent as the result of an inline query. + */ + +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() + } +} + +module.exports = InputTextMessageContent \ No newline at end of file diff --git a/lib/models/InputVenueMessageContent.js b/lib/models/InputVenueMessageContent.js new file mode 100644 index 0000000..10e973c --- /dev/null +++ b/lib/models/InputVenueMessageContent.js @@ -0,0 +1,104 @@ +'use strict' + +const InputMessageContent = require('./InputMessageContent') +/** + * Represents the content of a venue message to be sent as the result of an inline query. + */ + +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() + } +} + +module.exports = InputVenueMessageContent \ No newline at end of file diff --git a/lib/models/KeyboardButton.js b/lib/models/KeyboardButton.js new file mode 100644 index 0000000..0bdfbf4 --- /dev/null +++ b/lib/models/KeyboardButton.js @@ -0,0 +1,74 @@ +'use strict' + +/** + * This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields are mutually exclusive. + */ + +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() + } +} + +module.exports = KeyboardButton \ No newline at end of file diff --git a/lib/models/Location.js b/lib/models/Location.js new file mode 100644 index 0000000..4623a09 --- /dev/null +++ b/lib/models/Location.js @@ -0,0 +1,63 @@ +'use strict' + +/** + * This object represents a point on the map. + */ + +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() + } +} + +module.exports = Location \ No newline at end of file diff --git a/lib/models/Message.js b/lib/models/Message.js new file mode 100644 index 0000000..5bf02c7 --- /dev/null +++ b/lib/models/Message.js @@ -0,0 +1,486 @@ +'use strict' + +const User = require('./User') +const Chat = require('./Chat') +const MessageEntity = require('./MessageEntity') +const Audio = require('./Audio') +const Document = require('./Document') +const Game = require('./Game') +const PhotoSize = require('./PhotoSize') +const Sticker = require('./Sticker') +const Video = require('./Video') +const Voice = require('./Voice') +const Contact = require('./Contact') +const Location = require('./Location') +const Venue = require('./Venue') + +/** + * This object represents a message. + */ + +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} [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, + 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._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 + * @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 + * @returns {Chat|null} + */ + get forwardFromChat() { + return this._forwardFromChat + } + + /** + * For forwarded messages, date the original message was sent in Unix time + * @returns {number|null} + */ + get forwardDate() { + return this._forwardDate + } + + /** + * For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. + * @returns {Message|null} + */ + get replyToMessage() { + return this._replyToMessage + } + + /** + * Date the message was last edited in Unix time + * @returns {number|null} + */ + get editDate() { + return this._editDate + } + + /** + * For text messages, the actual UTF-8 text of the message, 0-4096 characters. + * @returns {string|null} + */ + get text() { + return this._text + } + + /** + * For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text + * @returns {MessageEntity[]|null} + */ + get entities() { + return this._entities + } + + /** + * Message is an audio file, information about the file + * @returns {Audio|null} + */ + get audio() { + return this._audio + } + + /** + * Message is a general file, information about the file + * @returns {Document|null} + */ + get document() { + return this._document + } + + /** + * Message is a game, information about the game. More about games » + * @returns {Game|null} + */ + get game() { + return this._game + } + + /** + * Message is a photo, available sizes of the photo + * @returns {PhotoSize[]|null} + */ + get photo() { + return this._photo + } + + /** + * Message is a sticker, information about the sticker + * @returns {Sticker|null} + */ + get sticker() { + return this._sticker + } + + /** + * Message is a video, information about the video + * @returns {Video|null} + */ + get video() { + return this._video + } + + /** + * Message is a voice message, information about the file + * @returns {Voice|null} + */ + get voice() { + return this._voice + } + + /** + * Caption for the document, photo or video, 0-200 characters + * @returns {string|null} + */ + get caption() { + return this._caption + } + + /** + * Message is a shared contact, information about the contact + * @returns {Contact|null} + */ + get contact() { + return this._contact + } + + /** + * Message is a shared location, information about the location + * @returns {Location|null} + */ + get location() { + return this._location + } + + /** + * Message is a venue, information about the venue + * @returns {Venue|null} + */ + get venue() { + return this._venue + } + + /** + * A new member was added to the group, information about them (this member may be the bot itself) + * @returns {User|null} + */ + get newChatMember() { + return this._newChatMember + } + + /** + * A member was removed from the group, information about them (this member may be the bot itself) + * @returns {User|null} + */ + get leftChatMember() { + return this._leftChatMember + } + + /** + * A chat title was changed to this value + * @returns {string|null} + */ + get newChatTitle() { + return this._newChatTitle + } + + /** + * A chat photo was change to this value + * @returns {PhotoSize[]|null} + */ + get newChatPhoto() { + return this._newChatPhoto + } + + /** + * Service message: the chat photo was deleted + * @returns {boolean|null} + */ + get deleteChatPhoto() { + return this._deleteChatPhoto + } + + /** + * Service message: the group has been created + * @returns {boolean|null} + */ + get groupChatCreated() { + return this._groupChatCreated + } + + /** + * Service message: the supergroup has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. + * @returns {boolean|null} + */ + get supergroupChatCreated() { + return this._supergroupChatCreated + } + + /** + * Service message: the channel has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. + * @returns {boolean|null} + */ + get channelChatCreated() { + return this._channelChatCreated + } + + /** + * 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 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 + } + + /** + * The supergroup has been migrated from a group 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 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 migrateFromChatId() { + return this._migrateFromChatId + } + + /** + * Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. + * @returns {Message|null} + */ + get pinnedMessage() { + return this._pinnedMessage + } + + /** + * + * @param {Object} raw + * @returns {Message} + */ + static deserialize(raw) { + return new Message( + raw['message_id'], + raw['from'] ? User.deserialize(raw['from']) : null, + raw['date'], + raw['chat'] ? Chat.deserialize(raw['chat']) : null, + raw['forward_from'] ? User.deserialize(raw['forward_from']) : null, + raw['forward_from_chat'] ? Chat.deserialize(raw['forward_from_chat']) : null, + raw['forward_date'] ? raw['forward_date'] : null, + raw['reply_to_message'] ? Message.deserialize(raw['reply_to_message']) : null, + raw['edit_date'] ? raw['edit_date'] : null, + raw['text'] ? raw['text'] : null, + raw['entities'] ? raw['entities'].map(item => MessageEntity.deserialize(item)) : null, + raw['audio'] ? Audio.deserialize(raw['audio']) : null, + raw['document'] ? Document.deserialize(raw['document']) : null, + raw['game'] ? Game.deserialize(raw['game']) : null, + raw['photo'] ? raw['photo'].map(item => PhotoSize.deserialize(item)) : null, + raw['sticker'] ? Sticker.deserialize(raw['sticker']) : null, + raw['video'] ? Video.deserialize(raw['video']) : null, + raw['voice'] ? Voice.deserialize(raw['voice']) : null, + raw['caption'] ? raw['caption'] : null, + raw['contact'] ? Contact.deserialize(raw['contact']) : null, + raw['location'] ? Location.deserialize(raw['location']) : null, + raw['venue'] ? Venue.deserialize(raw['venue']) : null, + raw['new_chat_member'] ? User.deserialize(raw['new_chat_member']) : null, + raw['left_chat_member'] ? User.deserialize(raw['left_chat_member']) : null, + raw['new_chat_title'] ? raw['new_chat_title'] : null, + raw['new_chat_photo'] ? raw['new_chat_photo'].map(item => PhotoSize.deserialize(item)) : null, + raw['delete_chat_photo'] ? raw['delete_chat_photo'] : null, + raw['group_chat_created'] ? raw['group_chat_created'] : null, + raw['supergroup_chat_created'] ? raw['supergroup_chat_created'] : null, + raw['channel_chat_created'] ? raw['channel_chat_created'] : null, + raw['migrate_to_chat_id'] ? raw['migrate_to_chat_id'] : null, + raw['migrate_from_chat_id'] ? raw['migrate_from_chat_id'] : null, + raw['pinned_message'] ? Message.deserialize(raw['pinned_message']) : null + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + message_id: this.messageId ? this.messageId : undefined, + from: this.from ? this.from.serialize() : undefined, + date: this.date ? this.date : undefined, + chat: this.chat ? this.chat.serialize() : undefined, + forward_from: this.forwardFrom ? this.forwardFrom.serialize() : undefined, + forward_from_chat: this.forwardFromChat ? this.forwardFromChat.serialize() : undefined, + forward_date: this.forwardDate ? this.forwardDate : undefined, + reply_to_message: this.replyToMessage ? this.replyToMessage.serialize() : undefined, + edit_date: this.editDate ? this.editDate : undefined, + text: this.text ? this.text : undefined, + entities: this.entities ? this.entities.map(item => item.serialize()) : undefined, + audio: this.audio ? this.audio.serialize() : undefined, + document: this.document ? this.document.serialize() : undefined, + game: this.game ? this.game.serialize() : undefined, + photo: this.photo ? this.photo.map(item => item.serialize()) : undefined, + sticker: this.sticker ? this.sticker.serialize() : undefined, + video: this.video ? this.video.serialize() : undefined, + voice: this.voice ? this.voice.serialize() : undefined, + caption: this.caption ? this.caption : undefined, + contact: this.contact ? this.contact.serialize() : undefined, + location: this.location ? this.location.serialize() : undefined, + venue: this.venue ? this.venue.serialize() : undefined, + new_chat_member: this.newChatMember ? this.newChatMember.serialize() : undefined, + left_chat_member: this.leftChatMember ? this.leftChatMember.serialize() : undefined, + new_chat_title: this.newChatTitle ? this.newChatTitle : undefined, + new_chat_photo: this.newChatPhoto ? this.newChatPhoto.map(item => item.serialize()) : undefined, + delete_chat_photo: this.deleteChatPhoto ? this.deleteChatPhoto : undefined, + group_chat_created: this.groupChatCreated ? this.groupChatCreated : undefined, + supergroup_chat_created: this.supergroupChatCreated ? this.supergroupChatCreated : undefined, + channel_chat_created: this.channelChatCreated ? this.channelChatCreated : undefined, + migrate_to_chat_id: this.migrateToChatId ? this.migrateToChatId : undefined, + migrate_from_chat_id: this.migrateFromChatId ? this.migrateFromChatId : undefined, + pinned_message: this.pinnedMessage ? this.pinnedMessage.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = Message \ No newline at end of file diff --git a/lib/models/MessageEntity.js b/lib/models/MessageEntity.js new file mode 100644 index 0000000..c5b83ce --- /dev/null +++ b/lib/models/MessageEntity.js @@ -0,0 +1,104 @@ +'use strict' + +const User = require('./User') + +/** + * This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. + */ + +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() + } +} + +module.exports = MessageEntity \ No newline at end of file diff --git a/lib/models/Models.js b/lib/models/Models.js new file mode 100644 index 0000000..67841b1 --- /dev/null +++ b/lib/models/Models.js @@ -0,0 +1,59 @@ +module.exports = { + Update: require('./Update'), + WebhookInfo: require('./WebhookInfo'), + User: require('./User'), + Chat: require('./Chat'), + Message: require('./Message'), + MessageEntity: require('./MessageEntity'), + PhotoSize: require('./PhotoSize'), + Audio: require('./Audio'), + Document: require('./Document'), + Sticker: require('./Sticker'), + Video: require('./Video'), + Voice: require('./Voice'), + Contact: require('./Contact'), + Location: require('./Location'), + Venue: require('./Venue'), + UserProfilePhotos: require('./UserProfilePhotos'), + File: require('./File'), + ReplyKeyboardMarkup: require('./ReplyKeyboardMarkup'), + KeyboardButton: require('./KeyboardButton'), + ReplyKeyboardHide: require('./ReplyKeyboardHide'), + InlineKeyboardMarkup: require('./InlineKeyboardMarkup'), + InlineKeyboardButton: require('./InlineKeyboardButton'), + CallbackQuery: require('./CallbackQuery'), + ForceReply: require('./ForceReply'), + ChatMember: require('./ChatMember'), + ResponseParameters: require('./ResponseParameters'), + InlineQuery: require('./InlineQuery'), + InlineQueryResultArticle: require('./InlineQueryResultArticle'), + InlineQueryResultPhoto: require('./InlineQueryResultPhoto'), + InlineQueryResultGif: require('./InlineQueryResultGif'), + InlineQueryResultMpeg4Gif: require('./InlineQueryResultMpeg4Gif'), + InlineQueryResultVideo: require('./InlineQueryResultVideo'), + InlineQueryResultAudio: require('./InlineQueryResultAudio'), + InlineQueryResultVoice: require('./InlineQueryResultVoice'), + InlineQueryResultDocument: require('./InlineQueryResultDocument'), + InlineQueryResultLocation: require('./InlineQueryResultLocation'), + InlineQueryResultVenue: require('./InlineQueryResultVenue'), + InlineQueryResultContact: require('./InlineQueryResultContact'), + InlineQueryResultGame: require('./InlineQueryResultGame'), + InlineQueryResultCachedPhoto: require('./InlineQueryResultCachedPhoto'), + InlineQueryResultCachedGif: require('./InlineQueryResultCachedGif'), + InlineQueryResultCachedMpeg4Gif: require('./InlineQueryResultCachedMpeg4Gif'), + InlineQueryResultCachedSticker: require('./InlineQueryResultCachedSticker'), + InlineQueryResultCachedDocument: require('./InlineQueryResultCachedDocument'), + InlineQueryResultCachedVideo: require('./InlineQueryResultCachedVideo'), + InlineQueryResultCachedVoice: require('./InlineQueryResultCachedVoice'), + InlineQueryResultCachedAudio: require('./InlineQueryResultCachedAudio'), + InputTextMessageContent: require('./InputTextMessageContent'), + InputLocationMessageContent: require('./InputLocationMessageContent'), + InputVenueMessageContent: require('./InputVenueMessageContent'), + InputContactMessageContent: require('./InputContactMessageContent'), + ChosenInlineResult: require('./ChosenInlineResult'), + Game: require('./Game'), + Animation: require('./Animation'), + GameHighScore: require('./GameHighScore'), + InputMessageContent: require('./InputMessageContent'), + InlineQueryResult: require('./InlineQueryResult'), +} \ No newline at end of file diff --git a/lib/models/PhotoSize.js b/lib/models/PhotoSize.js new file mode 100644 index 0000000..f95a65c --- /dev/null +++ b/lib/models/PhotoSize.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * This object represents one size of a photo or a file / sticker thumbnail. + */ + +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() + } +} + +module.exports = PhotoSize \ No newline at end of file diff --git a/lib/models/ReplyKeyboardHide.js b/lib/models/ReplyKeyboardHide.js new file mode 100644 index 0000000..bf03acc --- /dev/null +++ b/lib/models/ReplyKeyboardHide.js @@ -0,0 +1,63 @@ +'use strict' + +/** + * Upon receiving a message with this object, Telegram clients will hide the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). + */ + +class ReplyKeyboardHide { + /** + * + * @param {boolean} hideKeyboard + * @param {boolean|null} [selective] + */ + constructor(hideKeyboard, selective) { + this._hideKeyboard = hideKeyboard + this._selective = selective + } + + /** + * Requests clients to hide the custom keyboard + * @returns {boolean} + */ + get hideKeyboard() { + return this._hideKeyboard + } + + /** + * Use this parameter if you want to hide 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 hides 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 {ReplyKeyboardHide} + */ + static deserialize(raw) { + return new ReplyKeyboardHide(raw['hide_keyboard'], raw['selective'] ? raw['selective'] : null) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + hide_keyboard: this.hideKeyboard ? this.hideKeyboard : undefined, + selective: this.selective ? this.selective : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = ReplyKeyboardHide \ No newline at end of file diff --git a/lib/models/ReplyKeyboardMarkup.js b/lib/models/ReplyKeyboardMarkup.js new file mode 100644 index 0000000..6a4bd08 --- /dev/null +++ b/lib/models/ReplyKeyboardMarkup.js @@ -0,0 +1,87 @@ +'use strict' + +const KeyboardButton = require('./KeyboardButton') + +/** + * This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). + */ + +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() + } +} + +module.exports = ReplyKeyboardMarkup \ No newline at end of file diff --git a/lib/models/ResponseParameters.js b/lib/models/ResponseParameters.js new file mode 100644 index 0000000..252ed73 --- /dev/null +++ b/lib/models/ResponseParameters.js @@ -0,0 +1,63 @@ +'use strict' + +/** + * Contains information about why a request was unsuccessfull. + */ + +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() + } +} + +module.exports = ResponseParameters \ No newline at end of file diff --git a/lib/models/Sticker.js b/lib/models/Sticker.js new file mode 100644 index 0000000..25388e7 --- /dev/null +++ b/lib/models/Sticker.js @@ -0,0 +1,116 @@ +'use strict' + +const PhotoSize = require('./PhotoSize') + +/** + * This object represents a sticker. + */ + +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() + } +} + +module.exports = Sticker \ No newline at end of file diff --git a/lib/models/Update.js b/lib/models/Update.js new file mode 100644 index 0000000..8576283 --- /dev/null +++ b/lib/models/Update.js @@ -0,0 +1,119 @@ +'use strict' + +const Message = require('./Message') +const InlineQuery = require('./InlineQuery') +const ChosenInlineResult = require('./ChosenInlineResult') +const CallbackQuery = require('./CallbackQuery') + +/** + * This object represents an incoming update.Only one of the optional parameters can be present in any given update. + */ + +class Update { + /** + * + * @param {number} updateId + * @param {Message|null} [message] + * @param {Message|null} [editedMessage] + * @param {InlineQuery|null} [inlineQuery] + * @param {ChosenInlineResult|null} [chosenInlineResult] + * @param {CallbackQuery|null} [callbackQuery] + */ + constructor(updateId, message, editedMessage, inlineQuery, chosenInlineResult, callbackQuery) { + this._updateId = updateId + this._message = message + this._editedMessage = editedMessage + 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 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['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, + inline_query: this.inlineQuery ? this.inlineQuery.serialize() : undefined, + chosen_inline_result: this.chosenInlineResult ? this.chosenInlineResult.serialize() : undefined, + callback_query: this.callbackQuery ? this.callbackQuery.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = Update \ No newline at end of file diff --git a/lib/models/User.js b/lib/models/User.js new file mode 100644 index 0000000..29657e5 --- /dev/null +++ b/lib/models/User.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * This object represents a Telegram user or bot. + */ + +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() + } +} + +module.exports = User \ No newline at end of file diff --git a/lib/models/UserProfilePhotos.js b/lib/models/UserProfilePhotos.js new file mode 100644 index 0000000..272c453 --- /dev/null +++ b/lib/models/UserProfilePhotos.js @@ -0,0 +1,65 @@ +'use strict' + +const PhotoSize = require('./PhotoSize') + +/** + * This object represent a user's profile pictures. + */ + +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() + } +} + +module.exports = UserProfilePhotos \ No newline at end of file diff --git a/lib/models/Venue.js b/lib/models/Venue.js new file mode 100644 index 0000000..3099ffb --- /dev/null +++ b/lib/models/Venue.js @@ -0,0 +1,87 @@ +'use strict' + +const Location = require('./Location') + +/** + * This object represents a venue. + */ + +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() + } +} + +module.exports = Venue \ No newline at end of file diff --git a/lib/models/Video.js b/lib/models/Video.js new file mode 100644 index 0000000..b21479b --- /dev/null +++ b/lib/models/Video.js @@ -0,0 +1,136 @@ +'use strict' + +const PhotoSize = require('./PhotoSize') + +/** + * This object represents a video file. + */ + +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() + } +} + +module.exports = Video \ No newline at end of file diff --git a/lib/models/Voice.js b/lib/models/Voice.js new file mode 100644 index 0000000..44f2399 --- /dev/null +++ b/lib/models/Voice.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * This object represents a voice note. + */ + +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() + } +} + +module.exports = Voice \ No newline at end of file diff --git a/lib/models/WebhookInfo.js b/lib/models/WebhookInfo.js new file mode 100644 index 0000000..49a1fba --- /dev/null +++ b/lib/models/WebhookInfo.js @@ -0,0 +1,102 @@ +'use strict' + +/** + * Contains information about the current status of a webhook. + */ + +class WebhookInfo { + /** + * + * @param {string} url + * @param {boolean} hasCustomCertificate + * @param {number} pendingUpdateCount + * @param {number|null} [lastErrorDate] + * @param {string|null} [lastErrorMessage] + */ + constructor(url, hasCustomCertificate, pendingUpdateCount, lastErrorDate, lastErrorMessage) { + this._url = url + this._hasCustomCertificate = hasCustomCertificate + this._pendingUpdateCount = pendingUpdateCount + this._lastErrorDate = lastErrorDate + this._lastErrorMessage = lastErrorMessage + } + + /** + * 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 + } + + /** + * + * @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 + ) + } + + /** + * + * @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 + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = WebhookInfo \ No newline at end of file From 7373c4e20de2136f3bfabf2ff60851cd60521a61 Mon Sep 17 00:00:00 2001 From: Omid S Date: Thu, 20 Dec 2018 23:20:58 -0800 Subject: [PATCH 5/6] fixes bug in parsing 'InputFile or String' in api page --- api-scheme/models/ModelsGenerator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/api-scheme/models/ModelsGenerator.js b/api-scheme/models/ModelsGenerator.js index e911d9e..8c8db2d 100644 --- a/api-scheme/models/ModelsGenerator.js +++ b/api-scheme/models/ModelsGenerator.js @@ -9,6 +9,7 @@ const JS_TYPES = { String: 'string', Float: 'number', 'Float number': 'number', + 'InputFile or String': 'string', Boolean: 'boolean', True: 'boolean', False: 'boolean' From 8807f53a0e45ffab81a7019e246ad2df74ffd56a Mon Sep 17 00:00:00 2001 From: Omid S Date: Thu, 20 Dec 2018 23:21:10 -0800 Subject: [PATCH 6/6] updates models --- lib/models/Animation.js | 49 +- lib/models/Audio.js | 28 +- lib/models/CallbackQuery.js | 2 +- lib/models/Chat.js | 89 +- lib/models/ChatMember.js | 198 ++- lib/models/ChatPhoto.js | 63 + lib/models/Contact.js | 23 +- lib/models/EncryptedCredentials.js | 74 ++ lib/models/EncryptedPassportElement.js | 175 +++ lib/models/InlineKeyboardButton.js | 30 +- lib/models/InlineQueryResultAudio.js | 15 +- lib/models/InlineQueryResultCachedAudio.js | 24 +- lib/models/InlineQueryResultCachedDocument.js | 17 +- lib/models/InlineQueryResultCachedGif.js | 15 +- lib/models/InlineQueryResultCachedMpeg4Gif.js | 15 +- lib/models/InlineQueryResultCachedPhoto.js | 15 +- lib/models/InlineQueryResultCachedVideo.js | 15 +- lib/models/InlineQueryResultCachedVoice.js | 15 +- lib/models/InlineQueryResultContact.js | 13 + lib/models/InlineQueryResultDocument.js | 15 +- lib/models/InlineQueryResultGif.js | 28 +- lib/models/InlineQueryResultLocation.js | 13 + lib/models/InlineQueryResultMpeg4Gif.js | 28 +- lib/models/InlineQueryResultPhoto.js | 15 +- lib/models/InlineQueryResultVenue.js | 13 + lib/models/InlineQueryResultVideo.js | 17 +- lib/models/InlineQueryResultVoice.js | 15 +- lib/models/InputContactMessageContent.js | 17 +- lib/models/InputLocationMessageContent.js | 17 +- lib/models/InputMediaAnimation.js | 147 +++ lib/models/InputMediaAudio.js | 147 +++ lib/models/InputMediaDocument.js | 102 ++ lib/models/InputMediaPhoto.js | 85 ++ lib/models/InputMediaVideo.js | 160 +++ lib/models/InputVenueMessageContent.js | 18 +- lib/models/Invoice.js | 102 ++ lib/models/KeyboardButton.js | 2 +- lib/models/LabeledPrice.js | 63 + lib/models/MaskPosition.js | 85 ++ lib/models/Message.js | 184 ++- lib/models/MessageEntity.js | 2 +- lib/models/Models.js | 36 +- lib/models/OrderInfo.js | 87 ++ lib/models/PassportData.js | 66 + lib/models/PassportElementErrorDataField.js | 102 ++ lib/models/PassportElementErrorFile.js | 85 ++ lib/models/PassportElementErrorFiles.js | 85 ++ lib/models/PassportElementErrorFrontSide.js | 85 ++ lib/models/PassportElementErrorReverseSide.js | 85 ++ lib/models/PassportElementErrorSelfie.js | 85 ++ .../PassportElementErrorTranslationFile.js | 85 ++ .../PassportElementErrorTranslationFiles.js | 85 ++ lib/models/PassportElementErrorUnspecified.js | 85 ++ lib/models/PassportFile.js | 74 ++ lib/models/PreCheckoutQuery.js | 137 ++ lib/models/ReplyKeyboardRemove.js | 63 + lib/models/ResponseParameters.js | 2 +- lib/models/ShippingAddress.js | 114 ++ lib/models/ShippingOption.js | 76 ++ lib/models/ShippingQuery.js | 88 ++ lib/models/Sticker.js | 38 +- lib/models/StickerSet.js | 87 ++ lib/models/SuccessfulPayment.js | 136 ++ lib/models/Update.js | 73 +- lib/models/User.js | 35 +- lib/models/Venue.js | 23 +- lib/models/VideoNote.js | 104 ++ lib/models/WebhookInfo.js | 38 +- package-lock.json | 1168 +++++++++++++++++ 69 files changed, 5287 insertions(+), 90 deletions(-) create mode 100644 lib/models/ChatPhoto.js create mode 100644 lib/models/EncryptedCredentials.js create mode 100644 lib/models/EncryptedPassportElement.js create mode 100644 lib/models/InputMediaAnimation.js create mode 100644 lib/models/InputMediaAudio.js create mode 100644 lib/models/InputMediaDocument.js create mode 100644 lib/models/InputMediaPhoto.js create mode 100644 lib/models/InputMediaVideo.js create mode 100644 lib/models/Invoice.js create mode 100644 lib/models/LabeledPrice.js create mode 100644 lib/models/MaskPosition.js create mode 100644 lib/models/OrderInfo.js create mode 100644 lib/models/PassportData.js create mode 100644 lib/models/PassportElementErrorDataField.js create mode 100644 lib/models/PassportElementErrorFile.js create mode 100644 lib/models/PassportElementErrorFiles.js create mode 100644 lib/models/PassportElementErrorFrontSide.js create mode 100644 lib/models/PassportElementErrorReverseSide.js create mode 100644 lib/models/PassportElementErrorSelfie.js create mode 100644 lib/models/PassportElementErrorTranslationFile.js create mode 100644 lib/models/PassportElementErrorTranslationFiles.js create mode 100644 lib/models/PassportElementErrorUnspecified.js create mode 100644 lib/models/PassportFile.js create mode 100644 lib/models/PreCheckoutQuery.js create mode 100644 lib/models/ReplyKeyboardRemove.js create mode 100644 lib/models/ShippingAddress.js create mode 100644 lib/models/ShippingOption.js create mode 100644 lib/models/ShippingQuery.js create mode 100644 lib/models/StickerSet.js create mode 100644 lib/models/SuccessfulPayment.js create mode 100644 lib/models/VideoNote.js create mode 100644 package-lock.json diff --git a/lib/models/Animation.js b/lib/models/Animation.js index 2035b36..6ecc103 100644 --- a/lib/models/Animation.js +++ b/lib/models/Animation.js @@ -3,20 +3,35 @@ const PhotoSize = require('./PhotoSize') /** - * You can provide an animation for your game so that it looks stylish in chats (check out Lumberjack for an example). This object represents an animation file to be displayed in the message containing a game. + * This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). */ class Animation { /** * * @param {string} fileId + * @param {number} width + * @param {number} height + * @param {number} duration * @param {PhotoSize|null} [thumb] * @param {string|null} [fileName] * @param {string|null} [mimeType] * @param {number|null} [fileSize] */ - constructor(fileId, thumb, fileName, mimeType, fileSize) { + constructor( + fileId, + width, + height, + duration, + thumb, + fileName, + mimeType, + fileSize + ) { this._fileId = fileId + this._width = width + this._height = height + this._duration = duration this._thumb = thumb this._fileName = fileName this._mimeType = mimeType @@ -31,6 +46,30 @@ class Animation { 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 + } + /** * Animation thumbnail as defined by sender * @returns {PhotoSize|null} @@ -71,6 +110,9 @@ class Animation { static deserialize(raw) { return new Animation( raw['file_id'], + raw['width'], + raw['height'], + raw['duration'], raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null, raw['file_name'] ? raw['file_name'] : null, raw['mime_type'] ? raw['mime_type'] : null, @@ -85,6 +127,9 @@ class Animation { 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, file_name: this.fileName ? this.fileName : undefined, mime_type: this.mimeType ? this.mimeType : undefined, diff --git a/lib/models/Audio.js b/lib/models/Audio.js index 1676b86..f087fe5 100644 --- a/lib/models/Audio.js +++ b/lib/models/Audio.js @@ -1,5 +1,7 @@ 'use strict' +const PhotoSize = require('./PhotoSize') + /** * This object represents an audio file to be treated as music by the Telegram clients. */ @@ -13,14 +15,24 @@ class Audio { * @param {string|null} [title] * @param {string|null} [mimeType] * @param {number|null} [fileSize] + * @param {PhotoSize|null} [thumb] */ - constructor(fileId, duration, performer, title, mimeType, fileSize) { + constructor( + fileId, + duration, + performer, + title, + mimeType, + fileSize, + thumb + ) { this._fileId = fileId this._duration = duration this._performer = performer this._title = title this._mimeType = mimeType this._fileSize = fileSize + this._thumb = thumb } /** @@ -71,6 +83,14 @@ class Audio { return this._fileSize } + /** + * Thumbnail of the album cover to which the music file belongs + * @returns {PhotoSize|null} + */ + get thumb() { + return this._thumb + } + /** * * @param {Object} raw @@ -83,7 +103,8 @@ class Audio { raw['performer'] ? raw['performer'] : null, raw['title'] ? raw['title'] : null, raw['mime_type'] ? raw['mime_type'] : null, - raw['file_size'] ? raw['file_size'] : null + raw['file_size'] ? raw['file_size'] : null, + raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null ) } @@ -98,7 +119,8 @@ class Audio { 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 + file_size: this.fileSize ? this.fileSize : undefined, + thumb: this.thumb ? this.thumb.serialize() : undefined } } diff --git a/lib/models/CallbackQuery.js b/lib/models/CallbackQuery.js index 7eb401f..e937dca 100644 --- a/lib/models/CallbackQuery.js +++ b/lib/models/CallbackQuery.js @@ -69,7 +69,7 @@ class CallbackQuery { } /** - * Identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games. + * 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() { diff --git a/lib/models/Chat.js b/lib/models/Chat.js index 6b49bf9..0f5ee5e 100644 --- a/lib/models/Chat.js +++ b/lib/models/Chat.js @@ -1,5 +1,8 @@ 'use strict' +const ChatPhoto = require('./ChatPhoto') +const Message = require('./Message') + /** * This object represents a chat. */ @@ -14,6 +17,12 @@ class Chat { * @param {string|null} [firstName] * @param {string|null} [lastName] * @param {boolean|null} [allMembersAreAdministrators] + * @param {ChatPhoto|null} [photo] + * @param {string|null} [description] + * @param {string|null} [inviteLink] + * @param {Message|null} [pinnedMessage] + * @param {string|null} [stickerSetName] + * @param {boolean|null} [canSetStickerSet] */ constructor( id, @@ -22,7 +31,13 @@ class Chat { username, firstName, lastName, - allMembersAreAdministrators + allMembersAreAdministrators, + photo, + description, + inviteLink, + pinnedMessage, + stickerSetName, + canSetStickerSet ) { this._id = id this._type = type @@ -31,10 +46,16 @@ class Chat { this._firstName = firstName this._lastName = lastName this._allMembersAreAdministrators = allMembersAreAdministrators + this._photo = photo + this._description = description + this._inviteLink = inviteLink + this._pinnedMessage = pinnedMessage + this._stickerSetName = stickerSetName + this._canSetStickerSet = canSetStickerSet } /** - * 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. + * Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. * @returns {number} */ get id() { @@ -89,6 +110,54 @@ class Chat { return this._allMembersAreAdministrators } + /** + * Chat photo. Returned only in getChat. + * @returns {ChatPhoto|null} + */ + get photo() { + return this._photo + } + + /** + * Description, for supergroups and channel chats. Returned only in getChat. + * @returns {string|null} + */ + get description() { + return this._description + } + + /** + * Chat invite link, for supergroups and channel chats. Returned only in getChat. + * @returns {string|null} + */ + get inviteLink() { + return this._inviteLink + } + + /** + * Pinned message, for supergroups and channel chats. Returned only in getChat. + * @returns {Message|null} + */ + get pinnedMessage() { + return this._pinnedMessage + } + + /** + * For supergroups, name of group sticker set. Returned only in getChat. + * @returns {string|null} + */ + get stickerSetName() { + return this._stickerSetName + } + + /** + * True, if the bot can change the group sticker set. Returned only in getChat. + * @returns {boolean|null} + */ + get canSetStickerSet() { + return this._canSetStickerSet + } + /** * * @param {Object} raw @@ -102,7 +171,13 @@ class Chat { 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 + raw['all_members_are_administrators'] ? raw['all_members_are_administrators'] : null, + raw['photo'] ? ChatPhoto.deserialize(raw['photo']) : null, + raw['description'] ? raw['description'] : null, + raw['invite_link'] ? raw['invite_link'] : null, + raw['pinned_message'] ? Message.deserialize(raw['pinned_message']) : null, + raw['sticker_set_name'] ? raw['sticker_set_name'] : null, + raw['can_set_sticker_set'] ? raw['can_set_sticker_set'] : null ) } @@ -118,7 +193,13 @@ class Chat { 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 + all_members_are_administrators: this.allMembersAreAdministrators ? this.allMembersAreAdministrators : undefined, + photo: this.photo ? this.photo.serialize() : undefined, + description: this.description ? this.description : undefined, + invite_link: this.inviteLink ? this.inviteLink : undefined, + pinned_message: this.pinnedMessage ? this.pinnedMessage.serialize() : undefined, + sticker_set_name: this.stickerSetName ? this.stickerSetName : undefined, + can_set_sticker_set: this.canSetStickerSet ? this.canSetStickerSet : undefined } } diff --git a/lib/models/ChatMember.js b/lib/models/ChatMember.js index 84f5219..b292582 100644 --- a/lib/models/ChatMember.js +++ b/lib/models/ChatMember.js @@ -3,7 +3,7 @@ const User = require('./User') /** - * This object contains information about one member of the chat. + * This object contains information about one member of a chat. */ class ChatMember { @@ -11,10 +11,55 @@ class ChatMember { * * @param {User} user * @param {string} status + * @param {number|null} [untilDate] + * @param {boolean|null} [canBeEdited] + * @param {boolean|null} [canChangeInfo] + * @param {boolean|null} [canPostMessages] + * @param {boolean|null} [canEditMessages] + * @param {boolean|null} [canDeleteMessages] + * @param {boolean|null} [canInviteUsers] + * @param {boolean|null} [canRestrictMembers] + * @param {boolean|null} [canPinMessages] + * @param {boolean|null} [canPromoteMembers] + * @param {boolean|null} [canSendMessages] + * @param {boolean|null} [canSendMediaMessages] + * @param {boolean|null} [canSendOtherMessages] + * @param {boolean|null} [canAddWebPagePreviews] */ - constructor(user, status) { + constructor( + user, + status, + untilDate, + canBeEdited, + canChangeInfo, + canPostMessages, + canEditMessages, + canDeleteMessages, + canInviteUsers, + canRestrictMembers, + canPinMessages, + canPromoteMembers, + canSendMessages, + canSendMediaMessages, + canSendOtherMessages, + canAddWebPagePreviews + ) { this._user = user this._status = status + this._untilDate = untilDate + this._canBeEdited = canBeEdited + this._canChangeInfo = canChangeInfo + this._canPostMessages = canPostMessages + this._canEditMessages = canEditMessages + this._canDeleteMessages = canDeleteMessages + this._canInviteUsers = canInviteUsers + this._canRestrictMembers = canRestrictMembers + this._canPinMessages = canPinMessages + this._canPromoteMembers = canPromoteMembers + this._canSendMessages = canSendMessages + this._canSendMediaMessages = canSendMediaMessages + this._canSendOtherMessages = canSendOtherMessages + this._canAddWebPagePreviews = canAddWebPagePreviews } /** @@ -26,20 +71,149 @@ class ChatMember { } /** - * The member's status in the chat. Can be “creator”, “administrator”, “member”, “left” or “kicked” + * The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked” * @returns {string} */ get status() { return this._status } + /** + * Restricted and kicked only. Date when restrictions will be lifted for this user, unix time + * @returns {number|null} + */ + get untilDate() { + return this._untilDate + } + + /** + * Administrators only. True, if the bot is allowed to edit administrator privileges of that user + * @returns {boolean|null} + */ + get canBeEdited() { + return this._canBeEdited + } + + /** + * Administrators only. True, if the administrator can change the chat title, photo and other settings + * @returns {boolean|null} + */ + get canChangeInfo() { + return this._canChangeInfo + } + + /** + * Administrators only. True, if the administrator can post in the channel, channels only + * @returns {boolean|null} + */ + get canPostMessages() { + return this._canPostMessages + } + + /** + * Administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only + * @returns {boolean|null} + */ + get canEditMessages() { + return this._canEditMessages + } + + /** + * Administrators only. True, if the administrator can delete messages of other users + * @returns {boolean|null} + */ + get canDeleteMessages() { + return this._canDeleteMessages + } + + /** + * Administrators only. True, if the administrator can invite new users to the chat + * @returns {boolean|null} + */ + get canInviteUsers() { + return this._canInviteUsers + } + + /** + * Administrators only. True, if the administrator can restrict, ban or unban chat members + * @returns {boolean|null} + */ + get canRestrictMembers() { + return this._canRestrictMembers + } + + /** + * Administrators only. True, if the administrator can pin messages, supergroups only + * @returns {boolean|null} + */ + get canPinMessages() { + return this._canPinMessages + } + + /** + * Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user) + * @returns {boolean|null} + */ + get canPromoteMembers() { + return this._canPromoteMembers + } + + /** + * Restricted only. True, if the user can send text messages, contacts, locations and venues + * @returns {boolean|null} + */ + get canSendMessages() { + return this._canSendMessages + } + + /** + * Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages + * @returns {boolean|null} + */ + get canSendMediaMessages() { + return this._canSendMediaMessages + } + + /** + * Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages + * @returns {boolean|null} + */ + get canSendOtherMessages() { + return this._canSendOtherMessages + } + + /** + * Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages + * @returns {boolean|null} + */ + get canAddWebPagePreviews() { + return this._canAddWebPagePreviews + } + /** * * @param {Object} raw * @returns {ChatMember} */ static deserialize(raw) { - return new ChatMember(raw['user'] ? User.deserialize(raw['user']) : null, raw['status']) + return new ChatMember( + raw['user'] ? User.deserialize(raw['user']) : null, + raw['status'], + raw['until_date'] ? raw['until_date'] : null, + raw['can_be_edited'] ? raw['can_be_edited'] : null, + raw['can_change_info'] ? raw['can_change_info'] : null, + raw['can_post_messages'] ? raw['can_post_messages'] : null, + raw['can_edit_messages'] ? raw['can_edit_messages'] : null, + raw['can_delete_messages'] ? raw['can_delete_messages'] : null, + raw['can_invite_users'] ? raw['can_invite_users'] : null, + raw['can_restrict_members'] ? raw['can_restrict_members'] : null, + raw['can_pin_messages'] ? raw['can_pin_messages'] : null, + raw['can_promote_members'] ? raw['can_promote_members'] : null, + raw['can_send_messages'] ? raw['can_send_messages'] : null, + raw['can_send_media_messages'] ? raw['can_send_media_messages'] : null, + raw['can_send_other_messages'] ? raw['can_send_other_messages'] : null, + raw['can_add_web_page_previews'] ? raw['can_add_web_page_previews'] : null + ) } /** @@ -49,7 +223,21 @@ class ChatMember { serialize() { return { user: this.user ? this.user.serialize() : undefined, - status: this.status ? this.status : undefined + status: this.status ? this.status : undefined, + until_date: this.untilDate ? this.untilDate : undefined, + can_be_edited: this.canBeEdited ? this.canBeEdited : undefined, + can_change_info: this.canChangeInfo ? this.canChangeInfo : undefined, + can_post_messages: this.canPostMessages ? this.canPostMessages : undefined, + can_edit_messages: this.canEditMessages ? this.canEditMessages : undefined, + can_delete_messages: this.canDeleteMessages ? this.canDeleteMessages : undefined, + can_invite_users: this.canInviteUsers ? this.canInviteUsers : undefined, + can_restrict_members: this.canRestrictMembers ? this.canRestrictMembers : undefined, + can_pin_messages: this.canPinMessages ? this.canPinMessages : undefined, + can_promote_members: this.canPromoteMembers ? this.canPromoteMembers : undefined, + can_send_messages: this.canSendMessages ? this.canSendMessages : undefined, + can_send_media_messages: this.canSendMediaMessages ? this.canSendMediaMessages : undefined, + can_send_other_messages: this.canSendOtherMessages ? this.canSendOtherMessages : undefined, + can_add_web_page_previews: this.canAddWebPagePreviews ? this.canAddWebPagePreviews : undefined } } diff --git a/lib/models/ChatPhoto.js b/lib/models/ChatPhoto.js new file mode 100644 index 0000000..8634ec2 --- /dev/null +++ b/lib/models/ChatPhoto.js @@ -0,0 +1,63 @@ +'use strict' + +/** + * This object represents a chat photo. + */ + +class ChatPhoto { + /** + * + * @param {string} smallFileId + * @param {string} bigFileId + */ + constructor(smallFileId, bigFileId) { + this._smallFileId = smallFileId + this._bigFileId = bigFileId + } + + /** + * Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download. + * @returns {string} + */ + get smallFileId() { + return this._smallFileId + } + + /** + * Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. + * @returns {string} + */ + get bigFileId() { + return this._bigFileId + } + + /** + * + * @param {Object} raw + * @returns {ChatPhoto} + */ + static deserialize(raw) { + return new ChatPhoto(raw['small_file_id'], raw['big_file_id']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + small_file_id: this.smallFileId ? this.smallFileId : undefined, + big_file_id: this.bigFileId ? this.bigFileId : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = ChatPhoto \ No newline at end of file diff --git a/lib/models/Contact.js b/lib/models/Contact.js index 5c85615..2a7b91b 100644 --- a/lib/models/Contact.js +++ b/lib/models/Contact.js @@ -11,12 +11,14 @@ class Contact { * @param {string} firstName * @param {string|null} [lastName] * @param {number|null} [userId] + * @param {string|null} [vcard] */ - constructor(phoneNumber, firstName, lastName, userId) { + constructor(phoneNumber, firstName, lastName, userId, vcard) { this._phoneNumber = phoneNumber this._firstName = firstName this._lastName = lastName this._userId = userId + this._vcard = vcard } /** @@ -51,13 +53,27 @@ class Contact { return this._userId } + /** + * Additional data about the contact in the form of a vCard + * @returns {string|null} + */ + get vcard() { + return this._vcard + } + /** * * @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) + return new Contact( + raw['phone_number'], + raw['first_name'], + raw['last_name'] ? raw['last_name'] : null, + raw['user_id'] ? raw['user_id'] : null, + raw['vcard'] ? raw['vcard'] : null + ) } /** @@ -69,7 +85,8 @@ class Contact { 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 + user_id: this.userId ? this.userId : undefined, + vcard: this.vcard ? this.vcard : undefined } } diff --git a/lib/models/EncryptedCredentials.js b/lib/models/EncryptedCredentials.js new file mode 100644 index 0000000..f5ead5d --- /dev/null +++ b/lib/models/EncryptedCredentials.js @@ -0,0 +1,74 @@ +'use strict' + +/** + * Contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes. + */ + +class EncryptedCredentials { + /** + * + * @param {string} data + * @param {string} hash + * @param {string} secret + */ + constructor(data, hash, secret) { + this._data = data + this._hash = hash + this._secret = secret + } + + /** + * Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication + * @returns {string} + */ + get data() { + return this._data + } + + /** + * Base64-encoded data hash for data authentication + * @returns {string} + */ + get hash() { + return this._hash + } + + /** + * Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption + * @returns {string} + */ + get secret() { + return this._secret + } + + /** + * + * @param {Object} raw + * @returns {EncryptedCredentials} + */ + static deserialize(raw) { + return new EncryptedCredentials(raw['data'], raw['hash'], raw['secret']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + data: this.data ? this.data : undefined, + hash: this.hash ? this.hash : undefined, + secret: this.secret ? this.secret : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = EncryptedCredentials \ No newline at end of file diff --git a/lib/models/EncryptedPassportElement.js b/lib/models/EncryptedPassportElement.js new file mode 100644 index 0000000..a30925b --- /dev/null +++ b/lib/models/EncryptedPassportElement.js @@ -0,0 +1,175 @@ +'use strict' + +const PassportFile = require('./PassportFile') + +/** + * Contains information about documents or other Telegram Passport elements shared with the bot by the user. + */ + +class EncryptedPassportElement { + /** + * + * @param {string} type + * @param {string|null} [data] + * @param {string|null} [phoneNumber] + * @param {string|null} [email] + * @param {PassportFile[]|null} [files] + * @param {PassportFile|null} [frontSide] + * @param {PassportFile|null} [reverseSide] + * @param {PassportFile|null} [selfie] + * @param {PassportFile[]|null} [translation] + * @param {string} hash + */ + constructor( + type, + data, + phoneNumber, + email, + files, + frontSide, + reverseSide, + selfie, + translation, + hash + ) { + this._type = type + this._data = data + this._phoneNumber = phoneNumber + this._email = email + this._files = files + this._frontSide = frontSide + this._reverseSide = reverseSide + this._selfie = selfie + this._translation = translation + this._hash = hash + } + + /** + * Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. + * @returns {string|null} + */ + get data() { + return this._data + } + + /** + * User's verified phone number, available only for “phone_number” type + * @returns {string|null} + */ + get phoneNumber() { + return this._phoneNumber + } + + /** + * User's verified email address, available only for “email” type + * @returns {string|null} + */ + get email() { + return this._email + } + + /** + * Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. + * @returns {PassportFile[]|null} + */ + get files() { + return this._files + } + + /** + * Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. + * @returns {PassportFile|null} + */ + get frontSide() { + return this._frontSide + } + + /** + * Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. + * @returns {PassportFile|null} + */ + get reverseSide() { + return this._reverseSide + } + + /** + * Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. + * @returns {PassportFile|null} + */ + get selfie() { + return this._selfie + } + + /** + * Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. + * @returns {PassportFile[]|null} + */ + get translation() { + return this._translation + } + + /** + * Base64-encoded element hash for using in PassportElementErrorUnspecified + * @returns {string} + */ + get hash() { + return this._hash + } + + /** + * + * @param {Object} raw + * @returns {EncryptedPassportElement} + */ + static deserialize(raw) { + return new EncryptedPassportElement( + raw['type'], + raw['data'] ? raw['data'] : null, + raw['phone_number'] ? raw['phone_number'] : null, + raw['email'] ? raw['email'] : null, + raw['files'] ? raw['files'].map(item => PassportFile.deserialize(item)) : null, + raw['front_side'] ? PassportFile.deserialize(raw['front_side']) : null, + raw['reverse_side'] ? PassportFile.deserialize(raw['reverse_side']) : null, + raw['selfie'] ? PassportFile.deserialize(raw['selfie']) : null, + raw['translation'] ? raw['translation'].map(item => PassportFile.deserialize(item)) : null, + raw['hash'] + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + type: this.type ? this.type : undefined, + data: this.data ? this.data : undefined, + phone_number: this.phoneNumber ? this.phoneNumber : undefined, + email: this.email ? this.email : undefined, + files: this.files ? this.files.map(item => item.serialize()) : undefined, + front_side: this.frontSide ? this.frontSide.serialize() : undefined, + reverse_side: this.reverseSide ? this.reverseSide.serialize() : undefined, + selfie: this.selfie ? this.selfie.serialize() : undefined, + translation: this.translation ? this.translation.map(item => item.serialize()) : undefined, + hash: this.hash ? this.hash : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = EncryptedPassportElement \ No newline at end of file diff --git a/lib/models/InlineKeyboardButton.js b/lib/models/InlineKeyboardButton.js index 3420493..fc19c9f 100644 --- a/lib/models/InlineKeyboardButton.js +++ b/lib/models/InlineKeyboardButton.js @@ -15,14 +15,24 @@ class InlineKeyboardButton { * @param {string|null} [switchInlineQuery] * @param {string|null} [switchInlineQueryCurrentChat] * @param {CallbackGame|null} [callbackGame] + * @param {boolean|null} [pay] */ - constructor(text, url, callbackData, switchInlineQuery, switchInlineQueryCurrentChat, callbackGame) { + constructor( + text, + url, + callbackData, + switchInlineQuery, + switchInlineQueryCurrentChat, + callbackGame, + pay + ) { this._text = text this._url = url this._callbackData = callbackData this._switchInlineQuery = switchInlineQuery this._switchInlineQueryCurrentChat = switchInlineQueryCurrentChat this._callbackGame = callbackGame + this._pay = pay } /** @@ -34,7 +44,7 @@ class InlineKeyboardButton { } /** - * HTTP url to be opened when button is pressed + * HTTP or tg:// url to be opened when button is pressed * @returns {string|null} */ get url() { @@ -58,7 +68,7 @@ class InlineKeyboardButton { } /** - * 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. + * 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() { @@ -73,6 +83,14 @@ class InlineKeyboardButton { return this._callbackGame } + /** + * Specify True, to send a Pay button.NOTE: This type of button must always be the first button in the first row. + * @returns {boolean|null} + */ + get pay() { + return this._pay + } + /** * * @param {Object} raw @@ -85,7 +103,8 @@ class InlineKeyboardButton { 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 + raw['callback_game'] ? CallbackGame.deserialize(raw['callback_game']) : null, + raw['pay'] ? raw['pay'] : null ) } @@ -100,7 +119,8 @@ class InlineKeyboardButton { 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 + callback_game: this.callbackGame ? this.callbackGame.serialize() : undefined, + pay: this.pay ? this.pay : undefined } } diff --git a/lib/models/InlineQueryResultAudio.js b/lib/models/InlineQueryResultAudio.js index f0f13b7..86f326f 100644 --- a/lib/models/InlineQueryResultAudio.js +++ b/lib/models/InlineQueryResultAudio.js @@ -15,6 +15,7 @@ class InlineQueryResultAudio extends InlineQueryResult { * @param {string} audioUrl * @param {string} title * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {string|null} [performer] * @param {number|null} [audioDuration] * @param {InlineKeyboardMarkup|null} [replyMarkup] @@ -26,6 +27,7 @@ class InlineQueryResultAudio extends InlineQueryResult { audioUrl, title, caption, + parseMode, performer, audioDuration, replyMarkup, @@ -37,6 +39,7 @@ class InlineQueryResultAudio extends InlineQueryResult { this._audioUrl = audioUrl this._title = title this._caption = caption + this._parseMode = parseMode this._performer = performer this._audioDuration = audioDuration this._replyMarkup = replyMarkup @@ -76,13 +79,21 @@ class InlineQueryResultAudio extends InlineQueryResult { } /** - * Caption, 0-200 characters + * Caption, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Performer * @returns {string|null} @@ -127,6 +138,7 @@ class InlineQueryResultAudio extends InlineQueryResult { raw['audio_url'], raw['title'], raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['performer'] ? raw['performer'] : null, raw['audio_duration'] ? raw['audio_duration'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, @@ -145,6 +157,7 @@ class InlineQueryResultAudio extends InlineQueryResult { audio_url: this.audioUrl ? this.audioUrl : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, performer: this.performer ? this.performer : undefined, audio_duration: this.audioDuration ? this.audioDuration : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, diff --git a/lib/models/InlineQueryResultCachedAudio.js b/lib/models/InlineQueryResultCachedAudio.js index 795fc15..43d627e 100644 --- a/lib/models/InlineQueryResultCachedAudio.js +++ b/lib/models/InlineQueryResultCachedAudio.js @@ -14,15 +14,25 @@ class InlineQueryResultCachedAudio extends InlineQueryResult { * @param {string} id * @param {string} audioFileId * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ - constructor(type, id, audioFileId, caption, replyMarkup, inputMessageContent) { + constructor( + type, + id, + audioFileId, + caption, + parseMode, + replyMarkup, + inputMessageContent + ) { super() this._type = type this._id = id this._audioFileId = audioFileId this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -52,13 +62,21 @@ class InlineQueryResultCachedAudio extends InlineQueryResult { } /** - * Caption, 0-200 characters + * Caption, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -86,6 +104,7 @@ class InlineQueryResultCachedAudio extends InlineQueryResult { raw['id'], raw['audio_file_id'], raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -101,6 +120,7 @@ class InlineQueryResultCachedAudio extends InlineQueryResult { id: this.id ? this.id : undefined, audio_file_id: this.audioFileId ? this.audioFileId : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultCachedDocument.js b/lib/models/InlineQueryResultCachedDocument.js index d5d4e69..78d135c 100644 --- a/lib/models/InlineQueryResultCachedDocument.js +++ b/lib/models/InlineQueryResultCachedDocument.js @@ -4,7 +4,7 @@ const InlineKeyboardMarkup = require('./InlineKeyboardMarkup') const InputMessageContent = require('./InputMessageContent') const InlineQueryResult = require('./InlineQueryResult') /** - * Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only pdf-files and zip archives can be sent using this method. + * Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. */ class InlineQueryResultCachedDocument extends InlineQueryResult { @@ -16,6 +16,7 @@ class InlineQueryResultCachedDocument extends InlineQueryResult { * @param {string} documentFileId * @param {string|null} [description] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -26,6 +27,7 @@ class InlineQueryResultCachedDocument extends InlineQueryResult { documentFileId, description, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -36,6 +38,7 @@ class InlineQueryResultCachedDocument extends InlineQueryResult { this._documentFileId = documentFileId this._description = description this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -81,13 +84,21 @@ class InlineQueryResultCachedDocument extends InlineQueryResult { } /** - * Caption of the document to be sent, 0-200 characters + * Caption of the document to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -117,6 +128,7 @@ class InlineQueryResultCachedDocument extends InlineQueryResult { raw['document_file_id'], raw['description'] ? raw['description'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -134,6 +146,7 @@ class InlineQueryResultCachedDocument extends InlineQueryResult { document_file_id: this.documentFileId ? this.documentFileId : undefined, description: this.description ? this.description : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultCachedGif.js b/lib/models/InlineQueryResultCachedGif.js index d6a05f0..42f9ca2 100644 --- a/lib/models/InlineQueryResultCachedGif.js +++ b/lib/models/InlineQueryResultCachedGif.js @@ -15,6 +15,7 @@ class InlineQueryResultCachedGif extends InlineQueryResult { * @param {string} gifFileId * @param {string|null} [title] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -24,6 +25,7 @@ class InlineQueryResultCachedGif extends InlineQueryResult { gifFileId, title, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -33,6 +35,7 @@ class InlineQueryResultCachedGif extends InlineQueryResult { this._gifFileId = gifFileId this._title = title this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -70,13 +73,21 @@ class InlineQueryResultCachedGif extends InlineQueryResult { } /** - * Caption of the GIF file to be sent, 0-200 characters + * Caption of the GIF file to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -105,6 +116,7 @@ class InlineQueryResultCachedGif extends InlineQueryResult { raw['gif_file_id'], raw['title'] ? raw['title'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -121,6 +133,7 @@ class InlineQueryResultCachedGif extends InlineQueryResult { gif_file_id: this.gifFileId ? this.gifFileId : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultCachedMpeg4Gif.js b/lib/models/InlineQueryResultCachedMpeg4Gif.js index ae52c6f..c235307 100644 --- a/lib/models/InlineQueryResultCachedMpeg4Gif.js +++ b/lib/models/InlineQueryResultCachedMpeg4Gif.js @@ -15,6 +15,7 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult { * @param {string} mpeg4FileId * @param {string|null} [title] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -24,6 +25,7 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult { mpeg4FileId, title, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -33,6 +35,7 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult { this._mpeg4FileId = mpeg4FileId this._title = title this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -70,13 +73,21 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult { } /** - * Caption of the MPEG-4 file to be sent, 0-200 characters + * Caption of the MPEG-4 file to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -105,6 +116,7 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult { raw['mpeg4_file_id'], raw['title'] ? raw['title'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -121,6 +133,7 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult { mpeg4_file_id: this.mpeg4FileId ? this.mpeg4FileId : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultCachedPhoto.js b/lib/models/InlineQueryResultCachedPhoto.js index b17c685..0022613 100644 --- a/lib/models/InlineQueryResultCachedPhoto.js +++ b/lib/models/InlineQueryResultCachedPhoto.js @@ -16,6 +16,7 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult { * @param {string|null} [title] * @param {string|null} [description] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -26,6 +27,7 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult { title, description, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -36,6 +38,7 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult { this._title = title this._description = description this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -81,13 +84,21 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult { } /** - * Caption of the photo to be sent, 0-200 characters + * Caption of the photo to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -117,6 +128,7 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult { raw['title'] ? raw['title'] : null, raw['description'] ? raw['description'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -134,6 +146,7 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult { title: this.title ? this.title : undefined, description: this.description ? this.description : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultCachedVideo.js b/lib/models/InlineQueryResultCachedVideo.js index ba51800..c667841 100644 --- a/lib/models/InlineQueryResultCachedVideo.js +++ b/lib/models/InlineQueryResultCachedVideo.js @@ -16,6 +16,7 @@ class InlineQueryResultCachedVideo extends InlineQueryResult { * @param {string} title * @param {string|null} [description] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -26,6 +27,7 @@ class InlineQueryResultCachedVideo extends InlineQueryResult { title, description, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -36,6 +38,7 @@ class InlineQueryResultCachedVideo extends InlineQueryResult { this._title = title this._description = description this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -81,13 +84,21 @@ class InlineQueryResultCachedVideo extends InlineQueryResult { } /** - * Caption of the video to be sent, 0-200 characters + * Caption of the video to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -117,6 +128,7 @@ class InlineQueryResultCachedVideo extends InlineQueryResult { raw['title'], raw['description'] ? raw['description'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -134,6 +146,7 @@ class InlineQueryResultCachedVideo extends InlineQueryResult { title: this.title ? this.title : undefined, description: this.description ? this.description : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultCachedVoice.js b/lib/models/InlineQueryResultCachedVoice.js index 2d1f5ef..0568369 100644 --- a/lib/models/InlineQueryResultCachedVoice.js +++ b/lib/models/InlineQueryResultCachedVoice.js @@ -15,6 +15,7 @@ class InlineQueryResultCachedVoice extends InlineQueryResult { * @param {string} voiceFileId * @param {string} title * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -24,6 +25,7 @@ class InlineQueryResultCachedVoice extends InlineQueryResult { voiceFileId, title, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -33,6 +35,7 @@ class InlineQueryResultCachedVoice extends InlineQueryResult { this._voiceFileId = voiceFileId this._title = title this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -70,13 +73,21 @@ class InlineQueryResultCachedVoice extends InlineQueryResult { } /** - * Caption, 0-200 characters + * Caption, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -105,6 +116,7 @@ class InlineQueryResultCachedVoice extends InlineQueryResult { raw['voice_file_id'], raw['title'], raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -121,6 +133,7 @@ class InlineQueryResultCachedVoice extends InlineQueryResult { voice_file_id: this.voiceFileId ? this.voiceFileId : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultContact.js b/lib/models/InlineQueryResultContact.js index 41ec19a..73de4ab 100644 --- a/lib/models/InlineQueryResultContact.js +++ b/lib/models/InlineQueryResultContact.js @@ -15,6 +15,7 @@ class InlineQueryResultContact extends InlineQueryResult { * @param {string} phoneNumber * @param {string} firstName * @param {string|null} [lastName] + * @param {string|null} [vcard] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] * @param {string|null} [thumbUrl] @@ -27,6 +28,7 @@ class InlineQueryResultContact extends InlineQueryResult { phoneNumber, firstName, lastName, + vcard, replyMarkup, inputMessageContent, thumbUrl, @@ -39,6 +41,7 @@ class InlineQueryResultContact extends InlineQueryResult { this._phoneNumber = phoneNumber this._firstName = firstName this._lastName = lastName + this._vcard = vcard this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent this._thumbUrl = thumbUrl @@ -86,6 +89,14 @@ class InlineQueryResultContact extends InlineQueryResult { return this._lastName } + /** + * Additional data about the contact in the form of a vCard, 0-2048 bytes + * @returns {string|null} + */ + get vcard() { + return this._vcard + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -138,6 +149,7 @@ class InlineQueryResultContact extends InlineQueryResult { raw['phone_number'], raw['first_name'], raw['last_name'] ? raw['last_name'] : null, + raw['vcard'] ? raw['vcard'] : 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, @@ -157,6 +169,7 @@ class InlineQueryResultContact extends InlineQueryResult { phone_number: this.phoneNumber ? this.phoneNumber : undefined, first_name: this.firstName ? this.firstName : undefined, last_name: this.lastName ? this.lastName : undefined, + vcard: this.vcard ? this.vcard : 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, diff --git a/lib/models/InlineQueryResultDocument.js b/lib/models/InlineQueryResultDocument.js index a591d90..e279bbc 100644 --- a/lib/models/InlineQueryResultDocument.js +++ b/lib/models/InlineQueryResultDocument.js @@ -14,6 +14,7 @@ class InlineQueryResultDocument extends InlineQueryResult { * @param {string} id * @param {string} title * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {string} documentUrl * @param {string} mimeType * @param {string|null} [description] @@ -28,6 +29,7 @@ class InlineQueryResultDocument extends InlineQueryResult { id, title, caption, + parseMode, documentUrl, mimeType, description, @@ -42,6 +44,7 @@ class InlineQueryResultDocument extends InlineQueryResult { this._id = id this._title = title this._caption = caption + this._parseMode = parseMode this._documentUrl = documentUrl this._mimeType = mimeType this._description = description @@ -77,13 +80,21 @@ class InlineQueryResultDocument extends InlineQueryResult { } /** - * Caption of the document to be sent, 0-200 characters + * Caption of the document to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * A valid URL for the file * @returns {string} @@ -159,6 +170,7 @@ class InlineQueryResultDocument extends InlineQueryResult { raw['id'], raw['title'], raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['document_url'], raw['mime_type'], raw['description'] ? raw['description'] : null, @@ -180,6 +192,7 @@ class InlineQueryResultDocument extends InlineQueryResult { id: this.id ? this.id : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, document_url: this.documentUrl ? this.documentUrl : undefined, mime_type: this.mimeType ? this.mimeType : undefined, description: this.description ? this.description : undefined, diff --git a/lib/models/InlineQueryResultGif.js b/lib/models/InlineQueryResultGif.js index 2a3d317..e4bb722 100644 --- a/lib/models/InlineQueryResultGif.js +++ b/lib/models/InlineQueryResultGif.js @@ -15,9 +15,11 @@ class InlineQueryResultGif extends InlineQueryResult { * @param {string} gifUrl * @param {number|null} [gifWidth] * @param {number|null} [gifHeight] + * @param {number|null} [gifDuration] * @param {string} thumbUrl * @param {string|null} [title] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -27,9 +29,11 @@ class InlineQueryResultGif extends InlineQueryResult { gifUrl, gifWidth, gifHeight, + gifDuration, thumbUrl, title, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -39,9 +43,11 @@ class InlineQueryResultGif extends InlineQueryResult { this._gifUrl = gifUrl this._gifWidth = gifWidth this._gifHeight = gifHeight + this._gifDuration = gifDuration this._thumbUrl = thumbUrl this._title = title this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -86,6 +92,14 @@ class InlineQueryResultGif extends InlineQueryResult { return this._gifHeight } + /** + * Duration of the GIF + * @returns {number|null} + */ + get gifDuration() { + return this._gifDuration + } + /** * URL of the static thumbnail for the result (jpeg or gif) * @returns {string} @@ -103,13 +117,21 @@ class InlineQueryResultGif extends InlineQueryResult { } /** - * Caption of the GIF file to be sent, 0-200 characters + * Caption of the GIF file to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -138,9 +160,11 @@ class InlineQueryResultGif extends InlineQueryResult { raw['gif_url'], raw['gif_width'] ? raw['gif_width'] : null, raw['gif_height'] ? raw['gif_height'] : null, + raw['gif_duration'] ? raw['gif_duration'] : null, raw['thumb_url'], raw['title'] ? raw['title'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -157,9 +181,11 @@ class InlineQueryResultGif extends InlineQueryResult { gif_url: this.gifUrl ? this.gifUrl : undefined, gif_width: this.gifWidth ? this.gifWidth : undefined, gif_height: this.gifHeight ? this.gifHeight : undefined, + gif_duration: this.gifDuration ? this.gifDuration : undefined, thumb_url: this.thumbUrl ? this.thumbUrl : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultLocation.js b/lib/models/InlineQueryResultLocation.js index 349974d..26111dc 100644 --- a/lib/models/InlineQueryResultLocation.js +++ b/lib/models/InlineQueryResultLocation.js @@ -15,6 +15,7 @@ class InlineQueryResultLocation extends InlineQueryResult { * @param {number} latitude * @param {number} longitude * @param {string} title + * @param {number|null} [livePeriod] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] * @param {string|null} [thumbUrl] @@ -27,6 +28,7 @@ class InlineQueryResultLocation extends InlineQueryResult { latitude, longitude, title, + livePeriod, replyMarkup, inputMessageContent, thumbUrl, @@ -39,6 +41,7 @@ class InlineQueryResultLocation extends InlineQueryResult { this._latitude = latitude this._longitude = longitude this._title = title + this._livePeriod = livePeriod this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent this._thumbUrl = thumbUrl @@ -86,6 +89,14 @@ class InlineQueryResultLocation extends InlineQueryResult { return this._title } + /** + * Period in seconds for which the location can be updated, should be between 60 and 86400. + * @returns {number|null} + */ + get livePeriod() { + return this._livePeriod + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -138,6 +149,7 @@ class InlineQueryResultLocation extends InlineQueryResult { raw['latitude'], raw['longitude'], raw['title'], + raw['live_period'] ? raw['live_period'] : 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, @@ -157,6 +169,7 @@ class InlineQueryResultLocation extends InlineQueryResult { latitude: this.latitude ? this.latitude : undefined, longitude: this.longitude ? this.longitude : undefined, title: this.title ? this.title : undefined, + live_period: this.livePeriod ? this.livePeriod : 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, diff --git a/lib/models/InlineQueryResultMpeg4Gif.js b/lib/models/InlineQueryResultMpeg4Gif.js index e6bd408..97181e6 100644 --- a/lib/models/InlineQueryResultMpeg4Gif.js +++ b/lib/models/InlineQueryResultMpeg4Gif.js @@ -15,9 +15,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult { * @param {string} mpeg4Url * @param {number|null} [mpeg4Width] * @param {number|null} [mpeg4Height] + * @param {number|null} [mpeg4Duration] * @param {string} thumbUrl * @param {string|null} [title] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -27,9 +29,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult { mpeg4Url, mpeg4Width, mpeg4Height, + mpeg4Duration, thumbUrl, title, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -39,9 +43,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult { this._mpeg4Url = mpeg4Url this._mpeg4Width = mpeg4Width this._mpeg4Height = mpeg4Height + this._mpeg4Duration = mpeg4Duration this._thumbUrl = thumbUrl this._title = title this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -86,6 +92,14 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult { return this._mpeg4Height } + /** + * Video duration + * @returns {number|null} + */ + get mpeg4Duration() { + return this._mpeg4Duration + } + /** * URL of the static thumbnail (jpeg or gif) for the result * @returns {string} @@ -103,13 +117,21 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult { } /** - * Caption of the MPEG-4 file to be sent, 0-200 characters + * Caption of the MPEG-4 file to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -138,9 +160,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult { raw['mpeg4_url'], raw['mpeg4_width'] ? raw['mpeg4_width'] : null, raw['mpeg4_height'] ? raw['mpeg4_height'] : null, + raw['mpeg4_duration'] ? raw['mpeg4_duration'] : null, raw['thumb_url'], raw['title'] ? raw['title'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -157,9 +181,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult { mpeg4_url: this.mpeg4Url ? this.mpeg4Url : undefined, mpeg4_width: this.mpeg4Width ? this.mpeg4Width : undefined, mpeg4_height: this.mpeg4Height ? this.mpeg4Height : undefined, + mpeg4_duration: this.mpeg4Duration ? this.mpeg4Duration : undefined, thumb_url: this.thumbUrl ? this.thumbUrl : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultPhoto.js b/lib/models/InlineQueryResultPhoto.js index 8403ea0..6436011 100644 --- a/lib/models/InlineQueryResultPhoto.js +++ b/lib/models/InlineQueryResultPhoto.js @@ -19,6 +19,7 @@ class InlineQueryResultPhoto extends InlineQueryResult { * @param {string|null} [title] * @param {string|null} [description] * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] */ @@ -32,6 +33,7 @@ class InlineQueryResultPhoto extends InlineQueryResult { title, description, caption, + parseMode, replyMarkup, inputMessageContent ) { @@ -45,6 +47,7 @@ class InlineQueryResultPhoto extends InlineQueryResult { this._title = title this._description = description this._caption = caption + this._parseMode = parseMode this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent } @@ -114,13 +117,21 @@ class InlineQueryResultPhoto extends InlineQueryResult { } /** - * Caption of the photo to be sent, 0-200 characters + * Caption of the photo to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -153,6 +164,7 @@ class InlineQueryResultPhoto extends InlineQueryResult { raw['title'] ? raw['title'] : null, raw['description'] ? raw['description'] : null, raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['reply_markup'] ? InlineKeyboardMarkup.deserialize(raw['reply_markup']) : null, raw['input_message_content'] ? InputMessageContent.deserialize(raw['input_message_content']) : null ) @@ -173,6 +185,7 @@ class InlineQueryResultPhoto extends InlineQueryResult { title: this.title ? this.title : undefined, description: this.description ? this.description : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, reply_markup: this.replyMarkup ? this.replyMarkup.serialize() : undefined, input_message_content: this.inputMessageContent ? this.inputMessageContent.serialize() : undefined } diff --git a/lib/models/InlineQueryResultVenue.js b/lib/models/InlineQueryResultVenue.js index e9cbb9e..eb401fb 100644 --- a/lib/models/InlineQueryResultVenue.js +++ b/lib/models/InlineQueryResultVenue.js @@ -17,6 +17,7 @@ class InlineQueryResultVenue extends InlineQueryResult { * @param {string} title * @param {string} address * @param {string|null} [foursquareId] + * @param {string|null} [foursquareType] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] * @param {string|null} [thumbUrl] @@ -31,6 +32,7 @@ class InlineQueryResultVenue extends InlineQueryResult { title, address, foursquareId, + foursquareType, replyMarkup, inputMessageContent, thumbUrl, @@ -45,6 +47,7 @@ class InlineQueryResultVenue extends InlineQueryResult { this._title = title this._address = address this._foursquareId = foursquareId + this._foursquareType = foursquareType this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent this._thumbUrl = thumbUrl @@ -108,6 +111,14 @@ class InlineQueryResultVenue extends InlineQueryResult { return this._foursquareId } + /** + * Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + * @returns {string|null} + */ + get foursquareType() { + return this._foursquareType + } + /** * Inline keyboard attached to the message * @returns {InlineKeyboardMarkup|null} @@ -162,6 +173,7 @@ class InlineQueryResultVenue extends InlineQueryResult { raw['title'], raw['address'], raw['foursquare_id'] ? raw['foursquare_id'] : null, + raw['foursquare_type'] ? raw['foursquare_type'] : 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, @@ -183,6 +195,7 @@ class InlineQueryResultVenue extends InlineQueryResult { title: this.title ? this.title : undefined, address: this.address ? this.address : undefined, foursquare_id: this.foursquareId ? this.foursquareId : undefined, + foursquare_type: this.foursquareType ? this.foursquareType : 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, diff --git a/lib/models/InlineQueryResultVideo.js b/lib/models/InlineQueryResultVideo.js index a3a649a..90f90a7 100644 --- a/lib/models/InlineQueryResultVideo.js +++ b/lib/models/InlineQueryResultVideo.js @@ -17,6 +17,7 @@ class InlineQueryResultVideo extends InlineQueryResult { * @param {string} thumbUrl * @param {string} title * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {number|null} [videoWidth] * @param {number|null} [videoHeight] * @param {number|null} [videoDuration] @@ -32,6 +33,7 @@ class InlineQueryResultVideo extends InlineQueryResult { thumbUrl, title, caption, + parseMode, videoWidth, videoHeight, videoDuration, @@ -47,6 +49,7 @@ class InlineQueryResultVideo extends InlineQueryResult { this._thumbUrl = thumbUrl this._title = title this._caption = caption + this._parseMode = parseMode this._videoWidth = videoWidth this._videoHeight = videoHeight this._videoDuration = videoDuration @@ -104,13 +107,21 @@ class InlineQueryResultVideo extends InlineQueryResult { } /** - * Caption of the video to be sent, 0-200 characters + * Caption of the video to be sent, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Video width * @returns {number|null} @@ -152,7 +163,7 @@ class InlineQueryResultVideo extends InlineQueryResult { } /** - * Content of the message to be sent instead of the video + * Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video). * @returns {InputMessageContent|null} */ get inputMessageContent() { @@ -173,6 +184,7 @@ class InlineQueryResultVideo extends InlineQueryResult { raw['thumb_url'], raw['title'], raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, raw['video_width'] ? raw['video_width'] : null, raw['video_height'] ? raw['video_height'] : null, raw['video_duration'] ? raw['video_duration'] : null, @@ -195,6 +207,7 @@ class InlineQueryResultVideo extends InlineQueryResult { thumb_url: this.thumbUrl ? this.thumbUrl : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, video_width: this.videoWidth ? this.videoWidth : undefined, video_height: this.videoHeight ? this.videoHeight : undefined, video_duration: this.videoDuration ? this.videoDuration : undefined, diff --git a/lib/models/InlineQueryResultVoice.js b/lib/models/InlineQueryResultVoice.js index 4edf8b7..645c4ec 100644 --- a/lib/models/InlineQueryResultVoice.js +++ b/lib/models/InlineQueryResultVoice.js @@ -15,6 +15,7 @@ class InlineQueryResultVoice extends InlineQueryResult { * @param {string} voiceUrl * @param {string} title * @param {string|null} [caption] + * @param {string|null} [parseMode] * @param {number|null} [voiceDuration] * @param {InlineKeyboardMarkup|null} [replyMarkup] * @param {InputMessageContent|null} [inputMessageContent] @@ -25,6 +26,7 @@ class InlineQueryResultVoice extends InlineQueryResult { voiceUrl, title, caption, + parseMode, voiceDuration, replyMarkup, inputMessageContent @@ -35,6 +37,7 @@ class InlineQueryResultVoice extends InlineQueryResult { this._voiceUrl = voiceUrl this._title = title this._caption = caption + this._parseMode = parseMode this._voiceDuration = voiceDuration this._replyMarkup = replyMarkup this._inputMessageContent = inputMessageContent @@ -73,13 +76,21 @@ class InlineQueryResultVoice extends InlineQueryResult { } /** - * Caption, 0-200 characters + * Caption, 0-1024 characters * @returns {string|null} */ get caption() { return this._caption } + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + /** * Recording duration in seconds * @returns {number|null} @@ -116,6 +127,7 @@ class InlineQueryResultVoice extends InlineQueryResult { raw['voice_url'], raw['title'], raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : 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 @@ -133,6 +145,7 @@ class InlineQueryResultVoice extends InlineQueryResult { voice_url: this.voiceUrl ? this.voiceUrl : undefined, title: this.title ? this.title : undefined, caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : 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 diff --git a/lib/models/InputContactMessageContent.js b/lib/models/InputContactMessageContent.js index e365d29..77102ad 100644 --- a/lib/models/InputContactMessageContent.js +++ b/lib/models/InputContactMessageContent.js @@ -11,12 +11,14 @@ class InputContactMessageContent extends InputMessageContent { * @param {string} phoneNumber * @param {string} firstName * @param {string|null} [lastName] + * @param {string|null} [vcard] */ - constructor(phoneNumber, firstName, lastName) { + constructor(phoneNumber, firstName, lastName, vcard) { super() this._phoneNumber = phoneNumber this._firstName = firstName this._lastName = lastName + this._vcard = vcard } /** @@ -43,13 +45,21 @@ class InputContactMessageContent extends InputMessageContent { return this._lastName } + /** + * Additional data about the contact in the form of a vCard, 0-2048 bytes + * @returns {string|null} + */ + get vcard() { + return this._vcard + } + /** * * @param {Object} raw * @returns {InputContactMessageContent} */ static deserialize(raw) { - return new InputContactMessageContent(raw['phone_number'], raw['first_name'], raw['last_name'] ? raw['last_name'] : null) + return new InputContactMessageContent(raw['phone_number'], raw['first_name'], raw['last_name'] ? raw['last_name'] : null, raw['vcard'] ? raw['vcard'] : null) } /** @@ -60,7 +70,8 @@ class InputContactMessageContent extends InputMessageContent { return { phone_number: this.phoneNumber ? this.phoneNumber : undefined, first_name: this.firstName ? this.firstName : undefined, - last_name: this.lastName ? this.lastName : undefined + last_name: this.lastName ? this.lastName : undefined, + vcard: this.vcard ? this.vcard : undefined } } diff --git a/lib/models/InputLocationMessageContent.js b/lib/models/InputLocationMessageContent.js index 0ccfb77..1742f50 100644 --- a/lib/models/InputLocationMessageContent.js +++ b/lib/models/InputLocationMessageContent.js @@ -10,11 +10,13 @@ class InputLocationMessageContent extends InputMessageContent { * * @param {number} latitude * @param {number} longitude + * @param {number|null} [livePeriod] */ - constructor(latitude, longitude) { + constructor(latitude, longitude, livePeriod) { super() this._latitude = latitude this._longitude = longitude + this._livePeriod = livePeriod } /** @@ -33,13 +35,21 @@ class InputLocationMessageContent extends InputMessageContent { return this._longitude } + /** + * Period in seconds for which the location can be updated, should be between 60 and 86400. + * @returns {number|null} + */ + get livePeriod() { + return this._livePeriod + } + /** * * @param {Object} raw * @returns {InputLocationMessageContent} */ static deserialize(raw) { - return new InputLocationMessageContent(raw['latitude'], raw['longitude']) + return new InputLocationMessageContent(raw['latitude'], raw['longitude'], raw['live_period'] ? raw['live_period'] : null) } /** @@ -49,7 +59,8 @@ class InputLocationMessageContent extends InputMessageContent { serialize() { return { latitude: this.latitude ? this.latitude : undefined, - longitude: this.longitude ? this.longitude : undefined + longitude: this.longitude ? this.longitude : undefined, + live_period: this.livePeriod ? this.livePeriod : undefined } } diff --git a/lib/models/InputMediaAnimation.js b/lib/models/InputMediaAnimation.js new file mode 100644 index 0000000..d2191ff --- /dev/null +++ b/lib/models/InputMediaAnimation.js @@ -0,0 +1,147 @@ +'use strict' + +/** + * Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent. + */ + +class InputMediaAnimation { + /** + * + * @param {string} type + * @param {string} media + * @param {string|null} [thumb] + * @param {string|null} [caption] + * @param {string|null} [parseMode] + * @param {number|null} [width] + * @param {number|null} [height] + * @param {number|null} [duration] + */ + constructor( + type, + media, + thumb, + caption, + parseMode, + width, + height, + duration + ) { + this._type = type + this._media = media + this._thumb = thumb + this._caption = caption + this._parseMode = parseMode + this._width = width + this._height = height + this._duration = duration + } + + /** + * Type of the result, must be animation + * @returns {string} + */ + get type() { + return this._type + } + + /** + * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » + * @returns {string} + */ + get media() { + return this._media + } + + /** + * Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @returns {string|null} + */ + get thumb() { + return this._thumb + } + + /** + * Caption of the animation to be sent, 0-1024 characters + * @returns {string|null} + */ + get caption() { + return this._caption + } + + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + + /** + * Animation width + * @returns {number|null} + */ + get width() { + return this._width + } + + /** + * Animation height + * @returns {number|null} + */ + get height() { + return this._height + } + + /** + * Animation duration + * @returns {number|null} + */ + get duration() { + return this._duration + } + + /** + * + * @param {Object} raw + * @returns {InputMediaAnimation} + */ + static deserialize(raw) { + return new InputMediaAnimation( + raw['type'], + raw['media'], + raw['thumb'] ? raw['thumb'] : null, + raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, + raw['width'] ? raw['width'] : null, + raw['height'] ? raw['height'] : null, + raw['duration'] ? raw['duration'] : null + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + type: this.type ? this.type : undefined, + media: this.media ? this.media : undefined, + thumb: this.thumb ? this.thumb : undefined, + caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, + width: this.width ? this.width : undefined, + height: this.height ? this.height : undefined, + duration: this.duration ? this.duration : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InputMediaAnimation \ No newline at end of file diff --git a/lib/models/InputMediaAudio.js b/lib/models/InputMediaAudio.js new file mode 100644 index 0000000..226dc02 --- /dev/null +++ b/lib/models/InputMediaAudio.js @@ -0,0 +1,147 @@ +'use strict' + +/** + * Represents an audio file to be treated as music to be sent. + */ + +class InputMediaAudio { + /** + * + * @param {string} type + * @param {string} media + * @param {string|null} [thumb] + * @param {string|null} [caption] + * @param {string|null} [parseMode] + * @param {number|null} [duration] + * @param {string|null} [performer] + * @param {string|null} [title] + */ + constructor( + type, + media, + thumb, + caption, + parseMode, + duration, + performer, + title + ) { + this._type = type + this._media = media + this._thumb = thumb + this._caption = caption + this._parseMode = parseMode + this._duration = duration + this._performer = performer + this._title = title + } + + /** + * Type of the result, must be audio + * @returns {string} + */ + get type() { + return this._type + } + + /** + * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » + * @returns {string} + */ + get media() { + return this._media + } + + /** + * Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @returns {string|null} + */ + get thumb() { + return this._thumb + } + + /** + * Caption of the audio to be sent, 0-1024 characters + * @returns {string|null} + */ + get caption() { + return this._caption + } + + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + + /** + * Duration of the audio in seconds + * @returns {number|null} + */ + get duration() { + return this._duration + } + + /** + * Performer of the audio + * @returns {string|null} + */ + get performer() { + return this._performer + } + + /** + * Title of the audio + * @returns {string|null} + */ + get title() { + return this._title + } + + /** + * + * @param {Object} raw + * @returns {InputMediaAudio} + */ + static deserialize(raw) { + return new InputMediaAudio( + raw['type'], + raw['media'], + raw['thumb'] ? raw['thumb'] : null, + raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, + raw['duration'] ? raw['duration'] : null, + raw['performer'] ? raw['performer'] : null, + raw['title'] ? raw['title'] : null + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + type: this.type ? this.type : undefined, + media: this.media ? this.media : undefined, + thumb: this.thumb ? this.thumb : undefined, + caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, + duration: this.duration ? this.duration : undefined, + performer: this.performer ? this.performer : undefined, + title: this.title ? this.title : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InputMediaAudio \ No newline at end of file diff --git a/lib/models/InputMediaDocument.js b/lib/models/InputMediaDocument.js new file mode 100644 index 0000000..b7a45c6 --- /dev/null +++ b/lib/models/InputMediaDocument.js @@ -0,0 +1,102 @@ +'use strict' + +/** + * Represents a general file to be sent. + */ + +class InputMediaDocument { + /** + * + * @param {string} type + * @param {string} media + * @param {string|null} [thumb] + * @param {string|null} [caption] + * @param {string|null} [parseMode] + */ + constructor(type, media, thumb, caption, parseMode) { + this._type = type + this._media = media + this._thumb = thumb + this._caption = caption + this._parseMode = parseMode + } + + /** + * Type of the result, must be document + * @returns {string} + */ + get type() { + return this._type + } + + /** + * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » + * @returns {string} + */ + get media() { + return this._media + } + + /** + * Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @returns {string|null} + */ + get thumb() { + return this._thumb + } + + /** + * Caption of the document to be sent, 0-1024 characters + * @returns {string|null} + */ + get caption() { + return this._caption + } + + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + + /** + * + * @param {Object} raw + * @returns {InputMediaDocument} + */ + static deserialize(raw) { + return new InputMediaDocument( + raw['type'], + raw['media'], + raw['thumb'] ? raw['thumb'] : null, + raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + type: this.type ? this.type : undefined, + media: this.media ? this.media : undefined, + thumb: this.thumb ? this.thumb : undefined, + caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InputMediaDocument \ No newline at end of file diff --git a/lib/models/InputMediaPhoto.js b/lib/models/InputMediaPhoto.js new file mode 100644 index 0000000..5cdb9b8 --- /dev/null +++ b/lib/models/InputMediaPhoto.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents a photo to be sent. + */ + +class InputMediaPhoto { + /** + * + * @param {string} type + * @param {string} media + * @param {string|null} [caption] + * @param {string|null} [parseMode] + */ + constructor(type, media, caption, parseMode) { + this._type = type + this._media = media + this._caption = caption + this._parseMode = parseMode + } + + /** + * Type of the result, must be photo + * @returns {string} + */ + get type() { + return this._type + } + + /** + * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » + * @returns {string} + */ + get media() { + return this._media + } + + /** + * Caption of the photo to be sent, 0-1024 characters + * @returns {string|null} + */ + get caption() { + return this._caption + } + + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + + /** + * + * @param {Object} raw + * @returns {InputMediaPhoto} + */ + static deserialize(raw) { + return new InputMediaPhoto(raw['type'], raw['media'], raw['caption'] ? raw['caption'] : null, raw['parse_mode'] ? raw['parse_mode'] : null) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + type: this.type ? this.type : undefined, + media: this.media ? this.media : undefined, + caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InputMediaPhoto \ No newline at end of file diff --git a/lib/models/InputMediaVideo.js b/lib/models/InputMediaVideo.js new file mode 100644 index 0000000..8043530 --- /dev/null +++ b/lib/models/InputMediaVideo.js @@ -0,0 +1,160 @@ +'use strict' + +/** + * Represents a video to be sent. + */ + +class InputMediaVideo { + /** + * + * @param {string} type + * @param {string} media + * @param {string|null} [thumb] + * @param {string|null} [caption] + * @param {string|null} [parseMode] + * @param {number|null} [width] + * @param {number|null} [height] + * @param {number|null} [duration] + * @param {boolean|null} [supportsStreaming] + */ + constructor( + type, + media, + thumb, + caption, + parseMode, + width, + height, + duration, + supportsStreaming + ) { + this._type = type + this._media = media + this._thumb = thumb + this._caption = caption + this._parseMode = parseMode + this._width = width + this._height = height + this._duration = duration + this._supportsStreaming = supportsStreaming + } + + /** + * Type of the result, must be video + * @returns {string} + */ + get type() { + return this._type + } + + /** + * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More info on Sending Files » + * @returns {string} + */ + get media() { + return this._media + } + + /** + * Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://” if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files » + * @returns {string|null} + */ + get thumb() { + return this._thumb + } + + /** + * Caption of the video to be sent, 0-1024 characters + * @returns {string|null} + */ + get caption() { + return this._caption + } + + /** + * Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. + * @returns {string|null} + */ + get parseMode() { + return this._parseMode + } + + /** + * Video width + * @returns {number|null} + */ + get width() { + return this._width + } + + /** + * Video height + * @returns {number|null} + */ + get height() { + return this._height + } + + /** + * Video duration + * @returns {number|null} + */ + get duration() { + return this._duration + } + + /** + * Pass True, if the uploaded video is suitable for streaming + * @returns {boolean|null} + */ + get supportsStreaming() { + return this._supportsStreaming + } + + /** + * + * @param {Object} raw + * @returns {InputMediaVideo} + */ + static deserialize(raw) { + return new InputMediaVideo( + raw['type'], + raw['media'], + raw['thumb'] ? raw['thumb'] : null, + raw['caption'] ? raw['caption'] : null, + raw['parse_mode'] ? raw['parse_mode'] : null, + raw['width'] ? raw['width'] : null, + raw['height'] ? raw['height'] : null, + raw['duration'] ? raw['duration'] : null, + raw['supports_streaming'] ? raw['supports_streaming'] : null + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + type: this.type ? this.type : undefined, + media: this.media ? this.media : undefined, + thumb: this.thumb ? this.thumb : undefined, + caption: this.caption ? this.caption : undefined, + parse_mode: this.parseMode ? this.parseMode : undefined, + width: this.width ? this.width : undefined, + height: this.height ? this.height : undefined, + duration: this.duration ? this.duration : undefined, + supports_streaming: this.supportsStreaming ? this.supportsStreaming : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = InputMediaVideo \ No newline at end of file diff --git a/lib/models/InputVenueMessageContent.js b/lib/models/InputVenueMessageContent.js index 10e973c..3c0c25a 100644 --- a/lib/models/InputVenueMessageContent.js +++ b/lib/models/InputVenueMessageContent.js @@ -13,14 +13,16 @@ class InputVenueMessageContent extends InputMessageContent { * @param {string} title * @param {string} address * @param {string|null} [foursquareId] + * @param {string|null} [foursquareType] */ - constructor(latitude, longitude, title, address, foursquareId) { + constructor(latitude, longitude, title, address, foursquareId, foursquareType) { super() this._latitude = latitude this._longitude = longitude this._title = title this._address = address this._foursquareId = foursquareId + this._foursquareType = foursquareType } /** @@ -63,6 +65,14 @@ class InputVenueMessageContent extends InputMessageContent { return this._foursquareId } + /** + * Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + * @returns {string|null} + */ + get foursquareType() { + return this._foursquareType + } + /** * * @param {Object} raw @@ -74,7 +84,8 @@ class InputVenueMessageContent extends InputMessageContent { raw['longitude'], raw['title'], raw['address'], - raw['foursquare_id'] ? raw['foursquare_id'] : null + raw['foursquare_id'] ? raw['foursquare_id'] : null, + raw['foursquare_type'] ? raw['foursquare_type'] : null ) } @@ -88,7 +99,8 @@ class InputVenueMessageContent extends InputMessageContent { 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 + foursquare_id: this.foursquareId ? this.foursquareId : undefined, + foursquare_type: this.foursquareType ? this.foursquareType : undefined } } diff --git a/lib/models/Invoice.js b/lib/models/Invoice.js new file mode 100644 index 0000000..7a2dda4 --- /dev/null +++ b/lib/models/Invoice.js @@ -0,0 +1,102 @@ +'use strict' + +/** + * This object contains basic information about an invoice. + */ + +class Invoice { + /** + * + * @param {string} title + * @param {string} description + * @param {string} startParameter + * @param {string} currency + * @param {number} totalAmount + */ + constructor(title, description, startParameter, currency, totalAmount) { + this._title = title + this._description = description + this._startParameter = startParameter + this._currency = currency + this._totalAmount = totalAmount + } + + /** + * Product name + * @returns {string} + */ + get title() { + return this._title + } + + /** + * Product description + * @returns {string} + */ + get description() { + return this._description + } + + /** + * Unique bot deep-linking parameter that can be used to generate this invoice + * @returns {string} + */ + get startParameter() { + return this._startParameter + } + + /** + * Three-letter ISO 4217 currency code + * @returns {string} + */ + get currency() { + return this._currency + } + + /** + * Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + * @returns {number} + */ + get totalAmount() { + return this._totalAmount + } + + /** + * + * @param {Object} raw + * @returns {Invoice} + */ + static deserialize(raw) { + return new Invoice( + raw['title'], + raw['description'], + raw['start_parameter'], + raw['currency'], + raw['total_amount'] + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + title: this.title ? this.title : undefined, + description: this.description ? this.description : undefined, + start_parameter: this.startParameter ? this.startParameter : undefined, + currency: this.currency ? this.currency : undefined, + total_amount: this.totalAmount ? this.totalAmount : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = Invoice \ No newline at end of file diff --git a/lib/models/KeyboardButton.js b/lib/models/KeyboardButton.js index 0bdfbf4..87ff4bd 100644 --- a/lib/models/KeyboardButton.js +++ b/lib/models/KeyboardButton.js @@ -18,7 +18,7 @@ class KeyboardButton { } /** - * 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 + * Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed * @returns {string} */ get text() { diff --git a/lib/models/LabeledPrice.js b/lib/models/LabeledPrice.js new file mode 100644 index 0000000..ad9dc2a --- /dev/null +++ b/lib/models/LabeledPrice.js @@ -0,0 +1,63 @@ +'use strict' + +/** + * This object represents a portion of the price for goods or services. + */ + +class LabeledPrice { + /** + * + * @param {string} label + * @param {number} amount + */ + constructor(label, amount) { + this._label = label + this._amount = amount + } + + /** + * Portion label + * @returns {string} + */ + get label() { + return this._label + } + + /** + * Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + * @returns {number} + */ + get amount() { + return this._amount + } + + /** + * + * @param {Object} raw + * @returns {LabeledPrice} + */ + static deserialize(raw) { + return new LabeledPrice(raw['label'], raw['amount']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + label: this.label ? this.label : undefined, + amount: this.amount ? this.amount : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = LabeledPrice \ No newline at end of file diff --git a/lib/models/MaskPosition.js b/lib/models/MaskPosition.js new file mode 100644 index 0000000..8a46b72 --- /dev/null +++ b/lib/models/MaskPosition.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * This object describes the position on faces where a mask should be placed by default. + */ + +class MaskPosition { + /** + * + * @param {string} point + * @param {number} xShift + * @param {number} yShift + * @param {number} scale + */ + constructor(point, xShift, yShift, scale) { + this._point = point + this._xShift = xShift + this._yShift = yShift + this._scale = scale + } + + /** + * The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”. + * @returns {string} + */ + get point() { + return this._point + } + + /** + * Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position. + * @returns {number} + */ + get xShift() { + return this._xShift + } + + /** + * Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position. + * @returns {number} + */ + get yShift() { + return this._yShift + } + + /** + * Mask scaling coefficient. For example, 2.0 means double size. + * @returns {number} + */ + get scale() { + return this._scale + } + + /** + * + * @param {Object} raw + * @returns {MaskPosition} + */ + static deserialize(raw) { + return new MaskPosition(raw['point'], raw['x_shift'], raw['y_shift'], raw['scale']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + point: this.point ? this.point : undefined, + x_shift: this.xShift ? this.xShift : undefined, + y_shift: this.yShift ? this.yShift : undefined, + scale: this.scale ? this.scale : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = MaskPosition \ No newline at end of file diff --git a/lib/models/Message.js b/lib/models/Message.js index 5bf02c7..9d57cb5 100644 --- a/lib/models/Message.js +++ b/lib/models/Message.js @@ -5,14 +5,19 @@ const Chat = require('./Chat') const MessageEntity = require('./MessageEntity') const Audio = require('./Audio') const Document = require('./Document') +const Animation = require('./Animation') const Game = require('./Game') const PhotoSize = require('./PhotoSize') const Sticker = require('./Sticker') const Video = require('./Video') const Voice = require('./Voice') +const VideoNote = require('./VideoNote') const Contact = require('./Contact') const Location = require('./Location') const Venue = require('./Venue') +const Invoice = require('./Invoice') +const SuccessfulPayment = require('./SuccessfulPayment') +const PassportData = require('./PassportData') /** * This object represents a message. @@ -27,23 +32,30 @@ class Message { * @param {Chat} chat * @param {User|null} [forwardFrom] * @param {Chat|null} [forwardFromChat] + * @param {number|null} [forwardFromMessageId] + * @param {string|null} [forwardSignature] * @param {number|null} [forwardDate] * @param {Message|null} [replyToMessage] * @param {number|null} [editDate] + * @param {string|null} [mediaGroupId] + * @param {string|null} [authorSignature] * @param {string|null} [text] * @param {MessageEntity[]|null} [entities] + * @param {MessageEntity[]|null} [captionEntities] * @param {Audio|null} [audio] * @param {Document|null} [document] + * @param {Animation|null} [animation] * @param {Game|null} [game] * @param {PhotoSize[]|null} [photo] * @param {Sticker|null} [sticker] * @param {Video|null} [video] * @param {Voice|null} [voice] + * @param {VideoNote|null} [videoNote] * @param {string|null} [caption] * @param {Contact|null} [contact] * @param {Location|null} [location] * @param {Venue|null} [venue] - * @param {User|null} [newChatMember] + * @param {User[]|null} [newChatMembers] * @param {User|null} [leftChatMember] * @param {string|null} [newChatTitle] * @param {PhotoSize[]|null} [newChatPhoto] @@ -54,6 +66,10 @@ class Message { * @param {number|null} [migrateToChatId] * @param {number|null} [migrateFromChatId] * @param {Message|null} [pinnedMessage] + * @param {Invoice|null} [invoice] + * @param {SuccessfulPayment|null} [successfulPayment] + * @param {string|null} [connectedWebsite] + * @param {PassportData|null} [passportData] */ constructor( messageId, @@ -62,23 +78,30 @@ class Message { chat, forwardFrom, forwardFromChat, + forwardFromMessageId, + forwardSignature, forwardDate, replyToMessage, editDate, + mediaGroupId, + authorSignature, text, entities, + captionEntities, audio, document, + animation, game, photo, sticker, video, voice, + videoNote, caption, contact, location, venue, - newChatMember, + newChatMembers, leftChatMember, newChatTitle, newChatPhoto, @@ -88,7 +111,11 @@ class Message { channelChatCreated, migrateToChatId, migrateFromChatId, - pinnedMessage + pinnedMessage, + invoice, + successfulPayment, + connectedWebsite, + passportData ) { this._messageId = messageId this._from = from @@ -96,23 +123,30 @@ class Message { this._chat = chat this._forwardFrom = forwardFrom this._forwardFromChat = forwardFromChat + this._forwardFromMessageId = forwardFromMessageId + this._forwardSignature = forwardSignature this._forwardDate = forwardDate this._replyToMessage = replyToMessage this._editDate = editDate + this._mediaGroupId = mediaGroupId + this._authorSignature = authorSignature this._text = text this._entities = entities + this._captionEntities = captionEntities this._audio = audio this._document = document + this._animation = animation this._game = game this._photo = photo this._sticker = sticker this._video = video this._voice = voice + this._videoNote = videoNote this._caption = caption this._contact = contact this._location = location this._venue = venue - this._newChatMember = newChatMember + this._newChatMembers = newChatMembers this._leftChatMember = leftChatMember this._newChatTitle = newChatTitle this._newChatPhoto = newChatPhoto @@ -123,10 +157,14 @@ class Message { this._migrateToChatId = migrateToChatId this._migrateFromChatId = migrateFromChatId this._pinnedMessage = pinnedMessage + this._invoice = invoice + this._successfulPayment = successfulPayment + this._connectedWebsite = connectedWebsite + this._passportData = passportData } /** - * Unique message identifier + * Unique message identifier inside this chat * @returns {number} */ get messageId() { @@ -134,7 +172,7 @@ class Message { } /** - * Sender, can be empty for messages sent to channels + * Sender, empty for messages sent to channels * @returns {User|null} */ get from() { @@ -166,13 +204,29 @@ class Message { } /** - * For messages forwarded from a channel, information about the original channel + * For messages forwarded from channels, information about the original channel * @returns {Chat|null} */ get forwardFromChat() { return this._forwardFromChat } + /** + * For messages forwarded from channels, identifier of the original message in the channel + * @returns {number|null} + */ + get forwardFromMessageId() { + return this._forwardFromMessageId + } + + /** + * For messages forwarded from channels, signature of the post author if present + * @returns {string|null} + */ + get forwardSignature() { + return this._forwardSignature + } + /** * For forwarded messages, date the original message was sent in Unix time * @returns {number|null} @@ -197,6 +251,22 @@ class Message { return this._editDate } + /** + * The unique identifier of a media message group this message belongs to + * @returns {string|null} + */ + get mediaGroupId() { + return this._mediaGroupId + } + + /** + * Signature of the post author for messages in channels + * @returns {string|null} + */ + get authorSignature() { + return this._authorSignature + } + /** * For text messages, the actual UTF-8 text of the message, 0-4096 characters. * @returns {string|null} @@ -213,6 +283,14 @@ class Message { return this._entities } + /** + * For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption + * @returns {MessageEntity[]|null} + */ + get captionEntities() { + return this._captionEntities + } + /** * Message is an audio file, information about the file * @returns {Audio|null} @@ -229,6 +307,14 @@ class Message { return this._document } + /** + * Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set + * @returns {Animation|null} + */ + get animation() { + return this._animation + } + /** * Message is a game, information about the game. More about games » * @returns {Game|null} @@ -270,7 +356,15 @@ class Message { } /** - * Caption for the document, photo or video, 0-200 characters + * Message is a video note, information about the video message + * @returns {VideoNote|null} + */ + get videoNote() { + return this._videoNote + } + + /** + * Caption for the audio, document, photo, video or voice, 0-1024 characters * @returns {string|null} */ get caption() { @@ -302,11 +396,11 @@ class Message { } /** - * A new member was added to the group, information about them (this member may be the bot itself) - * @returns {User|null} + * New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) + * @returns {User[]|null} */ - get newChatMember() { - return this._newChatMember + get newChatMembers() { + return this._newChatMembers } /** @@ -366,7 +460,7 @@ class Message { } /** - * 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 smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. + * 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() { @@ -374,7 +468,7 @@ class Message { } /** - * The supergroup has been migrated from a group 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 smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. + * The supergroup has been migrated from a group 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 migrateFromChatId() { @@ -389,6 +483,38 @@ class Message { return this._pinnedMessage } + /** + * Message is an invoice for a payment, information about the invoice. More about payments » + * @returns {Invoice|null} + */ + get invoice() { + return this._invoice + } + + /** + * Message is a service message about a successful payment, information about the payment. More about payments » + * @returns {SuccessfulPayment|null} + */ + get successfulPayment() { + return this._successfulPayment + } + + /** + * The domain name of the website on which the user has logged in. More about Telegram Login » + * @returns {string|null} + */ + get connectedWebsite() { + return this._connectedWebsite + } + + /** + * Telegram Passport data + * @returns {PassportData|null} + */ + get passportData() { + return this._passportData + } + /** * * @param {Object} raw @@ -402,23 +528,30 @@ class Message { raw['chat'] ? Chat.deserialize(raw['chat']) : null, raw['forward_from'] ? User.deserialize(raw['forward_from']) : null, raw['forward_from_chat'] ? Chat.deserialize(raw['forward_from_chat']) : null, + raw['forward_from_message_id'] ? raw['forward_from_message_id'] : null, + raw['forward_signature'] ? raw['forward_signature'] : null, raw['forward_date'] ? raw['forward_date'] : null, raw['reply_to_message'] ? Message.deserialize(raw['reply_to_message']) : null, raw['edit_date'] ? raw['edit_date'] : null, + raw['media_group_id'] ? raw['media_group_id'] : null, + raw['author_signature'] ? raw['author_signature'] : null, raw['text'] ? raw['text'] : null, raw['entities'] ? raw['entities'].map(item => MessageEntity.deserialize(item)) : null, + raw['caption_entities'] ? raw['caption_entities'].map(item => MessageEntity.deserialize(item)) : null, raw['audio'] ? Audio.deserialize(raw['audio']) : null, raw['document'] ? Document.deserialize(raw['document']) : null, + raw['animation'] ? Animation.deserialize(raw['animation']) : null, raw['game'] ? Game.deserialize(raw['game']) : null, raw['photo'] ? raw['photo'].map(item => PhotoSize.deserialize(item)) : null, raw['sticker'] ? Sticker.deserialize(raw['sticker']) : null, raw['video'] ? Video.deserialize(raw['video']) : null, raw['voice'] ? Voice.deserialize(raw['voice']) : null, + raw['video_note'] ? VideoNote.deserialize(raw['video_note']) : null, raw['caption'] ? raw['caption'] : null, raw['contact'] ? Contact.deserialize(raw['contact']) : null, raw['location'] ? Location.deserialize(raw['location']) : null, raw['venue'] ? Venue.deserialize(raw['venue']) : null, - raw['new_chat_member'] ? User.deserialize(raw['new_chat_member']) : null, + raw['new_chat_members'] ? raw['new_chat_members'].map(item => User.deserialize(item)) : null, raw['left_chat_member'] ? User.deserialize(raw['left_chat_member']) : null, raw['new_chat_title'] ? raw['new_chat_title'] : null, raw['new_chat_photo'] ? raw['new_chat_photo'].map(item => PhotoSize.deserialize(item)) : null, @@ -428,7 +561,11 @@ class Message { raw['channel_chat_created'] ? raw['channel_chat_created'] : null, raw['migrate_to_chat_id'] ? raw['migrate_to_chat_id'] : null, raw['migrate_from_chat_id'] ? raw['migrate_from_chat_id'] : null, - raw['pinned_message'] ? Message.deserialize(raw['pinned_message']) : null + raw['pinned_message'] ? Message.deserialize(raw['pinned_message']) : null, + raw['invoice'] ? Invoice.deserialize(raw['invoice']) : null, + raw['successful_payment'] ? SuccessfulPayment.deserialize(raw['successful_payment']) : null, + raw['connected_website'] ? raw['connected_website'] : null, + raw['passport_data'] ? PassportData.deserialize(raw['passport_data']) : null ) } @@ -444,23 +581,30 @@ class Message { chat: this.chat ? this.chat.serialize() : undefined, forward_from: this.forwardFrom ? this.forwardFrom.serialize() : undefined, forward_from_chat: this.forwardFromChat ? this.forwardFromChat.serialize() : undefined, + forward_from_message_id: this.forwardFromMessageId ? this.forwardFromMessageId : undefined, + forward_signature: this.forwardSignature ? this.forwardSignature : undefined, forward_date: this.forwardDate ? this.forwardDate : undefined, reply_to_message: this.replyToMessage ? this.replyToMessage.serialize() : undefined, edit_date: this.editDate ? this.editDate : undefined, + media_group_id: this.mediaGroupId ? this.mediaGroupId : undefined, + author_signature: this.authorSignature ? this.authorSignature : undefined, text: this.text ? this.text : undefined, entities: this.entities ? this.entities.map(item => item.serialize()) : undefined, + caption_entities: this.captionEntities ? this.captionEntities.map(item => item.serialize()) : undefined, audio: this.audio ? this.audio.serialize() : undefined, document: this.document ? this.document.serialize() : undefined, + animation: this.animation ? this.animation.serialize() : undefined, game: this.game ? this.game.serialize() : undefined, photo: this.photo ? this.photo.map(item => item.serialize()) : undefined, sticker: this.sticker ? this.sticker.serialize() : undefined, video: this.video ? this.video.serialize() : undefined, voice: this.voice ? this.voice.serialize() : undefined, + video_note: this.videoNote ? this.videoNote.serialize() : undefined, caption: this.caption ? this.caption : undefined, contact: this.contact ? this.contact.serialize() : undefined, location: this.location ? this.location.serialize() : undefined, venue: this.venue ? this.venue.serialize() : undefined, - new_chat_member: this.newChatMember ? this.newChatMember.serialize() : undefined, + new_chat_members: this.newChatMembers ? this.newChatMembers.map(item => item.serialize()) : undefined, left_chat_member: this.leftChatMember ? this.leftChatMember.serialize() : undefined, new_chat_title: this.newChatTitle ? this.newChatTitle : undefined, new_chat_photo: this.newChatPhoto ? this.newChatPhoto.map(item => item.serialize()) : undefined, @@ -470,7 +614,11 @@ class Message { channel_chat_created: this.channelChatCreated ? this.channelChatCreated : undefined, migrate_to_chat_id: this.migrateToChatId ? this.migrateToChatId : undefined, migrate_from_chat_id: this.migrateFromChatId ? this.migrateFromChatId : undefined, - pinned_message: this.pinnedMessage ? this.pinnedMessage.serialize() : undefined + pinned_message: this.pinnedMessage ? this.pinnedMessage.serialize() : undefined, + invoice: this.invoice ? this.invoice.serialize() : undefined, + successful_payment: this.successfulPayment ? this.successfulPayment.serialize() : undefined, + connected_website: this.connectedWebsite ? this.connectedWebsite : undefined, + passport_data: this.passportData ? this.passportData.serialize() : undefined } } diff --git a/lib/models/MessageEntity.js b/lib/models/MessageEntity.js index c5b83ce..a5dd7e6 100644 --- a/lib/models/MessageEntity.js +++ b/lib/models/MessageEntity.js @@ -24,7 +24,7 @@ class MessageEntity { } /** - * 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) + * Type of the entity. Can be mention (@username), hashtag, cashtag, bot_command, url, email, phone_number, 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() { diff --git a/lib/models/Models.js b/lib/models/Models.js index 67841b1..9b50eca 100644 --- a/lib/models/Models.js +++ b/lib/models/Models.js @@ -8,9 +8,10 @@ module.exports = { PhotoSize: require('./PhotoSize'), Audio: require('./Audio'), Document: require('./Document'), - Sticker: require('./Sticker'), Video: require('./Video'), + Animation: require('./Animation'), Voice: require('./Voice'), + VideoNote: require('./VideoNote'), Contact: require('./Contact'), Location: require('./Location'), Venue: require('./Venue'), @@ -18,13 +19,22 @@ module.exports = { File: require('./File'), ReplyKeyboardMarkup: require('./ReplyKeyboardMarkup'), KeyboardButton: require('./KeyboardButton'), - ReplyKeyboardHide: require('./ReplyKeyboardHide'), + ReplyKeyboardRemove: require('./ReplyKeyboardRemove'), InlineKeyboardMarkup: require('./InlineKeyboardMarkup'), InlineKeyboardButton: require('./InlineKeyboardButton'), CallbackQuery: require('./CallbackQuery'), ForceReply: require('./ForceReply'), + ChatPhoto: require('./ChatPhoto'), ChatMember: require('./ChatMember'), ResponseParameters: require('./ResponseParameters'), + InputMediaPhoto: require('./InputMediaPhoto'), + InputMediaVideo: require('./InputMediaVideo'), + InputMediaAnimation: require('./InputMediaAnimation'), + InputMediaAudio: require('./InputMediaAudio'), + InputMediaDocument: require('./InputMediaDocument'), + Sticker: require('./Sticker'), + StickerSet: require('./StickerSet'), + MaskPosition: require('./MaskPosition'), InlineQuery: require('./InlineQuery'), InlineQueryResultArticle: require('./InlineQueryResultArticle'), InlineQueryResultPhoto: require('./InlineQueryResultPhoto'), @@ -51,8 +61,28 @@ module.exports = { InputVenueMessageContent: require('./InputVenueMessageContent'), InputContactMessageContent: require('./InputContactMessageContent'), ChosenInlineResult: require('./ChosenInlineResult'), + LabeledPrice: require('./LabeledPrice'), + Invoice: require('./Invoice'), + ShippingAddress: require('./ShippingAddress'), + OrderInfo: require('./OrderInfo'), + ShippingOption: require('./ShippingOption'), + SuccessfulPayment: require('./SuccessfulPayment'), + ShippingQuery: require('./ShippingQuery'), + PreCheckoutQuery: require('./PreCheckoutQuery'), + PassportData: require('./PassportData'), + PassportFile: require('./PassportFile'), + EncryptedPassportElement: require('./EncryptedPassportElement'), + EncryptedCredentials: require('./EncryptedCredentials'), + PassportElementErrorDataField: require('./PassportElementErrorDataField'), + PassportElementErrorFrontSide: require('./PassportElementErrorFrontSide'), + PassportElementErrorReverseSide: require('./PassportElementErrorReverseSide'), + PassportElementErrorSelfie: require('./PassportElementErrorSelfie'), + PassportElementErrorFile: require('./PassportElementErrorFile'), + PassportElementErrorFiles: require('./PassportElementErrorFiles'), + PassportElementErrorTranslationFile: require('./PassportElementErrorTranslationFile'), + PassportElementErrorTranslationFiles: require('./PassportElementErrorTranslationFiles'), + PassportElementErrorUnspecified: require('./PassportElementErrorUnspecified'), Game: require('./Game'), - Animation: require('./Animation'), GameHighScore: require('./GameHighScore'), InputMessageContent: require('./InputMessageContent'), InlineQueryResult: require('./InlineQueryResult'), diff --git a/lib/models/OrderInfo.js b/lib/models/OrderInfo.js new file mode 100644 index 0000000..9552723 --- /dev/null +++ b/lib/models/OrderInfo.js @@ -0,0 +1,87 @@ +'use strict' + +const ShippingAddress = require('./ShippingAddress') + +/** + * This object represents information about an order. + */ + +class OrderInfo { + /** + * + * @param {string|null} [name] + * @param {string|null} [phoneNumber] + * @param {string|null} [email] + * @param {ShippingAddress|null} [shippingAddress] + */ + constructor(name, phoneNumber, email, shippingAddress) { + this._name = name + this._phoneNumber = phoneNumber + this._email = email + this._shippingAddress = shippingAddress + } + + /** + * User name + * @returns {string|null} + */ + get name() { + return this._name + } + + /** + * User's phone number + * @returns {string|null} + */ + get phoneNumber() { + return this._phoneNumber + } + + /** + * User email + * @returns {string|null} + */ + get email() { + return this._email + } + + /** + * User shipping address + * @returns {ShippingAddress|null} + */ + get shippingAddress() { + return this._shippingAddress + } + + /** + * + * @param {Object} raw + * @returns {OrderInfo} + */ + static deserialize(raw) { + return new OrderInfo(raw['name'] ? raw['name'] : null, raw['phone_number'] ? raw['phone_number'] : null, raw['email'] ? raw['email'] : null, raw['shipping_address'] ? ShippingAddress.deserialize(raw['shipping_address']) : null) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + name: this.name ? this.name : undefined, + phone_number: this.phoneNumber ? this.phoneNumber : undefined, + email: this.email ? this.email : undefined, + shipping_address: this.shippingAddress ? this.shippingAddress.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = OrderInfo \ No newline at end of file diff --git a/lib/models/PassportData.js b/lib/models/PassportData.js new file mode 100644 index 0000000..6e8446e --- /dev/null +++ b/lib/models/PassportData.js @@ -0,0 +1,66 @@ +'use strict' + +const EncryptedPassportElement = require('./EncryptedPassportElement') +const EncryptedCredentials = require('./EncryptedCredentials') + +/** + * Contains information about Telegram Passport data shared with the bot by the user. + */ + +class PassportData { + /** + * + * @param {EncryptedPassportElement[]} data + * @param {EncryptedCredentials} credentials + */ + constructor(data, credentials) { + this._data = data + this._credentials = credentials + } + + /** + * Array with information about documents and other Telegram Passport elements that was shared with the bot + * @returns {EncryptedPassportElement[]} + */ + get data() { + return this._data + } + + /** + * Encrypted credentials required to decrypt the data + * @returns {EncryptedCredentials} + */ + get credentials() { + return this._credentials + } + + /** + * + * @param {Object} raw + * @returns {PassportData} + */ + static deserialize(raw) { + return new PassportData(raw['data'] ? raw['data'].map(item => EncryptedPassportElement.deserialize(item)) : null, raw['credentials'] ? EncryptedCredentials.deserialize(raw['credentials']) : null) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + data: this.data ? this.data.map(item => item.serialize()) : undefined, + credentials: this.credentials ? this.credentials.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportData \ No newline at end of file diff --git a/lib/models/PassportElementErrorDataField.js b/lib/models/PassportElementErrorDataField.js new file mode 100644 index 0000000..45ad852 --- /dev/null +++ b/lib/models/PassportElementErrorDataField.js @@ -0,0 +1,102 @@ +'use strict' + +/** + * Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes. + */ + +class PassportElementErrorDataField { + /** + * + * @param {string} source + * @param {string} type + * @param {string} fieldName + * @param {string} dataHash + * @param {string} message + */ + constructor(source, type, fieldName, dataHash, message) { + this._source = source + this._type = type + this._fieldName = fieldName + this._dataHash = dataHash + this._message = message + } + + /** + * Error source, must be data + * @returns {string} + */ + get source() { + return this._source + } + + /** + * The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Name of the data field which has the error + * @returns {string} + */ + get fieldName() { + return this._fieldName + } + + /** + * Base64-encoded data hash + * @returns {string} + */ + get dataHash() { + return this._dataHash + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorDataField} + */ + static deserialize(raw) { + return new PassportElementErrorDataField( + raw['source'], + raw['type'], + raw['field_name'], + raw['data_hash'], + raw['message'] + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + field_name: this.fieldName ? this.fieldName : undefined, + data_hash: this.dataHash ? this.dataHash : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorDataField \ No newline at end of file diff --git a/lib/models/PassportElementErrorFile.js b/lib/models/PassportElementErrorFile.js new file mode 100644 index 0000000..45d0f59 --- /dev/null +++ b/lib/models/PassportElementErrorFile.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes. + */ + +class PassportElementErrorFile { + /** + * + * @param {string} source + * @param {string} type + * @param {string} fileHash + * @param {string} message + */ + constructor(source, type, fileHash, message) { + this._source = source + this._type = type + this._fileHash = fileHash + this._message = message + } + + /** + * Error source, must be file + * @returns {string} + */ + get source() { + return this._source + } + + /** + * The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Base64-encoded file hash + * @returns {string} + */ + get fileHash() { + return this._fileHash + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorFile} + */ + static deserialize(raw) { + return new PassportElementErrorFile(raw['source'], raw['type'], raw['file_hash'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + file_hash: this.fileHash ? this.fileHash : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorFile \ No newline at end of file diff --git a/lib/models/PassportElementErrorFiles.js b/lib/models/PassportElementErrorFiles.js new file mode 100644 index 0000000..cf27e77 --- /dev/null +++ b/lib/models/PassportElementErrorFiles.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes. + */ + +class PassportElementErrorFiles { + /** + * + * @param {string} source + * @param {string} type + * @param {string[]} fileHashes + * @param {string} message + */ + constructor(source, type, fileHashes, message) { + this._source = source + this._type = type + this._fileHashes = fileHashes + this._message = message + } + + /** + * Error source, must be files + * @returns {string} + */ + get source() { + return this._source + } + + /** + * The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * List of base64-encoded file hashes + * @returns {string[]} + */ + get fileHashes() { + return this._fileHashes + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorFiles} + */ + static deserialize(raw) { + return new PassportElementErrorFiles(raw['source'], raw['type'], raw['file_hashes'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + file_hashes: this.fileHashes ? this.fileHashes : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorFiles \ No newline at end of file diff --git a/lib/models/PassportElementErrorFrontSide.js b/lib/models/PassportElementErrorFrontSide.js new file mode 100644 index 0000000..7b7f87a --- /dev/null +++ b/lib/models/PassportElementErrorFrontSide.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes. + */ + +class PassportElementErrorFrontSide { + /** + * + * @param {string} source + * @param {string} type + * @param {string} fileHash + * @param {string} message + */ + constructor(source, type, fileHash, message) { + this._source = source + this._type = type + this._fileHash = fileHash + this._message = message + } + + /** + * Error source, must be front_side + * @returns {string} + */ + get source() { + return this._source + } + + /** + * The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Base64-encoded hash of the file with the front side of the document + * @returns {string} + */ + get fileHash() { + return this._fileHash + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorFrontSide} + */ + static deserialize(raw) { + return new PassportElementErrorFrontSide(raw['source'], raw['type'], raw['file_hash'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + file_hash: this.fileHash ? this.fileHash : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorFrontSide \ No newline at end of file diff --git a/lib/models/PassportElementErrorReverseSide.js b/lib/models/PassportElementErrorReverseSide.js new file mode 100644 index 0000000..dd49a09 --- /dev/null +++ b/lib/models/PassportElementErrorReverseSide.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes. + */ + +class PassportElementErrorReverseSide { + /** + * + * @param {string} source + * @param {string} type + * @param {string} fileHash + * @param {string} message + */ + constructor(source, type, fileHash, message) { + this._source = source + this._type = type + this._fileHash = fileHash + this._message = message + } + + /** + * Error source, must be reverse_side + * @returns {string} + */ + get source() { + return this._source + } + + /** + * The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Base64-encoded hash of the file with the reverse side of the document + * @returns {string} + */ + get fileHash() { + return this._fileHash + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorReverseSide} + */ + static deserialize(raw) { + return new PassportElementErrorReverseSide(raw['source'], raw['type'], raw['file_hash'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + file_hash: this.fileHash ? this.fileHash : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorReverseSide \ No newline at end of file diff --git a/lib/models/PassportElementErrorSelfie.js b/lib/models/PassportElementErrorSelfie.js new file mode 100644 index 0000000..4cc42b9 --- /dev/null +++ b/lib/models/PassportElementErrorSelfie.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes. + */ + +class PassportElementErrorSelfie { + /** + * + * @param {string} source + * @param {string} type + * @param {string} fileHash + * @param {string} message + */ + constructor(source, type, fileHash, message) { + this._source = source + this._type = type + this._fileHash = fileHash + this._message = message + } + + /** + * Error source, must be selfie + * @returns {string} + */ + get source() { + return this._source + } + + /** + * The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Base64-encoded hash of the file with the selfie + * @returns {string} + */ + get fileHash() { + return this._fileHash + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorSelfie} + */ + static deserialize(raw) { + return new PassportElementErrorSelfie(raw['source'], raw['type'], raw['file_hash'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + file_hash: this.fileHash ? this.fileHash : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorSelfie \ No newline at end of file diff --git a/lib/models/PassportElementErrorTranslationFile.js b/lib/models/PassportElementErrorTranslationFile.js new file mode 100644 index 0000000..7ea82a7 --- /dev/null +++ b/lib/models/PassportElementErrorTranslationFile.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes. + */ + +class PassportElementErrorTranslationFile { + /** + * + * @param {string} source + * @param {string} type + * @param {string} fileHash + * @param {string} message + */ + constructor(source, type, fileHash, message) { + this._source = source + this._type = type + this._fileHash = fileHash + this._message = message + } + + /** + * Error source, must be translation_file + * @returns {string} + */ + get source() { + return this._source + } + + /** + * Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Base64-encoded file hash + * @returns {string} + */ + get fileHash() { + return this._fileHash + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorTranslationFile} + */ + static deserialize(raw) { + return new PassportElementErrorTranslationFile(raw['source'], raw['type'], raw['file_hash'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + file_hash: this.fileHash ? this.fileHash : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorTranslationFile \ No newline at end of file diff --git a/lib/models/PassportElementErrorTranslationFiles.js b/lib/models/PassportElementErrorTranslationFiles.js new file mode 100644 index 0000000..7b889c2 --- /dev/null +++ b/lib/models/PassportElementErrorTranslationFiles.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change. + */ + +class PassportElementErrorTranslationFiles { + /** + * + * @param {string} source + * @param {string} type + * @param {string[]} fileHashes + * @param {string} message + */ + constructor(source, type, fileHashes, message) { + this._source = source + this._type = type + this._fileHashes = fileHashes + this._message = message + } + + /** + * Error source, must be translation_files + * @returns {string} + */ + get source() { + return this._source + } + + /** + * Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” + * @returns {string} + */ + get type() { + return this._type + } + + /** + * List of base64-encoded file hashes + * @returns {string[]} + */ + get fileHashes() { + return this._fileHashes + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorTranslationFiles} + */ + static deserialize(raw) { + return new PassportElementErrorTranslationFiles(raw['source'], raw['type'], raw['file_hashes'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + file_hashes: this.fileHashes ? this.fileHashes : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorTranslationFiles \ No newline at end of file diff --git a/lib/models/PassportElementErrorUnspecified.js b/lib/models/PassportElementErrorUnspecified.js new file mode 100644 index 0000000..ae38b08 --- /dev/null +++ b/lib/models/PassportElementErrorUnspecified.js @@ -0,0 +1,85 @@ +'use strict' + +/** + * Represents an issue in an unspecified place. The error is considered resolved when new data is added. + */ + +class PassportElementErrorUnspecified { + /** + * + * @param {string} source + * @param {string} type + * @param {string} elementHash + * @param {string} message + */ + constructor(source, type, elementHash, message) { + this._source = source + this._type = type + this._elementHash = elementHash + this._message = message + } + + /** + * Error source, must be unspecified + * @returns {string} + */ + get source() { + return this._source + } + + /** + * Type of element of the user's Telegram Passport which has the issue + * @returns {string} + */ + get type() { + return this._type + } + + /** + * Base64-encoded element hash + * @returns {string} + */ + get elementHash() { + return this._elementHash + } + + /** + * Error message + * @returns {string} + */ + get message() { + return this._message + } + + /** + * + * @param {Object} raw + * @returns {PassportElementErrorUnspecified} + */ + static deserialize(raw) { + return new PassportElementErrorUnspecified(raw['source'], raw['type'], raw['element_hash'], raw['message']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + source: this.source ? this.source : undefined, + type: this.type ? this.type : undefined, + element_hash: this.elementHash ? this.elementHash : undefined, + message: this.message ? this.message : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportElementErrorUnspecified \ No newline at end of file diff --git a/lib/models/PassportFile.js b/lib/models/PassportFile.js new file mode 100644 index 0000000..3da633c --- /dev/null +++ b/lib/models/PassportFile.js @@ -0,0 +1,74 @@ +'use strict' + +/** + * This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB. + */ + +class PassportFile { + /** + * + * @param {string} fileId + * @param {number} fileSize + * @param {number} fileDate + */ + constructor(fileId, fileSize, fileDate) { + this._fileId = fileId + this._fileSize = fileSize + this._fileDate = fileDate + } + + /** + * Unique identifier for this file + * @returns {string} + */ + get fileId() { + return this._fileId + } + + /** + * File size + * @returns {number} + */ + get fileSize() { + return this._fileSize + } + + /** + * Unix time when the file was uploaded + * @returns {number} + */ + get fileDate() { + return this._fileDate + } + + /** + * + * @param {Object} raw + * @returns {PassportFile} + */ + static deserialize(raw) { + return new PassportFile(raw['file_id'], raw['file_size'], raw['file_date']) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + file_id: this.fileId ? this.fileId : undefined, + file_size: this.fileSize ? this.fileSize : undefined, + file_date: this.fileDate ? this.fileDate : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PassportFile \ No newline at end of file diff --git a/lib/models/PreCheckoutQuery.js b/lib/models/PreCheckoutQuery.js new file mode 100644 index 0000000..9ef2f83 --- /dev/null +++ b/lib/models/PreCheckoutQuery.js @@ -0,0 +1,137 @@ +'use strict' + +const User = require('./User') +const OrderInfo = require('./OrderInfo') + +/** + * This object contains information about an incoming pre-checkout query. + */ + +class PreCheckoutQuery { + /** + * + * @param {string} id + * @param {User} from + * @param {string} currency + * @param {number} totalAmount + * @param {string} invoicePayload + * @param {string|null} [shippingOptionId] + * @param {OrderInfo|null} [orderInfo] + */ + constructor( + id, + from, + currency, + totalAmount, + invoicePayload, + shippingOptionId, + orderInfo + ) { + this._id = id + this._from = from + this._currency = currency + this._totalAmount = totalAmount + this._invoicePayload = invoicePayload + this._shippingOptionId = shippingOptionId + this._orderInfo = orderInfo + } + + /** + * Unique query identifier + * @returns {string} + */ + get id() { + return this._id + } + + /** + * User who sent the query + * @returns {User} + */ + get from() { + return this._from + } + + /** + * Three-letter ISO 4217 currency code + * @returns {string} + */ + get currency() { + return this._currency + } + + /** + * Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + * @returns {number} + */ + get totalAmount() { + return this._totalAmount + } + + /** + * Bot specified invoice payload + * @returns {string} + */ + get invoicePayload() { + return this._invoicePayload + } + + /** + * Identifier of the shipping option chosen by the user + * @returns {string|null} + */ + get shippingOptionId() { + return this._shippingOptionId + } + + /** + * Order info provided by the user + * @returns {OrderInfo|null} + */ + get orderInfo() { + return this._orderInfo + } + + /** + * + * @param {Object} raw + * @returns {PreCheckoutQuery} + */ + static deserialize(raw) { + return new PreCheckoutQuery( + raw['id'], + raw['from'] ? User.deserialize(raw['from']) : null, + raw['currency'], + raw['total_amount'], + raw['invoice_payload'], + raw['shipping_option_id'] ? raw['shipping_option_id'] : null, + raw['order_info'] ? OrderInfo.deserialize(raw['order_info']) : null + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + id: this.id ? this.id : undefined, + from: this.from ? this.from.serialize() : undefined, + currency: this.currency ? this.currency : undefined, + total_amount: this.totalAmount ? this.totalAmount : undefined, + invoice_payload: this.invoicePayload ? this.invoicePayload : undefined, + shipping_option_id: this.shippingOptionId ? this.shippingOptionId : undefined, + order_info: this.orderInfo ? this.orderInfo.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = PreCheckoutQuery \ No newline at end of file diff --git a/lib/models/ReplyKeyboardRemove.js b/lib/models/ReplyKeyboardRemove.js new file mode 100644 index 0000000..4c33155 --- /dev/null +++ b/lib/models/ReplyKeyboardRemove.js @@ -0,0 +1,63 @@ +'use strict' + +/** + * Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). + */ + +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() + } +} + +module.exports = ReplyKeyboardRemove \ No newline at end of file diff --git a/lib/models/ResponseParameters.js b/lib/models/ResponseParameters.js index 252ed73..abac68f 100644 --- a/lib/models/ResponseParameters.js +++ b/lib/models/ResponseParameters.js @@ -1,7 +1,7 @@ 'use strict' /** - * Contains information about why a request was unsuccessfull. + * Contains information about why a request was unsuccessful. */ class ResponseParameters { diff --git a/lib/models/ShippingAddress.js b/lib/models/ShippingAddress.js new file mode 100644 index 0000000..bbe9cc8 --- /dev/null +++ b/lib/models/ShippingAddress.js @@ -0,0 +1,114 @@ +'use strict' + +/** + * This object represents a shipping address. + */ + +class ShippingAddress { + /** + * + * @param {string} countryCode + * @param {string} state + * @param {string} city + * @param {string} streetLine1 + * @param {string} streetLine2 + * @param {string} postCode + */ + constructor(countryCode, state, city, streetLine1, streetLine2, postCode) { + this._countryCode = countryCode + this._state = state + this._city = city + this._streetLine1 = streetLine1 + this._streetLine2 = streetLine2 + this._postCode = postCode + } + + /** + * ISO 3166-1 alpha-2 country code + * @returns {string} + */ + get countryCode() { + return this._countryCode + } + + /** + * State, if applicable + * @returns {string} + */ + get state() { + return this._state + } + + /** + * City + * @returns {string} + */ + get city() { + return this._city + } + + /** + * First line for the address + * @returns {string} + */ + get streetLine1() { + return this._streetLine1 + } + + /** + * Second line for the address + * @returns {string} + */ + get streetLine2() { + return this._streetLine2 + } + + /** + * Address post code + * @returns {string} + */ + get postCode() { + return this._postCode + } + + /** + * + * @param {Object} raw + * @returns {ShippingAddress} + */ + static deserialize(raw) { + return new ShippingAddress( + raw['country_code'], + raw['state'], + raw['city'], + raw['street_line1'], + raw['street_line2'], + raw['post_code'] + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + country_code: this.countryCode ? this.countryCode : undefined, + state: this.state ? this.state : undefined, + city: this.city ? this.city : undefined, + street_line1: this.streetLine1 ? this.streetLine1 : undefined, + street_line2: this.streetLine2 ? this.streetLine2 : undefined, + post_code: this.postCode ? this.postCode : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = ShippingAddress \ No newline at end of file diff --git a/lib/models/ShippingOption.js b/lib/models/ShippingOption.js new file mode 100644 index 0000000..fa3262a --- /dev/null +++ b/lib/models/ShippingOption.js @@ -0,0 +1,76 @@ +'use strict' + +const LabeledPrice = require('./LabeledPrice') + +/** + * This object represents one shipping option. + */ + +class ShippingOption { + /** + * + * @param {string} id + * @param {string} title + * @param {LabeledPrice[]} prices + */ + constructor(id, title, prices) { + this._id = id + this._title = title + this._prices = prices + } + + /** + * Shipping option identifier + * @returns {string} + */ + get id() { + return this._id + } + + /** + * Option title + * @returns {string} + */ + get title() { + return this._title + } + + /** + * List of price portions + * @returns {LabeledPrice[]} + */ + get prices() { + return this._prices + } + + /** + * + * @param {Object} raw + * @returns {ShippingOption} + */ + static deserialize(raw) { + return new ShippingOption(raw['id'], raw['title'], raw['prices'] ? raw['prices'].map(item => LabeledPrice.deserialize(item)) : null) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + id: this.id ? this.id : undefined, + title: this.title ? this.title : undefined, + prices: this.prices ? this.prices.map(item => item.serialize()) : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = ShippingOption \ No newline at end of file diff --git a/lib/models/ShippingQuery.js b/lib/models/ShippingQuery.js new file mode 100644 index 0000000..52463b7 --- /dev/null +++ b/lib/models/ShippingQuery.js @@ -0,0 +1,88 @@ +'use strict' + +const User = require('./User') +const ShippingAddress = require('./ShippingAddress') + +/** + * This object contains information about an incoming shipping query. + */ + +class ShippingQuery { + /** + * + * @param {string} id + * @param {User} from + * @param {string} invoicePayload + * @param {ShippingAddress} shippingAddress + */ + constructor(id, from, invoicePayload, shippingAddress) { + this._id = id + this._from = from + this._invoicePayload = invoicePayload + this._shippingAddress = shippingAddress + } + + /** + * Unique query identifier + * @returns {string} + */ + get id() { + return this._id + } + + /** + * User who sent the query + * @returns {User} + */ + get from() { + return this._from + } + + /** + * Bot specified invoice payload + * @returns {string} + */ + get invoicePayload() { + return this._invoicePayload + } + + /** + * User specified shipping address + * @returns {ShippingAddress} + */ + get shippingAddress() { + return this._shippingAddress + } + + /** + * + * @param {Object} raw + * @returns {ShippingQuery} + */ + static deserialize(raw) { + return new ShippingQuery(raw['id'], raw['from'] ? User.deserialize(raw['from']) : null, raw['invoice_payload'], raw['shipping_address'] ? ShippingAddress.deserialize(raw['shipping_address']) : null) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + id: this.id ? this.id : undefined, + from: this.from ? this.from.serialize() : undefined, + invoice_payload: this.invoicePayload ? this.invoicePayload : undefined, + shipping_address: this.shippingAddress ? this.shippingAddress.serialize() : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = ShippingQuery \ No newline at end of file diff --git a/lib/models/Sticker.js b/lib/models/Sticker.js index 25388e7..9ad3441 100644 --- a/lib/models/Sticker.js +++ b/lib/models/Sticker.js @@ -1,6 +1,7 @@ 'use strict' const PhotoSize = require('./PhotoSize') +const MaskPosition = require('./MaskPosition') /** * This object represents a sticker. @@ -14,14 +15,27 @@ class Sticker { * @param {number} height * @param {PhotoSize|null} [thumb] * @param {string|null} [emoji] + * @param {string|null} [setName] + * @param {MaskPosition|null} [maskPosition] * @param {number|null} [fileSize] */ - constructor(fileId, width, height, thumb, emoji, fileSize) { + constructor( + fileId, + width, + height, + thumb, + emoji, + setName, + maskPosition, + fileSize + ) { this._fileId = fileId this._width = width this._height = height this._thumb = thumb this._emoji = emoji + this._setName = setName + this._maskPosition = maskPosition this._fileSize = fileSize } @@ -50,7 +64,7 @@ class Sticker { } /** - * Sticker thumbnail in .webp or .jpg format + * Sticker thumbnail in the .webp or .jpg format * @returns {PhotoSize|null} */ get thumb() { @@ -65,6 +79,22 @@ class Sticker { return this._emoji } + /** + * Name of the sticker set to which the sticker belongs + * @returns {string|null} + */ + get setName() { + return this._setName + } + + /** + * For mask stickers, the position where the mask should be placed + * @returns {MaskPosition|null} + */ + get maskPosition() { + return this._maskPosition + } + /** * File size * @returns {number|null} @@ -85,6 +115,8 @@ class Sticker { raw['height'], raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null, raw['emoji'] ? raw['emoji'] : null, + raw['set_name'] ? raw['set_name'] : null, + raw['mask_position'] ? MaskPosition.deserialize(raw['mask_position']) : null, raw['file_size'] ? raw['file_size'] : null ) } @@ -100,6 +132,8 @@ class Sticker { height: this.height ? this.height : undefined, thumb: this.thumb ? this.thumb.serialize() : undefined, emoji: this.emoji ? this.emoji : undefined, + set_name: this.setName ? this.setName : undefined, + mask_position: this.maskPosition ? this.maskPosition.serialize() : undefined, file_size: this.fileSize ? this.fileSize : undefined } } diff --git a/lib/models/StickerSet.js b/lib/models/StickerSet.js new file mode 100644 index 0000000..5cfb704 --- /dev/null +++ b/lib/models/StickerSet.js @@ -0,0 +1,87 @@ +'use strict' + +const Sticker = require('./Sticker') + +/** + * This object represents a sticker set. + */ + +class StickerSet { + /** + * + * @param {string} name + * @param {string} title + * @param {boolean} containsMasks + * @param {Sticker[]} stickers + */ + constructor(name, title, containsMasks, stickers) { + this._name = name + this._title = title + this._containsMasks = containsMasks + this._stickers = stickers + } + + /** + * Sticker set name + * @returns {string} + */ + get name() { + return this._name + } + + /** + * Sticker set title + * @returns {string} + */ + get title() { + return this._title + } + + /** + * True, if the sticker set contains masks + * @returns {boolean} + */ + get containsMasks() { + return this._containsMasks + } + + /** + * List of all set stickers + * @returns {Sticker[]} + */ + get stickers() { + return this._stickers + } + + /** + * + * @param {Object} raw + * @returns {StickerSet} + */ + static deserialize(raw) { + return new StickerSet(raw['name'], raw['title'], raw['contains_masks'], raw['stickers'] ? raw['stickers'].map(item => Sticker.deserialize(item)) : null) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + name: this.name ? this.name : undefined, + title: this.title ? this.title : undefined, + contains_masks: this.containsMasks ? this.containsMasks : undefined, + stickers: this.stickers ? this.stickers.map(item => item.serialize()) : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = StickerSet \ No newline at end of file diff --git a/lib/models/SuccessfulPayment.js b/lib/models/SuccessfulPayment.js new file mode 100644 index 0000000..3bae853 --- /dev/null +++ b/lib/models/SuccessfulPayment.js @@ -0,0 +1,136 @@ +'use strict' + +const OrderInfo = require('./OrderInfo') + +/** + * This object contains basic information about a successful payment. + */ + +class SuccessfulPayment { + /** + * + * @param {string} currency + * @param {number} totalAmount + * @param {string} invoicePayload + * @param {string|null} [shippingOptionId] + * @param {OrderInfo|null} [orderInfo] + * @param {string} telegramPaymentChargeId + * @param {string} providerPaymentChargeId + */ + constructor( + currency, + totalAmount, + invoicePayload, + shippingOptionId, + orderInfo, + telegramPaymentChargeId, + providerPaymentChargeId + ) { + this._currency = currency + this._totalAmount = totalAmount + this._invoicePayload = invoicePayload + this._shippingOptionId = shippingOptionId + this._orderInfo = orderInfo + this._telegramPaymentChargeId = telegramPaymentChargeId + this._providerPaymentChargeId = providerPaymentChargeId + } + + /** + * Three-letter ISO 4217 currency code + * @returns {string} + */ + get currency() { + return this._currency + } + + /** + * Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). + * @returns {number} + */ + get totalAmount() { + return this._totalAmount + } + + /** + * Bot specified invoice payload + * @returns {string} + */ + get invoicePayload() { + return this._invoicePayload + } + + /** + * Identifier of the shipping option chosen by the user + * @returns {string|null} + */ + get shippingOptionId() { + return this._shippingOptionId + } + + /** + * Order info provided by the user + * @returns {OrderInfo|null} + */ + get orderInfo() { + return this._orderInfo + } + + /** + * Telegram payment identifier + * @returns {string} + */ + get telegramPaymentChargeId() { + return this._telegramPaymentChargeId + } + + /** + * Provider payment identifier + * @returns {string} + */ + get providerPaymentChargeId() { + return this._providerPaymentChargeId + } + + /** + * + * @param {Object} raw + * @returns {SuccessfulPayment} + */ + static deserialize(raw) { + return new SuccessfulPayment( + raw['currency'], + raw['total_amount'], + raw['invoice_payload'], + raw['shipping_option_id'] ? raw['shipping_option_id'] : null, + raw['order_info'] ? OrderInfo.deserialize(raw['order_info']) : null, + raw['telegram_payment_charge_id'], + raw['provider_payment_charge_id'] + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + currency: this.currency ? this.currency : undefined, + total_amount: this.totalAmount ? this.totalAmount : undefined, + invoice_payload: this.invoicePayload ? this.invoicePayload : undefined, + shipping_option_id: this.shippingOptionId ? this.shippingOptionId : undefined, + order_info: this.orderInfo ? this.orderInfo.serialize() : undefined, + telegram_payment_charge_id: this.telegramPaymentChargeId ? this.telegramPaymentChargeId : undefined, + provider_payment_charge_id: this.providerPaymentChargeId ? this.providerPaymentChargeId : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = SuccessfulPayment \ No newline at end of file diff --git a/lib/models/Update.js b/lib/models/Update.js index 8576283..47dcf33 100644 --- a/lib/models/Update.js +++ b/lib/models/Update.js @@ -4,9 +4,11 @@ const Message = require('./Message') const InlineQuery = require('./InlineQuery') const ChosenInlineResult = require('./ChosenInlineResult') const CallbackQuery = require('./CallbackQuery') +const ShippingQuery = require('./ShippingQuery') +const PreCheckoutQuery = require('./PreCheckoutQuery') /** - * This object represents an incoming update.Only one of the optional parameters can be present in any given update. + * This object represents an incoming update.At most one of the optional parameters can be present in any given update. */ class Update { @@ -15,21 +17,40 @@ 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] + * @param {ShippingQuery|null} [shippingQuery] + * @param {PreCheckoutQuery|null} [preCheckoutQuery] */ - constructor(updateId, message, editedMessage, inlineQuery, chosenInlineResult, callbackQuery) { + constructor( + updateId, + message, + editedMessage, + channelPost, + editedChannelPost, + inlineQuery, + chosenInlineResult, + callbackQuery, + shippingQuery, + preCheckoutQuery + ) { this._updateId = updateId this._message = message this._editedMessage = editedMessage + this._channelPost = channelPost + this._editedChannelPost = editedChannelPost this._inlineQuery = inlineQuery this._chosenInlineResult = chosenInlineResult this._callbackQuery = callbackQuery + this._shippingQuery = shippingQuery + this._preCheckoutQuery = preCheckoutQuery } /** - * 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. + * The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially. * @returns {number} */ get updateId() { @@ -52,6 +73,22 @@ class Update { 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} @@ -61,7 +98,7 @@ class Update { } /** - * The result of an inline query that was chosen by a user and sent to their chat partner. + * The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot. * @returns {ChosenInlineResult|null} */ get chosenInlineResult() { @@ -76,6 +113,22 @@ class Update { return this._callbackQuery } + /** + * New incoming shipping query. Only for invoices with flexible price + * @returns {ShippingQuery|null} + */ + get shippingQuery() { + return this._shippingQuery + } + + /** + * New incoming pre-checkout query. Contains full information about checkout + * @returns {PreCheckoutQuery|null} + */ + get preCheckoutQuery() { + return this._preCheckoutQuery + } + /** * * @param {Object} raw @@ -86,9 +139,13 @@ class 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 + raw['callback_query'] ? CallbackQuery.deserialize(raw['callback_query']) : null, + raw['shipping_query'] ? ShippingQuery.deserialize(raw['shipping_query']) : null, + raw['pre_checkout_query'] ? PreCheckoutQuery.deserialize(raw['pre_checkout_query']) : null ) } @@ -101,9 +158,13 @@ class Update { 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() : undefined + callback_query: this.callbackQuery ? this.callbackQuery.serialize() : undefined, + shipping_query: this.shippingQuery ? this.shippingQuery.serialize() : undefined, + pre_checkout_query: this.preCheckoutQuery ? this.preCheckoutQuery.serialize() : undefined } } diff --git a/lib/models/User.js b/lib/models/User.js index 29657e5..22b7913 100644 --- a/lib/models/User.js +++ b/lib/models/User.js @@ -8,15 +8,19 @@ class User { /** * * @param {number} id + * @param {boolean} isBot * @param {string} firstName * @param {string|null} [lastName] * @param {string|null} [username] + * @param {string|null} [languageCode] */ - constructor(id, firstName, lastName, username) { + constructor(id, isBot, firstName, lastName, username, languageCode) { this._id = id + this._isBot = isBot this._firstName = firstName this._lastName = lastName this._username = username + this._languageCode = languageCode } /** @@ -27,6 +31,14 @@ class User { return this._id } + /** + * True, if this user is a bot + * @returns {boolean} + */ + get isBot() { + return this._isBot + } + /** * User‘s or bot’s first name * @returns {string} @@ -51,13 +63,28 @@ class User { return this._username } + /** + * IETF language tag of the user's language + * @returns {string|null} + */ + get languageCode() { + return this._languageCode + } + /** * * @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) + return new User( + raw['id'], + raw['is_bot'], + raw['first_name'], + raw['last_name'] ? raw['last_name'] : null, + raw['username'] ? raw['username'] : null, + raw['language_code'] ? raw['language_code'] : null + ) } /** @@ -67,9 +94,11 @@ class User { serialize() { return { id: this.id ? this.id : undefined, + is_bot: this.isBot ? this.isBot : undefined, first_name: this.firstName ? this.firstName : undefined, last_name: this.lastName ? this.lastName : undefined, - username: this.username ? this.username : undefined + username: this.username ? this.username : undefined, + language_code: this.languageCode ? this.languageCode : undefined } } diff --git a/lib/models/Venue.js b/lib/models/Venue.js index 3099ffb..36d76a2 100644 --- a/lib/models/Venue.js +++ b/lib/models/Venue.js @@ -13,12 +13,14 @@ class Venue { * @param {string} title * @param {string} address * @param {string|null} [foursquareId] + * @param {string|null} [foursquareType] */ - constructor(location, title, address, foursquareId) { + constructor(location, title, address, foursquareId, foursquareType) { this._location = location this._title = title this._address = address this._foursquareId = foursquareId + this._foursquareType = foursquareType } /** @@ -53,13 +55,27 @@ class Venue { return this._foursquareId } + /** + * Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) + * @returns {string|null} + */ + get foursquareType() { + return this._foursquareType + } + /** * * @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) + return new Venue( + raw['location'] ? Location.deserialize(raw['location']) : null, + raw['title'], + raw['address'], + raw['foursquare_id'] ? raw['foursquare_id'] : null, + raw['foursquare_type'] ? raw['foursquare_type'] : null + ) } /** @@ -71,7 +87,8 @@ class Venue { 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 + foursquare_id: this.foursquareId ? this.foursquareId : undefined, + foursquare_type: this.foursquareType ? this.foursquareType : undefined } } diff --git a/lib/models/VideoNote.js b/lib/models/VideoNote.js new file mode 100644 index 0000000..cd3d86a --- /dev/null +++ b/lib/models/VideoNote.js @@ -0,0 +1,104 @@ +'use strict' + +const PhotoSize = require('./PhotoSize') + +/** + * This object represents a video message (available in Telegram apps as of v.4.0). + */ + +class VideoNote { + /** + * + * @param {string} fileId + * @param {number} length + * @param {number} duration + * @param {PhotoSize|null} [thumb] + * @param {number|null} [fileSize] + */ + constructor(fileId, length, duration, thumb, fileSize) { + this._fileId = fileId + this._length = length + this._duration = duration + this._thumb = thumb + this._fileSize = fileSize + } + + /** + * Unique identifier for this file + * @returns {string} + */ + get fileId() { + return this._fileId + } + + /** + * Video width and height (diameter of the video message) as defined by sender + * @returns {number} + */ + get length() { + return this._length + } + + /** + * 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 + } + + /** + * File size + * @returns {number|null} + */ + get fileSize() { + return this._fileSize + } + + /** + * + * @param {Object} raw + * @returns {VideoNote} + */ + static deserialize(raw) { + return new VideoNote( + raw['file_id'], + raw['length'], + raw['duration'], + raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : null, + raw['file_size'] ? raw['file_size'] : null + ) + } + + /** + * + * @returns {Object} + */ + serialize() { + return { + file_id: this.fileId ? this.fileId : undefined, + length: this.length ? this.length : undefined, + duration: this.duration ? this.duration : undefined, + thumb: this.thumb ? this.thumb.serialize() : undefined, + file_size: this.fileSize ? this.fileSize : undefined + } + } + + /** + * + * @returns {string} + */ + toJSON() { + return this.serialize() + } +} + +module.exports = VideoNote \ No newline at end of file diff --git a/lib/models/WebhookInfo.js b/lib/models/WebhookInfo.js index 49a1fba..a2680b3 100644 --- a/lib/models/WebhookInfo.js +++ b/lib/models/WebhookInfo.js @@ -12,13 +12,25 @@ class WebhookInfo { * @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) { + 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 } /** @@ -61,6 +73,22 @@ class WebhookInfo { 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 @@ -72,7 +100,9 @@ class WebhookInfo { 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['last_error_message'] ? raw['last_error_message'] : null, + raw['max_connections'] ? raw['max_connections'] : null, + raw['allowed_updates'] ? raw['allowed_updates'] : null ) } @@ -86,7 +116,9 @@ class WebhookInfo { 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 + last_error_message: this.lastErrorMessage ? this.lastErrorMessage : undefined, + max_connections: this.maxConnections ? this.maxConnections : undefined, + allowed_updates: this.allowedUpdates ? this.allowedUpdates : undefined } } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..104c3f3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1168 @@ +{ + "name": "telegram-node-bot", + "version": "4.0.5", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "abab": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", + "integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4=", + "dev": true, + "optional": true + }, + "acorn": { + "version": "2.7.0", + "resolved": "http://registry.npmjs.org/acorn/-/acorn-2.7.0.tgz", + "integrity": "sha1-q259nYhqrKiwhbwzEreaGYQz8Oc=", + "dev": true + }, + "acorn-globals": { + "version": "1.0.9", + "resolved": "http://registry.npmjs.org/acorn-globals/-/acorn-globals-1.0.9.tgz", + "integrity": "sha1-VbtemGkVB7dFedBRNBMhfDgMVM8=", + "dev": true, + "optional": true, + "requires": { + "acorn": "^2.1.0" + } + }, + "ajv": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.2.tgz", + "integrity": "sha512-FBHEW6Jf5TB9MGBgUUA9XHkTbjXYfAUjY43ACMfmdMRHniyoMHjHjzD50OK8LGDWQwp4rWEsIq5kEqq7rvIM1g==", + "dev": true, + "optional": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "optional": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true, + "optional": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true, + "optional": true + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true, + "optional": true + }, + "babylon": { + "version": "7.0.0-beta.19", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.19.tgz", + "integrity": "sha512-Vg0C9s/REX6/WIXN37UKpv5ZhRi6A4pjHlpkE34+8/a6c2W1Q692n3hmc+SZG5lKRnaExLUbxtJ1SVT+KaCQ/A==", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "bluebird": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", + "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==", + "dev": true + }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true, + "optional": true + }, + "catharsis": { + "version": "0.8.9", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.9.tgz", + "integrity": "sha1-mMyJDKZS3S7w5ws3klMQ/56Q/Is=", + "dev": true, + "requires": { + "underscore-contrib": "~0.3.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "cheerio": { + "version": "0.20.0", + "resolved": "http://registry.npmjs.org/cheerio/-/cheerio-0.20.0.tgz", + "integrity": "sha1-XHEPK6uVZTJyhCugHG6mGzVF7DU=", + "dev": true, + "requires": { + "css-select": "~1.2.0", + "dom-serializer": "~0.1.0", + "entities": "~1.1.1", + "htmlparser2": "~3.8.1", + "jsdom": "^7.0.2", + "lodash": "^4.1.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + } + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "css-select": { + "version": "1.2.0", + "resolved": "http://registry.npmjs.org/css-select/-/css-select-1.2.0.tgz", + "integrity": "sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg=", + "dev": true, + "requires": { + "boolbase": "~1.0.0", + "css-what": "2.1", + "domutils": "1.5.1", + "nth-check": "~1.0.1" + } + }, + "css-what": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.2.tgz", + "integrity": "sha512-wan8dMWQ0GUeF7DGEPVjhHemVW/vy6xUYmFzRY8RYqgA0JtXC9rJmbScBjqSu6dg9q0lwPQy6ZAmJVr3PPTvqQ==", + "dev": true + }, + "cssom": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.4.tgz", + "integrity": "sha512-+7prCSORpXNeR4/fUP3rL+TzqtiFfhMvTd7uEqMdgPvLPt4+uzFUeufx5RHjGTACCargg/DiEt/moMQmvnfkog==", + "dev": true + }, + "cssstyle": { + "version": "0.2.37", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-0.2.37.tgz", + "integrity": "sha1-VBCXI0yyUTyDzu06zdwn/yeYfVQ=", + "dev": true, + "optional": true, + "requires": { + "cssom": "0.3.x" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true, + "optional": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "dom-serializer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", + "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "dev": true, + "requires": { + "domelementtype": "~1.1.1", + "entities": "~1.1.1" + }, + "dependencies": { + "domelementtype": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", + "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", + "dev": true + } + } + }, + "domelementtype": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", + "dev": true + }, + "domhandler": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", + "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", + "dev": true, + "requires": { + "domelementtype": "1" + } + }, + "domutils": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", + "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "optional": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "entities": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "escodegen": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.0.tgz", + "integrity": "sha512-IeMV45ReixHS53K/OmfKAIztN/igDHzTJUhZM3k1jMhIZWjk45SMwAtBsEXiJp3vSPmTcu6CXn7mDvFHRN66fw==", + "dev": true, + "optional": true, + "requires": { + "esprima": "^3.1.3", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" + } + }, + "esprima": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "dev": true, + "optional": true + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true, + "optional": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true, + "optional": true + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true, + "optional": true + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true, + "optional": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true, + "optional": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true, + "optional": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true, + "optional": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "optional": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", + "dev": true + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true, + "optional": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "optional": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "htmlparser2": { + "version": "3.8.3", + "resolved": "http://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", + "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", + "dev": true, + "requires": { + "domelementtype": "1", + "domhandler": "2.3", + "domutils": "1.5", + "entities": "1.0", + "readable-stream": "1.1" + }, + "dependencies": { + "entities": { + "version": "1.0.0", + "resolved": "http://registry.npmjs.org/entities/-/entities-1.0.0.tgz", + "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", + "dev": true + } + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "ink-docstrap": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ink-docstrap/-/ink-docstrap-1.3.2.tgz", + "integrity": "sha512-STx5orGQU1gfrkoI/fMU7lX6CSP7LBGO10gXNgOZhwKhUqbtNjCkYSewJtNnLmWP1tAGN6oyEpG1HFPw5vpa5Q==", + "dev": true, + "requires": { + "moment": "^2.14.1", + "sanitize-html": "^1.13.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true, + "optional": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true, + "optional": true + }, + "js2xmlparser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-3.0.0.tgz", + "integrity": "sha1-P7YOqgicVED5MZ9RdgzNB+JJlzM=", + "dev": true, + "requires": { + "xmlcreate": "^1.0.1" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, + "jsdoc": { + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.5.5.tgz", + "integrity": "sha512-6PxB65TAU4WO0Wzyr/4/YhlGovXl0EVYfpKbpSroSj0qBxT4/xod/l40Opkm38dRHRdQgdeY836M0uVnJQG7kg==", + "dev": true, + "requires": { + "babylon": "7.0.0-beta.19", + "bluebird": "~3.5.0", + "catharsis": "~0.8.9", + "escape-string-regexp": "~1.0.5", + "js2xmlparser": "~3.0.0", + "klaw": "~2.0.0", + "marked": "~0.3.6", + "mkdirp": "~0.5.1", + "requizzle": "~0.2.1", + "strip-json-comments": "~2.0.1", + "taffydb": "2.6.2", + "underscore": "~1.8.3" + } + }, + "jsdom": { + "version": "7.2.2", + "resolved": "http://registry.npmjs.org/jsdom/-/jsdom-7.2.2.tgz", + "integrity": "sha1-QLQCdwwr2iNGkJa+6Rq2deOx/G4=", + "dev": true, + "optional": true, + "requires": { + "abab": "^1.0.0", + "acorn": "^2.4.0", + "acorn-globals": "^1.0.4", + "cssom": ">= 0.3.0 < 0.4.0", + "cssstyle": ">= 0.2.29 < 0.3.0", + "escodegen": "^1.6.1", + "nwmatcher": ">= 1.3.7 < 2.0.0", + "parse5": "^1.5.1", + "request": "^2.55.0", + "sax": "^1.1.4", + "symbol-tree": ">= 3.1.0 < 4.0.0", + "tough-cookie": "^2.2.0", + "webidl-conversions": "^2.0.0", + "whatwg-url-compat": "~0.6.5", + "xml-name-validator": ">= 2.0.1 < 3.0.0" + } + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true, + "optional": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "optional": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true, + "optional": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "klaw": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-2.0.0.tgz", + "integrity": "sha1-WcEo4Nxc5BAgEVEZTuucv4WGUPY=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.9" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "optional": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "lodash.escaperegexp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", + "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=", + "dev": true + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", + "dev": true + }, + "lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=", + "dev": true + }, + "lodash.mergewith": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", + "integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==", + "dev": true + }, + "marked": { + "version": "0.3.19", + "resolved": "http://registry.npmjs.org/marked/-/marked-0.3.19.tgz", + "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", + "dev": true + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", + "dev": true + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "dev": true, + "requires": { + "mime-db": "~1.37.0" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "moment": { + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.23.0.tgz", + "integrity": "sha512-3IE39bHVqFbWWaPOMHZF98Q9c3LDKGTmypMiTM2QygGXXElkFWIH7GxfmlwmY2vwa+wmNsoYZmG2iusf1ZjJoA==", + "dev": true + }, + "nth-check": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", + "dev": true, + "requires": { + "boolbase": "~1.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "nwmatcher": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.4.tgz", + "integrity": "sha512-3iuY4N5dhgMpCUrOVnuAdGrgxVqV2cJpM+XNccjR2DKOB1RUP0aA+wGXEiNziG/UKboFyGBIoKOaNlJxx8bciQ==", + "dev": true, + "optional": true + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true, + "optional": true + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "optional": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + } + }, + "parse5": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-1.5.1.tgz", + "integrity": "sha1-m387DeMr543CQBsXVzzK8Pb1nZQ=", + "dev": true, + "optional": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true, + "optional": true + }, + "postcss": { + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.7.tgz", + "integrity": "sha512-HThWSJEPkupqew2fnuQMEI2YcTj/8gMV3n80cMdJsKxfIh5tHf7nM5JigNX6LxVMqo6zkgQNAI88hyFvBk41Pg==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "source-map": "^0.6.1", + "supports-color": "^5.5.0" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "dev": true + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true, + "optional": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "optional": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true, + "optional": true + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, + "optional": true, + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + } + } + } + }, + "requizzle": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.1.tgz", + "integrity": "sha1-aUPDUwxNmn5G8c3dUcFY/GcM294=", + "dev": true, + "requires": { + "underscore": "~1.6.0" + }, + "dependencies": { + "underscore": { + "version": "1.6.0", + "resolved": "http://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", + "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", + "dev": true + } + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "sanitize-html": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-1.20.0.tgz", + "integrity": "sha512-BpxXkBoAG+uKCHjoXFmox6kCSYpnulABoGcZ/R3QyY9ndXbIM5S94eOr1IqnzTG8TnbmXaxWoDDzKC5eJv7fEQ==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "htmlparser2": "^3.10.0", + "lodash.clonedeep": "^4.5.0", + "lodash.escaperegexp": "^4.1.2", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.mergewith": "^4.6.1", + "postcss": "^7.0.5", + "srcset": "^1.0.0", + "xtend": "^4.0.1" + }, + "dependencies": { + "htmlparser2": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.0.tgz", + "integrity": "sha512-J1nEUGv+MkXS0weHNWVKJJ+UrLfePxRWpN3C9bEi9fLxL2+ggW94DQvgYVXsaT30PGwYRIZKNZXuyMhp3Di4bQ==", + "dev": true, + "requires": { + "domelementtype": "^1.3.0", + "domhandler": "^2.3.0", + "domutils": "^1.5.1", + "entities": "^1.1.1", + "inherits": "^2.0.1", + "readable-stream": "^3.0.6" + } + }, + "readable-stream": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.1.0.tgz", + "integrity": "sha512-vpydAvIJvPODZNagCPuHG87O9JNPtvFEtjHHRVwNVsVVRBqemvPJkc2SYbxJsiZXawJdtZNmkmnsPuE3IgsG0A==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", + "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true, + "optional": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "srcset": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/srcset/-/srcset-1.0.0.tgz", + "integrity": "sha1-pWad4StC87HV6D7QPHEEb8SPQe8=", + "dev": true, + "requires": { + "array-uniq": "^1.0.2", + "number-is-nan": "^1.0.0" + } + }, + "sshpk": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.0.tgz", + "integrity": "sha512-Zhev35/y7hRMcID/upReIvRse+I9SVhyVre/KTJSJQWMz3C3+G+HpO7m1wK/yckEtujKZ7dS4hkVxAnmHaIGVQ==", + "dev": true, + "optional": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "symbol-tree": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", + "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", + "dev": true, + "optional": true + }, + "taffydb": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", + "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", + "dev": true + }, + "tiny_request": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/tiny_request/-/tiny_request-1.0.13.tgz", + "integrity": "sha1-gbmXd5R1GdNLDnOsnrb1AnpVL5I=" + }, + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dev": true, + "optional": true, + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", + "dev": true, + "optional": true + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "underscore": { + "version": "1.8.3", + "resolved": "http://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", + "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", + "dev": true + }, + "underscore-contrib": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/underscore-contrib/-/underscore-contrib-0.3.0.tgz", + "integrity": "sha1-ZltmwkeD+PorGMn4y7Dix9SMJsc=", + "dev": true, + "requires": { + "underscore": "1.6.0" + }, + "dependencies": { + "underscore": { + "version": "1.6.0", + "resolved": "http://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", + "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", + "dev": true + } + } + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "optional": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true, + "optional": true + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "optional": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "webidl-conversions": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-2.0.1.tgz", + "integrity": "sha1-O/glj30xjHRDw28uFpQCoaZwNQY=", + "dev": true, + "optional": true + }, + "whatwg-url-compat": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/whatwg-url-compat/-/whatwg-url-compat-0.6.5.tgz", + "integrity": "sha1-AImBEa9om7CXVBzVpFymyHmERb8=", + "dev": true, + "optional": true, + "requires": { + "tr46": "~0.0.1" + } + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true, + "optional": true + }, + "xml-name-validator": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-2.0.1.tgz", + "integrity": "sha1-TYuPHszTQZqjYgYb7O9RXh5VljU=", + "dev": true, + "optional": true + }, + "xmlcreate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-1.0.2.tgz", + "integrity": "sha1-+mv3YqYKQT+z3Y9LA8WyaSONMI8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } +}