tgsnake
Version:
Telegram MTProto framework for nodejs.
81 lines (80 loc) • 2.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VideoNote = 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 VideoNote extends TL_js_1.TLObject {
fileId;
fileUniqueId;
width;
height;
duration;
thumb;
date;
dcId;
mimeType;
fileSize;
constructor({ fileId, fileUniqueId, width, height, duration, thumb, date, dcId, mimeType, fileSize, }, client) {
super(client);
this.fileId = fileId;
this.fileUniqueId = fileUniqueId;
this.width = width;
this.height = height;
this.duration = duration;
this.thumb = thumb;
this.date = date;
this.dcId = dcId;
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.VIDEO_NOTE,
fileTypeUniqueId: platform_node_js_1.FileTypeUniqueId.DOCUMENT,
volumeId: BigInt(0),
localId: 0,
id: document.id,
accessHash: document.accessHash,
fileReference: document.fileReference,
});
let width = 0;
let height = 0;
let duration = 0;
let thumb = [];
for (let attribute of document.attributes) {
if (attribute instanceof platform_node_js_1.Raw.DocumentAttributeVideo) {
attribute;
duration = attribute.duration;
width = attribute.w;
height = attribute.h;
}
}
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 VideoNote({
fileId,
fileUniqueId,
width,
height,
thumb,
duration,
fileSize: document.size,
mimeType: document.mimeType,
dcId: document.dcId,
date: new Date(document.date * 1000),
}, client);
}
resend(chatId, more) {
return this.api.sendVideoNote(chatId, this.fileId, more);
}
}
exports.VideoNote = VideoNote;