Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes chatSession key names #145

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
.idea/
node_modules
docs
lib/models/*
!lib/models/InlineQueryResult.js
!lib/models/InputMessageContent.js
!lib/models/CallbackGame.js
ScreenShot.png
1 change: 1 addition & 0 deletions api-scheme/models/ModelsGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const JS_TYPES = {
String: 'string',
Float: 'number',
'Float number': 'number',
'InputFile or String': 'string',
Boolean: 'boolean',
True: 'boolean',
False: 'boolean'
Expand Down
149 changes: 149 additions & 0 deletions lib/models/Animation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
'use strict'

const PhotoSize = require('./PhotoSize')

/**
* 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,
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
this._fileSize = fileSize
}

/**
* Unique file identifier
* @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
}

/**
* 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['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,
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,
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
136 changes: 136 additions & 0 deletions lib/models/Audio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
'use strict'

const PhotoSize = require('./PhotoSize')

/**
* 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]
* @param {PhotoSize|null} [thumb]
*/
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
}

/**
* 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
}

/**
* Thumbnail of the album cover to which the music file belongs
* @returns {PhotoSize|null}
*/
get thumb() {
return this._thumb
}

/**
*
* @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,
raw['thumb'] ? PhotoSize.deserialize(raw['thumb']) : 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,
thumb: this.thumb ? this.thumb.serialize() : undefined
}
}

/**
*
* @returns {string}
*/
toJSON() {
return this.serialize()
}
}

module.exports = Audio
Loading