UNPKG

tgsnake

Version:

Telegram MTProto framework for nodejs.

100 lines (99 loc) 3.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WebPage = void 0; const platform_node_js_1 = require("../../../platform.node.js"); const TL_js_1 = require("../../TL.js"); const Audio_js_1 = require("./Audio.js"); const Document_js_1 = require("./Document.js"); const Photo_js_1 = require("./Photo.js"); const Animated_js_1 = require("./Animated.js"); const Video_js_1 = require("./Video.js"); class WebPage extends TL_js_1.TLObject { id; url; displayUrl; type; siteName; title; description; audio; document; photo; animation; video; embedUrl; embedType; embedWidth; embedHeight; duration; author; isLargeMedia; constructor({ id, url, displayUrl, type, siteName, title, description, audio, document, photo, animation, video, embedUrl, embedType, embedWidth, embedHeight, duration, author, isLargeMedia, }, client) { super(client); this.id = id; this.url = url; this.displayUrl = displayUrl; this.type = type; this.siteName = siteName; this.title = title; this.description = description; this.audio = audio; this.document = document; this.photo = photo; this.animation = animation; this.video = video; this.embedUrl = embedUrl; this.embedType = embedType; this.embedWidth = embedWidth; this.embedHeight = embedHeight; this.duration = duration; this.author = author; this.isLargeMedia = isLargeMedia; } static parse(client, webpage) { let audio; let document; let photo; let animation; let video; if (webpage.photo && webpage.photo instanceof platform_node_js_1.Raw.Photo) { photo = Photo_js_1.Photo.parse(client, webpage.photo); } if (webpage.document && webpage.document instanceof platform_node_js_1.Raw.Document) { if (webpage.document.attributes.some((attribute) => attribute instanceof platform_node_js_1.Raw.DocumentAttributeAudio)) { audio = Audio_js_1.Audio.parse(client, webpage.document); } else if (webpage.document.attributes.some((attribute) => attribute instanceof platform_node_js_1.Raw.DocumentAttributeAnimated)) { animation = Animated_js_1.Animation.parse(client, webpage.document); } else if (webpage.document.attributes.some((attribute) => attribute instanceof platform_node_js_1.Raw.DocumentAttributeVideo)) { video = Video_js_1.Video.parse(client, webpage.document); } else { document = Document_js_1.Document.parse(client, webpage.document); } } return new WebPage({ audio, document, photo, animation, video, id: webpage.id, url: webpage.url, displayUrl: webpage.displayUrl, type: webpage.type, siteName: webpage.siteName, title: webpage.title, description: webpage.description, embedUrl: webpage.embedUrl, embedType: webpage.embedType, embedWidth: webpage.embedWidth, embedHeight: webpage.embedHeight, duration: webpage.duration, author: webpage.author, isLargeMedia: webpage.hasLargeMedia, }, client); } } exports.WebPage = WebPage;