UNPKG

tgsnake

Version:

Telegram MTProto framework for nodejs.

86 lines (85 loc) 2.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Voice = void 0; const TL_js_1 = require("../../TL.js"); const platform_node_js_1 = require("../../../platform.node.js"); const PhotoSize_js_1 = require("./PhotoSize.js"); class Voice extends TL_js_1.TLObject { fileId; fileUniqueId; duration; thumb; date; dcId; performer; title; filename; mimeType; fileSize; constructor({ fileId, fileUniqueId, duration, thumb, date, dcId, performer, title, filename, mimeType, fileSize, }, client) { super(client); this.fileId = fileId; this.fileUniqueId = fileUniqueId; this.duration = duration; this.thumb = thumb; this.date = date; this.dcId = dcId; this.performer = performer; this.title = title; this.filename = filename; this.mimeType = mimeType; this.fileSize = fileSize; } static parse(client, document) { const { fileId, fileUniqueId } = platform_node_js_1.FileId.encode({ version: 4, subVersion: 32, dcId: document.dcId, fileType: platform_node_js_1.FileType.VOICE, fileTypeUniqueId: platform_node_js_1.FileTypeUniqueId.DOCUMENT, volumeId: BigInt(0), localId: 0, id: document.id, accessHash: document.accessHash, fileReference: document.fileReference, }); let duration = 0; let thumb = []; let performer; let title; let filename; for (let attribute of document.attributes) { if (attribute instanceof platform_node_js_1.Raw.DocumentAttributeAudio) { attribute; duration = attribute.duration; title = attribute.title; performer = attribute.performer; } if (attribute instanceof platform_node_js_1.Raw.DocumentAttributeFilename) { attribute; filename = attribute.fileName; } } if (document.thumbs) { for (let t of document.thumbs) { if (t instanceof platform_node_js_1.Raw.PhotoSize) { thumb.push(PhotoSize_js_1.PhotoSize.parse(client, t, document.id, document.accessHash, document.fileReference, document.dcId)); } } } return new Voice({ fileId, fileUniqueId, duration, thumb, performer, title, filename, mimeType: document.mimeType, fileSize: document.size, dcId: document.dcId, date: new Date(document.date * 1000), }, client); } } exports.Voice = Voice;