From 34546d49ee2f3afdce89f9e7e6b3db15d4dbc800 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Thu, 17 Sep 2020 22:33:23 +0300 Subject: [PATCH] MTProto schema converter Types for methods --- package.json | 2 +- src/components/appMediaPlaybackController.ts | 7 +- src/components/audio.ts | 13 +- src/components/emoticonsDropdown/tabs/gifs.ts | 22 +- .../emoticonsDropdown/tabs/stickers.ts | 29 +- src/components/gifsMasonry.ts | 5 +- src/components/popupAvatar.ts | 4 +- src/components/popupStickers.ts | 9 +- src/components/sidebarLeft/chatFolders.ts | 17 +- src/components/sidebarLeft/editFolder.ts | 2 +- src/components/sidebarLeft/editProfile.ts | 3 +- src/components/sidebarLeft/includedChats.ts | 4 +- src/components/sidebarRight/gifs.ts | 3 +- src/components/sidebarRight/stickers.ts | 14 +- src/components/wrappers.ts | 43 +- src/layer.d.ts | 10777 ++++++++++++++++ src/lib/appManagers/AppInlineBotsManager.ts | 62 +- src/lib/appManagers/apiUpdatesManager.ts | 90 +- src/lib/appManagers/appChatsManager.ts | 25 +- src/lib/appManagers/appDialogsManager.ts | 9 +- src/lib/appManagers/appDocsManager.ts | 76 +- src/lib/appManagers/appDownloadManager.ts | 2 +- src/lib/appManagers/appImManager.ts | 19 +- src/lib/appManagers/appMediaViewer.ts | 7 +- src/lib/appManagers/appMessagesManager.ts | 206 +- src/lib/appManagers/appPeersManager.ts | 20 +- src/lib/appManagers/appPhotosManager.ts | 98 +- src/lib/appManagers/appPollsManager.ts | 16 +- src/lib/appManagers/appStateManager.ts | 2 +- src/lib/appManagers/appStickersManager.ts | 174 +- src/lib/appManagers/appUsersManager.ts | 87 +- src/lib/bin_utils.ts | 2 +- src/lib/crypto/crypto_methods.ts | 3 +- src/lib/crypto/srp.ts | 6 +- src/lib/mtproto/apiFileManager.ts | 26 +- src/lib/mtproto/mtproto.service.ts | 9 +- src/lib/mtproto/mtproto.worker.ts | 1 + src/lib/mtproto/mtprotoworker.ts | 5 +- src/lib/mtproto/passwordManager.ts | 2 +- src/pages/pagePassword.ts | 2 +- src/pages/pageSignQR.ts | 51 +- src/scripts/format_jsons.js | 10 +- src/scripts/format_schema.js | 4 +- src/scripts/generate_mtproto_types.js | 241 + src/scripts/{ => in}/countries.dat | 0 src/scripts/{ => in}/countries_pretty.json | 0 src/scripts/{ => in}/emoji_pretty.json | 0 src/scripts/{ => in}/schema.json | 0 src/scripts/in/schema_additional_params.json | 44 + src/scripts/{ => out}/countries.json | 0 src/scripts/{ => out}/emoji.json | 0 .../{schema_pretty.json => out/schema.json} | 0 src/tests/srp.test.ts | 7 +- src/types.d.ts | 141 +- tsconfig.json | 1 + 55 files changed, 11549 insertions(+), 853 deletions(-) create mode 100644 src/layer.d.ts create mode 100644 src/scripts/generate_mtproto_types.js rename src/scripts/{ => in}/countries.dat (100%) rename src/scripts/{ => in}/countries_pretty.json (100%) rename src/scripts/{ => in}/emoji_pretty.json (100%) rename src/scripts/{ => in}/schema.json (100%) create mode 100644 src/scripts/in/schema_additional_params.json rename src/scripts/{ => out}/countries.json (100%) rename src/scripts/{ => out}/emoji.json (100%) rename src/scripts/{schema_pretty.json => out/schema.json} (100%) diff --git a/package.json b/package.json index a8cc544e..f2d88bd0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "start": "webpack-dev-server --config webpack.dev.js", + "start": "node --max-old-space-size=8192 node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.js", "start:production": "webpack-dev-server --config webpack.prod.js", "serve": "npm run build; node server.js", "build": "webpack --config webpack.prod.js", diff --git a/src/components/appMediaPlaybackController.ts b/src/components/appMediaPlaybackController.ts index 6a4302b8..088a0edd 100644 --- a/src/components/appMediaPlaybackController.ts +++ b/src/components/appMediaPlaybackController.ts @@ -1,7 +1,6 @@ -import { MTDocument } from "../types"; import { $rootScope } from "../lib/utils"; import appMessagesManager from "../lib/appManagers/appMessagesManager"; -import appDocsManager from "../lib/appManagers/appDocsManager"; +import appDocsManager, {MyDocument} from "../lib/appManagers/appDocsManager"; import { isSafari } from "../lib/config"; import { CancellablePromise, deferredPromise } from "../lib/polyfill"; @@ -34,7 +33,7 @@ class AppMediaPlaybackController { document.body.append(this.container); } - public addMedia(doc: MTDocument, mid: number, autoload = true): HTMLMediaElement { + public addMedia(doc: MyDocument, mid: number, autoload = true): HTMLMediaElement { if(this.media[mid]) return this.media[mid]; const media = document.createElement(doc.type == 'round' ? 'video' : 'audio'); @@ -93,7 +92,7 @@ class AppMediaPlaybackController { } // если что - загрузит voice или round заранее, так правильнее - const downloadPromise: Promise = !doc.supportsStreaming ? appDocsManager.downloadDocNew(doc.id) : Promise.resolve(); + const downloadPromise: Promise = !doc.supportsStreaming ? appDocsManager.downloadDocNew(doc) : Promise.resolve(); Promise.all([deferred, downloadPromise]).then(() => { //media.autoplay = true; //console.log('will set media url:', media, doc, doc.type, doc.url); diff --git a/src/components/audio.ts b/src/components/audio.ts index 522c40f3..22189e99 100644 --- a/src/components/audio.ts +++ b/src/components/audio.ts @@ -1,13 +1,12 @@ -import appDocsManager from "../lib/appManagers/appDocsManager"; +import appDocsManager, {MyDocument} from "../lib/appManagers/appDocsManager"; import { RichTextProcessor } from "../lib/richtextprocessor"; import { formatDate } from "./wrappers"; import ProgressivePreloader from "./preloader"; import { MediaProgressLine } from "../lib/mediaPlayer"; import appMediaPlaybackController from "./appMediaPlaybackController"; -import { MTDocument } from "../types"; +import { DocumentAttribute } from "../layer"; import { mediaSizes, isSafari } from "../lib/config"; import { Download } from "../lib/appManagers/appDownloadManager"; -import { deferredPromise, CancellablePromise } from "../lib/polyfill"; // https://github.com/LonamiWebs/Telethon/blob/4393ec0b83d511b6a20d8a20334138730f084375/telethon/utils.py#L1285 export function decodeWaveform(waveform: Uint8Array | number[]) { @@ -43,7 +42,7 @@ export function decodeWaveform(waveform: Uint8Array | number[]) { return result; } -function wrapVoiceMessage(doc: MTDocument, audioEl: AudioElement) { +function wrapVoiceMessage(doc: MyDocument, audioEl: AudioElement) { audioEl.classList.add('is-voice'); const barWidth = 2; @@ -62,7 +61,7 @@ function wrapVoiceMessage(doc: MTDocument, audioEl: AudioElement) { timeDiv.classList.add('audio-time'); audioEl.append(svg, timeDiv); - let waveform = doc.attributes[0].waveform || []; + let waveform = (doc.attributes.find(attribute => attribute._ == 'documentAttributeAudio') as DocumentAttribute.documentAttributeAudio).waveform || []; waveform = decodeWaveform(waveform.slice()); //console.log('decoded waveform:', waveform); @@ -209,7 +208,7 @@ function wrapVoiceMessage(doc: MTDocument, audioEl: AudioElement) { return onLoad; } -function wrapAudio(doc: MTDocument, audioEl: AudioElement) { +function wrapAudio(doc: MyDocument, audioEl: AudioElement) { const withTime = !!+audioEl.getAttribute('with-time'); const title = doc.audioTitle || doc.file_name; @@ -368,7 +367,7 @@ export default class AudioElement extends HTMLElement { preloader = new ProgressivePreloader(null, true); } - download = appDocsManager.downloadDocNew(doc.id); + download = appDocsManager.downloadDocNew(doc); preloader.attach(downloadDiv, true, download); download.then(() => { diff --git a/src/components/emoticonsDropdown/tabs/gifs.ts b/src/components/emoticonsDropdown/tabs/gifs.ts index 742ee971..b898cc5d 100644 --- a/src/components/emoticonsDropdown/tabs/gifs.ts +++ b/src/components/emoticonsDropdown/tabs/gifs.ts @@ -3,8 +3,7 @@ import GifsMasonry from "../../gifsMasonry"; import Scrollable from "../../scrollable_new"; import { putPreloader } from "../../misc"; import apiManager from "../../../lib/mtproto/mtprotoworker"; -import { MTDocument } from "../../../types"; -import appDocsManager from "../../../lib/appManagers/appDocsManager"; +import appDocsManager, {MyDocument} from "../../../lib/appManagers/appDocsManager"; export default class GifsTab implements EmoticonsTab { public content: HTMLElement; @@ -18,21 +17,20 @@ export default class GifsTab implements EmoticonsTab { const scroll = new Scrollable(this.content, 'y', 'GIFS', null); const preloader = putPreloader(this.content, true); - apiManager.invokeApi('messages.getSavedGifs', {hash: 0}).then((_res) => { - let res = _res as { - _: 'messages.savedGifs', - gifs: MTDocument[], - hash: number - }; + apiManager.invokeApi('messages.getSavedGifs', {hash: 0}).then((res) => { //console.log('getSavedGifs res:', res); + if(res._ == 'messages.savedGifs') { + res.gifs.forEach((doc, idx) => { + res.gifs[idx] = doc = appDocsManager.saveDoc(doc); + //if(doc._ == 'documentEmpty') return; + masonry.add(doc as MyDocument, EMOTICONSSTICKERGROUP, EmoticonsDropdown.lazyLoadQueue); + }); + } + //let line: MTDocument[] = []; preloader.remove(); - res.gifs.forEach((doc, idx) => { - res.gifs[idx] = appDocsManager.saveDoc(doc); - masonry.add(res.gifs[idx], EMOTICONSSTICKERGROUP, EmoticonsDropdown.lazyLoadQueue); - }); }); this.init = null; diff --git a/src/components/emoticonsDropdown/tabs/stickers.ts b/src/components/emoticonsDropdown/tabs/stickers.ts index e2aeeec1..d8c67a1c 100644 --- a/src/components/emoticonsDropdown/tabs/stickers.ts +++ b/src/components/emoticonsDropdown/tabs/stickers.ts @@ -1,8 +1,8 @@ import emoticonsDropdown, { EmoticonsTab, EMOTICONSSTICKERGROUP, EmoticonsDropdown } from ".."; -import { MTDocument } from "../../../types"; +import { StickerSet } from "../../../layer"; import Scrollable from "../../scrollable_new"; import { wrapSticker } from "../../wrappers"; -import appStickersManager, { MTStickerSet, MTStickerSetFull } from "../../../lib/appManagers/appStickersManager"; +import appStickersManager from "../../../lib/appManagers/appStickersManager"; import appDownloadManager from "../../../lib/appManagers/appDownloadManager"; import { readBlobAsText } from "../../../helpers/blob"; import lottieLoader from "../../../lib/lottieLoader"; @@ -11,7 +11,7 @@ import { RichTextProcessor } from "../../../lib/richtextprocessor"; import { $rootScope } from "../../../lib/utils"; import apiManager from "../../../lib/mtproto/mtprotoworker"; import StickyIntersector from "../../stickyIntersector"; -import appDocsManager from "../../../lib/appManagers/appDocsManager"; +import appDocsManager, {MyDocument} from "../../../lib/appManagers/appDocsManager"; import animationIntersector from "../../animationIntersector"; export default class StickersTab implements EmoticonsTab { @@ -23,7 +23,7 @@ export default class StickersTab implements EmoticonsTab { }} = {}; private recentDiv: HTMLElement; - private recentStickers: MTDocument[] = []; + private recentStickers: MyDocument[] = []; private scroll: Scrollable; @@ -38,7 +38,7 @@ export default class StickersTab implements EmoticonsTab { private animatedDivs: Set = new Set(); private animatedIntersector: IntersectionObserver; - categoryPush(categoryDiv: HTMLElement, categoryTitle: string, promise: Promise, prepend?: boolean) { + categoryPush(categoryDiv: HTMLElement, categoryTitle: string, promise: Promise, prepend?: boolean) { //if((docs.length % 5) != 0) categoryDiv.classList.add('not-full'); const itemsDiv = document.createElement('div'); @@ -56,6 +56,7 @@ export default class StickersTab implements EmoticonsTab { promise.then(documents => { documents.forEach(doc => { + //if(doc._ == 'documentEmpty') return; itemsDiv.append(this.renderSticker(doc)); }); @@ -76,7 +77,7 @@ export default class StickersTab implements EmoticonsTab { }); } - renderSticker(doc: MTDocument, div?: HTMLDivElement) { + renderSticker(doc: MyDocument, div?: HTMLDivElement) { if(!div) { div = document.createElement('div'); @@ -101,7 +102,7 @@ export default class StickersTab implements EmoticonsTab { return div; } - async renderStickerSet(set: MTStickerSet, prepend = false) { + async renderStickerSet(set: StickerSet.stickerSet, prepend = false) { const categoryDiv = document.createElement('div'); categoryDiv.classList.add('sticker-category'); @@ -122,7 +123,7 @@ export default class StickersTab implements EmoticonsTab { //stickersScroll.append(categoryDiv); const promise = appStickersManager.getStickerSet(set); - this.categoryPush(categoryDiv, RichTextProcessor.wrapEmojiText(set.title), promise.then(stickerSet => stickerSet.documents), prepend); + this.categoryPush(categoryDiv, RichTextProcessor.wrapEmojiText(set.title), promise.then(stickerSet => stickerSet.documents as MyDocument[]), prepend); const stickerSet = await promise; //console.log('got stickerSet', stickerSet, li); @@ -153,7 +154,7 @@ export default class StickersTab implements EmoticonsTab { }); }); } - } else { // as thumb will be used first sticker + } else if(stickerSet.documents[0]._ != 'documentEmpty') { // as thumb will be used first sticker wrapSticker({ doc: stickerSet.documents[0], div: li as any, @@ -196,7 +197,7 @@ export default class StickersTab implements EmoticonsTab { }); */ $rootScope.$on('stickers_installed', (e: CustomEvent) => { - const set: MTStickerSet = e.detail; + const set: StickerSet.stickerSet = e.detail; if(!this.stickerSets[set.id] && this.mounted) { this.renderStickerSet(set, true); @@ -204,7 +205,7 @@ export default class StickersTab implements EmoticonsTab { }); $rootScope.$on('stickers_deleted', (e: CustomEvent) => { - const set: MTStickerSet = e.detail; + const set: StickerSet.stickerSet = e.detail; if(this.stickerSets[set.id] && this.mounted) { const elements = this.stickerSets[set.id]; @@ -225,7 +226,7 @@ export default class StickersTab implements EmoticonsTab { Promise.all([ appStickersManager.getRecentStickers().then(stickers => { - this.recentStickers = stickers.stickers.slice(0, 20); + this.recentStickers = stickers.stickers.slice(0, 20) as MyDocument[]; //stickersScroll.prepend(categoryDiv); @@ -242,7 +243,7 @@ export default class StickersTab implements EmoticonsTab { let stickers: { _: 'messages.allStickers', hash: number, - sets: Array + sets: Array } = res as any; preloader.remove(); @@ -353,7 +354,7 @@ export default class StickersTab implements EmoticonsTab { this.init = null; } - pushRecentSticker(doc: MTDocument) { + pushRecentSticker(doc: MyDocument) { if(!this.recentDiv.parentElement) { return; } diff --git a/src/components/gifsMasonry.ts b/src/components/gifsMasonry.ts index 85223311..5725ffad 100644 --- a/src/components/gifsMasonry.ts +++ b/src/components/gifsMasonry.ts @@ -1,6 +1,5 @@ -import { MTDocument } from "../types"; import { calcImageInBox, findUpClassName } from "../lib/utils"; -import appDocsManager from "../lib/appManagers/appDocsManager"; +import appDocsManager, {MyDocument} from "../lib/appManagers/appDocsManager"; import { wrapVideo } from "./wrappers"; import { renderImageFromUrl } from "./misc"; import LazyLoadQueue from "./lazyLoadQueue"; @@ -14,7 +13,7 @@ export default class GifsMasonry { } - public add(doc: MTDocument, group: string, lazyLoadQueue?: LazyLoadQueue) { + public add(doc: MyDocument, group: string, lazyLoadQueue?: LazyLoadQueue) { let gifWidth = doc.w; let gifHeight = doc.h; if(gifHeight < height) { diff --git a/src/components/popupAvatar.ts b/src/components/popupAvatar.ts index 3c56934b..5c594551 100644 --- a/src/components/popupAvatar.ts +++ b/src/components/popupAvatar.ts @@ -15,7 +15,7 @@ export class PopupAvatar { removeHandlers: () => {} }; - private onCrop: (upload: () => Promise) => void; + private onCrop: (upload: () => ReturnType) => void; constructor() { this.container.style.display = ''; // need for no blink @@ -81,7 +81,7 @@ export class PopupAvatar { }); } - public open(postCanvas: HTMLCanvasElement, onCrop: (upload: () => Promise) => void) { + public open(postCanvas: HTMLCanvasElement, onCrop: PopupAvatar['onCrop']) { this.canvas = postCanvas; this.onCrop = onCrop; diff --git a/src/components/popupStickers.ts b/src/components/popupStickers.ts index 4cb60027..36a4d812 100644 --- a/src/components/popupStickers.ts +++ b/src/components/popupStickers.ts @@ -1,5 +1,5 @@ import { PopupElement } from "./popup"; -import appStickersManager, { MTStickerSet } from "../lib/appManagers/appStickersManager"; +import appStickersManager from "../lib/appManagers/appStickersManager"; import { RichTextProcessor } from "../lib/richtextprocessor"; import Scrollable from "./scrollable_new"; import { wrapSticker } from "./wrappers"; @@ -8,13 +8,14 @@ import { putPreloader } from "./misc"; import animationIntersector from "./animationIntersector"; import { findUpClassName } from "../lib/utils"; import appImManager from "../lib/appManagers/appImManager"; +import { StickerSet } from "../layer"; export default class PopupStickers extends PopupElement { private stickersFooter: HTMLElement; private stickersDiv: HTMLElement; private h6: HTMLElement; - private set: MTStickerSet; + private set: StickerSet.stickerSet; constructor(private stickerSetInput: { //_: 'inputStickerSetID', @@ -118,6 +119,10 @@ export default class PopupStickers extends PopupElement { this.stickersDiv.innerHTML = ''; for(let doc of set.documents) { + if(doc._ == 'documentEmpty') { + continue; + } + const div = document.createElement('div'); div.classList.add('sticker-set-sticker'); diff --git a/src/components/sidebarLeft/chatFolders.ts b/src/components/sidebarLeft/chatFolders.ts index 7949e948..d2fa02da 100644 --- a/src/components/sidebarLeft/chatFolders.ts +++ b/src/components/sidebarLeft/chatFolders.ts @@ -1,19 +1,14 @@ import { SliderTab } from "../slider"; import lottieLoader, { RLottiePlayer } from "../../lib/lottieLoader"; import apiManager from "../../lib/mtproto/mtprotoworker"; -import appMessagesManager, { DialogFilter } from "../../lib/appManagers/appMessagesManager"; +import appMessagesManager, { MyDialogFilter } from "../../lib/appManagers/appMessagesManager"; import { RichTextProcessor } from "../../lib/richtextprocessor"; import appPeersManager from "../../lib/appManagers/appPeersManager"; import { $rootScope, cancelEvent } from "../../lib/utils"; import appSidebarLeft from "../../lib/appManagers/appSidebarLeft"; import { ripple } from "../ripple"; import { toast } from "../toast"; - -type DialogFilterSuggested = { - _: 'dialogFilterSuggested', - filter: DialogFilter, - description: string -}; +import { DialogFilterSuggested, DialogFilter } from "../../layer"; export default class AppChatFoldersTab implements SliderTab { public container: HTMLElement; @@ -25,8 +20,8 @@ export default class AppChatFoldersTab implements SliderTab { private filtersRendered: {[filterID: number]: HTMLElement} = {}; - private renderFolder(dialogFilter: DialogFilterSuggested | DialogFilter, container?: HTMLElement, div: HTMLElement = document.createElement('div')) { - let filter: DialogFilter; + private renderFolder(dialogFilter: DialogFilterSuggested | DialogFilter | MyDialogFilter, container?: HTMLElement, div: HTMLElement = document.createElement('div')) { + let filter: DialogFilter | MyDialogFilter; let description = ''; let d: string[] = []; if(dialogFilter._ == 'dialogFilterSuggested') { @@ -157,7 +152,7 @@ export default class AppChatFoldersTab implements SliderTab { this.suggestedContainer.style.display = suggestedFilters.length ? '' : 'none'; Array.from(this.suggestedContainer.children).slice(1).forEach(el => el.remove()); - (suggestedFilters as DialogFilterSuggested[]).forEach(filter => { + suggestedFilters.forEach(filter => { const div = this.renderFolder(filter); const button = document.createElement('button'); button.classList.add('btn-primary'); @@ -175,7 +170,7 @@ export default class AppChatFoldersTab implements SliderTab { button.setAttribute('disabled', 'true'); - appMessagesManager.filtersStorage.createDialogFilter(filter.filter).then(bool => { + appMessagesManager.filtersStorage.createDialogFilter(filter.filter as any).then(bool => { if(bool) { div.remove(); } diff --git a/src/components/sidebarLeft/editFolder.ts b/src/components/sidebarLeft/editFolder.ts index 6cacd02f..0784f494 100644 --- a/src/components/sidebarLeft/editFolder.ts +++ b/src/components/sidebarLeft/editFolder.ts @@ -1,7 +1,7 @@ import { SliderTab } from "../slider"; import appSidebarLeft, { AppSidebarLeft } from "../../lib/appManagers/appSidebarLeft"; import lottieLoader, { RLottiePlayer } from "../../lib/lottieLoader"; -import appMessagesManager, { DialogFilter } from "../../lib/appManagers/appMessagesManager"; +import appMessagesManager, { MyDialogFilter as DialogFilter } from "../../lib/appManagers/appMessagesManager"; import { parseMenuButtonsTo } from "../misc"; import appDialogsManager from "../../lib/appManagers/appDialogsManager"; import { copy, deepEqual } from "../../lib/utils"; diff --git a/src/components/sidebarLeft/editProfile.ts b/src/components/sidebarLeft/editProfile.ts index 88cb9c12..173291aa 100644 --- a/src/components/sidebarLeft/editProfile.ts +++ b/src/components/sidebarLeft/editProfile.ts @@ -6,6 +6,7 @@ import appSidebarLeft from "../../lib/appManagers/appSidebarLeft"; import Scrollable from "../scrollable_new"; import appUsersManager from "../../lib/appManagers/appUsersManager"; import { $rootScope } from "../../lib/utils"; +import { InputFile } from "../../layer"; // TODO: аватарка не поменяется в этой вкладке после изменения почему-то (если поставить в другом клиенте, и потом тут проверить, для этого ещё вышел в чатлист) @@ -14,7 +15,7 @@ export default class AppEditProfileTab implements SliderTab { private scrollWrapper = this.container.querySelector('.scroll-wrapper') as HTMLDivElement; private nextBtn = this.container.querySelector('.btn-corner') as HTMLButtonElement; private canvas = this.container.querySelector('.avatar-edit-canvas') as HTMLCanvasElement; - private uploadAvatar: () => Promise = null; + private uploadAvatar: () => Promise = null; private firstNameInput = this.container.querySelector('.firstname') as HTMLInputElement; private lastNameInput = this.container.querySelector('.lastname') as HTMLInputElement; diff --git a/src/components/sidebarLeft/includedChats.ts b/src/components/sidebarLeft/includedChats.ts index 5ad0d3c0..e01407da 100644 --- a/src/components/sidebarLeft/includedChats.ts +++ b/src/components/sidebarLeft/includedChats.ts @@ -4,8 +4,8 @@ import appSidebarLeft, { AppSidebarLeft } from "../../lib/appManagers/appSidebar import appDialogsManager from "../../lib/appManagers/appDialogsManager"; import appPeersManager from "../../lib/appManagers/appPeersManager"; import appUsersManager from "../../lib/appManagers/appUsersManager"; -import { $rootScope, copy, deepEqual } from "../../lib/utils"; -import { DialogFilter } from "../../lib/appManagers/appMessagesManager"; +import { $rootScope, copy } from "../../lib/utils"; +import { MyDialogFilter as DialogFilter } from "../../lib/appManagers/appMessagesManager"; export default class AppIncludedChatsTab implements SliderTab { public container: HTMLElement; diff --git a/src/components/sidebarRight/gifs.ts b/src/components/sidebarRight/gifs.ts index 005646fa..f8ef7d4a 100644 --- a/src/components/sidebarRight/gifs.ts +++ b/src/components/sidebarRight/gifs.ts @@ -9,6 +9,7 @@ import appInlineBotsManager, { AppInlineBotsManager } from "../../lib/appManager import GifsMasonry from "../gifsMasonry"; import { findUpClassName } from "../../lib/utils"; import appImManager from "../../lib/appManagers/appImManager"; +import type { MyDocument } from "../../lib/appManagers/appDocsManager"; const ANIMATIONGROUP = 'GIFS-SEARCH'; @@ -116,7 +117,7 @@ export default class AppGifsTab implements SliderTab { if(results.length) { results.forEach((result) => { if(result._ === 'botInlineMediaResult' && result.document) { - this.masonry.add(result.document, ANIMATIONGROUP, this.lazyLoadQueue); + this.masonry.add(result.document as MyDocument, ANIMATIONGROUP, this.lazyLoadQueue); } }); } else { diff --git a/src/components/sidebarRight/stickers.ts b/src/components/sidebarRight/stickers.ts index 8b1c6a01..097ba438 100644 --- a/src/components/sidebarRight/stickers.ts +++ b/src/components/sidebarRight/stickers.ts @@ -4,12 +4,13 @@ import Scrollable from "../scrollable_new"; import LazyLoadQueue from "../lazyLoadQueue"; import { findUpClassName } from "../../lib/utils"; import appImManager from "../../lib/appManagers/appImManager"; -import appStickersManager, { MTStickerSet, MTStickerSetCovered, MTStickerSetMultiCovered } from "../../lib/appManagers/appStickersManager"; +import appStickersManager from "../../lib/appManagers/appStickersManager"; import PopupStickers from "../popupStickers"; import animationIntersector from "../animationIntersector"; import { RichTextProcessor } from "../../lib/richtextprocessor"; import { wrapSticker } from "../wrappers"; import appSidebarRight, { AppSidebarRight } from "../../lib/appManagers/appSidebarRight"; +import { StickerSet, StickerSetCovered, Document } from "../../layer"; export default class AppStickersTab implements SliderTab { private container = document.getElementById('stickers-container') as HTMLDivElement; @@ -80,7 +81,7 @@ export default class AppStickersTab implements SliderTab { animationIntersector.checkAnimations(undefined, 'STICKERS-SEARCH'); } - public renderSet(set: MTStickerSet) { + public renderSet(set: StickerSet.stickerSet) { //console.log('renderSet:', set); const div = document.createElement('div'); div.classList.add('sticker-set'); @@ -124,8 +125,13 @@ export default class AppStickersTab implements SliderTab { for(let i = 0; i < count; ++i) { const div = stickersDiv.children[i] as HTMLDivElement; + const doc = set.documents[i]; + if(doc._ == 'documentEmpty') { + continue; + } + wrapSticker({ - doc: set.documents[i], + doc, div, lazyLoadQueue: this.lazyLoadQueue, group: 'STICKERS-SEARCH', @@ -194,7 +200,7 @@ export default class AppStickersTab implements SliderTab { }); } - private filterRendered(query: string, coveredSets: (MTStickerSetCovered | MTStickerSetMultiCovered)[]) { + private filterRendered(query: string, coveredSets: StickerSetCovered[]) { coveredSets = coveredSets.slice(); const children = Array.from(this.setsDiv.children) as HTMLElement[]; diff --git a/src/components/wrappers.ts b/src/components/wrappers.ts index af761539..06831f9c 100644 --- a/src/components/wrappers.ts +++ b/src/components/wrappers.ts @@ -1,6 +1,6 @@ -import appPhotosManager, { MTPhoto } from '../lib/appManagers/appPhotosManager'; +import appPhotosManager, {MyPhoto} from '../lib/appManagers/appPhotosManager'; import LottieLoader from '../lib/lottieLoader'; -import appDocsManager from "../lib/appManagers/appDocsManager"; +import appDocsManager, { MyDocument } from "../lib/appManagers/appDocsManager"; import { formatBytes, getEmojiToneIndex, isInDOM } from "../lib/utils"; import ProgressivePreloader from './preloader'; import LazyLoadQueue from './lazyLoadQueue'; @@ -11,16 +11,16 @@ import appMessagesManager from '../lib/appManagers/appMessagesManager'; import { Layouter, RectPart } from './groupedLayout'; import PollElement from './poll'; import { mediaSizes, isSafari } from '../lib/config'; -import { MTDocument, MTPhotoSize } from '../types'; import animationIntersector from './animationIntersector'; import AudioElement from './audio'; import { DownloadBlob } from '../lib/appManagers/appDownloadManager'; import webpWorkerController from '../lib/webp/webpWorkerController'; import { readBlobAsText } from '../helpers/blob'; import appMediaPlaybackController from './appMediaPlaybackController'; +import { PhotoSize } from '../layer'; export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTail, isOut, middleware, lazyLoadQueue, noInfo, group}: { - doc: MTDocument, + doc: MyDocument, container?: HTMLDivElement, message?: any, boxWidth?: number, @@ -140,7 +140,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai appPhotosManager.setAttachmentSize(doc, container, boxWidth, boxHeight, false, true); } - if(doc.thumbs && doc.thumbs[0]?.bytes) { + if(doc.thumbs?.length && 'bytes' in doc.thumbs[0]) { appPhotosManager.setAttachmentPreview(doc.thumbs[0].bytes, container, false); } @@ -281,7 +281,7 @@ export const formatDate = (timestamp: number, monthShort = false, withYear = tru return str + ' at ' + date.getHours() + ':' + ('0' + date.getMinutes()).slice(-2); }; -export function wrapDocument(doc: MTDocument, withTime = false, uploading = false, mid?: number): HTMLElement { +export function wrapDocument(doc: MyDocument, withTime = false, uploading = false, mid?: number): HTMLElement { if(doc.type == 'audio' || doc.type == 'voice') { return wrapAudio(doc, withTime, mid); } @@ -351,7 +351,7 @@ export function wrapDocument(doc: MTDocument, withTime = false, uploading = fals return docDiv; } -export function wrapAudio(doc: MTDocument, withTime = false, mid?: number): HTMLElement { +export function wrapAudio(doc: MyDocument, withTime = false, mid?: number): HTMLElement { let elem = new AudioElement(); elem.setAttribute('doc-id', doc.id); elem.setAttribute('with-time', '' + +withTime); @@ -359,7 +359,7 @@ export function wrapAudio(doc: MTDocument, withTime = false, mid?: number): HTML return elem; } -function wrapMediaWithTail(photo: MTPhoto | MTDocument, message: {mid: number, message: string}, container: HTMLDivElement, boxWidth: number, boxHeight: number, isOut: boolean) { +function wrapMediaWithTail(photo: MyPhoto | MyDocument, message: {mid: number, message: string}, container: HTMLDivElement, boxWidth: number, boxHeight: number, isOut: boolean) { const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.classList.add('bubble__media-container', isOut ? 'is-out' : 'is-in'); @@ -414,7 +414,7 @@ function wrapMediaWithTail(photo: MTPhoto | MTDocument, message: {mid: number, m return img; } -export function wrapPhoto(photo: MTPhoto | MTDocument, message: any, container: HTMLDivElement, boxWidth = mediaSizes.active.regular.width, boxHeight = mediaSizes.active.regular.height, withTail: boolean, isOut: boolean, lazyLoadQueue: LazyLoadQueue, middleware: () => boolean, size: MTPhotoSize = null) { +export function wrapPhoto(photo: MyPhoto | MyDocument, message: any, container: HTMLDivElement, boxWidth = mediaSizes.active.regular.width, boxHeight = mediaSizes.active.regular.height, withTail: boolean, isOut: boolean, lazyLoadQueue: LazyLoadQueue, middleware: () => boolean, size: PhotoSize = null) { let image: HTMLImageElement; if(withTail) { image = wrapMediaWithTail(photo, message, container, boxWidth, boxHeight, isOut); @@ -424,8 +424,8 @@ export function wrapPhoto(photo: MTPhoto | MTDocument, message: any, container: } if(photo._ == 'document' || !photo.downloaded) { - const thumbs = (photo as MTPhoto).sizes || (photo as MTDocument).thumbs; - if(thumbs && thumbs[0]?.bytes) { + const thumbs = (photo as MyPhoto).sizes || (photo as MyDocument).thumbs; + if(thumbs?.length && 'bytes' in thumbs[0]) { appPhotosManager.setAttachmentPreview(thumbs[0].bytes, container, false); } } @@ -465,7 +465,7 @@ export function wrapPhoto(photo: MTPhoto | MTDocument, message: any, container: } export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, onlyThumb, emoji, width, height, withThumb, loop}: { - doc: MTDocument, + doc: MyDocument, div: HTMLDivElement, middleware?: () => boolean, lazyLoadQueue?: LazyLoadQueue, @@ -504,7 +504,7 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o const toneIndex = emoji ? getEmojiToneIndex(emoji) : -1; - if(doc.thumbs?.length && !div.firstElementChild && (!doc.downloaded || stickerType == 2 || onlyThumb) && toneIndex <= 0) { + if(doc.thumbs?.length && !div.firstElementChild && (!doc.downloaded || stickerType == 2 || onlyThumb) && toneIndex <= 0/* && doc.thumbs[0]._ != 'photoSizeEmpty' */) { const thumb = doc.thumbs[0]; //console.log('wrap sticker', thumb, div); @@ -515,16 +515,19 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o div.append(img); } }; - - if(thumb.bytes || thumb.url) { + + if('url' in thumb) { + img = new Image(); + renderImageFromUrl(img, thumb.url, afterRender); + } else if('bytes' in thumb) { img = new Image(); - if((!isSafari || doc.stickerThumbConverted || thumb.url)/* && false */) { + if((!isSafari || doc.pFlags.stickerThumbConverted || thumb.url)/* && false */) { renderImageFromUrl(img, appPhotosManager.getPreviewURLFromThumb(thumb, true), afterRender); } else { - webpWorkerController.convert(doc.id, thumb.bytes).then(bytes => { + webpWorkerController.convert(doc.id, thumb.bytes as Uint8Array).then(bytes => { thumb.bytes = bytes; - doc.stickerThumbConverted = true; + doc.pFlags.stickerThumbConverted = true; if(middleware && !middleware()) return; @@ -578,7 +581,7 @@ export function wrapSticker({doc, div, middleware, lazyLoadQueue, group, play, o //appDocsManager.downloadDocNew(doc.id).promise.then(res => res.json()).then(async(json) => { //fetch(doc.url).then(res => res.json()).then(async(json) => { - await appDocsManager.downloadDocNew(doc.id) + await appDocsManager.downloadDocNew(doc) .then(readBlobAsText) .then(JSON.parse) .then(async(json) => { @@ -718,7 +721,7 @@ export function wrapAlbum({groupID, attachmentDiv, middleware, uploading, lazyLo uploading?: boolean, isOut: boolean }) { - const items: {size: MTPhotoSize, media: any, message: any}[] = []; + const items: {size: PhotoSize.photoSize, media: any, message: any}[] = []; // !higher msgID will be the FIRST in album const storage = Object.keys(appMessagesManager.groupedMessagesStorage[groupID]).map(id => +id).sort((a, b) => a - b); diff --git a/src/layer.d.ts b/src/layer.d.ts new file mode 100644 index 00000000..c184f8ee --- /dev/null +++ b/src/layer.d.ts @@ -0,0 +1,10777 @@ +/** + * @link https://core.telegram.org/type/Error + */ +export type Error = Error.error; + +export namespace Error { + export type error = { + _: 'error', + code: number, + text: string + }; +} + +/** + * @link https://core.telegram.org/type/InputPeer + */ +export type InputPeer = InputPeer.inputPeerEmpty | InputPeer.inputPeerSelf | InputPeer.inputPeerChat | InputPeer.inputPeerUser | InputPeer.inputPeerChannel | InputPeer.inputPeerUserFromMessage | InputPeer.inputPeerChannelFromMessage; + +export namespace InputPeer { + export type inputPeerEmpty = { + _: 'inputPeerEmpty' + }; + + export type inputPeerSelf = { + _: 'inputPeerSelf' + }; + + export type inputPeerChat = { + _: 'inputPeerChat', + chat_id: number + }; + + export type inputPeerUser = { + _: 'inputPeerUser', + user_id: number, + access_hash: string + }; + + export type inputPeerChannel = { + _: 'inputPeerChannel', + channel_id: number, + access_hash: string + }; + + export type inputPeerUserFromMessage = { + _: 'inputPeerUserFromMessage', + peer: InputPeer, + msg_id: number, + user_id: number + }; + + export type inputPeerChannelFromMessage = { + _: 'inputPeerChannelFromMessage', + peer: InputPeer, + msg_id: number, + channel_id: number + }; +} + +/** + * @link https://core.telegram.org/type/InputUser + */ +export type InputUser = InputUser.inputUserEmpty | InputUser.inputUserSelf | InputUser.inputUser | InputUser.inputUserFromMessage; + +export namespace InputUser { + export type inputUserEmpty = { + _: 'inputUserEmpty' + }; + + export type inputUserSelf = { + _: 'inputUserSelf' + }; + + export type inputUser = { + _: 'inputUser', + user_id: number, + access_hash: string + }; + + export type inputUserFromMessage = { + _: 'inputUserFromMessage', + peer: InputPeer, + msg_id: number, + user_id: number + }; +} + +/** + * @link https://core.telegram.org/type/InputContact + */ +export type InputContact = InputContact.inputPhoneContact; + +export namespace InputContact { + export type inputPhoneContact = { + _: 'inputPhoneContact', + client_id: string, + phone: string, + first_name: string, + last_name: string + }; +} + +/** + * @link https://core.telegram.org/type/InputFile + */ +export type InputFile = InputFile.inputFile | InputFile.inputFileBig; + +export namespace InputFile { + export type inputFile = { + _: 'inputFile', + id: string, + parts: number, + name: string, + md5_checksum: string + }; + + export type inputFileBig = { + _: 'inputFileBig', + id: string, + parts: number, + name: string + }; +} + +/** + * @link https://core.telegram.org/type/InputMedia + */ +export type InputMedia = InputMedia.inputMediaEmpty | InputMedia.inputMediaUploadedPhoto | InputMedia.inputMediaPhoto | InputMedia.inputMediaGeoPoint | InputMedia.inputMediaContact | InputMedia.inputMediaUploadedDocument | InputMedia.inputMediaDocument | InputMedia.inputMediaVenue | InputMedia.inputMediaGifExternal | InputMedia.inputMediaPhotoExternal | InputMedia.inputMediaDocumentExternal | InputMedia.inputMediaGame | InputMedia.inputMediaInvoice | InputMedia.inputMediaGeoLive | InputMedia.inputMediaPoll | InputMedia.inputMediaDice; + +export namespace InputMedia { + export type inputMediaEmpty = { + _: 'inputMediaEmpty' + }; + + export type inputMediaUploadedPhoto = { + _: 'inputMediaUploadedPhoto', + flags?: number, + file: InputFile, + stickers?: Array, + ttl_seconds?: number + }; + + export type inputMediaPhoto = { + _: 'inputMediaPhoto', + flags?: number, + id: InputPhoto, + ttl_seconds?: number + }; + + export type inputMediaGeoPoint = { + _: 'inputMediaGeoPoint', + geo_point: InputGeoPoint + }; + + export type inputMediaContact = { + _: 'inputMediaContact', + phone_number: string, + first_name: string, + last_name: string, + vcard: string + }; + + export type inputMediaUploadedDocument = { + _: 'inputMediaUploadedDocument', + flags?: number, + pFlags?: Partial<{ + nosound_video?: true, + }>, + file: InputFile, + thumb?: InputFile, + mime_type: string, + attributes: Array, + stickers?: Array, + ttl_seconds?: number + }; + + export type inputMediaDocument = { + _: 'inputMediaDocument', + flags?: number, + id: InputDocument, + ttl_seconds?: number + }; + + export type inputMediaVenue = { + _: 'inputMediaVenue', + geo_point: InputGeoPoint, + title: string, + address: string, + provider: string, + venue_id: string, + venue_type: string + }; + + export type inputMediaGifExternal = { + _: 'inputMediaGifExternal', + url: string, + q: string + }; + + export type inputMediaPhotoExternal = { + _: 'inputMediaPhotoExternal', + flags?: number, + url: string, + ttl_seconds?: number + }; + + export type inputMediaDocumentExternal = { + _: 'inputMediaDocumentExternal', + flags?: number, + url: string, + ttl_seconds?: number + }; + + export type inputMediaGame = { + _: 'inputMediaGame', + id: InputGame + }; + + export type inputMediaInvoice = { + _: 'inputMediaInvoice', + flags?: number, + title: string, + description: string, + photo?: InputWebDocument, + invoice: Invoice, + payload: Uint8Array | number[], + provider: string, + provider_data: DataJSON, + start_param: string + }; + + export type inputMediaGeoLive = { + _: 'inputMediaGeoLive', + flags?: number, + pFlags?: Partial<{ + stopped?: true, + }>, + geo_point: InputGeoPoint, + period?: number + }; + + export type inputMediaPoll = { + _: 'inputMediaPoll', + flags?: number, + poll: Poll, + correct_answers?: Array, + solution?: string, + solution_entities?: Array + }; + + export type inputMediaDice = { + _: 'inputMediaDice', + emoticon: string + }; +} + +/** + * @link https://core.telegram.org/type/InputChatPhoto + */ +export type InputChatPhoto = InputChatPhoto.inputChatPhotoEmpty | InputChatPhoto.inputChatUploadedPhoto | InputChatPhoto.inputChatPhoto; + +export namespace InputChatPhoto { + export type inputChatPhotoEmpty = { + _: 'inputChatPhotoEmpty' + }; + + export type inputChatUploadedPhoto = { + _: 'inputChatUploadedPhoto', + file: InputFile + }; + + export type inputChatPhoto = { + _: 'inputChatPhoto', + id: InputPhoto + }; +} + +/** + * @link https://core.telegram.org/type/InputGeoPoint + */ +export type InputGeoPoint = InputGeoPoint.inputGeoPointEmpty | InputGeoPoint.inputGeoPoint; + +export namespace InputGeoPoint { + export type inputGeoPointEmpty = { + _: 'inputGeoPointEmpty' + }; + + export type inputGeoPoint = { + _: 'inputGeoPoint', + lat: number, + long: number + }; +} + +/** + * @link https://core.telegram.org/type/InputPhoto + */ +export type InputPhoto = InputPhoto.inputPhotoEmpty | InputPhoto.inputPhoto; + +export namespace InputPhoto { + export type inputPhotoEmpty = { + _: 'inputPhotoEmpty' + }; + + export type inputPhoto = { + _: 'inputPhoto', + id: string, + access_hash: string, + file_reference: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/InputFileLocation + */ +export type InputFileLocation = InputFileLocation.inputFileLocation | InputFileLocation.inputEncryptedFileLocation | InputFileLocation.inputDocumentFileLocation | InputFileLocation.inputSecureFileLocation | InputFileLocation.inputTakeoutFileLocation | InputFileLocation.inputPhotoFileLocation | InputFileLocation.inputPhotoLegacyFileLocation | InputFileLocation.inputPeerPhotoFileLocation | InputFileLocation.inputStickerSetThumb; + +export namespace InputFileLocation { + export type inputFileLocation = { + _: 'inputFileLocation', + volume_id: string, + local_id: number, + secret: string, + file_reference: Uint8Array | number[] + }; + + export type inputEncryptedFileLocation = { + _: 'inputEncryptedFileLocation', + id: string, + access_hash: string + }; + + export type inputDocumentFileLocation = { + _: 'inputDocumentFileLocation', + id: string, + access_hash: string, + file_reference: Uint8Array | number[], + thumb_size: string + }; + + export type inputSecureFileLocation = { + _: 'inputSecureFileLocation', + id: string, + access_hash: string + }; + + export type inputTakeoutFileLocation = { + _: 'inputTakeoutFileLocation' + }; + + export type inputPhotoFileLocation = { + _: 'inputPhotoFileLocation', + id: string, + access_hash: string, + file_reference: Uint8Array | number[], + thumb_size: string + }; + + export type inputPhotoLegacyFileLocation = { + _: 'inputPhotoLegacyFileLocation', + id: string, + access_hash: string, + file_reference: Uint8Array | number[], + volume_id: string, + local_id: number, + secret: string + }; + + export type inputPeerPhotoFileLocation = { + _: 'inputPeerPhotoFileLocation', + flags?: number, + pFlags?: Partial<{ + big?: true, + }>, + peer: InputPeer, + volume_id: string, + local_id: number + }; + + export type inputStickerSetThumb = { + _: 'inputStickerSetThumb', + stickerset: InputStickerSet, + volume_id: string, + local_id: number + }; +} + +/** + * @link https://core.telegram.org/type/Peer + */ +export type Peer = Peer.peerUser | Peer.peerChat | Peer.peerChannel; + +export namespace Peer { + export type peerUser = { + _: 'peerUser', + user_id: number + }; + + export type peerChat = { + _: 'peerChat', + chat_id: number + }; + + export type peerChannel = { + _: 'peerChannel', + channel_id: number + }; +} + +/** + * @link https://core.telegram.org/type/storage.FileType + */ +export type StorageFileType = StorageFileType.storageFileUnknown | StorageFileType.storageFilePartial | StorageFileType.storageFileJpeg | StorageFileType.storageFileGif | StorageFileType.storageFilePng | StorageFileType.storageFilePdf | StorageFileType.storageFileMp3 | StorageFileType.storageFileMov | StorageFileType.storageFileMp4 | StorageFileType.storageFileWebp; + +export namespace StorageFileType { + export type storageFileUnknown = { + _: 'storage.fileUnknown' + }; + + export type storageFilePartial = { + _: 'storage.filePartial' + }; + + export type storageFileJpeg = { + _: 'storage.fileJpeg' + }; + + export type storageFileGif = { + _: 'storage.fileGif' + }; + + export type storageFilePng = { + _: 'storage.filePng' + }; + + export type storageFilePdf = { + _: 'storage.filePdf' + }; + + export type storageFileMp3 = { + _: 'storage.fileMp3' + }; + + export type storageFileMov = { + _: 'storage.fileMov' + }; + + export type storageFileMp4 = { + _: 'storage.fileMp4' + }; + + export type storageFileWebp = { + _: 'storage.fileWebp' + }; +} + +/** + * @link https://core.telegram.org/type/User + */ +export type User = User.userEmpty | User.user; + +export namespace User { + export type userEmpty = { + _: 'userEmpty', + id: number + }; + + export type user = { + _: 'user', + flags?: number, + pFlags?: Partial<{ + self?: true, + contact?: true, + mutual_contact?: true, + deleted?: true, + bot?: true, + bot_chat_history?: true, + bot_nochats?: true, + verified?: true, + restricted?: true, + min?: true, + bot_inline_geo?: true, + support?: true, + scam?: true, + }>, + id: number, + access_hash?: string, + first_name?: string, + last_name?: string, + username?: string, + phone?: string, + photo?: UserProfilePhoto, + status?: UserStatus, + bot_info_version?: number, + restriction_reason?: Array, + bot_inline_placeholder?: string, + lang_code?: string + }; +} + +/** + * @link https://core.telegram.org/type/UserProfilePhoto + */ +export type UserProfilePhoto = UserProfilePhoto.userProfilePhotoEmpty | UserProfilePhoto.userProfilePhoto; + +export namespace UserProfilePhoto { + export type userProfilePhotoEmpty = { + _: 'userProfilePhotoEmpty' + }; + + export type userProfilePhoto = { + _: 'userProfilePhoto', + photo_id: string, + photo_small: FileLocation, + photo_big: FileLocation, + dc_id: number + }; +} + +/** + * @link https://core.telegram.org/type/UserStatus + */ +export type UserStatus = UserStatus.userStatusEmpty | UserStatus.userStatusOnline | UserStatus.userStatusOffline | UserStatus.userStatusRecently | UserStatus.userStatusLastWeek | UserStatus.userStatusLastMonth; + +export namespace UserStatus { + export type userStatusEmpty = { + _: 'userStatusEmpty' + }; + + export type userStatusOnline = { + _: 'userStatusOnline', + expires: number + }; + + export type userStatusOffline = { + _: 'userStatusOffline', + was_online: number + }; + + export type userStatusRecently = { + _: 'userStatusRecently' + }; + + export type userStatusLastWeek = { + _: 'userStatusLastWeek' + }; + + export type userStatusLastMonth = { + _: 'userStatusLastMonth' + }; +} + +/** + * @link https://core.telegram.org/type/Chat + */ +export type Chat = Chat.chatEmpty | Chat.chat | Chat.chatForbidden | Chat.channel | Chat.channelForbidden; + +export namespace Chat { + export type chatEmpty = { + _: 'chatEmpty', + id: number + }; + + export type chat = { + _: 'chat', + flags?: number, + pFlags?: Partial<{ + creator?: true, + kicked?: true, + left?: true, + deactivated?: true, + }>, + id: number, + title: string, + photo: ChatPhoto, + participants_count: number, + date: number, + version: number, + migrated_to?: InputChannel, + admin_rights?: ChatAdminRights, + default_banned_rights?: ChatBannedRights + }; + + export type chatForbidden = { + _: 'chatForbidden', + id: number, + title: string + }; + + export type channel = { + _: 'channel', + flags?: number, + pFlags?: Partial<{ + creator?: true, + left?: true, + broadcast?: true, + verified?: true, + megagroup?: true, + restricted?: true, + signatures?: true, + min?: true, + scam?: true, + has_link?: true, + has_geo?: true, + slowmode_enabled?: true, + }>, + id: number, + access_hash?: string, + title: string, + username?: string, + photo: ChatPhoto, + date: number, + version: number, + restriction_reason?: Array, + admin_rights?: ChatAdminRights, + banned_rights?: ChatBannedRights, + default_banned_rights?: ChatBannedRights, + participants_count?: number + }; + + export type channelForbidden = { + _: 'channelForbidden', + flags?: number, + pFlags?: Partial<{ + broadcast?: true, + megagroup?: true, + }>, + id: number, + access_hash: string, + title: string, + until_date?: number + }; +} + +/** + * @link https://core.telegram.org/type/ChatFull + */ +export type ChatFull = ChatFull.chatFull | ChatFull.channelFull; + +export namespace ChatFull { + export type chatFull = { + _: 'chatFull', + flags?: number, + pFlags?: Partial<{ + can_set_username?: true, + has_scheduled?: true, + }>, + id: number, + about: string, + participants: ChatParticipants, + chat_photo?: Photo, + notify_settings: PeerNotifySettings, + exported_invite: ExportedChatInvite, + bot_info?: Array, + pinned_msg_id?: number, + folder_id?: number + }; + + export type channelFull = { + _: 'channelFull', + flags?: number, + pFlags?: Partial<{ + can_view_participants?: true, + can_set_username?: true, + can_set_stickers?: true, + hidden_prehistory?: true, + can_view_stats?: true, + can_set_location?: true, + has_scheduled?: true, + }>, + id: number, + about: string, + participants_count?: number, + admins_count?: number, + kicked_count?: number, + banned_count?: number, + online_count?: number, + read_inbox_max_id: number, + read_outbox_max_id: number, + unread_count: number, + chat_photo: Photo, + notify_settings: PeerNotifySettings, + exported_invite: ExportedChatInvite, + bot_info: Array, + migrated_from_chat_id?: number, + migrated_from_max_id?: number, + pinned_msg_id?: number, + stickerset?: StickerSet, + available_min_id?: number, + folder_id?: number, + linked_chat_id?: number, + location?: ChannelLocation, + slowmode_seconds?: number, + slowmode_next_send_date?: number, + stats_dc?: number, + pts: number + }; +} + +/** + * @link https://core.telegram.org/type/ChatParticipant + */ +export type ChatParticipant = ChatParticipant.chatParticipant | ChatParticipant.chatParticipantCreator | ChatParticipant.chatParticipantAdmin; + +export namespace ChatParticipant { + export type chatParticipant = { + _: 'chatParticipant', + user_id: number, + inviter_id: number, + date: number + }; + + export type chatParticipantCreator = { + _: 'chatParticipantCreator', + user_id: number + }; + + export type chatParticipantAdmin = { + _: 'chatParticipantAdmin', + user_id: number, + inviter_id: number, + date: number + }; +} + +/** + * @link https://core.telegram.org/type/ChatParticipants + */ +export type ChatParticipants = ChatParticipants.chatParticipantsForbidden | ChatParticipants.chatParticipants; + +export namespace ChatParticipants { + export type chatParticipantsForbidden = { + _: 'chatParticipantsForbidden', + flags?: number, + chat_id: number, + self_participant?: ChatParticipant + }; + + export type chatParticipants = { + _: 'chatParticipants', + chat_id: number, + participants: Array, + version: number + }; +} + +/** + * @link https://core.telegram.org/type/ChatPhoto + */ +export type ChatPhoto = ChatPhoto.chatPhotoEmpty | ChatPhoto.chatPhoto; + +export namespace ChatPhoto { + export type chatPhotoEmpty = { + _: 'chatPhotoEmpty' + }; + + export type chatPhoto = { + _: 'chatPhoto', + photo_small: FileLocation, + photo_big: FileLocation, + dc_id: number + }; +} + +/** + * @link https://core.telegram.org/type/Message + */ +export type Message = Message.messageEmpty | Message.message | Message.messageService; + +export namespace Message { + export type messageEmpty = { + _: 'messageEmpty', + id: number + }; + + export type message = { + _: 'message', + flags?: number, + pFlags?: Partial<{ + out?: true, + mentioned?: true, + media_unread?: true, + silent?: true, + post?: true, + from_scheduled?: true, + legacy?: true, + edit_hide?: true, + }>, + id: number, + from_id?: number, + to_id: Peer, + fwd_from?: MessageFwdHeader, + via_bot_id?: number, + reply_to_msg_id?: number, + date: number, + message: string, + media?: MessageMedia, + reply_markup?: ReplyMarkup, + entities?: Array, + views?: number, + edit_date?: number, + post_author?: string, + grouped_id?: string, + restriction_reason?: Array + }; + + export type messageService = { + _: 'messageService', + flags?: number, + pFlags?: Partial<{ + out?: true, + mentioned?: true, + media_unread?: true, + silent?: true, + post?: true, + legacy?: true, + }>, + id: number, + from_id?: number, + to_id: Peer, + reply_to_msg_id?: number, + date: number, + action: MessageAction + }; +} + +/** + * @link https://core.telegram.org/type/MessageMedia + */ +export type MessageMedia = MessageMedia.messageMediaEmpty | MessageMedia.messageMediaPhoto | MessageMedia.messageMediaGeo | MessageMedia.messageMediaContact | MessageMedia.messageMediaUnsupported | MessageMedia.messageMediaDocument | MessageMedia.messageMediaWebPage | MessageMedia.messageMediaVenue | MessageMedia.messageMediaGame | MessageMedia.messageMediaInvoice | MessageMedia.messageMediaGeoLive | MessageMedia.messageMediaPoll | MessageMedia.messageMediaDice; + +export namespace MessageMedia { + export type messageMediaEmpty = { + _: 'messageMediaEmpty' + }; + + export type messageMediaPhoto = { + _: 'messageMediaPhoto', + flags?: number, + photo?: Photo, + ttl_seconds?: number + }; + + export type messageMediaGeo = { + _: 'messageMediaGeo', + geo: GeoPoint + }; + + export type messageMediaContact = { + _: 'messageMediaContact', + phone_number: string, + first_name: string, + last_name: string, + vcard: string, + user_id: number + }; + + export type messageMediaUnsupported = { + _: 'messageMediaUnsupported' + }; + + export type messageMediaDocument = { + _: 'messageMediaDocument', + flags?: number, + document?: Document, + ttl_seconds?: number + }; + + export type messageMediaWebPage = { + _: 'messageMediaWebPage', + webpage: WebPage + }; + + export type messageMediaVenue = { + _: 'messageMediaVenue', + geo: GeoPoint, + title: string, + address: string, + provider: string, + venue_id: string, + venue_type: string + }; + + export type messageMediaGame = { + _: 'messageMediaGame', + game: Game + }; + + export type messageMediaInvoice = { + _: 'messageMediaInvoice', + flags?: number, + pFlags?: Partial<{ + shipping_address_requested?: true, + test?: true, + }>, + title: string, + description: string, + photo?: WebDocument, + receipt_msg_id?: number, + currency: string, + total_amount: string, + start_param: string + }; + + export type messageMediaGeoLive = { + _: 'messageMediaGeoLive', + geo: GeoPoint, + period: number + }; + + export type messageMediaPoll = { + _: 'messageMediaPoll', + poll: Poll, + results: PollResults + }; + + export type messageMediaDice = { + _: 'messageMediaDice', + value: number, + emoticon: string + }; +} + +/** + * @link https://core.telegram.org/type/MessageAction + */ +export type MessageAction = MessageAction.messageActionEmpty | MessageAction.messageActionChatCreate | MessageAction.messageActionChatEditTitle | MessageAction.messageActionChatEditPhoto | MessageAction.messageActionChatDeletePhoto | MessageAction.messageActionChatAddUser | MessageAction.messageActionChatDeleteUser | MessageAction.messageActionChatJoinedByLink | MessageAction.messageActionChannelCreate | MessageAction.messageActionChatMigrateTo | MessageAction.messageActionChannelMigrateFrom | MessageAction.messageActionPinMessage | MessageAction.messageActionHistoryClear | MessageAction.messageActionGameScore | MessageAction.messageActionPaymentSentMe | MessageAction.messageActionPaymentSent | MessageAction.messageActionPhoneCall | MessageAction.messageActionScreenshotTaken | MessageAction.messageActionCustomAction | MessageAction.messageActionBotAllowed | MessageAction.messageActionSecureValuesSentMe | MessageAction.messageActionSecureValuesSent | MessageAction.messageActionContactSignUp; + +export namespace MessageAction { + export type messageActionEmpty = { + _: 'messageActionEmpty' + }; + + export type messageActionChatCreate = { + _: 'messageActionChatCreate', + title: string, + users: Array + }; + + export type messageActionChatEditTitle = { + _: 'messageActionChatEditTitle', + title: string + }; + + export type messageActionChatEditPhoto = { + _: 'messageActionChatEditPhoto', + photo: Photo + }; + + export type messageActionChatDeletePhoto = { + _: 'messageActionChatDeletePhoto' + }; + + export type messageActionChatAddUser = { + _: 'messageActionChatAddUser', + users: Array + }; + + export type messageActionChatDeleteUser = { + _: 'messageActionChatDeleteUser', + user_id: number + }; + + export type messageActionChatJoinedByLink = { + _: 'messageActionChatJoinedByLink', + inviter_id: number + }; + + export type messageActionChannelCreate = { + _: 'messageActionChannelCreate', + title: string + }; + + export type messageActionChatMigrateTo = { + _: 'messageActionChatMigrateTo', + channel_id: number + }; + + export type messageActionChannelMigrateFrom = { + _: 'messageActionChannelMigrateFrom', + title: string, + chat_id: number + }; + + export type messageActionPinMessage = { + _: 'messageActionPinMessage' + }; + + export type messageActionHistoryClear = { + _: 'messageActionHistoryClear' + }; + + export type messageActionGameScore = { + _: 'messageActionGameScore', + game_id: string, + score: number + }; + + export type messageActionPaymentSentMe = { + _: 'messageActionPaymentSentMe', + flags?: number, + currency: string, + total_amount: string, + payload: Uint8Array | number[], + info?: PaymentRequestedInfo, + shipping_option_id?: string, + charge: PaymentCharge + }; + + export type messageActionPaymentSent = { + _: 'messageActionPaymentSent', + currency: string, + total_amount: string + }; + + export type messageActionPhoneCall = { + _: 'messageActionPhoneCall', + flags?: number, + pFlags?: Partial<{ + video?: true, + }>, + call_id: string, + reason?: PhoneCallDiscardReason, + duration?: number + }; + + export type messageActionScreenshotTaken = { + _: 'messageActionScreenshotTaken' + }; + + export type messageActionCustomAction = { + _: 'messageActionCustomAction', + message: string + }; + + export type messageActionBotAllowed = { + _: 'messageActionBotAllowed', + domain: string + }; + + export type messageActionSecureValuesSentMe = { + _: 'messageActionSecureValuesSentMe', + values: Array, + credentials: SecureCredentialsEncrypted + }; + + export type messageActionSecureValuesSent = { + _: 'messageActionSecureValuesSent', + types: Array + }; + + export type messageActionContactSignUp = { + _: 'messageActionContactSignUp' + }; +} + +/** + * @link https://core.telegram.org/type/Dialog + */ +export type Dialog = Dialog.dialog | Dialog.dialogFolder; + +export namespace Dialog { + export type dialog = { + _: 'dialog', + flags?: number, + pFlags?: Partial<{ + pinned?: true, + unread_mark?: true, + }>, + peer: Peer, + top_message: number, + read_inbox_max_id: number, + read_outbox_max_id: number, + unread_count: number, + unread_mentions_count: number, + notify_settings: PeerNotifySettings, + pts?: number, + draft?: DraftMessage, + folder_id?: number + }; + + export type dialogFolder = { + _: 'dialogFolder', + flags?: number, + pFlags?: Partial<{ + pinned?: true, + }>, + folder: Folder, + peer: Peer, + top_message: number, + unread_muted_peers_count: number, + unread_unmuted_peers_count: number, + unread_muted_messages_count: number, + unread_unmuted_messages_count: number + }; +} + +/** + * @link https://core.telegram.org/type/Photo + */ +export type Photo = Photo.photoEmpty | Photo.photo; + +export namespace Photo { + export type photoEmpty = { + _: 'photoEmpty', + id: string + }; + + export type photo = { + _: 'photo', + flags?: number, + pFlags?: Partial<{ + has_stickers?: true, + }>, + id: string, + access_hash: string, + file_reference: Uint8Array | number[], + date: number, + sizes: Array, + dc_id: number, + downloaded?: boolean | number, + url?: string + }; +} + +/** + * @link https://core.telegram.org/type/PhotoSize + */ +export type PhotoSize = PhotoSize.photoSizeEmpty | PhotoSize.photoSize | PhotoSize.photoCachedSize | PhotoSize.photoStrippedSize; + +export namespace PhotoSize { + export type photoSizeEmpty = { + _: 'photoSizeEmpty', + type: string + }; + + export type photoSize = { + _: 'photoSize', + type: string, + location: FileLocation, + w: number, + h: number, + size: number, + url?: string + }; + + export type photoCachedSize = { + _: 'photoCachedSize', + type: string, + location: FileLocation, + w: number, + h: number, + bytes: Uint8Array | number[], + url?: string + }; + + export type photoStrippedSize = { + _: 'photoStrippedSize', + type: string, + bytes: Uint8Array | number[], + url?: string + }; +} + +/** + * @link https://core.telegram.org/type/GeoPoint + */ +export type GeoPoint = GeoPoint.geoPointEmpty | GeoPoint.geoPoint; + +export namespace GeoPoint { + export type geoPointEmpty = { + _: 'geoPointEmpty' + }; + + export type geoPoint = { + _: 'geoPoint', + long: number, + lat: number, + access_hash: string + }; +} + +/** + * @link https://core.telegram.org/type/auth.SentCode + */ +export type AuthSentCode = AuthSentCode.authSentCode; + +export namespace AuthSentCode { + export type authSentCode = { + _: 'auth.sentCode', + flags?: number, + type: AuthSentCodeType, + phone_code_hash: string, + next_type?: AuthCodeType, + timeout?: number + }; +} + +/** + * @link https://core.telegram.org/type/auth.Authorization + */ +export type AuthAuthorization = AuthAuthorization.authAuthorization | AuthAuthorization.authAuthorizationSignUpRequired; + +export namespace AuthAuthorization { + export type authAuthorization = { + _: 'auth.authorization', + flags?: number, + tmp_sessions?: number, + user: User + }; + + export type authAuthorizationSignUpRequired = { + _: 'auth.authorizationSignUpRequired', + flags?: number, + terms_of_service?: HelpTermsOfService + }; +} + +/** + * @link https://core.telegram.org/type/auth.ExportedAuthorization + */ +export type AuthExportedAuthorization = AuthExportedAuthorization.authExportedAuthorization; + +export namespace AuthExportedAuthorization { + export type authExportedAuthorization = { + _: 'auth.exportedAuthorization', + id: number, + bytes: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/InputNotifyPeer + */ +export type InputNotifyPeer = InputNotifyPeer.inputNotifyPeer | InputNotifyPeer.inputNotifyUsers | InputNotifyPeer.inputNotifyChats | InputNotifyPeer.inputNotifyBroadcasts; + +export namespace InputNotifyPeer { + export type inputNotifyPeer = { + _: 'inputNotifyPeer', + peer: InputPeer + }; + + export type inputNotifyUsers = { + _: 'inputNotifyUsers' + }; + + export type inputNotifyChats = { + _: 'inputNotifyChats' + }; + + export type inputNotifyBroadcasts = { + _: 'inputNotifyBroadcasts' + }; +} + +/** + * @link https://core.telegram.org/type/InputPeerNotifySettings + */ +export type InputPeerNotifySettings = InputPeerNotifySettings.inputPeerNotifySettings; + +export namespace InputPeerNotifySettings { + export type inputPeerNotifySettings = { + _: 'inputPeerNotifySettings', + flags?: number, + show_previews?: boolean, + silent?: boolean, + mute_until?: number, + sound?: string + }; +} + +/** + * @link https://core.telegram.org/type/PeerNotifySettings + */ +export type PeerNotifySettings = PeerNotifySettings.peerNotifySettings; + +export namespace PeerNotifySettings { + export type peerNotifySettings = { + _: 'peerNotifySettings', + flags?: number, + show_previews?: boolean, + silent?: boolean, + mute_until?: number, + sound?: string + }; +} + +/** + * @link https://core.telegram.org/type/PeerSettings + */ +export type PeerSettings = PeerSettings.peerSettings; + +export namespace PeerSettings { + export type peerSettings = { + _: 'peerSettings', + flags?: number, + pFlags?: Partial<{ + report_spam?: true, + add_contact?: true, + block_contact?: true, + share_contact?: true, + need_contacts_exception?: true, + report_geo?: true, + }> + }; +} + +/** + * @link https://core.telegram.org/type/WallPaper + */ +export type WallPaper = WallPaper.wallPaper | WallPaper.wallPaperNoFile; + +export namespace WallPaper { + export type wallPaper = { + _: 'wallPaper', + id: string, + flags?: number, + pFlags?: Partial<{ + creator?: true, + default?: true, + pattern?: true, + dark?: true, + }>, + access_hash: string, + slug: string, + document: Document, + settings?: WallPaperSettings + }; + + export type wallPaperNoFile = { + _: 'wallPaperNoFile', + flags?: number, + pFlags?: Partial<{ + default?: true, + dark?: true, + }>, + settings?: WallPaperSettings + }; +} + +/** + * @link https://core.telegram.org/type/ReportReason + */ +export type ReportReason = ReportReason.inputReportReasonSpam | ReportReason.inputReportReasonViolence | ReportReason.inputReportReasonPornography | ReportReason.inputReportReasonChildAbuse | ReportReason.inputReportReasonOther | ReportReason.inputReportReasonCopyright | ReportReason.inputReportReasonGeoIrrelevant; + +export namespace ReportReason { + export type inputReportReasonSpam = { + _: 'inputReportReasonSpam' + }; + + export type inputReportReasonViolence = { + _: 'inputReportReasonViolence' + }; + + export type inputReportReasonPornography = { + _: 'inputReportReasonPornography' + }; + + export type inputReportReasonChildAbuse = { + _: 'inputReportReasonChildAbuse' + }; + + export type inputReportReasonOther = { + _: 'inputReportReasonOther', + text: string + }; + + export type inputReportReasonCopyright = { + _: 'inputReportReasonCopyright' + }; + + export type inputReportReasonGeoIrrelevant = { + _: 'inputReportReasonGeoIrrelevant' + }; +} + +/** + * @link https://core.telegram.org/type/UserFull + */ +export type UserFull = UserFull.userFull; + +export namespace UserFull { + export type userFull = { + _: 'userFull', + flags?: number, + pFlags?: Partial<{ + blocked?: true, + phone_calls_available?: true, + phone_calls_private?: true, + can_pin_message?: true, + has_scheduled?: true, + }>, + user: User, + about?: string, + settings: PeerSettings, + profile_photo?: Photo, + notify_settings: PeerNotifySettings, + bot_info?: BotInfo, + pinned_msg_id?: number, + common_chats_count: number, + folder_id?: number + }; +} + +/** + * @link https://core.telegram.org/type/Contact + */ +export type Contact = Contact.contact; + +export namespace Contact { + export type contact = { + _: 'contact', + user_id: number, + mutual: boolean + }; +} + +/** + * @link https://core.telegram.org/type/ImportedContact + */ +export type ImportedContact = ImportedContact.importedContact; + +export namespace ImportedContact { + export type importedContact = { + _: 'importedContact', + user_id: number, + client_id: string + }; +} + +/** + * @link https://core.telegram.org/type/ContactBlocked + */ +export type ContactBlocked = ContactBlocked.contactBlocked; + +export namespace ContactBlocked { + export type contactBlocked = { + _: 'contactBlocked', + user_id: number, + date: number + }; +} + +/** + * @link https://core.telegram.org/type/ContactStatus + */ +export type ContactStatus = ContactStatus.contactStatus; + +export namespace ContactStatus { + export type contactStatus = { + _: 'contactStatus', + user_id: number, + status: UserStatus + }; +} + +/** + * @link https://core.telegram.org/type/contacts.Contacts + */ +export type ContactsContacts = ContactsContacts.contactsContactsNotModified | ContactsContacts.contactsContacts; + +export namespace ContactsContacts { + export type contactsContactsNotModified = { + _: 'contacts.contactsNotModified' + }; + + export type contactsContacts = { + _: 'contacts.contacts', + contacts: Array, + saved_count: number, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/contacts.ImportedContacts + */ +export type ContactsImportedContacts = ContactsImportedContacts.contactsImportedContacts; + +export namespace ContactsImportedContacts { + export type contactsImportedContacts = { + _: 'contacts.importedContacts', + imported: Array, + popular_invites: Array, + retry_contacts: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/contacts.Blocked + */ +export type ContactsBlocked = ContactsBlocked.contactsBlocked | ContactsBlocked.contactsBlockedSlice; + +export namespace ContactsBlocked { + export type contactsBlocked = { + _: 'contacts.blocked', + blocked: Array, + users: Array + }; + + export type contactsBlockedSlice = { + _: 'contacts.blockedSlice', + count: number, + blocked: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.Dialogs + */ +export type MessagesDialogs = MessagesDialogs.messagesDialogs | MessagesDialogs.messagesDialogsSlice | MessagesDialogs.messagesDialogsNotModified; + +export namespace MessagesDialogs { + export type messagesDialogs = { + _: 'messages.dialogs', + dialogs: Array, + messages: Array, + chats: Array, + users: Array + }; + + export type messagesDialogsSlice = { + _: 'messages.dialogsSlice', + count: number, + dialogs: Array, + messages: Array, + chats: Array, + users: Array + }; + + export type messagesDialogsNotModified = { + _: 'messages.dialogsNotModified', + count: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.Messages + */ +export type MessagesMessages = MessagesMessages.messagesMessages | MessagesMessages.messagesMessagesSlice | MessagesMessages.messagesChannelMessages | MessagesMessages.messagesMessagesNotModified; + +export namespace MessagesMessages { + export type messagesMessages = { + _: 'messages.messages', + messages: Array, + chats: Array, + users: Array + }; + + export type messagesMessagesSlice = { + _: 'messages.messagesSlice', + flags?: number, + pFlags?: Partial<{ + inexact?: true, + }>, + count: number, + next_rate?: number, + messages: Array, + chats: Array, + users: Array + }; + + export type messagesChannelMessages = { + _: 'messages.channelMessages', + flags?: number, + pFlags?: Partial<{ + inexact?: true, + }>, + pts: number, + count: number, + messages: Array, + chats: Array, + users: Array + }; + + export type messagesMessagesNotModified = { + _: 'messages.messagesNotModified', + count: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.Chats + */ +export type MessagesChats = MessagesChats.messagesChats | MessagesChats.messagesChatsSlice; + +export namespace MessagesChats { + export type messagesChats = { + _: 'messages.chats', + chats: Array + }; + + export type messagesChatsSlice = { + _: 'messages.chatsSlice', + count: number, + chats: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.ChatFull + */ +export type MessagesChatFull = MessagesChatFull.messagesChatFull; + +export namespace MessagesChatFull { + export type messagesChatFull = { + _: 'messages.chatFull', + full_chat: ChatFull, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.AffectedHistory + */ +export type MessagesAffectedHistory = MessagesAffectedHistory.messagesAffectedHistory; + +export namespace MessagesAffectedHistory { + export type messagesAffectedHistory = { + _: 'messages.affectedHistory', + pts: number, + pts_count: number, + offset: number + }; +} + +/** + * @link https://core.telegram.org/type/MessagesFilter + */ +export type MessagesFilter = MessagesFilter.inputMessagesFilterEmpty | MessagesFilter.inputMessagesFilterPhotos | MessagesFilter.inputMessagesFilterVideo | MessagesFilter.inputMessagesFilterPhotoVideo | MessagesFilter.inputMessagesFilterDocument | MessagesFilter.inputMessagesFilterUrl | MessagesFilter.inputMessagesFilterGif | MessagesFilter.inputMessagesFilterVoice | MessagesFilter.inputMessagesFilterMusic | MessagesFilter.inputMessagesFilterChatPhotos | MessagesFilter.inputMessagesFilterPhoneCalls | MessagesFilter.inputMessagesFilterRoundVoice | MessagesFilter.inputMessagesFilterRoundVideo | MessagesFilter.inputMessagesFilterMyMentions | MessagesFilter.inputMessagesFilterGeo | MessagesFilter.inputMessagesFilterContacts; + +export namespace MessagesFilter { + export type inputMessagesFilterEmpty = { + _: 'inputMessagesFilterEmpty' + }; + + export type inputMessagesFilterPhotos = { + _: 'inputMessagesFilterPhotos' + }; + + export type inputMessagesFilterVideo = { + _: 'inputMessagesFilterVideo' + }; + + export type inputMessagesFilterPhotoVideo = { + _: 'inputMessagesFilterPhotoVideo' + }; + + export type inputMessagesFilterDocument = { + _: 'inputMessagesFilterDocument' + }; + + export type inputMessagesFilterUrl = { + _: 'inputMessagesFilterUrl' + }; + + export type inputMessagesFilterGif = { + _: 'inputMessagesFilterGif' + }; + + export type inputMessagesFilterVoice = { + _: 'inputMessagesFilterVoice' + }; + + export type inputMessagesFilterMusic = { + _: 'inputMessagesFilterMusic' + }; + + export type inputMessagesFilterChatPhotos = { + _: 'inputMessagesFilterChatPhotos' + }; + + export type inputMessagesFilterPhoneCalls = { + _: 'inputMessagesFilterPhoneCalls', + flags?: number, + pFlags?: Partial<{ + missed?: true, + }> + }; + + export type inputMessagesFilterRoundVoice = { + _: 'inputMessagesFilterRoundVoice' + }; + + export type inputMessagesFilterRoundVideo = { + _: 'inputMessagesFilterRoundVideo' + }; + + export type inputMessagesFilterMyMentions = { + _: 'inputMessagesFilterMyMentions' + }; + + export type inputMessagesFilterGeo = { + _: 'inputMessagesFilterGeo' + }; + + export type inputMessagesFilterContacts = { + _: 'inputMessagesFilterContacts' + }; +} + +/** + * @link https://core.telegram.org/type/Update + */ +export type Update = Update.updateNewMessage | Update.updateMessageID | Update.updateDeleteMessages | Update.updateUserTyping | Update.updateChatUserTyping | Update.updateChatParticipants | Update.updateUserStatus | Update.updateUserName | Update.updateUserPhoto | Update.updateNewEncryptedMessage | Update.updateEncryptedChatTyping | Update.updateEncryption | Update.updateEncryptedMessagesRead | Update.updateChatParticipantAdd | Update.updateChatParticipantDelete | Update.updateDcOptions | Update.updateUserBlocked | Update.updateNotifySettings | Update.updateServiceNotification | Update.updatePrivacy | Update.updateUserPhone | Update.updateReadHistoryInbox | Update.updateReadHistoryOutbox | Update.updateWebPage | Update.updateReadMessagesContents | Update.updateChannelTooLong | Update.updateChannel | Update.updateNewChannelMessage | Update.updateReadChannelInbox | Update.updateDeleteChannelMessages | Update.updateChannelMessageViews | Update.updateChatParticipantAdmin | Update.updateNewStickerSet | Update.updateStickerSetsOrder | Update.updateStickerSets | Update.updateSavedGifs | Update.updateBotInlineQuery | Update.updateBotInlineSend | Update.updateEditChannelMessage | Update.updateChannelPinnedMessage | Update.updateBotCallbackQuery | Update.updateEditMessage | Update.updateInlineBotCallbackQuery | Update.updateReadChannelOutbox | Update.updateDraftMessage | Update.updateReadFeaturedStickers | Update.updateRecentStickers | Update.updateConfig | Update.updatePtsChanged | Update.updateChannelWebPage | Update.updateDialogPinned | Update.updatePinnedDialogs | Update.updateBotWebhookJSON | Update.updateBotWebhookJSONQuery | Update.updateBotShippingQuery | Update.updateBotPrecheckoutQuery | Update.updatePhoneCall | Update.updateLangPackTooLong | Update.updateLangPack | Update.updateFavedStickers | Update.updateChannelReadMessagesContents | Update.updateContactsReset | Update.updateChannelAvailableMessages | Update.updateDialogUnreadMark | Update.updateUserPinnedMessage | Update.updateChatPinnedMessage | Update.updateMessagePoll | Update.updateChatDefaultBannedRights | Update.updateFolderPeers | Update.updatePeerSettings | Update.updatePeerLocated | Update.updateNewScheduledMessage | Update.updateDeleteScheduledMessages | Update.updateTheme | Update.updateGeoLiveViewed | Update.updateLoginToken | Update.updateMessagePollVote | Update.updateDialogFilter | Update.updateDialogFilterOrder | Update.updateDialogFilters; + +export namespace Update { + export type updateNewMessage = { + _: 'updateNewMessage', + message: Message, + pts: number, + pts_count: number + }; + + export type updateMessageID = { + _: 'updateMessageID', + id: number, + random_id: string + }; + + export type updateDeleteMessages = { + _: 'updateDeleteMessages', + messages: Array, + pts: number, + pts_count: number + }; + + export type updateUserTyping = { + _: 'updateUserTyping', + user_id: number, + action: SendMessageAction + }; + + export type updateChatUserTyping = { + _: 'updateChatUserTyping', + chat_id: number, + user_id: number, + action: SendMessageAction + }; + + export type updateChatParticipants = { + _: 'updateChatParticipants', + participants: ChatParticipants + }; + + export type updateUserStatus = { + _: 'updateUserStatus', + user_id: number, + status: UserStatus + }; + + export type updateUserName = { + _: 'updateUserName', + user_id: number, + first_name: string, + last_name: string, + username: string + }; + + export type updateUserPhoto = { + _: 'updateUserPhoto', + user_id: number, + date: number, + photo: UserProfilePhoto, + previous: boolean + }; + + export type updateNewEncryptedMessage = { + _: 'updateNewEncryptedMessage', + message: EncryptedMessage, + qts: number + }; + + export type updateEncryptedChatTyping = { + _: 'updateEncryptedChatTyping', + chat_id: number + }; + + export type updateEncryption = { + _: 'updateEncryption', + chat: EncryptedChat, + date: number + }; + + export type updateEncryptedMessagesRead = { + _: 'updateEncryptedMessagesRead', + chat_id: number, + max_date: number, + date: number + }; + + export type updateChatParticipantAdd = { + _: 'updateChatParticipantAdd', + chat_id: number, + user_id: number, + inviter_id: number, + date: number, + version: number + }; + + export type updateChatParticipantDelete = { + _: 'updateChatParticipantDelete', + chat_id: number, + user_id: number, + version: number + }; + + export type updateDcOptions = { + _: 'updateDcOptions', + dc_options: Array + }; + + export type updateUserBlocked = { + _: 'updateUserBlocked', + user_id: number, + blocked: boolean + }; + + export type updateNotifySettings = { + _: 'updateNotifySettings', + peer: NotifyPeer, + notify_settings: PeerNotifySettings + }; + + export type updateServiceNotification = { + _: 'updateServiceNotification', + flags?: number, + pFlags?: Partial<{ + popup?: true, + }>, + inbox_date?: number, + type: string, + message: string, + media: MessageMedia, + entities: Array + }; + + export type updatePrivacy = { + _: 'updatePrivacy', + key: PrivacyKey, + rules: Array + }; + + export type updateUserPhone = { + _: 'updateUserPhone', + user_id: number, + phone: string + }; + + export type updateReadHistoryInbox = { + _: 'updateReadHistoryInbox', + flags?: number, + folder_id?: number, + peer: Peer, + max_id: number, + still_unread_count: number, + pts: number, + pts_count: number + }; + + export type updateReadHistoryOutbox = { + _: 'updateReadHistoryOutbox', + peer: Peer, + max_id: number, + pts: number, + pts_count: number + }; + + export type updateWebPage = { + _: 'updateWebPage', + webpage: WebPage, + pts: number, + pts_count: number + }; + + export type updateReadMessagesContents = { + _: 'updateReadMessagesContents', + messages: Array, + pts: number, + pts_count: number + }; + + export type updateChannelTooLong = { + _: 'updateChannelTooLong', + flags?: number, + channel_id: number, + pts?: number + }; + + export type updateChannel = { + _: 'updateChannel', + channel_id: number + }; + + export type updateNewChannelMessage = { + _: 'updateNewChannelMessage', + message: Message, + pts: number, + pts_count: number + }; + + export type updateReadChannelInbox = { + _: 'updateReadChannelInbox', + flags?: number, + folder_id?: number, + channel_id: number, + max_id: number, + still_unread_count: number, + pts: number + }; + + export type updateDeleteChannelMessages = { + _: 'updateDeleteChannelMessages', + channel_id: number, + messages: Array, + pts: number, + pts_count: number + }; + + export type updateChannelMessageViews = { + _: 'updateChannelMessageViews', + channel_id: number, + id: number, + views: number + }; + + export type updateChatParticipantAdmin = { + _: 'updateChatParticipantAdmin', + chat_id: number, + user_id: number, + is_admin: boolean, + version: number + }; + + export type updateNewStickerSet = { + _: 'updateNewStickerSet', + stickerset: MessagesStickerSet + }; + + export type updateStickerSetsOrder = { + _: 'updateStickerSetsOrder', + flags?: number, + pFlags?: Partial<{ + masks?: true, + }>, + order: Array + }; + + export type updateStickerSets = { + _: 'updateStickerSets' + }; + + export type updateSavedGifs = { + _: 'updateSavedGifs' + }; + + export type updateBotInlineQuery = { + _: 'updateBotInlineQuery', + flags?: number, + query_id: string, + user_id: number, + query: string, + geo?: GeoPoint, + offset: string + }; + + export type updateBotInlineSend = { + _: 'updateBotInlineSend', + flags?: number, + user_id: number, + query: string, + geo?: GeoPoint, + id: string, + msg_id?: InputBotInlineMessageID + }; + + export type updateEditChannelMessage = { + _: 'updateEditChannelMessage', + message: Message, + pts: number, + pts_count: number + }; + + export type updateChannelPinnedMessage = { + _: 'updateChannelPinnedMessage', + channel_id: number, + id: number + }; + + export type updateBotCallbackQuery = { + _: 'updateBotCallbackQuery', + flags?: number, + query_id: string, + user_id: number, + peer: Peer, + msg_id: number, + chat_instance: string, + data?: Uint8Array | number[], + game_short_name?: string + }; + + export type updateEditMessage = { + _: 'updateEditMessage', + message: Message, + pts: number, + pts_count: number + }; + + export type updateInlineBotCallbackQuery = { + _: 'updateInlineBotCallbackQuery', + flags?: number, + query_id: string, + user_id: number, + msg_id: InputBotInlineMessageID, + chat_instance: string, + data?: Uint8Array | number[], + game_short_name?: string + }; + + export type updateReadChannelOutbox = { + _: 'updateReadChannelOutbox', + channel_id: number, + max_id: number + }; + + export type updateDraftMessage = { + _: 'updateDraftMessage', + peer: Peer, + draft: DraftMessage + }; + + export type updateReadFeaturedStickers = { + _: 'updateReadFeaturedStickers' + }; + + export type updateRecentStickers = { + _: 'updateRecentStickers' + }; + + export type updateConfig = { + _: 'updateConfig' + }; + + export type updatePtsChanged = { + _: 'updatePtsChanged' + }; + + export type updateChannelWebPage = { + _: 'updateChannelWebPage', + channel_id: number, + webpage: WebPage, + pts: number, + pts_count: number + }; + + export type updateDialogPinned = { + _: 'updateDialogPinned', + flags?: number, + pFlags?: Partial<{ + pinned?: true, + }>, + folder_id?: number, + peer: DialogPeer + }; + + export type updatePinnedDialogs = { + _: 'updatePinnedDialogs', + flags?: number, + folder_id?: number, + order?: Array + }; + + export type updateBotWebhookJSON = { + _: 'updateBotWebhookJSON', + data: DataJSON + }; + + export type updateBotWebhookJSONQuery = { + _: 'updateBotWebhookJSONQuery', + query_id: string, + data: DataJSON, + timeout: number + }; + + export type updateBotShippingQuery = { + _: 'updateBotShippingQuery', + query_id: string, + user_id: number, + payload: Uint8Array | number[], + shipping_address: PostAddress + }; + + export type updateBotPrecheckoutQuery = { + _: 'updateBotPrecheckoutQuery', + flags?: number, + query_id: string, + user_id: number, + payload: Uint8Array | number[], + info?: PaymentRequestedInfo, + shipping_option_id?: string, + currency: string, + total_amount: string + }; + + export type updatePhoneCall = { + _: 'updatePhoneCall', + phone_call: PhoneCall + }; + + export type updateLangPackTooLong = { + _: 'updateLangPackTooLong', + lang_code: string + }; + + export type updateLangPack = { + _: 'updateLangPack', + difference: LangPackDifference + }; + + export type updateFavedStickers = { + _: 'updateFavedStickers' + }; + + export type updateChannelReadMessagesContents = { + _: 'updateChannelReadMessagesContents', + channel_id: number, + messages: Array + }; + + export type updateContactsReset = { + _: 'updateContactsReset' + }; + + export type updateChannelAvailableMessages = { + _: 'updateChannelAvailableMessages', + channel_id: number, + available_min_id: number + }; + + export type updateDialogUnreadMark = { + _: 'updateDialogUnreadMark', + flags?: number, + pFlags?: Partial<{ + unread?: true, + }>, + peer: DialogPeer + }; + + export type updateUserPinnedMessage = { + _: 'updateUserPinnedMessage', + user_id: number, + id: number + }; + + export type updateChatPinnedMessage = { + _: 'updateChatPinnedMessage', + chat_id: number, + id: number, + version: number + }; + + export type updateMessagePoll = { + _: 'updateMessagePoll', + flags?: number, + poll_id: string, + poll?: Poll, + results: PollResults + }; + + export type updateChatDefaultBannedRights = { + _: 'updateChatDefaultBannedRights', + peer: Peer, + default_banned_rights: ChatBannedRights, + version: number + }; + + export type updateFolderPeers = { + _: 'updateFolderPeers', + folder_peers: Array, + pts: number, + pts_count: number + }; + + export type updatePeerSettings = { + _: 'updatePeerSettings', + peer: Peer, + settings: PeerSettings + }; + + export type updatePeerLocated = { + _: 'updatePeerLocated', + peers: Array + }; + + export type updateNewScheduledMessage = { + _: 'updateNewScheduledMessage', + message: Message + }; + + export type updateDeleteScheduledMessages = { + _: 'updateDeleteScheduledMessages', + peer: Peer, + messages: Array + }; + + export type updateTheme = { + _: 'updateTheme', + theme: Theme + }; + + export type updateGeoLiveViewed = { + _: 'updateGeoLiveViewed', + peer: Peer, + msg_id: number + }; + + export type updateLoginToken = { + _: 'updateLoginToken' + }; + + export type updateMessagePollVote = { + _: 'updateMessagePollVote', + poll_id: string, + user_id: number, + options: Array + }; + + export type updateDialogFilter = { + _: 'updateDialogFilter', + flags?: number, + id: number, + filter?: DialogFilter + }; + + export type updateDialogFilterOrder = { + _: 'updateDialogFilterOrder', + order: Array + }; + + export type updateDialogFilters = { + _: 'updateDialogFilters' + }; +} + +/** + * @link https://core.telegram.org/type/updates.State + */ +export type UpdatesState = UpdatesState.updatesState; + +export namespace UpdatesState { + export type updatesState = { + _: 'updates.state', + pts: number, + qts: number, + date: number, + seq: number, + unread_count: number + }; +} + +/** + * @link https://core.telegram.org/type/updates.Difference + */ +export type UpdatesDifference = UpdatesDifference.updatesDifferenceEmpty | UpdatesDifference.updatesDifference | UpdatesDifference.updatesDifferenceSlice | UpdatesDifference.updatesDifferenceTooLong; + +export namespace UpdatesDifference { + export type updatesDifferenceEmpty = { + _: 'updates.differenceEmpty', + date: number, + seq: number + }; + + export type updatesDifference = { + _: 'updates.difference', + new_messages: Array, + new_encrypted_messages: Array, + other_updates: Array, + chats: Array, + users: Array, + state: UpdatesState + }; + + export type updatesDifferenceSlice = { + _: 'updates.differenceSlice', + new_messages: Array, + new_encrypted_messages: Array, + other_updates: Array, + chats: Array, + users: Array, + intermediate_state: UpdatesState + }; + + export type updatesDifferenceTooLong = { + _: 'updates.differenceTooLong', + pts: number + }; +} + +/** + * @link https://core.telegram.org/type/Updates + */ +export type Updates = Updates.updatesTooLong | Updates.updateShortMessage | Updates.updateShortChatMessage | Updates.updateShort | Updates.updatesCombined | Updates.updates | Updates.updateShortSentMessage; + +export namespace Updates { + export type updatesTooLong = { + _: 'updatesTooLong' + }; + + export type updateShortMessage = { + _: 'updateShortMessage', + flags?: number, + pFlags?: Partial<{ + out?: true, + mentioned?: true, + media_unread?: true, + silent?: true, + }>, + id: number, + user_id: number, + message: string, + pts: number, + pts_count: number, + date: number, + fwd_from?: MessageFwdHeader, + via_bot_id?: number, + reply_to_msg_id?: number, + entities?: Array + }; + + export type updateShortChatMessage = { + _: 'updateShortChatMessage', + flags?: number, + pFlags?: Partial<{ + out?: true, + mentioned?: true, + media_unread?: true, + silent?: true, + }>, + id: number, + from_id: number, + chat_id: number, + message: string, + pts: number, + pts_count: number, + date: number, + fwd_from?: MessageFwdHeader, + via_bot_id?: number, + reply_to_msg_id?: number, + entities?: Array + }; + + export type updateShort = { + _: 'updateShort', + update: Update, + date: number + }; + + export type updatesCombined = { + _: 'updatesCombined', + updates: Array, + users: Array, + chats: Array, + date: number, + seq_start: number, + seq: number + }; + + export type updates = { + _: 'updates', + updates: Array, + users: Array, + chats: Array, + date: number, + seq: number + }; + + export type updateShortSentMessage = { + _: 'updateShortSentMessage', + flags?: number, + pFlags?: Partial<{ + out?: true, + }>, + id: number, + pts: number, + pts_count: number, + date: number, + media?: MessageMedia, + entities?: Array + }; +} + +/** + * @link https://core.telegram.org/type/photos.Photos + */ +export type PhotosPhotos = PhotosPhotos.photosPhotos | PhotosPhotos.photosPhotosSlice; + +export namespace PhotosPhotos { + export type photosPhotos = { + _: 'photos.photos', + photos: Array, + users: Array + }; + + export type photosPhotosSlice = { + _: 'photos.photosSlice', + count: number, + photos: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/photos.Photo + */ +export type PhotosPhoto = PhotosPhoto.photosPhoto; + +export namespace PhotosPhoto { + export type photosPhoto = { + _: 'photos.photo', + photo: Photo, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/upload.File + */ +export type UploadFile = UploadFile.uploadFile | UploadFile.uploadFileCdnRedirect; + +export namespace UploadFile { + export type uploadFile = { + _: 'upload.file', + type: StorageFileType, + mtime: number, + bytes: Uint8Array | number[] + }; + + export type uploadFileCdnRedirect = { + _: 'upload.fileCdnRedirect', + dc_id: number, + file_token: Uint8Array | number[], + encryption_key: Uint8Array | number[], + encryption_iv: Uint8Array | number[], + file_hashes: Array + }; +} + +/** + * @link https://core.telegram.org/type/DcOption + */ +export type DcOption = DcOption.dcOption; + +export namespace DcOption { + export type dcOption = { + _: 'dcOption', + flags?: number, + pFlags?: Partial<{ + ipv6?: true, + media_only?: true, + tcpo_only?: true, + cdn?: true, + static?: true, + }>, + id: number, + ip_address: string, + port: number, + secret?: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/Config + */ +export type Config = Config.config; + +export namespace Config { + export type config = { + _: 'config', + flags?: number, + pFlags?: Partial<{ + phonecalls_enabled?: true, + default_p2p_contacts?: true, + preload_featured_stickers?: true, + ignore_phone_entities?: true, + revoke_pm_inbox?: true, + blocked_mode?: true, + pfs_enabled?: true, + }>, + date: number, + expires: number, + test_mode: boolean, + this_dc: number, + dc_options: Array, + dc_txt_domain_name: string, + chat_size_max: number, + megagroup_size_max: number, + forwarded_count_max: number, + online_update_period_ms: number, + offline_blur_timeout_ms: number, + offline_idle_timeout_ms: number, + online_cloud_timeout_ms: number, + notify_cloud_delay_ms: number, + notify_default_delay_ms: number, + push_chat_period_ms: number, + push_chat_limit: number, + saved_gifs_limit: number, + edit_time_limit: number, + revoke_time_limit: number, + revoke_pm_time_limit: number, + rating_e_decay: number, + stickers_recent_limit: number, + stickers_faved_limit: number, + channels_read_media_period: number, + tmp_sessions?: number, + pinned_dialogs_count_max: number, + pinned_infolder_count_max: number, + call_receive_timeout_ms: number, + call_ring_timeout_ms: number, + call_connect_timeout_ms: number, + call_packet_timeout_ms: number, + me_url_prefix: string, + autoupdate_url_prefix?: string, + gif_search_username?: string, + venue_search_username?: string, + img_search_username?: string, + static_maps_provider?: string, + caption_length_max: number, + message_length_max: number, + webfile_dc_id: number, + suggested_lang_code?: string, + lang_pack_version?: number, + base_lang_pack_version?: number + }; +} + +/** + * @link https://core.telegram.org/type/NearestDc + */ +export type NearestDc = NearestDc.nearestDc; + +export namespace NearestDc { + export type nearestDc = { + _: 'nearestDc', + country: string, + this_dc: number, + nearest_dc: number + }; +} + +/** + * @link https://core.telegram.org/type/help.AppUpdate + */ +export type HelpAppUpdate = HelpAppUpdate.helpAppUpdate | HelpAppUpdate.helpNoAppUpdate; + +export namespace HelpAppUpdate { + export type helpAppUpdate = { + _: 'help.appUpdate', + flags?: number, + pFlags?: Partial<{ + can_not_skip?: true, + }>, + id: number, + version: string, + text: string, + entities: Array, + document?: Document, + url?: string + }; + + export type helpNoAppUpdate = { + _: 'help.noAppUpdate' + }; +} + +/** + * @link https://core.telegram.org/type/help.InviteText + */ +export type HelpInviteText = HelpInviteText.helpInviteText; + +export namespace HelpInviteText { + export type helpInviteText = { + _: 'help.inviteText', + message: string + }; +} + +/** + * @link https://core.telegram.org/type/EncryptedChat + */ +export type EncryptedChat = EncryptedChat.encryptedChatEmpty | EncryptedChat.encryptedChatWaiting | EncryptedChat.encryptedChatRequested | EncryptedChat.encryptedChat | EncryptedChat.encryptedChatDiscarded; + +export namespace EncryptedChat { + export type encryptedChatEmpty = { + _: 'encryptedChatEmpty', + id: number + }; + + export type encryptedChatWaiting = { + _: 'encryptedChatWaiting', + id: number, + access_hash: string, + date: number, + admin_id: number, + participant_id: number + }; + + export type encryptedChatRequested = { + _: 'encryptedChatRequested', + id: number, + access_hash: string, + date: number, + admin_id: number, + participant_id: number, + g_a: Uint8Array | number[] + }; + + export type encryptedChat = { + _: 'encryptedChat', + id: number, + access_hash: string, + date: number, + admin_id: number, + participant_id: number, + g_a_or_b: Uint8Array | number[], + key_fingerprint: string + }; + + export type encryptedChatDiscarded = { + _: 'encryptedChatDiscarded', + id: number + }; +} + +/** + * @link https://core.telegram.org/type/InputEncryptedChat + */ +export type InputEncryptedChat = InputEncryptedChat.inputEncryptedChat; + +export namespace InputEncryptedChat { + export type inputEncryptedChat = { + _: 'inputEncryptedChat', + chat_id: number, + access_hash: string + }; +} + +/** + * @link https://core.telegram.org/type/EncryptedFile + */ +export type EncryptedFile = EncryptedFile.encryptedFileEmpty | EncryptedFile.encryptedFile; + +export namespace EncryptedFile { + export type encryptedFileEmpty = { + _: 'encryptedFileEmpty' + }; + + export type encryptedFile = { + _: 'encryptedFile', + id: string, + access_hash: string, + size: number, + dc_id: number, + key_fingerprint: number + }; +} + +/** + * @link https://core.telegram.org/type/InputEncryptedFile + */ +export type InputEncryptedFile = InputEncryptedFile.inputEncryptedFileEmpty | InputEncryptedFile.inputEncryptedFileUploaded | InputEncryptedFile.inputEncryptedFile | InputEncryptedFile.inputEncryptedFileBigUploaded; + +export namespace InputEncryptedFile { + export type inputEncryptedFileEmpty = { + _: 'inputEncryptedFileEmpty' + }; + + export type inputEncryptedFileUploaded = { + _: 'inputEncryptedFileUploaded', + id: string, + parts: number, + md5_checksum: string, + key_fingerprint: number + }; + + export type inputEncryptedFile = { + _: 'inputEncryptedFile', + id: string, + access_hash: string + }; + + export type inputEncryptedFileBigUploaded = { + _: 'inputEncryptedFileBigUploaded', + id: string, + parts: number, + key_fingerprint: number + }; +} + +/** + * @link https://core.telegram.org/type/EncryptedMessage + */ +export type EncryptedMessage = EncryptedMessage.encryptedMessage | EncryptedMessage.encryptedMessageService; + +export namespace EncryptedMessage { + export type encryptedMessage = { + _: 'encryptedMessage', + random_id: string, + chat_id: number, + date: number, + bytes: Uint8Array | number[], + file: EncryptedFile + }; + + export type encryptedMessageService = { + _: 'encryptedMessageService', + random_id: string, + chat_id: number, + date: number, + bytes: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/messages.DhConfig + */ +export type MessagesDhConfig = MessagesDhConfig.messagesDhConfigNotModified | MessagesDhConfig.messagesDhConfig; + +export namespace MessagesDhConfig { + export type messagesDhConfigNotModified = { + _: 'messages.dhConfigNotModified', + random: Uint8Array | number[] + }; + + export type messagesDhConfig = { + _: 'messages.dhConfig', + g: number, + p: Uint8Array | number[], + version: number, + random: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/messages.SentEncryptedMessage + */ +export type MessagesSentEncryptedMessage = MessagesSentEncryptedMessage.messagesSentEncryptedMessage | MessagesSentEncryptedMessage.messagesSentEncryptedFile; + +export namespace MessagesSentEncryptedMessage { + export type messagesSentEncryptedMessage = { + _: 'messages.sentEncryptedMessage', + date: number + }; + + export type messagesSentEncryptedFile = { + _: 'messages.sentEncryptedFile', + date: number, + file: EncryptedFile + }; +} + +/** + * @link https://core.telegram.org/type/InputDocument + */ +export type InputDocument = InputDocument.inputDocumentEmpty | InputDocument.inputDocument; + +export namespace InputDocument { + export type inputDocumentEmpty = { + _: 'inputDocumentEmpty' + }; + + export type inputDocument = { + _: 'inputDocument', + id: string, + access_hash: string, + file_reference: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/Document + */ +export type Document = Document.documentEmpty | Document.document; + +export namespace Document { + export type documentEmpty = { + _: 'documentEmpty', + id: string + }; + + export type document = { + _: 'document', + flags?: number, + id: string, + access_hash: string, + file_reference: Uint8Array | number[], + date: number, + mime_type: string, + size: number, + thumbs?: Array, + dc_id: number, + attributes: Array, + type?: 'gif' | 'sticker' | 'audio' | 'voice' | 'video' | 'round' | 'photo', + h?: number, + w?: number, + file_name?: string, + file?: File, + duration?: number, + downloaded?: boolean, + url?: string, + audioTitle?: string, + audioPerformer?: string, + sticker?: number, + stickerEmoji?: string, + stickerEmojiRaw?: string, + stickerSetInput?: InputStickerSet.inputStickerSetID, + pFlags?: Partial<{ + stickerThumbConverted?: true, + }>, + animated?: boolean, + supportsStreaming?: boolean + }; +} + +/** + * @link https://core.telegram.org/type/help.Support + */ +export type HelpSupport = HelpSupport.helpSupport; + +export namespace HelpSupport { + export type helpSupport = { + _: 'help.support', + phone_number: string, + user: User + }; +} + +/** + * @link https://core.telegram.org/type/NotifyPeer + */ +export type NotifyPeer = NotifyPeer.notifyPeer | NotifyPeer.notifyUsers | NotifyPeer.notifyChats | NotifyPeer.notifyBroadcasts; + +export namespace NotifyPeer { + export type notifyPeer = { + _: 'notifyPeer', + peer: Peer + }; + + export type notifyUsers = { + _: 'notifyUsers' + }; + + export type notifyChats = { + _: 'notifyChats' + }; + + export type notifyBroadcasts = { + _: 'notifyBroadcasts' + }; +} + +/** + * @link https://core.telegram.org/type/SendMessageAction + */ +export type SendMessageAction = SendMessageAction.sendMessageTypingAction | SendMessageAction.sendMessageCancelAction | SendMessageAction.sendMessageRecordVideoAction | SendMessageAction.sendMessageUploadVideoAction | SendMessageAction.sendMessageRecordAudioAction | SendMessageAction.sendMessageUploadAudioAction | SendMessageAction.sendMessageUploadPhotoAction | SendMessageAction.sendMessageUploadDocumentAction | SendMessageAction.sendMessageGeoLocationAction | SendMessageAction.sendMessageChooseContactAction | SendMessageAction.sendMessageGamePlayAction | SendMessageAction.sendMessageRecordRoundAction | SendMessageAction.sendMessageUploadRoundAction; + +export namespace SendMessageAction { + export type sendMessageTypingAction = { + _: 'sendMessageTypingAction' + }; + + export type sendMessageCancelAction = { + _: 'sendMessageCancelAction' + }; + + export type sendMessageRecordVideoAction = { + _: 'sendMessageRecordVideoAction' + }; + + export type sendMessageUploadVideoAction = { + _: 'sendMessageUploadVideoAction', + progress: number + }; + + export type sendMessageRecordAudioAction = { + _: 'sendMessageRecordAudioAction' + }; + + export type sendMessageUploadAudioAction = { + _: 'sendMessageUploadAudioAction', + progress: number + }; + + export type sendMessageUploadPhotoAction = { + _: 'sendMessageUploadPhotoAction', + progress: number + }; + + export type sendMessageUploadDocumentAction = { + _: 'sendMessageUploadDocumentAction', + progress: number + }; + + export type sendMessageGeoLocationAction = { + _: 'sendMessageGeoLocationAction' + }; + + export type sendMessageChooseContactAction = { + _: 'sendMessageChooseContactAction' + }; + + export type sendMessageGamePlayAction = { + _: 'sendMessageGamePlayAction' + }; + + export type sendMessageRecordRoundAction = { + _: 'sendMessageRecordRoundAction' + }; + + export type sendMessageUploadRoundAction = { + _: 'sendMessageUploadRoundAction', + progress: number + }; +} + +/** + * @link https://core.telegram.org/type/contacts.Found + */ +export type ContactsFound = ContactsFound.contactsFound; + +export namespace ContactsFound { + export type contactsFound = { + _: 'contacts.found', + my_results: Array, + results: Array, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputPrivacyKey + */ +export type InputPrivacyKey = InputPrivacyKey.inputPrivacyKeyStatusTimestamp | InputPrivacyKey.inputPrivacyKeyChatInvite | InputPrivacyKey.inputPrivacyKeyPhoneCall | InputPrivacyKey.inputPrivacyKeyPhoneP2P | InputPrivacyKey.inputPrivacyKeyForwards | InputPrivacyKey.inputPrivacyKeyProfilePhoto | InputPrivacyKey.inputPrivacyKeyPhoneNumber | InputPrivacyKey.inputPrivacyKeyAddedByPhone; + +export namespace InputPrivacyKey { + export type inputPrivacyKeyStatusTimestamp = { + _: 'inputPrivacyKeyStatusTimestamp' + }; + + export type inputPrivacyKeyChatInvite = { + _: 'inputPrivacyKeyChatInvite' + }; + + export type inputPrivacyKeyPhoneCall = { + _: 'inputPrivacyKeyPhoneCall' + }; + + export type inputPrivacyKeyPhoneP2P = { + _: 'inputPrivacyKeyPhoneP2P' + }; + + export type inputPrivacyKeyForwards = { + _: 'inputPrivacyKeyForwards' + }; + + export type inputPrivacyKeyProfilePhoto = { + _: 'inputPrivacyKeyProfilePhoto' + }; + + export type inputPrivacyKeyPhoneNumber = { + _: 'inputPrivacyKeyPhoneNumber' + }; + + export type inputPrivacyKeyAddedByPhone = { + _: 'inputPrivacyKeyAddedByPhone' + }; +} + +/** + * @link https://core.telegram.org/type/PrivacyKey + */ +export type PrivacyKey = PrivacyKey.privacyKeyStatusTimestamp | PrivacyKey.privacyKeyChatInvite | PrivacyKey.privacyKeyPhoneCall | PrivacyKey.privacyKeyPhoneP2P | PrivacyKey.privacyKeyForwards | PrivacyKey.privacyKeyProfilePhoto | PrivacyKey.privacyKeyPhoneNumber | PrivacyKey.privacyKeyAddedByPhone; + +export namespace PrivacyKey { + export type privacyKeyStatusTimestamp = { + _: 'privacyKeyStatusTimestamp' + }; + + export type privacyKeyChatInvite = { + _: 'privacyKeyChatInvite' + }; + + export type privacyKeyPhoneCall = { + _: 'privacyKeyPhoneCall' + }; + + export type privacyKeyPhoneP2P = { + _: 'privacyKeyPhoneP2P' + }; + + export type privacyKeyForwards = { + _: 'privacyKeyForwards' + }; + + export type privacyKeyProfilePhoto = { + _: 'privacyKeyProfilePhoto' + }; + + export type privacyKeyPhoneNumber = { + _: 'privacyKeyPhoneNumber' + }; + + export type privacyKeyAddedByPhone = { + _: 'privacyKeyAddedByPhone' + }; +} + +/** + * @link https://core.telegram.org/type/InputPrivacyRule + */ +export type InputPrivacyRule = InputPrivacyRule.inputPrivacyValueAllowContacts | InputPrivacyRule.inputPrivacyValueAllowAll | InputPrivacyRule.inputPrivacyValueAllowUsers | InputPrivacyRule.inputPrivacyValueDisallowContacts | InputPrivacyRule.inputPrivacyValueDisallowAll | InputPrivacyRule.inputPrivacyValueDisallowUsers | InputPrivacyRule.inputPrivacyValueAllowChatParticipants | InputPrivacyRule.inputPrivacyValueDisallowChatParticipants; + +export namespace InputPrivacyRule { + export type inputPrivacyValueAllowContacts = { + _: 'inputPrivacyValueAllowContacts' + }; + + export type inputPrivacyValueAllowAll = { + _: 'inputPrivacyValueAllowAll' + }; + + export type inputPrivacyValueAllowUsers = { + _: 'inputPrivacyValueAllowUsers', + users: Array + }; + + export type inputPrivacyValueDisallowContacts = { + _: 'inputPrivacyValueDisallowContacts' + }; + + export type inputPrivacyValueDisallowAll = { + _: 'inputPrivacyValueDisallowAll' + }; + + export type inputPrivacyValueDisallowUsers = { + _: 'inputPrivacyValueDisallowUsers', + users: Array + }; + + export type inputPrivacyValueAllowChatParticipants = { + _: 'inputPrivacyValueAllowChatParticipants', + chats: Array + }; + + export type inputPrivacyValueDisallowChatParticipants = { + _: 'inputPrivacyValueDisallowChatParticipants', + chats: Array + }; +} + +/** + * @link https://core.telegram.org/type/PrivacyRule + */ +export type PrivacyRule = PrivacyRule.privacyValueAllowContacts | PrivacyRule.privacyValueAllowAll | PrivacyRule.privacyValueAllowUsers | PrivacyRule.privacyValueDisallowContacts | PrivacyRule.privacyValueDisallowAll | PrivacyRule.privacyValueDisallowUsers | PrivacyRule.privacyValueAllowChatParticipants | PrivacyRule.privacyValueDisallowChatParticipants; + +export namespace PrivacyRule { + export type privacyValueAllowContacts = { + _: 'privacyValueAllowContacts' + }; + + export type privacyValueAllowAll = { + _: 'privacyValueAllowAll' + }; + + export type privacyValueAllowUsers = { + _: 'privacyValueAllowUsers', + users: Array + }; + + export type privacyValueDisallowContacts = { + _: 'privacyValueDisallowContacts' + }; + + export type privacyValueDisallowAll = { + _: 'privacyValueDisallowAll' + }; + + export type privacyValueDisallowUsers = { + _: 'privacyValueDisallowUsers', + users: Array + }; + + export type privacyValueAllowChatParticipants = { + _: 'privacyValueAllowChatParticipants', + chats: Array + }; + + export type privacyValueDisallowChatParticipants = { + _: 'privacyValueDisallowChatParticipants', + chats: Array + }; +} + +/** + * @link https://core.telegram.org/type/account.PrivacyRules + */ +export type AccountPrivacyRules = AccountPrivacyRules.accountPrivacyRules; + +export namespace AccountPrivacyRules { + export type accountPrivacyRules = { + _: 'account.privacyRules', + rules: Array, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/AccountDaysTTL + */ +export type AccountDaysTTL = AccountDaysTTL.accountDaysTTL; + +export namespace AccountDaysTTL { + export type accountDaysTTL = { + _: 'accountDaysTTL', + days: number + }; +} + +/** + * @link https://core.telegram.org/type/DocumentAttribute + */ +export type DocumentAttribute = DocumentAttribute.documentAttributeImageSize | DocumentAttribute.documentAttributeAnimated | DocumentAttribute.documentAttributeSticker | DocumentAttribute.documentAttributeVideo | DocumentAttribute.documentAttributeAudio | DocumentAttribute.documentAttributeFilename | DocumentAttribute.documentAttributeHasStickers; + +export namespace DocumentAttribute { + export type documentAttributeImageSize = { + _: 'documentAttributeImageSize', + w: number, + h: number + }; + + export type documentAttributeAnimated = { + _: 'documentAttributeAnimated' + }; + + export type documentAttributeSticker = { + _: 'documentAttributeSticker', + flags?: number, + pFlags?: Partial<{ + mask?: true, + }>, + alt: string, + stickerset: InputStickerSet, + mask_coords?: MaskCoords + }; + + export type documentAttributeVideo = { + _: 'documentAttributeVideo', + flags?: number, + pFlags?: Partial<{ + round_message?: true, + supports_streaming?: true, + }>, + duration: number, + w: number, + h: number + }; + + export type documentAttributeAudio = { + _: 'documentAttributeAudio', + flags?: number, + pFlags?: Partial<{ + voice?: true, + }>, + duration: number, + title?: string, + performer?: string, + waveform?: Uint8Array | number[] + }; + + export type documentAttributeFilename = { + _: 'documentAttributeFilename', + file_name: string + }; + + export type documentAttributeHasStickers = { + _: 'documentAttributeHasStickers' + }; +} + +/** + * @link https://core.telegram.org/type/messages.Stickers + */ +export type MessagesStickers = MessagesStickers.messagesStickersNotModified | MessagesStickers.messagesStickers; + +export namespace MessagesStickers { + export type messagesStickersNotModified = { + _: 'messages.stickersNotModified' + }; + + export type messagesStickers = { + _: 'messages.stickers', + hash: number, + stickers: Array + }; +} + +/** + * @link https://core.telegram.org/type/StickerPack + */ +export type StickerPack = StickerPack.stickerPack; + +export namespace StickerPack { + export type stickerPack = { + _: 'stickerPack', + emoticon: string, + documents: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.AllStickers + */ +export type MessagesAllStickers = MessagesAllStickers.messagesAllStickersNotModified | MessagesAllStickers.messagesAllStickers; + +export namespace MessagesAllStickers { + export type messagesAllStickersNotModified = { + _: 'messages.allStickersNotModified' + }; + + export type messagesAllStickers = { + _: 'messages.allStickers', + hash: number, + sets: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.AffectedMessages + */ +export type MessagesAffectedMessages = MessagesAffectedMessages.messagesAffectedMessages; + +export namespace MessagesAffectedMessages { + export type messagesAffectedMessages = { + _: 'messages.affectedMessages', + pts: number, + pts_count: number + }; +} + +/** + * @link https://core.telegram.org/type/WebPage + */ +export type WebPage = WebPage.webPageEmpty | WebPage.webPagePending | WebPage.webPage | WebPage.webPageNotModified; + +export namespace WebPage { + export type webPageEmpty = { + _: 'webPageEmpty', + id: string + }; + + export type webPagePending = { + _: 'webPagePending', + id: string, + date: number + }; + + export type webPage = { + _: 'webPage', + flags?: number, + id: string, + url: string, + display_url: string, + hash: number, + type?: string, + site_name?: string, + title?: string, + description?: string, + photo?: Photo, + embed_url?: string, + embed_type?: string, + embed_width?: number, + embed_height?: number, + duration?: number, + author?: string, + document?: Document, + cached_page?: Page, + attributes?: Array + }; + + export type webPageNotModified = { + _: 'webPageNotModified', + flags?: number, + cached_page_views?: number + }; +} + +/** + * @link https://core.telegram.org/type/Authorization + */ +export type Authorization = Authorization.authorization; + +export namespace Authorization { + export type authorization = { + _: 'authorization', + flags?: number, + pFlags?: Partial<{ + current?: true, + official_app?: true, + password_pending?: true, + }>, + hash: string, + device_model: string, + platform: string, + system_version: string, + api_id: number, + app_name: string, + app_version: string, + date_created: number, + date_active: number, + ip: string, + country: string, + region: string + }; +} + +/** + * @link https://core.telegram.org/type/account.Authorizations + */ +export type AccountAuthorizations = AccountAuthorizations.accountAuthorizations; + +export namespace AccountAuthorizations { + export type accountAuthorizations = { + _: 'account.authorizations', + authorizations: Array + }; +} + +/** + * @link https://core.telegram.org/type/account.Password + */ +export type AccountPassword = AccountPassword.accountPassword; + +export namespace AccountPassword { + export type accountPassword = { + _: 'account.password', + flags?: number, + pFlags?: Partial<{ + has_recovery?: true, + has_secure_values?: true, + has_password?: true, + }>, + current_algo?: PasswordKdfAlgo, + srp_B?: Uint8Array | number[], + srp_id?: string, + hint?: string, + email_unconfirmed_pattern?: string, + new_algo: PasswordKdfAlgo, + new_secure_algo: SecurePasswordKdfAlgo, + secure_random: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/account.PasswordSettings + */ +export type AccountPasswordSettings = AccountPasswordSettings.accountPasswordSettings; + +export namespace AccountPasswordSettings { + export type accountPasswordSettings = { + _: 'account.passwordSettings', + flags?: number, + email?: string, + secure_settings?: SecureSecretSettings + }; +} + +/** + * @link https://core.telegram.org/type/account.PasswordInputSettings + */ +export type AccountPasswordInputSettings = AccountPasswordInputSettings.accountPasswordInputSettings; + +export namespace AccountPasswordInputSettings { + export type accountPasswordInputSettings = { + _: 'account.passwordInputSettings', + flags?: number, + new_algo?: PasswordKdfAlgo, + new_password_hash?: Uint8Array | number[], + hint?: string, + email?: string, + new_secure_settings?: SecureSecretSettings + }; +} + +/** + * @link https://core.telegram.org/type/auth.PasswordRecovery + */ +export type AuthPasswordRecovery = AuthPasswordRecovery.authPasswordRecovery; + +export namespace AuthPasswordRecovery { + export type authPasswordRecovery = { + _: 'auth.passwordRecovery', + email_pattern: string + }; +} + +/** + * @link https://core.telegram.org/type/ReceivedNotifyMessage + */ +export type ReceivedNotifyMessage = ReceivedNotifyMessage.receivedNotifyMessage; + +export namespace ReceivedNotifyMessage { + export type receivedNotifyMessage = { + _: 'receivedNotifyMessage', + id: number, + flags?: number + }; +} + +/** + * @link https://core.telegram.org/type/ExportedChatInvite + */ +export type ExportedChatInvite = ExportedChatInvite.chatInviteEmpty | ExportedChatInvite.chatInviteExported; + +export namespace ExportedChatInvite { + export type chatInviteEmpty = { + _: 'chatInviteEmpty' + }; + + export type chatInviteExported = { + _: 'chatInviteExported', + link: string + }; +} + +/** + * @link https://core.telegram.org/type/ChatInvite + */ +export type ChatInvite = ChatInvite.chatInviteAlready | ChatInvite.chatInvite; + +export namespace ChatInvite { + export type chatInviteAlready = { + _: 'chatInviteAlready', + chat: Chat + }; + + export type chatInvite = { + _: 'chatInvite', + flags?: number, + pFlags?: Partial<{ + channel?: true, + broadcast?: true, + public?: true, + megagroup?: true, + }>, + title: string, + photo: Photo, + participants_count: number, + participants?: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputStickerSet + */ +export type InputStickerSet = InputStickerSet.inputStickerSetEmpty | InputStickerSet.inputStickerSetID | InputStickerSet.inputStickerSetShortName | InputStickerSet.inputStickerSetAnimatedEmoji | InputStickerSet.inputStickerSetDice; + +export namespace InputStickerSet { + export type inputStickerSetEmpty = { + _: 'inputStickerSetEmpty' + }; + + export type inputStickerSetID = { + _: 'inputStickerSetID', + id: string, + access_hash: string + }; + + export type inputStickerSetShortName = { + _: 'inputStickerSetShortName', + short_name: string + }; + + export type inputStickerSetAnimatedEmoji = { + _: 'inputStickerSetAnimatedEmoji' + }; + + export type inputStickerSetDice = { + _: 'inputStickerSetDice', + emoticon: string + }; +} + +/** + * @link https://core.telegram.org/type/StickerSet + */ +export type StickerSet = StickerSet.stickerSet; + +export namespace StickerSet { + export type stickerSet = { + _: 'stickerSet', + flags?: number, + pFlags?: Partial<{ + archived?: true, + official?: true, + masks?: true, + animated?: true, + }>, + installed_date?: number, + id: string, + access_hash: string, + title: string, + short_name: string, + thumb?: PhotoSize, + thumb_dc_id?: number, + count: number, + hash: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.StickerSet + */ +export type MessagesStickerSet = MessagesStickerSet.messagesStickerSet; + +export namespace MessagesStickerSet { + export type messagesStickerSet = { + _: 'messages.stickerSet', + set: StickerSet, + packs: Array, + documents: Array + }; +} + +/** + * @link https://core.telegram.org/type/BotCommand + */ +export type BotCommand = BotCommand.botCommand; + +export namespace BotCommand { + export type botCommand = { + _: 'botCommand', + command: string, + description: string + }; +} + +/** + * @link https://core.telegram.org/type/BotInfo + */ +export type BotInfo = BotInfo.botInfo; + +export namespace BotInfo { + export type botInfo = { + _: 'botInfo', + user_id: number, + description: string, + commands: Array + }; +} + +/** + * @link https://core.telegram.org/type/KeyboardButton + */ +export type KeyboardButton = KeyboardButton.keyboardButton | KeyboardButton.keyboardButtonUrl | KeyboardButton.keyboardButtonCallback | KeyboardButton.keyboardButtonRequestPhone | KeyboardButton.keyboardButtonRequestGeoLocation | KeyboardButton.keyboardButtonSwitchInline | KeyboardButton.keyboardButtonGame | KeyboardButton.keyboardButtonBuy | KeyboardButton.keyboardButtonUrlAuth | KeyboardButton.inputKeyboardButtonUrlAuth | KeyboardButton.keyboardButtonRequestPoll; + +export namespace KeyboardButton { + export type keyboardButton = { + _: 'keyboardButton', + text: string + }; + + export type keyboardButtonUrl = { + _: 'keyboardButtonUrl', + text: string, + url: string + }; + + export type keyboardButtonCallback = { + _: 'keyboardButtonCallback', + text: string, + data: Uint8Array | number[] + }; + + export type keyboardButtonRequestPhone = { + _: 'keyboardButtonRequestPhone', + text: string + }; + + export type keyboardButtonRequestGeoLocation = { + _: 'keyboardButtonRequestGeoLocation', + text: string + }; + + export type keyboardButtonSwitchInline = { + _: 'keyboardButtonSwitchInline', + flags?: number, + pFlags?: Partial<{ + same_peer?: true, + }>, + text: string, + query: string + }; + + export type keyboardButtonGame = { + _: 'keyboardButtonGame', + text: string + }; + + export type keyboardButtonBuy = { + _: 'keyboardButtonBuy', + text: string + }; + + export type keyboardButtonUrlAuth = { + _: 'keyboardButtonUrlAuth', + flags?: number, + text: string, + fwd_text?: string, + url: string, + button_id: number + }; + + export type inputKeyboardButtonUrlAuth = { + _: 'inputKeyboardButtonUrlAuth', + flags?: number, + pFlags?: Partial<{ + request_write_access?: true, + }>, + text: string, + fwd_text?: string, + url: string, + bot: InputUser + }; + + export type keyboardButtonRequestPoll = { + _: 'keyboardButtonRequestPoll', + flags?: number, + quiz?: boolean, + text: string + }; +} + +/** + * @link https://core.telegram.org/type/KeyboardButtonRow + */ +export type KeyboardButtonRow = KeyboardButtonRow.keyboardButtonRow; + +export namespace KeyboardButtonRow { + export type keyboardButtonRow = { + _: 'keyboardButtonRow', + buttons: Array + }; +} + +/** + * @link https://core.telegram.org/type/ReplyMarkup + */ +export type ReplyMarkup = ReplyMarkup.replyKeyboardHide | ReplyMarkup.replyKeyboardForceReply | ReplyMarkup.replyKeyboardMarkup | ReplyMarkup.replyInlineMarkup; + +export namespace ReplyMarkup { + export type replyKeyboardHide = { + _: 'replyKeyboardHide', + flags?: number, + pFlags?: Partial<{ + selective?: true, + }> + }; + + export type replyKeyboardForceReply = { + _: 'replyKeyboardForceReply', + flags?: number, + pFlags?: Partial<{ + single_use?: true, + selective?: true, + }> + }; + + export type replyKeyboardMarkup = { + _: 'replyKeyboardMarkup', + flags?: number, + pFlags?: Partial<{ + resize?: true, + single_use?: true, + selective?: true, + }>, + rows: Array + }; + + export type replyInlineMarkup = { + _: 'replyInlineMarkup', + rows: Array + }; +} + +/** + * @link https://core.telegram.org/type/MessageEntity + */ +export type MessageEntity = MessageEntity.messageEntityUnknown | MessageEntity.messageEntityMention | MessageEntity.messageEntityHashtag | MessageEntity.messageEntityBotCommand | MessageEntity.messageEntityUrl | MessageEntity.messageEntityEmail | MessageEntity.messageEntityBold | MessageEntity.messageEntityItalic | MessageEntity.messageEntityCode | MessageEntity.messageEntityPre | MessageEntity.messageEntityTextUrl | MessageEntity.messageEntityMentionName | MessageEntity.inputMessageEntityMentionName | MessageEntity.messageEntityPhone | MessageEntity.messageEntityCashtag | MessageEntity.messageEntityUnderline | MessageEntity.messageEntityStrike | MessageEntity.messageEntityBlockquote | MessageEntity.messageEntityBankCard; + +export namespace MessageEntity { + export type messageEntityUnknown = { + _: 'messageEntityUnknown', + offset: number, + length: number + }; + + export type messageEntityMention = { + _: 'messageEntityMention', + offset: number, + length: number + }; + + export type messageEntityHashtag = { + _: 'messageEntityHashtag', + offset: number, + length: number + }; + + export type messageEntityBotCommand = { + _: 'messageEntityBotCommand', + offset: number, + length: number + }; + + export type messageEntityUrl = { + _: 'messageEntityUrl', + offset: number, + length: number + }; + + export type messageEntityEmail = { + _: 'messageEntityEmail', + offset: number, + length: number + }; + + export type messageEntityBold = { + _: 'messageEntityBold', + offset: number, + length: number + }; + + export type messageEntityItalic = { + _: 'messageEntityItalic', + offset: number, + length: number + }; + + export type messageEntityCode = { + _: 'messageEntityCode', + offset: number, + length: number + }; + + export type messageEntityPre = { + _: 'messageEntityPre', + offset: number, + length: number, + language: string + }; + + export type messageEntityTextUrl = { + _: 'messageEntityTextUrl', + offset: number, + length: number, + url: string + }; + + export type messageEntityMentionName = { + _: 'messageEntityMentionName', + offset: number, + length: number, + user_id: number + }; + + export type inputMessageEntityMentionName = { + _: 'inputMessageEntityMentionName', + offset: number, + length: number, + user_id: InputUser + }; + + export type messageEntityPhone = { + _: 'messageEntityPhone', + offset: number, + length: number + }; + + export type messageEntityCashtag = { + _: 'messageEntityCashtag', + offset: number, + length: number + }; + + export type messageEntityUnderline = { + _: 'messageEntityUnderline', + offset: number, + length: number + }; + + export type messageEntityStrike = { + _: 'messageEntityStrike', + offset: number, + length: number + }; + + export type messageEntityBlockquote = { + _: 'messageEntityBlockquote', + offset: number, + length: number + }; + + export type messageEntityBankCard = { + _: 'messageEntityBankCard', + offset: number, + length: number + }; +} + +/** + * @link https://core.telegram.org/type/InputChannel + */ +export type InputChannel = InputChannel.inputChannelEmpty | InputChannel.inputChannel | InputChannel.inputChannelFromMessage; + +export namespace InputChannel { + export type inputChannelEmpty = { + _: 'inputChannelEmpty' + }; + + export type inputChannel = { + _: 'inputChannel', + channel_id: number, + access_hash: string + }; + + export type inputChannelFromMessage = { + _: 'inputChannelFromMessage', + peer: InputPeer, + msg_id: number, + channel_id: number + }; +} + +/** + * @link https://core.telegram.org/type/contacts.ResolvedPeer + */ +export type ContactsResolvedPeer = ContactsResolvedPeer.contactsResolvedPeer; + +export namespace ContactsResolvedPeer { + export type contactsResolvedPeer = { + _: 'contacts.resolvedPeer', + peer: Peer, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/MessageRange + */ +export type MessageRange = MessageRange.messageRange; + +export namespace MessageRange { + export type messageRange = { + _: 'messageRange', + min_id: number, + max_id: number + }; +} + +/** + * @link https://core.telegram.org/type/updates.ChannelDifference + */ +export type UpdatesChannelDifference = UpdatesChannelDifference.updatesChannelDifferenceEmpty | UpdatesChannelDifference.updatesChannelDifferenceTooLong | UpdatesChannelDifference.updatesChannelDifference; + +export namespace UpdatesChannelDifference { + export type updatesChannelDifferenceEmpty = { + _: 'updates.channelDifferenceEmpty', + flags?: number, + pFlags?: Partial<{ + final?: true, + }>, + pts: number, + timeout?: number + }; + + export type updatesChannelDifferenceTooLong = { + _: 'updates.channelDifferenceTooLong', + flags?: number, + pFlags?: Partial<{ + final?: true, + }>, + timeout?: number, + dialog: Dialog, + messages: Array, + chats: Array, + users: Array + }; + + export type updatesChannelDifference = { + _: 'updates.channelDifference', + flags?: number, + pFlags?: Partial<{ + final?: true, + }>, + pts: number, + timeout?: number, + new_messages: Array, + other_updates: Array, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/ChannelMessagesFilter + */ +export type ChannelMessagesFilter = ChannelMessagesFilter.channelMessagesFilterEmpty | ChannelMessagesFilter.channelMessagesFilter; + +export namespace ChannelMessagesFilter { + export type channelMessagesFilterEmpty = { + _: 'channelMessagesFilterEmpty' + }; + + export type channelMessagesFilter = { + _: 'channelMessagesFilter', + flags?: number, + pFlags?: Partial<{ + exclude_new_messages?: true, + }>, + ranges: Array + }; +} + +/** + * @link https://core.telegram.org/type/ChannelParticipant + */ +export type ChannelParticipant = ChannelParticipant.channelParticipant | ChannelParticipant.channelParticipantSelf | ChannelParticipant.channelParticipantCreator | ChannelParticipant.channelParticipantAdmin | ChannelParticipant.channelParticipantBanned; + +export namespace ChannelParticipant { + export type channelParticipant = { + _: 'channelParticipant', + user_id: number, + date: number + }; + + export type channelParticipantSelf = { + _: 'channelParticipantSelf', + user_id: number, + inviter_id: number, + date: number + }; + + export type channelParticipantCreator = { + _: 'channelParticipantCreator', + flags?: number, + user_id: number, + rank?: string + }; + + export type channelParticipantAdmin = { + _: 'channelParticipantAdmin', + flags?: number, + pFlags?: Partial<{ + can_edit?: true, + self?: true, + }>, + user_id: number, + inviter_id?: number, + promoted_by: number, + date: number, + admin_rights: ChatAdminRights, + rank?: string + }; + + export type channelParticipantBanned = { + _: 'channelParticipantBanned', + flags?: number, + pFlags?: Partial<{ + left?: true, + }>, + user_id: number, + kicked_by: number, + date: number, + banned_rights: ChatBannedRights + }; +} + +/** + * @link https://core.telegram.org/type/ChannelParticipantsFilter + */ +export type ChannelParticipantsFilter = ChannelParticipantsFilter.channelParticipantsRecent | ChannelParticipantsFilter.channelParticipantsAdmins | ChannelParticipantsFilter.channelParticipantsKicked | ChannelParticipantsFilter.channelParticipantsBots | ChannelParticipantsFilter.channelParticipantsBanned | ChannelParticipantsFilter.channelParticipantsSearch | ChannelParticipantsFilter.channelParticipantsContacts; + +export namespace ChannelParticipantsFilter { + export type channelParticipantsRecent = { + _: 'channelParticipantsRecent' + }; + + export type channelParticipantsAdmins = { + _: 'channelParticipantsAdmins' + }; + + export type channelParticipantsKicked = { + _: 'channelParticipantsKicked', + q: string + }; + + export type channelParticipantsBots = { + _: 'channelParticipantsBots' + }; + + export type channelParticipantsBanned = { + _: 'channelParticipantsBanned', + q: string + }; + + export type channelParticipantsSearch = { + _: 'channelParticipantsSearch', + q: string + }; + + export type channelParticipantsContacts = { + _: 'channelParticipantsContacts', + q: string + }; +} + +/** + * @link https://core.telegram.org/type/channels.ChannelParticipants + */ +export type ChannelsChannelParticipants = ChannelsChannelParticipants.channelsChannelParticipants | ChannelsChannelParticipants.channelsChannelParticipantsNotModified; + +export namespace ChannelsChannelParticipants { + export type channelsChannelParticipants = { + _: 'channels.channelParticipants', + count: number, + participants: Array, + users: Array + }; + + export type channelsChannelParticipantsNotModified = { + _: 'channels.channelParticipantsNotModified' + }; +} + +/** + * @link https://core.telegram.org/type/channels.ChannelParticipant + */ +export type ChannelsChannelParticipant = ChannelsChannelParticipant.channelsChannelParticipant; + +export namespace ChannelsChannelParticipant { + export type channelsChannelParticipant = { + _: 'channels.channelParticipant', + participant: ChannelParticipant, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/help.TermsOfService + */ +export type HelpTermsOfService = HelpTermsOfService.helpTermsOfService; + +export namespace HelpTermsOfService { + export type helpTermsOfService = { + _: 'help.termsOfService', + flags?: number, + pFlags?: Partial<{ + popup?: true, + }>, + id: DataJSON, + text: string, + entities: Array, + min_age_confirm?: number + }; +} + +/** + * @link https://core.telegram.org/type/FoundGif + */ +export type FoundGif = FoundGif.foundGif | FoundGif.foundGifCached; + +export namespace FoundGif { + export type foundGif = { + _: 'foundGif', + url: string, + thumb_url: string, + content_url: string, + content_type: string, + w: number, + h: number + }; + + export type foundGifCached = { + _: 'foundGifCached', + url: string, + photo: Photo, + document: Document + }; +} + +/** + * @link https://core.telegram.org/type/messages.FoundGifs + */ +export type MessagesFoundGifs = MessagesFoundGifs.messagesFoundGifs; + +export namespace MessagesFoundGifs { + export type messagesFoundGifs = { + _: 'messages.foundGifs', + next_offset: number, + results: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.SavedGifs + */ +export type MessagesSavedGifs = MessagesSavedGifs.messagesSavedGifsNotModified | MessagesSavedGifs.messagesSavedGifs; + +export namespace MessagesSavedGifs { + export type messagesSavedGifsNotModified = { + _: 'messages.savedGifsNotModified' + }; + + export type messagesSavedGifs = { + _: 'messages.savedGifs', + hash: number, + gifs: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputBotInlineMessage + */ +export type InputBotInlineMessage = InputBotInlineMessage.inputBotInlineMessageMediaAuto | InputBotInlineMessage.inputBotInlineMessageText | InputBotInlineMessage.inputBotInlineMessageMediaGeo | InputBotInlineMessage.inputBotInlineMessageMediaVenue | InputBotInlineMessage.inputBotInlineMessageMediaContact | InputBotInlineMessage.inputBotInlineMessageGame; + +export namespace InputBotInlineMessage { + export type inputBotInlineMessageMediaAuto = { + _: 'inputBotInlineMessageMediaAuto', + flags?: number, + message: string, + entities?: Array, + reply_markup?: ReplyMarkup + }; + + export type inputBotInlineMessageText = { + _: 'inputBotInlineMessageText', + flags?: number, + pFlags?: Partial<{ + no_webpage?: true, + }>, + message: string, + entities?: Array, + reply_markup?: ReplyMarkup + }; + + export type inputBotInlineMessageMediaGeo = { + _: 'inputBotInlineMessageMediaGeo', + flags?: number, + geo_point: InputGeoPoint, + period: number, + reply_markup?: ReplyMarkup + }; + + export type inputBotInlineMessageMediaVenue = { + _: 'inputBotInlineMessageMediaVenue', + flags?: number, + geo_point: InputGeoPoint, + title: string, + address: string, + provider: string, + venue_id: string, + venue_type: string, + reply_markup?: ReplyMarkup + }; + + export type inputBotInlineMessageMediaContact = { + _: 'inputBotInlineMessageMediaContact', + flags?: number, + phone_number: string, + first_name: string, + last_name: string, + vcard: string, + reply_markup?: ReplyMarkup + }; + + export type inputBotInlineMessageGame = { + _: 'inputBotInlineMessageGame', + flags?: number, + reply_markup?: ReplyMarkup + }; +} + +/** + * @link https://core.telegram.org/type/InputBotInlineResult + */ +export type InputBotInlineResult = InputBotInlineResult.inputBotInlineResult | InputBotInlineResult.inputBotInlineResultPhoto | InputBotInlineResult.inputBotInlineResultDocument | InputBotInlineResult.inputBotInlineResultGame; + +export namespace InputBotInlineResult { + export type inputBotInlineResult = { + _: 'inputBotInlineResult', + flags?: number, + id: string, + type: string, + title?: string, + description?: string, + url?: string, + thumb?: InputWebDocument, + content?: InputWebDocument, + send_message: InputBotInlineMessage + }; + + export type inputBotInlineResultPhoto = { + _: 'inputBotInlineResultPhoto', + id: string, + type: string, + photo: InputPhoto, + send_message: InputBotInlineMessage + }; + + export type inputBotInlineResultDocument = { + _: 'inputBotInlineResultDocument', + flags?: number, + id: string, + type: string, + title?: string, + description?: string, + document: InputDocument, + send_message: InputBotInlineMessage + }; + + export type inputBotInlineResultGame = { + _: 'inputBotInlineResultGame', + id: string, + short_name: string, + send_message: InputBotInlineMessage + }; +} + +/** + * @link https://core.telegram.org/type/BotInlineMessage + */ +export type BotInlineMessage = BotInlineMessage.botInlineMessageMediaAuto | BotInlineMessage.botInlineMessageText | BotInlineMessage.botInlineMessageMediaGeo | BotInlineMessage.botInlineMessageMediaVenue | BotInlineMessage.botInlineMessageMediaContact; + +export namespace BotInlineMessage { + export type botInlineMessageMediaAuto = { + _: 'botInlineMessageMediaAuto', + flags?: number, + message: string, + entities?: Array, + reply_markup?: ReplyMarkup + }; + + export type botInlineMessageText = { + _: 'botInlineMessageText', + flags?: number, + pFlags?: Partial<{ + no_webpage?: true, + }>, + message: string, + entities?: Array, + reply_markup?: ReplyMarkup + }; + + export type botInlineMessageMediaGeo = { + _: 'botInlineMessageMediaGeo', + flags?: number, + geo: GeoPoint, + period: number, + reply_markup?: ReplyMarkup + }; + + export type botInlineMessageMediaVenue = { + _: 'botInlineMessageMediaVenue', + flags?: number, + geo: GeoPoint, + title: string, + address: string, + provider: string, + venue_id: string, + venue_type: string, + reply_markup?: ReplyMarkup + }; + + export type botInlineMessageMediaContact = { + _: 'botInlineMessageMediaContact', + flags?: number, + phone_number: string, + first_name: string, + last_name: string, + vcard: string, + reply_markup?: ReplyMarkup + }; +} + +/** + * @link https://core.telegram.org/type/BotInlineResult + */ +export type BotInlineResult = BotInlineResult.botInlineResult | BotInlineResult.botInlineMediaResult; + +export namespace BotInlineResult { + export type botInlineResult = { + _: 'botInlineResult', + flags?: number, + id: string, + type: string, + title?: string, + description?: string, + url?: string, + thumb?: WebDocument, + content?: WebDocument, + send_message: BotInlineMessage + }; + + export type botInlineMediaResult = { + _: 'botInlineMediaResult', + flags?: number, + id: string, + type: string, + photo?: Photo, + document?: Document, + title?: string, + description?: string, + send_message: BotInlineMessage + }; +} + +/** + * @link https://core.telegram.org/type/messages.BotResults + */ +export type MessagesBotResults = MessagesBotResults.messagesBotResults; + +export namespace MessagesBotResults { + export type messagesBotResults = { + _: 'messages.botResults', + flags?: number, + pFlags?: Partial<{ + gallery?: true, + }>, + query_id: string, + next_offset?: string, + switch_pm?: InlineBotSwitchPM, + results: Array, + cache_time: number, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/ExportedMessageLink + */ +export type ExportedMessageLink = ExportedMessageLink.exportedMessageLink; + +export namespace ExportedMessageLink { + export type exportedMessageLink = { + _: 'exportedMessageLink', + link: string, + html: string + }; +} + +/** + * @link https://core.telegram.org/type/MessageFwdHeader + */ +export type MessageFwdHeader = MessageFwdHeader.messageFwdHeader; + +export namespace MessageFwdHeader { + export type messageFwdHeader = { + _: 'messageFwdHeader', + flags?: number, + from_id?: number, + from_name?: string, + date: number, + channel_id?: number, + channel_post?: number, + post_author?: string, + saved_from_peer?: Peer, + saved_from_msg_id?: number, + psa_type?: string + }; +} + +/** + * @link https://core.telegram.org/type/auth.CodeType + */ +export type AuthCodeType = AuthCodeType.authCodeTypeSms | AuthCodeType.authCodeTypeCall | AuthCodeType.authCodeTypeFlashCall; + +export namespace AuthCodeType { + export type authCodeTypeSms = { + _: 'auth.codeTypeSms' + }; + + export type authCodeTypeCall = { + _: 'auth.codeTypeCall' + }; + + export type authCodeTypeFlashCall = { + _: 'auth.codeTypeFlashCall' + }; +} + +/** + * @link https://core.telegram.org/type/auth.SentCodeType + */ +export type AuthSentCodeType = AuthSentCodeType.authSentCodeTypeApp | AuthSentCodeType.authSentCodeTypeSms | AuthSentCodeType.authSentCodeTypeCall | AuthSentCodeType.authSentCodeTypeFlashCall; + +export namespace AuthSentCodeType { + export type authSentCodeTypeApp = { + _: 'auth.sentCodeTypeApp', + length: number + }; + + export type authSentCodeTypeSms = { + _: 'auth.sentCodeTypeSms', + length: number + }; + + export type authSentCodeTypeCall = { + _: 'auth.sentCodeTypeCall', + length: number + }; + + export type authSentCodeTypeFlashCall = { + _: 'auth.sentCodeTypeFlashCall', + pattern: string + }; +} + +/** + * @link https://core.telegram.org/type/messages.BotCallbackAnswer + */ +export type MessagesBotCallbackAnswer = MessagesBotCallbackAnswer.messagesBotCallbackAnswer; + +export namespace MessagesBotCallbackAnswer { + export type messagesBotCallbackAnswer = { + _: 'messages.botCallbackAnswer', + flags?: number, + pFlags?: Partial<{ + alert?: true, + has_url?: true, + native_ui?: true, + }>, + message?: string, + url?: string, + cache_time: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.MessageEditData + */ +export type MessagesMessageEditData = MessagesMessageEditData.messagesMessageEditData; + +export namespace MessagesMessageEditData { + export type messagesMessageEditData = { + _: 'messages.messageEditData', + flags?: number, + pFlags?: Partial<{ + caption?: true, + }> + }; +} + +/** + * @link https://core.telegram.org/type/InputBotInlineMessageID + */ +export type InputBotInlineMessageID = InputBotInlineMessageID.inputBotInlineMessageID; + +export namespace InputBotInlineMessageID { + export type inputBotInlineMessageID = { + _: 'inputBotInlineMessageID', + dc_id: number, + id: string, + access_hash: string + }; +} + +/** + * @link https://core.telegram.org/type/InlineBotSwitchPM + */ +export type InlineBotSwitchPM = InlineBotSwitchPM.inlineBotSwitchPM; + +export namespace InlineBotSwitchPM { + export type inlineBotSwitchPM = { + _: 'inlineBotSwitchPM', + text: string, + start_param: string + }; +} + +/** + * @link https://core.telegram.org/type/messages.PeerDialogs + */ +export type MessagesPeerDialogs = MessagesPeerDialogs.messagesPeerDialogs; + +export namespace MessagesPeerDialogs { + export type messagesPeerDialogs = { + _: 'messages.peerDialogs', + dialogs: Array, + messages: Array, + chats: Array, + users: Array, + state: UpdatesState + }; +} + +/** + * @link https://core.telegram.org/type/TopPeer + */ +export type TopPeer = TopPeer.topPeer; + +export namespace TopPeer { + export type topPeer = { + _: 'topPeer', + peer: Peer, + rating: number + }; +} + +/** + * @link https://core.telegram.org/type/TopPeerCategory + */ +export type TopPeerCategory = TopPeerCategory.topPeerCategoryBotsPM | TopPeerCategory.topPeerCategoryBotsInline | TopPeerCategory.topPeerCategoryCorrespondents | TopPeerCategory.topPeerCategoryGroups | TopPeerCategory.topPeerCategoryChannels | TopPeerCategory.topPeerCategoryPhoneCalls | TopPeerCategory.topPeerCategoryForwardUsers | TopPeerCategory.topPeerCategoryForwardChats; + +export namespace TopPeerCategory { + export type topPeerCategoryBotsPM = { + _: 'topPeerCategoryBotsPM' + }; + + export type topPeerCategoryBotsInline = { + _: 'topPeerCategoryBotsInline' + }; + + export type topPeerCategoryCorrespondents = { + _: 'topPeerCategoryCorrespondents' + }; + + export type topPeerCategoryGroups = { + _: 'topPeerCategoryGroups' + }; + + export type topPeerCategoryChannels = { + _: 'topPeerCategoryChannels' + }; + + export type topPeerCategoryPhoneCalls = { + _: 'topPeerCategoryPhoneCalls' + }; + + export type topPeerCategoryForwardUsers = { + _: 'topPeerCategoryForwardUsers' + }; + + export type topPeerCategoryForwardChats = { + _: 'topPeerCategoryForwardChats' + }; +} + +/** + * @link https://core.telegram.org/type/TopPeerCategoryPeers + */ +export type TopPeerCategoryPeers = TopPeerCategoryPeers.topPeerCategoryPeers; + +export namespace TopPeerCategoryPeers { + export type topPeerCategoryPeers = { + _: 'topPeerCategoryPeers', + category: TopPeerCategory, + count: number, + peers: Array + }; +} + +/** + * @link https://core.telegram.org/type/contacts.TopPeers + */ +export type ContactsTopPeers = ContactsTopPeers.contactsTopPeersNotModified | ContactsTopPeers.contactsTopPeers | ContactsTopPeers.contactsTopPeersDisabled; + +export namespace ContactsTopPeers { + export type contactsTopPeersNotModified = { + _: 'contacts.topPeersNotModified' + }; + + export type contactsTopPeers = { + _: 'contacts.topPeers', + categories: Array, + chats: Array, + users: Array + }; + + export type contactsTopPeersDisabled = { + _: 'contacts.topPeersDisabled' + }; +} + +/** + * @link https://core.telegram.org/type/DraftMessage + */ +export type DraftMessage = DraftMessage.draftMessageEmpty | DraftMessage.draftMessage; + +export namespace DraftMessage { + export type draftMessageEmpty = { + _: 'draftMessageEmpty', + flags?: number, + date?: number + }; + + export type draftMessage = { + _: 'draftMessage', + flags?: number, + pFlags?: Partial<{ + no_webpage?: true, + }>, + reply_to_msg_id?: number, + message: string, + entities?: Array, + date: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.FeaturedStickers + */ +export type MessagesFeaturedStickers = MessagesFeaturedStickers.messagesFeaturedStickersNotModified | MessagesFeaturedStickers.messagesFeaturedStickers; + +export namespace MessagesFeaturedStickers { + export type messagesFeaturedStickersNotModified = { + _: 'messages.featuredStickersNotModified', + count: number + }; + + export type messagesFeaturedStickers = { + _: 'messages.featuredStickers', + hash: number, + count: number, + sets: Array, + unread: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.RecentStickers + */ +export type MessagesRecentStickers = MessagesRecentStickers.messagesRecentStickersNotModified | MessagesRecentStickers.messagesRecentStickers; + +export namespace MessagesRecentStickers { + export type messagesRecentStickersNotModified = { + _: 'messages.recentStickersNotModified' + }; + + export type messagesRecentStickers = { + _: 'messages.recentStickers', + hash: number, + packs: Array, + stickers: Array, + dates: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.ArchivedStickers + */ +export type MessagesArchivedStickers = MessagesArchivedStickers.messagesArchivedStickers; + +export namespace MessagesArchivedStickers { + export type messagesArchivedStickers = { + _: 'messages.archivedStickers', + count: number, + sets: Array + }; +} + +/** + * @link https://core.telegram.org/type/messages.StickerSetInstallResult + */ +export type MessagesStickerSetInstallResult = MessagesStickerSetInstallResult.messagesStickerSetInstallResultSuccess | MessagesStickerSetInstallResult.messagesStickerSetInstallResultArchive; + +export namespace MessagesStickerSetInstallResult { + export type messagesStickerSetInstallResultSuccess = { + _: 'messages.stickerSetInstallResultSuccess' + }; + + export type messagesStickerSetInstallResultArchive = { + _: 'messages.stickerSetInstallResultArchive', + sets: Array + }; +} + +/** + * @link https://core.telegram.org/type/StickerSetCovered + */ +export type StickerSetCovered = StickerSetCovered.stickerSetCovered | StickerSetCovered.stickerSetMultiCovered; + +export namespace StickerSetCovered { + export type stickerSetCovered = { + _: 'stickerSetCovered', + set: StickerSet, + cover: Document + }; + + export type stickerSetMultiCovered = { + _: 'stickerSetMultiCovered', + set: StickerSet, + covers: Array + }; +} + +/** + * @link https://core.telegram.org/type/MaskCoords + */ +export type MaskCoords = MaskCoords.maskCoords; + +export namespace MaskCoords { + export type maskCoords = { + _: 'maskCoords', + n: number, + x: number, + y: number, + zoom: number + }; +} + +/** + * @link https://core.telegram.org/type/InputStickeredMedia + */ +export type InputStickeredMedia = InputStickeredMedia.inputStickeredMediaPhoto | InputStickeredMedia.inputStickeredMediaDocument; + +export namespace InputStickeredMedia { + export type inputStickeredMediaPhoto = { + _: 'inputStickeredMediaPhoto', + id: InputPhoto + }; + + export type inputStickeredMediaDocument = { + _: 'inputStickeredMediaDocument', + id: InputDocument + }; +} + +/** + * @link https://core.telegram.org/type/Game + */ +export type Game = Game.game; + +export namespace Game { + export type game = { + _: 'game', + flags?: number, + id: string, + access_hash: string, + short_name: string, + title: string, + description: string, + photo: Photo, + document?: Document + }; +} + +/** + * @link https://core.telegram.org/type/InputGame + */ +export type InputGame = InputGame.inputGameID | InputGame.inputGameShortName; + +export namespace InputGame { + export type inputGameID = { + _: 'inputGameID', + id: string, + access_hash: string + }; + + export type inputGameShortName = { + _: 'inputGameShortName', + bot_id: InputUser, + short_name: string + }; +} + +/** + * @link https://core.telegram.org/type/HighScore + */ +export type HighScore = HighScore.highScore; + +export namespace HighScore { + export type highScore = { + _: 'highScore', + pos: number, + user_id: number, + score: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.HighScores + */ +export type MessagesHighScores = MessagesHighScores.messagesHighScores; + +export namespace MessagesHighScores { + export type messagesHighScores = { + _: 'messages.highScores', + scores: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/RichText + */ +export type RichText = RichText.textEmpty | RichText.textPlain | RichText.textBold | RichText.textItalic | RichText.textUnderline | RichText.textStrike | RichText.textFixed | RichText.textUrl | RichText.textEmail | RichText.textConcat | RichText.textSubscript | RichText.textSuperscript | RichText.textMarked | RichText.textPhone | RichText.textImage | RichText.textAnchor; + +export namespace RichText { + export type textEmpty = { + _: 'textEmpty' + }; + + export type textPlain = { + _: 'textPlain', + text: string + }; + + export type textBold = { + _: 'textBold', + text: RichText + }; + + export type textItalic = { + _: 'textItalic', + text: RichText + }; + + export type textUnderline = { + _: 'textUnderline', + text: RichText + }; + + export type textStrike = { + _: 'textStrike', + text: RichText + }; + + export type textFixed = { + _: 'textFixed', + text: RichText + }; + + export type textUrl = { + _: 'textUrl', + text: RichText, + url: string, + webpage_id: string + }; + + export type textEmail = { + _: 'textEmail', + text: RichText, + email: string + }; + + export type textConcat = { + _: 'textConcat', + texts: Array + }; + + export type textSubscript = { + _: 'textSubscript', + text: RichText + }; + + export type textSuperscript = { + _: 'textSuperscript', + text: RichText + }; + + export type textMarked = { + _: 'textMarked', + text: RichText + }; + + export type textPhone = { + _: 'textPhone', + text: RichText, + phone: string + }; + + export type textImage = { + _: 'textImage', + document_id: string, + w: number, + h: number + }; + + export type textAnchor = { + _: 'textAnchor', + text: RichText, + name: string + }; +} + +/** + * @link https://core.telegram.org/type/PageBlock + */ +export type PageBlock = PageBlock.pageBlockUnsupported | PageBlock.pageBlockTitle | PageBlock.pageBlockSubtitle | PageBlock.pageBlockAuthorDate | PageBlock.pageBlockHeader | PageBlock.pageBlockSubheader | PageBlock.pageBlockParagraph | PageBlock.pageBlockPreformatted | PageBlock.pageBlockFooter | PageBlock.pageBlockDivider | PageBlock.pageBlockAnchor | PageBlock.pageBlockList | PageBlock.pageBlockBlockquote | PageBlock.pageBlockPullquote | PageBlock.pageBlockPhoto | PageBlock.pageBlockVideo | PageBlock.pageBlockCover | PageBlock.pageBlockEmbed | PageBlock.pageBlockEmbedPost | PageBlock.pageBlockCollage | PageBlock.pageBlockSlideshow | PageBlock.pageBlockChannel | PageBlock.pageBlockAudio | PageBlock.pageBlockKicker | PageBlock.pageBlockTable | PageBlock.pageBlockOrderedList | PageBlock.pageBlockDetails | PageBlock.pageBlockRelatedArticles | PageBlock.pageBlockMap; + +export namespace PageBlock { + export type pageBlockUnsupported = { + _: 'pageBlockUnsupported' + }; + + export type pageBlockTitle = { + _: 'pageBlockTitle', + text: RichText + }; + + export type pageBlockSubtitle = { + _: 'pageBlockSubtitle', + text: RichText + }; + + export type pageBlockAuthorDate = { + _: 'pageBlockAuthorDate', + author: RichText, + published_date: number + }; + + export type pageBlockHeader = { + _: 'pageBlockHeader', + text: RichText + }; + + export type pageBlockSubheader = { + _: 'pageBlockSubheader', + text: RichText + }; + + export type pageBlockParagraph = { + _: 'pageBlockParagraph', + text: RichText + }; + + export type pageBlockPreformatted = { + _: 'pageBlockPreformatted', + text: RichText, + language: string + }; + + export type pageBlockFooter = { + _: 'pageBlockFooter', + text: RichText + }; + + export type pageBlockDivider = { + _: 'pageBlockDivider' + }; + + export type pageBlockAnchor = { + _: 'pageBlockAnchor', + name: string + }; + + export type pageBlockList = { + _: 'pageBlockList', + items: Array + }; + + export type pageBlockBlockquote = { + _: 'pageBlockBlockquote', + text: RichText, + caption: RichText + }; + + export type pageBlockPullquote = { + _: 'pageBlockPullquote', + text: RichText, + caption: RichText + }; + + export type pageBlockPhoto = { + _: 'pageBlockPhoto', + flags?: number, + photo_id: string, + caption: PageCaption, + url?: string, + webpage_id?: string + }; + + export type pageBlockVideo = { + _: 'pageBlockVideo', + flags?: number, + pFlags?: Partial<{ + autoplay?: true, + loop?: true, + }>, + video_id: string, + caption: PageCaption + }; + + export type pageBlockCover = { + _: 'pageBlockCover', + cover: PageBlock + }; + + export type pageBlockEmbed = { + _: 'pageBlockEmbed', + flags?: number, + pFlags?: Partial<{ + full_width?: true, + allow_scrolling?: true, + }>, + url?: string, + html?: string, + poster_photo_id?: string, + w?: number, + h?: number, + caption: PageCaption + }; + + export type pageBlockEmbedPost = { + _: 'pageBlockEmbedPost', + url: string, + webpage_id: string, + author_photo_id: string, + author: string, + date: number, + blocks: Array, + caption: PageCaption + }; + + export type pageBlockCollage = { + _: 'pageBlockCollage', + items: Array, + caption: PageCaption + }; + + export type pageBlockSlideshow = { + _: 'pageBlockSlideshow', + items: Array, + caption: PageCaption + }; + + export type pageBlockChannel = { + _: 'pageBlockChannel', + channel: Chat + }; + + export type pageBlockAudio = { + _: 'pageBlockAudio', + audio_id: string, + caption: PageCaption + }; + + export type pageBlockKicker = { + _: 'pageBlockKicker', + text: RichText + }; + + export type pageBlockTable = { + _: 'pageBlockTable', + flags?: number, + pFlags?: Partial<{ + bordered?: true, + striped?: true, + }>, + title: RichText, + rows: Array + }; + + export type pageBlockOrderedList = { + _: 'pageBlockOrderedList', + items: Array + }; + + export type pageBlockDetails = { + _: 'pageBlockDetails', + flags?: number, + pFlags?: Partial<{ + open?: true, + }>, + blocks: Array, + title: RichText + }; + + export type pageBlockRelatedArticles = { + _: 'pageBlockRelatedArticles', + title: RichText, + articles: Array + }; + + export type pageBlockMap = { + _: 'pageBlockMap', + geo: GeoPoint, + zoom: number, + w: number, + h: number, + caption: PageCaption + }; +} + +/** + * @link https://core.telegram.org/type/PhoneCallDiscardReason + */ +export type PhoneCallDiscardReason = PhoneCallDiscardReason.phoneCallDiscardReasonMissed | PhoneCallDiscardReason.phoneCallDiscardReasonDisconnect | PhoneCallDiscardReason.phoneCallDiscardReasonHangup | PhoneCallDiscardReason.phoneCallDiscardReasonBusy; + +export namespace PhoneCallDiscardReason { + export type phoneCallDiscardReasonMissed = { + _: 'phoneCallDiscardReasonMissed' + }; + + export type phoneCallDiscardReasonDisconnect = { + _: 'phoneCallDiscardReasonDisconnect' + }; + + export type phoneCallDiscardReasonHangup = { + _: 'phoneCallDiscardReasonHangup' + }; + + export type phoneCallDiscardReasonBusy = { + _: 'phoneCallDiscardReasonBusy' + }; +} + +/** + * @link https://core.telegram.org/type/DataJSON + */ +export type DataJSON = DataJSON.dataJSON; + +export namespace DataJSON { + export type dataJSON = { + _: 'dataJSON', + data: string + }; +} + +/** + * @link https://core.telegram.org/type/LabeledPrice + */ +export type LabeledPrice = LabeledPrice.labeledPrice; + +export namespace LabeledPrice { + export type labeledPrice = { + _: 'labeledPrice', + label: string, + amount: string + }; +} + +/** + * @link https://core.telegram.org/type/Invoice + */ +export type Invoice = Invoice.invoice; + +export namespace Invoice { + export type invoice = { + _: 'invoice', + flags?: number, + pFlags?: Partial<{ + test?: true, + name_requested?: true, + phone_requested?: true, + email_requested?: true, + shipping_address_requested?: true, + flexible?: true, + phone_to_provider?: true, + email_to_provider?: true, + }>, + currency: string, + prices: Array + }; +} + +/** + * @link https://core.telegram.org/type/PaymentCharge + */ +export type PaymentCharge = PaymentCharge.paymentCharge; + +export namespace PaymentCharge { + export type paymentCharge = { + _: 'paymentCharge', + id: string, + provider_charge_id: string + }; +} + +/** + * @link https://core.telegram.org/type/PostAddress + */ +export type PostAddress = PostAddress.postAddress; + +export namespace PostAddress { + export type postAddress = { + _: 'postAddress', + street_line1: string, + street_line2: string, + city: string, + state: string, + country_iso2: string, + post_code: string + }; +} + +/** + * @link https://core.telegram.org/type/PaymentRequestedInfo + */ +export type PaymentRequestedInfo = PaymentRequestedInfo.paymentRequestedInfo; + +export namespace PaymentRequestedInfo { + export type paymentRequestedInfo = { + _: 'paymentRequestedInfo', + flags?: number, + name?: string, + phone?: string, + email?: string, + shipping_address?: PostAddress + }; +} + +/** + * @link https://core.telegram.org/type/PaymentSavedCredentials + */ +export type PaymentSavedCredentials = PaymentSavedCredentials.paymentSavedCredentialsCard; + +export namespace PaymentSavedCredentials { + export type paymentSavedCredentialsCard = { + _: 'paymentSavedCredentialsCard', + id: string, + title: string + }; +} + +/** + * @link https://core.telegram.org/type/WebDocument + */ +export type WebDocument = WebDocument.webDocument | WebDocument.webDocumentNoProxy; + +export namespace WebDocument { + export type webDocument = { + _: 'webDocument', + url: string, + access_hash: string, + size: number, + mime_type: string, + attributes: Array + }; + + export type webDocumentNoProxy = { + _: 'webDocumentNoProxy', + url: string, + size: number, + mime_type: string, + attributes: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputWebDocument + */ +export type InputWebDocument = InputWebDocument.inputWebDocument; + +export namespace InputWebDocument { + export type inputWebDocument = { + _: 'inputWebDocument', + url: string, + size: number, + mime_type: string, + attributes: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputWebFileLocation + */ +export type InputWebFileLocation = InputWebFileLocation.inputWebFileLocation | InputWebFileLocation.inputWebFileGeoPointLocation; + +export namespace InputWebFileLocation { + export type inputWebFileLocation = { + _: 'inputWebFileLocation', + url: string, + access_hash: string + }; + + export type inputWebFileGeoPointLocation = { + _: 'inputWebFileGeoPointLocation', + geo_point: InputGeoPoint, + access_hash: string, + w: number, + h: number, + zoom: number, + scale: number + }; +} + +/** + * @link https://core.telegram.org/type/upload.WebFile + */ +export type UploadWebFile = UploadWebFile.uploadWebFile; + +export namespace UploadWebFile { + export type uploadWebFile = { + _: 'upload.webFile', + size: number, + mime_type: string, + file_type: StorageFileType, + mtime: number, + bytes: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/payments.PaymentForm + */ +export type PaymentsPaymentForm = PaymentsPaymentForm.paymentsPaymentForm; + +export namespace PaymentsPaymentForm { + export type paymentsPaymentForm = { + _: 'payments.paymentForm', + flags?: number, + pFlags?: Partial<{ + can_save_credentials?: true, + password_missing?: true, + }>, + bot_id: number, + invoice: Invoice, + provider_id: number, + url: string, + native_provider?: string, + native_params?: DataJSON, + saved_info?: PaymentRequestedInfo, + saved_credentials?: PaymentSavedCredentials, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/payments.ValidatedRequestedInfo + */ +export type PaymentsValidatedRequestedInfo = PaymentsValidatedRequestedInfo.paymentsValidatedRequestedInfo; + +export namespace PaymentsValidatedRequestedInfo { + export type paymentsValidatedRequestedInfo = { + _: 'payments.validatedRequestedInfo', + flags?: number, + id?: string, + shipping_options?: Array + }; +} + +/** + * @link https://core.telegram.org/type/payments.PaymentResult + */ +export type PaymentsPaymentResult = PaymentsPaymentResult.paymentsPaymentResult | PaymentsPaymentResult.paymentsPaymentVerificationNeeded; + +export namespace PaymentsPaymentResult { + export type paymentsPaymentResult = { + _: 'payments.paymentResult', + updates: Updates + }; + + export type paymentsPaymentVerificationNeeded = { + _: 'payments.paymentVerificationNeeded', + url: string + }; +} + +/** + * @link https://core.telegram.org/type/payments.PaymentReceipt + */ +export type PaymentsPaymentReceipt = PaymentsPaymentReceipt.paymentsPaymentReceipt; + +export namespace PaymentsPaymentReceipt { + export type paymentsPaymentReceipt = { + _: 'payments.paymentReceipt', + flags?: number, + date: number, + bot_id: number, + invoice: Invoice, + provider_id: number, + info?: PaymentRequestedInfo, + shipping?: ShippingOption, + currency: string, + total_amount: string, + credentials_title: string, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/payments.SavedInfo + */ +export type PaymentsSavedInfo = PaymentsSavedInfo.paymentsSavedInfo; + +export namespace PaymentsSavedInfo { + export type paymentsSavedInfo = { + _: 'payments.savedInfo', + flags?: number, + pFlags?: Partial<{ + has_saved_credentials?: true, + }>, + saved_info?: PaymentRequestedInfo + }; +} + +/** + * @link https://core.telegram.org/type/InputPaymentCredentials + */ +export type InputPaymentCredentials = InputPaymentCredentials.inputPaymentCredentialsSaved | InputPaymentCredentials.inputPaymentCredentials | InputPaymentCredentials.inputPaymentCredentialsApplePay | InputPaymentCredentials.inputPaymentCredentialsAndroidPay; + +export namespace InputPaymentCredentials { + export type inputPaymentCredentialsSaved = { + _: 'inputPaymentCredentialsSaved', + id: string, + tmp_password: Uint8Array | number[] + }; + + export type inputPaymentCredentials = { + _: 'inputPaymentCredentials', + flags?: number, + pFlags?: Partial<{ + save?: true, + }>, + data: DataJSON + }; + + export type inputPaymentCredentialsApplePay = { + _: 'inputPaymentCredentialsApplePay', + payment_data: DataJSON + }; + + export type inputPaymentCredentialsAndroidPay = { + _: 'inputPaymentCredentialsAndroidPay', + payment_token: DataJSON, + google_transaction_id: string + }; +} + +/** + * @link https://core.telegram.org/type/account.TmpPassword + */ +export type AccountTmpPassword = AccountTmpPassword.accountTmpPassword; + +export namespace AccountTmpPassword { + export type accountTmpPassword = { + _: 'account.tmpPassword', + tmp_password: Uint8Array | number[], + valid_until: number + }; +} + +/** + * @link https://core.telegram.org/type/ShippingOption + */ +export type ShippingOption = ShippingOption.shippingOption; + +export namespace ShippingOption { + export type shippingOption = { + _: 'shippingOption', + id: string, + title: string, + prices: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputStickerSetItem + */ +export type InputStickerSetItem = InputStickerSetItem.inputStickerSetItem; + +export namespace InputStickerSetItem { + export type inputStickerSetItem = { + _: 'inputStickerSetItem', + flags?: number, + document: InputDocument, + emoji: string, + mask_coords?: MaskCoords + }; +} + +/** + * @link https://core.telegram.org/type/InputPhoneCall + */ +export type InputPhoneCall = InputPhoneCall.inputPhoneCall; + +export namespace InputPhoneCall { + export type inputPhoneCall = { + _: 'inputPhoneCall', + id: string, + access_hash: string + }; +} + +/** + * @link https://core.telegram.org/type/PhoneCall + */ +export type PhoneCall = PhoneCall.phoneCallEmpty | PhoneCall.phoneCallWaiting | PhoneCall.phoneCallRequested | PhoneCall.phoneCallAccepted | PhoneCall.phoneCall | PhoneCall.phoneCallDiscarded; + +export namespace PhoneCall { + export type phoneCallEmpty = { + _: 'phoneCallEmpty', + id: string + }; + + export type phoneCallWaiting = { + _: 'phoneCallWaiting', + flags?: number, + pFlags?: Partial<{ + video?: true, + }>, + id: string, + access_hash: string, + date: number, + admin_id: number, + participant_id: number, + protocol: PhoneCallProtocol, + receive_date?: number + }; + + export type phoneCallRequested = { + _: 'phoneCallRequested', + flags?: number, + pFlags?: Partial<{ + video?: true, + }>, + id: string, + access_hash: string, + date: number, + admin_id: number, + participant_id: number, + g_a_hash: Uint8Array | number[], + protocol: PhoneCallProtocol + }; + + export type phoneCallAccepted = { + _: 'phoneCallAccepted', + flags?: number, + pFlags?: Partial<{ + video?: true, + }>, + id: string, + access_hash: string, + date: number, + admin_id: number, + participant_id: number, + g_b: Uint8Array | number[], + protocol: PhoneCallProtocol + }; + + export type phoneCall = { + _: 'phoneCall', + flags?: number, + pFlags?: Partial<{ + p2p_allowed?: true, + }>, + id: string, + access_hash: string, + date: number, + admin_id: number, + participant_id: number, + g_a_or_b: Uint8Array | number[], + key_fingerprint: string, + protocol: PhoneCallProtocol, + connections: Array, + start_date: number + }; + + export type phoneCallDiscarded = { + _: 'phoneCallDiscarded', + flags?: number, + pFlags?: Partial<{ + need_rating?: true, + need_debug?: true, + video?: true, + }>, + id: string, + reason?: PhoneCallDiscardReason, + duration?: number + }; +} + +/** + * @link https://core.telegram.org/type/PhoneConnection + */ +export type PhoneConnection = PhoneConnection.phoneConnection; + +export namespace PhoneConnection { + export type phoneConnection = { + _: 'phoneConnection', + id: string, + ip: string, + ipv6: string, + port: number, + peer_tag: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/PhoneCallProtocol + */ +export type PhoneCallProtocol = PhoneCallProtocol.phoneCallProtocol; + +export namespace PhoneCallProtocol { + export type phoneCallProtocol = { + _: 'phoneCallProtocol', + flags?: number, + pFlags?: Partial<{ + udp_p2p?: true, + udp_reflector?: true, + }>, + min_layer: number, + max_layer: number, + library_versions: Array + }; +} + +/** + * @link https://core.telegram.org/type/phone.PhoneCall + */ +export type PhonePhoneCall = PhonePhoneCall.phonePhoneCall; + +export namespace PhonePhoneCall { + export type phonePhoneCall = { + _: 'phone.phoneCall', + phone_call: PhoneCall, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/upload.CdnFile + */ +export type UploadCdnFile = UploadCdnFile.uploadCdnFileReuploadNeeded | UploadCdnFile.uploadCdnFile; + +export namespace UploadCdnFile { + export type uploadCdnFileReuploadNeeded = { + _: 'upload.cdnFileReuploadNeeded', + request_token: Uint8Array | number[] + }; + + export type uploadCdnFile = { + _: 'upload.cdnFile', + bytes: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/CdnPublicKey + */ +export type CdnPublicKey = CdnPublicKey.cdnPublicKey; + +export namespace CdnPublicKey { + export type cdnPublicKey = { + _: 'cdnPublicKey', + dc_id: number, + public_key: string + }; +} + +/** + * @link https://core.telegram.org/type/CdnConfig + */ +export type CdnConfig = CdnConfig.cdnConfig; + +export namespace CdnConfig { + export type cdnConfig = { + _: 'cdnConfig', + public_keys: Array + }; +} + +/** + * @link https://core.telegram.org/type/LangPackString + */ +export type LangPackString = LangPackString.langPackString | LangPackString.langPackStringPluralized | LangPackString.langPackStringDeleted; + +export namespace LangPackString { + export type langPackString = { + _: 'langPackString', + key: string, + value: string + }; + + export type langPackStringPluralized = { + _: 'langPackStringPluralized', + flags?: number, + key: string, + zero_value?: string, + one_value?: string, + two_value?: string, + few_value?: string, + many_value?: string, + other_value: string + }; + + export type langPackStringDeleted = { + _: 'langPackStringDeleted', + key: string + }; +} + +/** + * @link https://core.telegram.org/type/LangPackDifference + */ +export type LangPackDifference = LangPackDifference.langPackDifference; + +export namespace LangPackDifference { + export type langPackDifference = { + _: 'langPackDifference', + lang_code: string, + from_version: number, + version: number, + strings: Array + }; +} + +/** + * @link https://core.telegram.org/type/LangPackLanguage + */ +export type LangPackLanguage = LangPackLanguage.langPackLanguage; + +export namespace LangPackLanguage { + export type langPackLanguage = { + _: 'langPackLanguage', + flags?: number, + pFlags?: Partial<{ + official?: true, + rtl?: true, + beta?: true, + }>, + name: string, + native_name: string, + lang_code: string, + base_lang_code?: string, + plural_code: string, + strings_count: number, + translated_count: number, + translations_url: string + }; +} + +/** + * @link https://core.telegram.org/type/ChannelAdminLogEventAction + */ +export type ChannelAdminLogEventAction = ChannelAdminLogEventAction.channelAdminLogEventActionChangeTitle | ChannelAdminLogEventAction.channelAdminLogEventActionChangeAbout | ChannelAdminLogEventAction.channelAdminLogEventActionChangeUsername | ChannelAdminLogEventAction.channelAdminLogEventActionChangePhoto | ChannelAdminLogEventAction.channelAdminLogEventActionToggleInvites | ChannelAdminLogEventAction.channelAdminLogEventActionToggleSignatures | ChannelAdminLogEventAction.channelAdminLogEventActionUpdatePinned | ChannelAdminLogEventAction.channelAdminLogEventActionEditMessage | ChannelAdminLogEventAction.channelAdminLogEventActionDeleteMessage | ChannelAdminLogEventAction.channelAdminLogEventActionParticipantJoin | ChannelAdminLogEventAction.channelAdminLogEventActionParticipantLeave | ChannelAdminLogEventAction.channelAdminLogEventActionParticipantInvite | ChannelAdminLogEventAction.channelAdminLogEventActionParticipantToggleBan | ChannelAdminLogEventAction.channelAdminLogEventActionParticipantToggleAdmin | ChannelAdminLogEventAction.channelAdminLogEventActionChangeStickerSet | ChannelAdminLogEventAction.channelAdminLogEventActionTogglePreHistoryHidden | ChannelAdminLogEventAction.channelAdminLogEventActionDefaultBannedRights | ChannelAdminLogEventAction.channelAdminLogEventActionStopPoll | ChannelAdminLogEventAction.channelAdminLogEventActionChangeLinkedChat | ChannelAdminLogEventAction.channelAdminLogEventActionChangeLocation | ChannelAdminLogEventAction.channelAdminLogEventActionToggleSlowMode; + +export namespace ChannelAdminLogEventAction { + export type channelAdminLogEventActionChangeTitle = { + _: 'channelAdminLogEventActionChangeTitle', + prev_value: string, + new_value: string + }; + + export type channelAdminLogEventActionChangeAbout = { + _: 'channelAdminLogEventActionChangeAbout', + prev_value: string, + new_value: string + }; + + export type channelAdminLogEventActionChangeUsername = { + _: 'channelAdminLogEventActionChangeUsername', + prev_value: string, + new_value: string + }; + + export type channelAdminLogEventActionChangePhoto = { + _: 'channelAdminLogEventActionChangePhoto', + prev_photo: Photo, + new_photo: Photo + }; + + export type channelAdminLogEventActionToggleInvites = { + _: 'channelAdminLogEventActionToggleInvites', + new_value: boolean + }; + + export type channelAdminLogEventActionToggleSignatures = { + _: 'channelAdminLogEventActionToggleSignatures', + new_value: boolean + }; + + export type channelAdminLogEventActionUpdatePinned = { + _: 'channelAdminLogEventActionUpdatePinned', + message: Message + }; + + export type channelAdminLogEventActionEditMessage = { + _: 'channelAdminLogEventActionEditMessage', + prev_message: Message, + new_message: Message + }; + + export type channelAdminLogEventActionDeleteMessage = { + _: 'channelAdminLogEventActionDeleteMessage', + message: Message + }; + + export type channelAdminLogEventActionParticipantJoin = { + _: 'channelAdminLogEventActionParticipantJoin' + }; + + export type channelAdminLogEventActionParticipantLeave = { + _: 'channelAdminLogEventActionParticipantLeave' + }; + + export type channelAdminLogEventActionParticipantInvite = { + _: 'channelAdminLogEventActionParticipantInvite', + participant: ChannelParticipant + }; + + export type channelAdminLogEventActionParticipantToggleBan = { + _: 'channelAdminLogEventActionParticipantToggleBan', + prev_participant: ChannelParticipant, + new_participant: ChannelParticipant + }; + + export type channelAdminLogEventActionParticipantToggleAdmin = { + _: 'channelAdminLogEventActionParticipantToggleAdmin', + prev_participant: ChannelParticipant, + new_participant: ChannelParticipant + }; + + export type channelAdminLogEventActionChangeStickerSet = { + _: 'channelAdminLogEventActionChangeStickerSet', + prev_stickerset: InputStickerSet, + new_stickerset: InputStickerSet + }; + + export type channelAdminLogEventActionTogglePreHistoryHidden = { + _: 'channelAdminLogEventActionTogglePreHistoryHidden', + new_value: boolean + }; + + export type channelAdminLogEventActionDefaultBannedRights = { + _: 'channelAdminLogEventActionDefaultBannedRights', + prev_banned_rights: ChatBannedRights, + new_banned_rights: ChatBannedRights + }; + + export type channelAdminLogEventActionStopPoll = { + _: 'channelAdminLogEventActionStopPoll', + message: Message + }; + + export type channelAdminLogEventActionChangeLinkedChat = { + _: 'channelAdminLogEventActionChangeLinkedChat', + prev_value: number, + new_value: number + }; + + export type channelAdminLogEventActionChangeLocation = { + _: 'channelAdminLogEventActionChangeLocation', + prev_value: ChannelLocation, + new_value: ChannelLocation + }; + + export type channelAdminLogEventActionToggleSlowMode = { + _: 'channelAdminLogEventActionToggleSlowMode', + prev_value: number, + new_value: number + }; +} + +/** + * @link https://core.telegram.org/type/ChannelAdminLogEvent + */ +export type ChannelAdminLogEvent = ChannelAdminLogEvent.channelAdminLogEvent; + +export namespace ChannelAdminLogEvent { + export type channelAdminLogEvent = { + _: 'channelAdminLogEvent', + id: string, + date: number, + user_id: number, + action: ChannelAdminLogEventAction + }; +} + +/** + * @link https://core.telegram.org/type/channels.AdminLogResults + */ +export type ChannelsAdminLogResults = ChannelsAdminLogResults.channelsAdminLogResults; + +export namespace ChannelsAdminLogResults { + export type channelsAdminLogResults = { + _: 'channels.adminLogResults', + events: Array, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/ChannelAdminLogEventsFilter + */ +export type ChannelAdminLogEventsFilter = ChannelAdminLogEventsFilter.channelAdminLogEventsFilter; + +export namespace ChannelAdminLogEventsFilter { + export type channelAdminLogEventsFilter = { + _: 'channelAdminLogEventsFilter', + flags?: number, + pFlags?: Partial<{ + join?: true, + leave?: true, + invite?: true, + ban?: true, + unban?: true, + kick?: true, + unkick?: true, + promote?: true, + demote?: true, + info?: true, + settings?: true, + pinned?: true, + edit?: true, + delete?: true, + }> + }; +} + +/** + * @link https://core.telegram.org/type/PopularContact + */ +export type PopularContact = PopularContact.popularContact; + +export namespace PopularContact { + export type popularContact = { + _: 'popularContact', + client_id: string, + importers: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.FavedStickers + */ +export type MessagesFavedStickers = MessagesFavedStickers.messagesFavedStickersNotModified | MessagesFavedStickers.messagesFavedStickers; + +export namespace MessagesFavedStickers { + export type messagesFavedStickersNotModified = { + _: 'messages.favedStickersNotModified' + }; + + export type messagesFavedStickers = { + _: 'messages.favedStickers', + hash: number, + packs: Array, + stickers: Array + }; +} + +/** + * @link https://core.telegram.org/type/RecentMeUrl + */ +export type RecentMeUrl = RecentMeUrl.recentMeUrlUnknown | RecentMeUrl.recentMeUrlUser | RecentMeUrl.recentMeUrlChat | RecentMeUrl.recentMeUrlChatInvite | RecentMeUrl.recentMeUrlStickerSet; + +export namespace RecentMeUrl { + export type recentMeUrlUnknown = { + _: 'recentMeUrlUnknown', + url: string + }; + + export type recentMeUrlUser = { + _: 'recentMeUrlUser', + url: string, + user_id: number + }; + + export type recentMeUrlChat = { + _: 'recentMeUrlChat', + url: string, + chat_id: number + }; + + export type recentMeUrlChatInvite = { + _: 'recentMeUrlChatInvite', + url: string, + chat_invite: ChatInvite + }; + + export type recentMeUrlStickerSet = { + _: 'recentMeUrlStickerSet', + url: string, + set: StickerSetCovered + }; +} + +/** + * @link https://core.telegram.org/type/help.RecentMeUrls + */ +export type HelpRecentMeUrls = HelpRecentMeUrls.helpRecentMeUrls; + +export namespace HelpRecentMeUrls { + export type helpRecentMeUrls = { + _: 'help.recentMeUrls', + urls: Array, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputSingleMedia + */ +export type InputSingleMedia = InputSingleMedia.inputSingleMedia; + +export namespace InputSingleMedia { + export type inputSingleMedia = { + _: 'inputSingleMedia', + flags?: number, + media: InputMedia, + random_id: string, + message: string, + entities?: Array + }; +} + +/** + * @link https://core.telegram.org/type/WebAuthorization + */ +export type WebAuthorization = WebAuthorization.webAuthorization; + +export namespace WebAuthorization { + export type webAuthorization = { + _: 'webAuthorization', + hash: string, + bot_id: number, + domain: string, + browser: string, + platform: string, + date_created: number, + date_active: number, + ip: string, + region: string + }; +} + +/** + * @link https://core.telegram.org/type/account.WebAuthorizations + */ +export type AccountWebAuthorizations = AccountWebAuthorizations.accountWebAuthorizations; + +export namespace AccountWebAuthorizations { + export type accountWebAuthorizations = { + _: 'account.webAuthorizations', + authorizations: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/InputMessage + */ +export type InputMessage = InputMessage.inputMessageID | InputMessage.inputMessageReplyTo | InputMessage.inputMessagePinned; + +export namespace InputMessage { + export type inputMessageID = { + _: 'inputMessageID', + id: number + }; + + export type inputMessageReplyTo = { + _: 'inputMessageReplyTo', + id: number + }; + + export type inputMessagePinned = { + _: 'inputMessagePinned' + }; +} + +/** + * @link https://core.telegram.org/type/InputDialogPeer + */ +export type InputDialogPeer = InputDialogPeer.inputDialogPeer | InputDialogPeer.inputDialogPeerFolder; + +export namespace InputDialogPeer { + export type inputDialogPeer = { + _: 'inputDialogPeer', + peer: InputPeer + }; + + export type inputDialogPeerFolder = { + _: 'inputDialogPeerFolder', + folder_id: number + }; +} + +/** + * @link https://core.telegram.org/type/DialogPeer + */ +export type DialogPeer = DialogPeer.dialogPeer | DialogPeer.dialogPeerFolder; + +export namespace DialogPeer { + export type dialogPeer = { + _: 'dialogPeer', + peer: Peer + }; + + export type dialogPeerFolder = { + _: 'dialogPeerFolder', + folder_id: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.FoundStickerSets + */ +export type MessagesFoundStickerSets = MessagesFoundStickerSets.messagesFoundStickerSetsNotModified | MessagesFoundStickerSets.messagesFoundStickerSets; + +export namespace MessagesFoundStickerSets { + export type messagesFoundStickerSetsNotModified = { + _: 'messages.foundStickerSetsNotModified' + }; + + export type messagesFoundStickerSets = { + _: 'messages.foundStickerSets', + hash: number, + sets: Array + }; +} + +/** + * @link https://core.telegram.org/type/FileHash + */ +export type FileHash = FileHash.fileHash; + +export namespace FileHash { + export type fileHash = { + _: 'fileHash', + offset: number, + limit: number, + hash: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/InputClientProxy + */ +export type InputClientProxy = InputClientProxy.inputClientProxy; + +export namespace InputClientProxy { + export type inputClientProxy = { + _: 'inputClientProxy', + address: string, + port: number + }; +} + +/** + * @link https://core.telegram.org/type/help.TermsOfServiceUpdate + */ +export type HelpTermsOfServiceUpdate = HelpTermsOfServiceUpdate.helpTermsOfServiceUpdateEmpty | HelpTermsOfServiceUpdate.helpTermsOfServiceUpdate; + +export namespace HelpTermsOfServiceUpdate { + export type helpTermsOfServiceUpdateEmpty = { + _: 'help.termsOfServiceUpdateEmpty', + expires: number + }; + + export type helpTermsOfServiceUpdate = { + _: 'help.termsOfServiceUpdate', + expires: number, + terms_of_service: HelpTermsOfService + }; +} + +/** + * @link https://core.telegram.org/type/InputSecureFile + */ +export type InputSecureFile = InputSecureFile.inputSecureFileUploaded | InputSecureFile.inputSecureFile; + +export namespace InputSecureFile { + export type inputSecureFileUploaded = { + _: 'inputSecureFileUploaded', + id: string, + parts: number, + md5_checksum: string, + file_hash: Uint8Array | number[], + secret: Uint8Array | number[] + }; + + export type inputSecureFile = { + _: 'inputSecureFile', + id: string, + access_hash: string + }; +} + +/** + * @link https://core.telegram.org/type/SecureFile + */ +export type SecureFile = SecureFile.secureFileEmpty | SecureFile.secureFile; + +export namespace SecureFile { + export type secureFileEmpty = { + _: 'secureFileEmpty' + }; + + export type secureFile = { + _: 'secureFile', + id: string, + access_hash: string, + size: number, + dc_id: number, + date: number, + file_hash: Uint8Array | number[], + secret: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/SecureData + */ +export type SecureData = SecureData.secureData; + +export namespace SecureData { + export type secureData = { + _: 'secureData', + data: Uint8Array | number[], + data_hash: Uint8Array | number[], + secret: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/SecurePlainData + */ +export type SecurePlainData = SecurePlainData.securePlainPhone | SecurePlainData.securePlainEmail; + +export namespace SecurePlainData { + export type securePlainPhone = { + _: 'securePlainPhone', + phone: string + }; + + export type securePlainEmail = { + _: 'securePlainEmail', + email: string + }; +} + +/** + * @link https://core.telegram.org/type/SecureValueType + */ +export type SecureValueType = SecureValueType.secureValueTypePersonalDetails | SecureValueType.secureValueTypePassport | SecureValueType.secureValueTypeDriverLicense | SecureValueType.secureValueTypeIdentityCard | SecureValueType.secureValueTypeInternalPassport | SecureValueType.secureValueTypeAddress | SecureValueType.secureValueTypeUtilityBill | SecureValueType.secureValueTypeBankStatement | SecureValueType.secureValueTypeRentalAgreement | SecureValueType.secureValueTypePassportRegistration | SecureValueType.secureValueTypeTemporaryRegistration | SecureValueType.secureValueTypePhone | SecureValueType.secureValueTypeEmail; + +export namespace SecureValueType { + export type secureValueTypePersonalDetails = { + _: 'secureValueTypePersonalDetails' + }; + + export type secureValueTypePassport = { + _: 'secureValueTypePassport' + }; + + export type secureValueTypeDriverLicense = { + _: 'secureValueTypeDriverLicense' + }; + + export type secureValueTypeIdentityCard = { + _: 'secureValueTypeIdentityCard' + }; + + export type secureValueTypeInternalPassport = { + _: 'secureValueTypeInternalPassport' + }; + + export type secureValueTypeAddress = { + _: 'secureValueTypeAddress' + }; + + export type secureValueTypeUtilityBill = { + _: 'secureValueTypeUtilityBill' + }; + + export type secureValueTypeBankStatement = { + _: 'secureValueTypeBankStatement' + }; + + export type secureValueTypeRentalAgreement = { + _: 'secureValueTypeRentalAgreement' + }; + + export type secureValueTypePassportRegistration = { + _: 'secureValueTypePassportRegistration' + }; + + export type secureValueTypeTemporaryRegistration = { + _: 'secureValueTypeTemporaryRegistration' + }; + + export type secureValueTypePhone = { + _: 'secureValueTypePhone' + }; + + export type secureValueTypeEmail = { + _: 'secureValueTypeEmail' + }; +} + +/** + * @link https://core.telegram.org/type/SecureValue + */ +export type SecureValue = SecureValue.secureValue; + +export namespace SecureValue { + export type secureValue = { + _: 'secureValue', + flags?: number, + type: SecureValueType, + data?: SecureData, + front_side?: SecureFile, + reverse_side?: SecureFile, + selfie?: SecureFile, + translation?: Array, + files?: Array, + plain_data?: SecurePlainData, + hash: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/InputSecureValue + */ +export type InputSecureValue = InputSecureValue.inputSecureValue; + +export namespace InputSecureValue { + export type inputSecureValue = { + _: 'inputSecureValue', + flags?: number, + type: SecureValueType, + data?: SecureData, + front_side?: InputSecureFile, + reverse_side?: InputSecureFile, + selfie?: InputSecureFile, + translation?: Array, + files?: Array, + plain_data?: SecurePlainData + }; +} + +/** + * @link https://core.telegram.org/type/SecureValueHash + */ +export type SecureValueHash = SecureValueHash.secureValueHash; + +export namespace SecureValueHash { + export type secureValueHash = { + _: 'secureValueHash', + type: SecureValueType, + hash: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/SecureValueError + */ +export type SecureValueError = SecureValueError.secureValueErrorData | SecureValueError.secureValueErrorFrontSide | SecureValueError.secureValueErrorReverseSide | SecureValueError.secureValueErrorSelfie | SecureValueError.secureValueErrorFile | SecureValueError.secureValueErrorFiles | SecureValueError.secureValueError | SecureValueError.secureValueErrorTranslationFile | SecureValueError.secureValueErrorTranslationFiles; + +export namespace SecureValueError { + export type secureValueErrorData = { + _: 'secureValueErrorData', + type: SecureValueType, + data_hash: Uint8Array | number[], + field: string, + text: string + }; + + export type secureValueErrorFrontSide = { + _: 'secureValueErrorFrontSide', + type: SecureValueType, + file_hash: Uint8Array | number[], + text: string + }; + + export type secureValueErrorReverseSide = { + _: 'secureValueErrorReverseSide', + type: SecureValueType, + file_hash: Uint8Array | number[], + text: string + }; + + export type secureValueErrorSelfie = { + _: 'secureValueErrorSelfie', + type: SecureValueType, + file_hash: Uint8Array | number[], + text: string + }; + + export type secureValueErrorFile = { + _: 'secureValueErrorFile', + type: SecureValueType, + file_hash: Uint8Array | number[], + text: string + }; + + export type secureValueErrorFiles = { + _: 'secureValueErrorFiles', + type: SecureValueType, + file_hash: Array, + text: string + }; + + export type secureValueError = { + _: 'secureValueError', + type: SecureValueType, + hash: Uint8Array | number[], + text: string + }; + + export type secureValueErrorTranslationFile = { + _: 'secureValueErrorTranslationFile', + type: SecureValueType, + file_hash: Uint8Array | number[], + text: string + }; + + export type secureValueErrorTranslationFiles = { + _: 'secureValueErrorTranslationFiles', + type: SecureValueType, + file_hash: Array, + text: string + }; +} + +/** + * @link https://core.telegram.org/type/SecureCredentialsEncrypted + */ +export type SecureCredentialsEncrypted = SecureCredentialsEncrypted.secureCredentialsEncrypted; + +export namespace SecureCredentialsEncrypted { + export type secureCredentialsEncrypted = { + _: 'secureCredentialsEncrypted', + data: Uint8Array | number[], + hash: Uint8Array | number[], + secret: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/account.AuthorizationForm + */ +export type AccountAuthorizationForm = AccountAuthorizationForm.accountAuthorizationForm; + +export namespace AccountAuthorizationForm { + export type accountAuthorizationForm = { + _: 'account.authorizationForm', + flags?: number, + required_types: Array, + values: Array, + errors: Array, + users: Array, + privacy_policy_url?: string + }; +} + +/** + * @link https://core.telegram.org/type/account.SentEmailCode + */ +export type AccountSentEmailCode = AccountSentEmailCode.accountSentEmailCode; + +export namespace AccountSentEmailCode { + export type accountSentEmailCode = { + _: 'account.sentEmailCode', + email_pattern: string, + length: number + }; +} + +/** + * @link https://core.telegram.org/type/help.DeepLinkInfo + */ +export type HelpDeepLinkInfo = HelpDeepLinkInfo.helpDeepLinkInfoEmpty | HelpDeepLinkInfo.helpDeepLinkInfo; + +export namespace HelpDeepLinkInfo { + export type helpDeepLinkInfoEmpty = { + _: 'help.deepLinkInfoEmpty' + }; + + export type helpDeepLinkInfo = { + _: 'help.deepLinkInfo', + flags?: number, + pFlags?: Partial<{ + update_app?: true, + }>, + message: string, + entities?: Array + }; +} + +/** + * @link https://core.telegram.org/type/SavedContact + */ +export type SavedContact = SavedContact.savedPhoneContact; + +export namespace SavedContact { + export type savedPhoneContact = { + _: 'savedPhoneContact', + phone: string, + first_name: string, + last_name: string, + date: number + }; +} + +/** + * @link https://core.telegram.org/type/account.Takeout + */ +export type AccountTakeout = AccountTakeout.accountTakeout; + +export namespace AccountTakeout { + export type accountTakeout = { + _: 'account.takeout', + id: string + }; +} + +/** + * @link https://core.telegram.org/type/PasswordKdfAlgo + */ +export type PasswordKdfAlgo = PasswordKdfAlgo.passwordKdfAlgoUnknown | PasswordKdfAlgo.passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow; + +export namespace PasswordKdfAlgo { + export type passwordKdfAlgoUnknown = { + _: 'passwordKdfAlgoUnknown' + }; + + export type passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow = { + _: 'passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow', + salt1: Uint8Array | number[], + salt2: Uint8Array | number[], + g: number, + p: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/SecurePasswordKdfAlgo + */ +export type SecurePasswordKdfAlgo = SecurePasswordKdfAlgo.securePasswordKdfAlgoUnknown | SecurePasswordKdfAlgo.securePasswordKdfAlgoPBKDF2HMACSHA512iter100000 | SecurePasswordKdfAlgo.securePasswordKdfAlgoSHA512; + +export namespace SecurePasswordKdfAlgo { + export type securePasswordKdfAlgoUnknown = { + _: 'securePasswordKdfAlgoUnknown' + }; + + export type securePasswordKdfAlgoPBKDF2HMACSHA512iter100000 = { + _: 'securePasswordKdfAlgoPBKDF2HMACSHA512iter100000', + salt: Uint8Array | number[] + }; + + export type securePasswordKdfAlgoSHA512 = { + _: 'securePasswordKdfAlgoSHA512', + salt: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/SecureSecretSettings + */ +export type SecureSecretSettings = SecureSecretSettings.secureSecretSettings; + +export namespace SecureSecretSettings { + export type secureSecretSettings = { + _: 'secureSecretSettings', + secure_algo: SecurePasswordKdfAlgo, + secure_secret: Uint8Array | number[], + secure_secret_id: string + }; +} + +/** + * @link https://core.telegram.org/type/InputCheckPasswordSRP + */ +export type InputCheckPasswordSRP = InputCheckPasswordSRP.inputCheckPasswordEmpty | InputCheckPasswordSRP.inputCheckPasswordSRP; + +export namespace InputCheckPasswordSRP { + export type inputCheckPasswordEmpty = { + _: 'inputCheckPasswordEmpty' + }; + + export type inputCheckPasswordSRP = { + _: 'inputCheckPasswordSRP', + srp_id: string, + A: Uint8Array | number[], + M1: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/SecureRequiredType + */ +export type SecureRequiredType = SecureRequiredType.secureRequiredType | SecureRequiredType.secureRequiredTypeOneOf; + +export namespace SecureRequiredType { + export type secureRequiredType = { + _: 'secureRequiredType', + flags?: number, + pFlags?: Partial<{ + native_names?: true, + selfie_required?: true, + translation_required?: true, + }>, + type: SecureValueType + }; + + export type secureRequiredTypeOneOf = { + _: 'secureRequiredTypeOneOf', + types: Array + }; +} + +/** + * @link https://core.telegram.org/type/help.PassportConfig + */ +export type HelpPassportConfig = HelpPassportConfig.helpPassportConfigNotModified | HelpPassportConfig.helpPassportConfig; + +export namespace HelpPassportConfig { + export type helpPassportConfigNotModified = { + _: 'help.passportConfigNotModified' + }; + + export type helpPassportConfig = { + _: 'help.passportConfig', + hash: number, + countries_langs: DataJSON + }; +} + +/** + * @link https://core.telegram.org/type/InputAppEvent + */ +export type InputAppEvent = InputAppEvent.inputAppEvent; + +export namespace InputAppEvent { + export type inputAppEvent = { + _: 'inputAppEvent', + time: number, + type: string, + peer: string, + data: JSONValue + }; +} + +/** + * @link https://core.telegram.org/type/JSONObjectValue + */ +export type JSONObjectValue = JSONObjectValue.jsonObjectValue; + +export namespace JSONObjectValue { + export type jsonObjectValue = { + _: 'jsonObjectValue', + key: string, + value: JSONValue + }; +} + +/** + * @link https://core.telegram.org/type/JSONValue + */ +export type JSONValue = JSONValue.jsonNull | JSONValue.jsonBool | JSONValue.jsonNumber | JSONValue.jsonString | JSONValue.jsonArray | JSONValue.jsonObject; + +export namespace JSONValue { + export type jsonNull = { + _: 'jsonNull' + }; + + export type jsonBool = { + _: 'jsonBool', + value: boolean + }; + + export type jsonNumber = { + _: 'jsonNumber', + value: number + }; + + export type jsonString = { + _: 'jsonString', + value: string + }; + + export type jsonArray = { + _: 'jsonArray', + value: Array + }; + + export type jsonObject = { + _: 'jsonObject', + value: Array + }; +} + +/** + * @link https://core.telegram.org/type/PageTableCell + */ +export type PageTableCell = PageTableCell.pageTableCell; + +export namespace PageTableCell { + export type pageTableCell = { + _: 'pageTableCell', + flags?: number, + pFlags?: Partial<{ + header?: true, + align_center?: true, + align_right?: true, + valign_middle?: true, + valign_bottom?: true, + }>, + text?: RichText, + colspan?: number, + rowspan?: number + }; +} + +/** + * @link https://core.telegram.org/type/PageTableRow + */ +export type PageTableRow = PageTableRow.pageTableRow; + +export namespace PageTableRow { + export type pageTableRow = { + _: 'pageTableRow', + cells: Array + }; +} + +/** + * @link https://core.telegram.org/type/PageCaption + */ +export type PageCaption = PageCaption.pageCaption; + +export namespace PageCaption { + export type pageCaption = { + _: 'pageCaption', + text: RichText, + credit: RichText + }; +} + +/** + * @link https://core.telegram.org/type/PageListItem + */ +export type PageListItem = PageListItem.pageListItemText | PageListItem.pageListItemBlocks; + +export namespace PageListItem { + export type pageListItemText = { + _: 'pageListItemText', + text: RichText + }; + + export type pageListItemBlocks = { + _: 'pageListItemBlocks', + blocks: Array + }; +} + +/** + * @link https://core.telegram.org/type/PageListOrderedItem + */ +export type PageListOrderedItem = PageListOrderedItem.pageListOrderedItemText | PageListOrderedItem.pageListOrderedItemBlocks; + +export namespace PageListOrderedItem { + export type pageListOrderedItemText = { + _: 'pageListOrderedItemText', + num: string, + text: RichText + }; + + export type pageListOrderedItemBlocks = { + _: 'pageListOrderedItemBlocks', + num: string, + blocks: Array + }; +} + +/** + * @link https://core.telegram.org/type/PageRelatedArticle + */ +export type PageRelatedArticle = PageRelatedArticle.pageRelatedArticle; + +export namespace PageRelatedArticle { + export type pageRelatedArticle = { + _: 'pageRelatedArticle', + flags?: number, + url: string, + webpage_id: string, + title?: string, + description?: string, + photo_id?: string, + author?: string, + published_date?: number + }; +} + +/** + * @link https://core.telegram.org/type/Page + */ +export type Page = Page.page; + +export namespace Page { + export type page = { + _: 'page', + flags?: number, + pFlags?: Partial<{ + part?: true, + rtl?: true, + v2?: true, + }>, + url: string, + blocks: Array, + photos: Array, + documents: Array, + views?: number + }; +} + +/** + * @link https://core.telegram.org/type/help.SupportName + */ +export type HelpSupportName = HelpSupportName.helpSupportName; + +export namespace HelpSupportName { + export type helpSupportName = { + _: 'help.supportName', + name: string + }; +} + +/** + * @link https://core.telegram.org/type/help.UserInfo + */ +export type HelpUserInfo = HelpUserInfo.helpUserInfoEmpty | HelpUserInfo.helpUserInfo; + +export namespace HelpUserInfo { + export type helpUserInfoEmpty = { + _: 'help.userInfoEmpty' + }; + + export type helpUserInfo = { + _: 'help.userInfo', + message: string, + entities: Array, + author: string, + date: number + }; +} + +/** + * @link https://core.telegram.org/type/PollAnswer + */ +export type PollAnswer = PollAnswer.pollAnswer; + +export namespace PollAnswer { + export type pollAnswer = { + _: 'pollAnswer', + text: string, + option: Uint8Array | number[] + }; +} + +/** + * @link https://core.telegram.org/type/Poll + */ +export type Poll = Poll.poll; + +export namespace Poll { + export type poll = { + _: 'poll', + id: string, + flags?: number, + pFlags?: Partial<{ + closed?: true, + public_voters?: true, + multiple_choice?: true, + quiz?: true, + }>, + question: string, + answers: Array, + close_period?: number, + close_date?: number + }; +} + +/** + * @link https://core.telegram.org/type/PollAnswerVoters + */ +export type PollAnswerVoters = PollAnswerVoters.pollAnswerVoters; + +export namespace PollAnswerVoters { + export type pollAnswerVoters = { + _: 'pollAnswerVoters', + flags?: number, + pFlags?: Partial<{ + chosen?: true, + correct?: true, + }>, + option: Uint8Array | number[], + voters: number + }; +} + +/** + * @link https://core.telegram.org/type/PollResults + */ +export type PollResults = PollResults.pollResults; + +export namespace PollResults { + export type pollResults = { + _: 'pollResults', + flags?: number, + pFlags?: Partial<{ + min?: true, + }>, + results?: Array, + total_voters?: number, + recent_voters?: Array, + solution?: string, + solution_entities?: Array + }; +} + +/** + * @link https://core.telegram.org/type/ChatOnlines + */ +export type ChatOnlines = ChatOnlines.chatOnlines; + +export namespace ChatOnlines { + export type chatOnlines = { + _: 'chatOnlines', + onlines: number + }; +} + +/** + * @link https://core.telegram.org/type/StatsURL + */ +export type StatsURL = StatsURL.statsURL; + +export namespace StatsURL { + export type statsURL = { + _: 'statsURL', + url: string + }; +} + +/** + * @link https://core.telegram.org/type/ChatAdminRights + */ +export type ChatAdminRights = ChatAdminRights.chatAdminRights; + +export namespace ChatAdminRights { + export type chatAdminRights = { + _: 'chatAdminRights', + flags?: number, + pFlags?: Partial<{ + change_info?: true, + post_messages?: true, + edit_messages?: true, + delete_messages?: true, + ban_users?: true, + invite_users?: true, + pin_messages?: true, + add_admins?: true, + }> + }; +} + +/** + * @link https://core.telegram.org/type/ChatBannedRights + */ +export type ChatBannedRights = ChatBannedRights.chatBannedRights; + +export namespace ChatBannedRights { + export type chatBannedRights = { + _: 'chatBannedRights', + flags?: number, + pFlags?: Partial<{ + view_messages?: true, + send_messages?: true, + send_media?: true, + send_stickers?: true, + send_gifs?: true, + send_games?: true, + send_inline?: true, + embed_links?: true, + send_polls?: true, + change_info?: true, + invite_users?: true, + pin_messages?: true, + }>, + until_date: number + }; +} + +/** + * @link https://core.telegram.org/type/InputWallPaper + */ +export type InputWallPaper = InputWallPaper.inputWallPaper | InputWallPaper.inputWallPaperSlug | InputWallPaper.inputWallPaperNoFile; + +export namespace InputWallPaper { + export type inputWallPaper = { + _: 'inputWallPaper', + id: string, + access_hash: string + }; + + export type inputWallPaperSlug = { + _: 'inputWallPaperSlug', + slug: string + }; + + export type inputWallPaperNoFile = { + _: 'inputWallPaperNoFile' + }; +} + +/** + * @link https://core.telegram.org/type/account.WallPapers + */ +export type AccountWallPapers = AccountWallPapers.accountWallPapersNotModified | AccountWallPapers.accountWallPapers; + +export namespace AccountWallPapers { + export type accountWallPapersNotModified = { + _: 'account.wallPapersNotModified' + }; + + export type accountWallPapers = { + _: 'account.wallPapers', + hash: number, + wallpapers: Array + }; +} + +/** + * @link https://core.telegram.org/type/CodeSettings + */ +export type CodeSettings = CodeSettings.codeSettings; + +export namespace CodeSettings { + export type codeSettings = { + _: 'codeSettings', + flags?: number, + pFlags?: Partial<{ + allow_flashcall?: true, + current_number?: true, + allow_app_hash?: true, + }> + }; +} + +/** + * @link https://core.telegram.org/type/WallPaperSettings + */ +export type WallPaperSettings = WallPaperSettings.wallPaperSettings; + +export namespace WallPaperSettings { + export type wallPaperSettings = { + _: 'wallPaperSettings', + flags?: number, + pFlags?: Partial<{ + blur?: true, + motion?: true, + }>, + background_color?: number, + second_background_color?: number, + intensity?: number, + rotation?: number + }; +} + +/** + * @link https://core.telegram.org/type/AutoDownloadSettings + */ +export type AutoDownloadSettings = AutoDownloadSettings.autoDownloadSettings; + +export namespace AutoDownloadSettings { + export type autoDownloadSettings = { + _: 'autoDownloadSettings', + flags?: number, + pFlags?: Partial<{ + disabled?: true, + video_preload_large?: true, + audio_preload_next?: true, + phonecalls_less_data?: true, + }>, + photo_size_max: number, + video_size_max: number, + file_size_max: number, + video_upload_maxbitrate: number + }; +} + +/** + * @link https://core.telegram.org/type/account.AutoDownloadSettings + */ +export type AccountAutoDownloadSettings = AccountAutoDownloadSettings.accountAutoDownloadSettings; + +export namespace AccountAutoDownloadSettings { + export type accountAutoDownloadSettings = { + _: 'account.autoDownloadSettings', + low: AutoDownloadSettings, + medium: AutoDownloadSettings, + high: AutoDownloadSettings + }; +} + +/** + * @link https://core.telegram.org/type/EmojiKeyword + */ +export type EmojiKeyword = EmojiKeyword.emojiKeyword | EmojiKeyword.emojiKeywordDeleted; + +export namespace EmojiKeyword { + export type emojiKeyword = { + _: 'emojiKeyword', + keyword: string, + emoticons: Array + }; + + export type emojiKeywordDeleted = { + _: 'emojiKeywordDeleted', + keyword: string, + emoticons: Array + }; +} + +/** + * @link https://core.telegram.org/type/EmojiKeywordsDifference + */ +export type EmojiKeywordsDifference = EmojiKeywordsDifference.emojiKeywordsDifference; + +export namespace EmojiKeywordsDifference { + export type emojiKeywordsDifference = { + _: 'emojiKeywordsDifference', + lang_code: string, + from_version: number, + version: number, + keywords: Array + }; +} + +/** + * @link https://core.telegram.org/type/EmojiURL + */ +export type EmojiURL = EmojiURL.emojiURL; + +export namespace EmojiURL { + export type emojiURL = { + _: 'emojiURL', + url: string + }; +} + +/** + * @link https://core.telegram.org/type/EmojiLanguage + */ +export type EmojiLanguage = EmojiLanguage.emojiLanguage; + +export namespace EmojiLanguage { + export type emojiLanguage = { + _: 'emojiLanguage', + lang_code: string + }; +} + +/** + * @link https://core.telegram.org/type/FileLocation + */ +export type FileLocation = FileLocation.fileLocationToBeDeprecated; + +export namespace FileLocation { + export type fileLocationToBeDeprecated = { + _: 'fileLocationToBeDeprecated', + volume_id: string, + local_id: number + }; +} + +/** + * @link https://core.telegram.org/type/Folder + */ +export type Folder = Folder.folder; + +export namespace Folder { + export type folder = { + _: 'folder', + flags?: number, + pFlags?: Partial<{ + autofill_new_broadcasts?: true, + autofill_public_groups?: true, + autofill_new_correspondents?: true, + }>, + id: number, + title: string, + photo?: ChatPhoto + }; +} + +/** + * @link https://core.telegram.org/type/InputFolderPeer + */ +export type InputFolderPeer = InputFolderPeer.inputFolderPeer; + +export namespace InputFolderPeer { + export type inputFolderPeer = { + _: 'inputFolderPeer', + peer: InputPeer, + folder_id: number + }; +} + +/** + * @link https://core.telegram.org/type/FolderPeer + */ +export type FolderPeer = FolderPeer.folderPeer; + +export namespace FolderPeer { + export type folderPeer = { + _: 'folderPeer', + peer: Peer, + folder_id: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.SearchCounter + */ +export type MessagesSearchCounter = MessagesSearchCounter.messagesSearchCounter; + +export namespace MessagesSearchCounter { + export type messagesSearchCounter = { + _: 'messages.searchCounter', + flags?: number, + pFlags?: Partial<{ + inexact?: true, + }>, + filter: MessagesFilter, + count: number + }; +} + +/** + * @link https://core.telegram.org/type/UrlAuthResult + */ +export type UrlAuthResult = UrlAuthResult.urlAuthResultRequest | UrlAuthResult.urlAuthResultAccepted | UrlAuthResult.urlAuthResultDefault; + +export namespace UrlAuthResult { + export type urlAuthResultRequest = { + _: 'urlAuthResultRequest', + flags?: number, + pFlags?: Partial<{ + request_write_access?: true, + }>, + bot: User, + domain: string + }; + + export type urlAuthResultAccepted = { + _: 'urlAuthResultAccepted', + url: string + }; + + export type urlAuthResultDefault = { + _: 'urlAuthResultDefault' + }; +} + +/** + * @link https://core.telegram.org/type/ChannelLocation + */ +export type ChannelLocation = ChannelLocation.channelLocationEmpty | ChannelLocation.channelLocation; + +export namespace ChannelLocation { + export type channelLocationEmpty = { + _: 'channelLocationEmpty' + }; + + export type channelLocation = { + _: 'channelLocation', + geo_point: GeoPoint, + address: string + }; +} + +/** + * @link https://core.telegram.org/type/PeerLocated + */ +export type PeerLocated = PeerLocated.peerLocated | PeerLocated.peerSelfLocated; + +export namespace PeerLocated { + export type peerLocated = { + _: 'peerLocated', + peer: Peer, + expires: number, + distance: number + }; + + export type peerSelfLocated = { + _: 'peerSelfLocated', + expires: number + }; +} + +/** + * @link https://core.telegram.org/type/RestrictionReason + */ +export type RestrictionReason = RestrictionReason.restrictionReason; + +export namespace RestrictionReason { + export type restrictionReason = { + _: 'restrictionReason', + platform: string, + reason: string, + text: string + }; +} + +/** + * @link https://core.telegram.org/type/InputTheme + */ +export type InputTheme = InputTheme.inputTheme | InputTheme.inputThemeSlug; + +export namespace InputTheme { + export type inputTheme = { + _: 'inputTheme', + id: string, + access_hash: string + }; + + export type inputThemeSlug = { + _: 'inputThemeSlug', + slug: string + }; +} + +/** + * @link https://core.telegram.org/type/Theme + */ +export type Theme = Theme.theme; + +export namespace Theme { + export type theme = { + _: 'theme', + flags?: number, + pFlags?: Partial<{ + creator?: true, + default?: true, + }>, + id: string, + access_hash: string, + slug: string, + title: string, + document?: Document, + settings?: ThemeSettings, + installs_count: number + }; +} + +/** + * @link https://core.telegram.org/type/account.Themes + */ +export type AccountThemes = AccountThemes.accountThemesNotModified | AccountThemes.accountThemes; + +export namespace AccountThemes { + export type accountThemesNotModified = { + _: 'account.themesNotModified' + }; + + export type accountThemes = { + _: 'account.themes', + hash: number, + themes: Array + }; +} + +/** + * @link https://core.telegram.org/type/auth.LoginToken + */ +export type AuthLoginToken = AuthLoginToken.authLoginToken | AuthLoginToken.authLoginTokenMigrateTo | AuthLoginToken.authLoginTokenSuccess; + +export namespace AuthLoginToken { + export type authLoginToken = { + _: 'auth.loginToken', + expires: number, + token: Uint8Array | number[] + }; + + export type authLoginTokenMigrateTo = { + _: 'auth.loginTokenMigrateTo', + dc_id: number, + token: Uint8Array | number[] + }; + + export type authLoginTokenSuccess = { + _: 'auth.loginTokenSuccess', + authorization: AuthAuthorization + }; +} + +/** + * @link https://core.telegram.org/type/account.ContentSettings + */ +export type AccountContentSettings = AccountContentSettings.accountContentSettings; + +export namespace AccountContentSettings { + export type accountContentSettings = { + _: 'account.contentSettings', + flags?: number, + pFlags?: Partial<{ + sensitive_enabled?: true, + sensitive_can_change?: true, + }> + }; +} + +/** + * @link https://core.telegram.org/type/messages.InactiveChats + */ +export type MessagesInactiveChats = MessagesInactiveChats.messagesInactiveChats; + +export namespace MessagesInactiveChats { + export type messagesInactiveChats = { + _: 'messages.inactiveChats', + dates: Array, + chats: Array, + users: Array + }; +} + +/** + * @link https://core.telegram.org/type/BaseTheme + */ +export type BaseTheme = BaseTheme.baseThemeClassic | BaseTheme.baseThemeDay | BaseTheme.baseThemeNight | BaseTheme.baseThemeTinted | BaseTheme.baseThemeArctic; + +export namespace BaseTheme { + export type baseThemeClassic = { + _: 'baseThemeClassic' + }; + + export type baseThemeDay = { + _: 'baseThemeDay' + }; + + export type baseThemeNight = { + _: 'baseThemeNight' + }; + + export type baseThemeTinted = { + _: 'baseThemeTinted' + }; + + export type baseThemeArctic = { + _: 'baseThemeArctic' + }; +} + +/** + * @link https://core.telegram.org/type/InputThemeSettings + */ +export type InputThemeSettings = InputThemeSettings.inputThemeSettings; + +export namespace InputThemeSettings { + export type inputThemeSettings = { + _: 'inputThemeSettings', + flags?: number, + base_theme: BaseTheme, + accent_color: number, + message_top_color?: number, + message_bottom_color?: number, + wallpaper?: InputWallPaper, + wallpaper_settings?: WallPaperSettings + }; +} + +/** + * @link https://core.telegram.org/type/ThemeSettings + */ +export type ThemeSettings = ThemeSettings.themeSettings; + +export namespace ThemeSettings { + export type themeSettings = { + _: 'themeSettings', + flags?: number, + base_theme: BaseTheme, + accent_color: number, + message_top_color?: number, + message_bottom_color?: number, + wallpaper?: WallPaper + }; +} + +/** + * @link https://core.telegram.org/type/WebPageAttribute + */ +export type WebPageAttribute = WebPageAttribute.webPageAttributeTheme; + +export namespace WebPageAttribute { + export type webPageAttributeTheme = { + _: 'webPageAttributeTheme', + flags?: number, + documents?: Array, + settings?: ThemeSettings + }; +} + +/** + * @link https://core.telegram.org/type/MessageUserVote + */ +export type MessageUserVote = MessageUserVote.messageUserVote | MessageUserVote.messageUserVoteInputOption | MessageUserVote.messageUserVoteMultiple; + +export namespace MessageUserVote { + export type messageUserVote = { + _: 'messageUserVote', + user_id: number, + option: Uint8Array | number[], + date: number + }; + + export type messageUserVoteInputOption = { + _: 'messageUserVoteInputOption', + user_id: number, + date: number + }; + + export type messageUserVoteMultiple = { + _: 'messageUserVoteMultiple', + user_id: number, + options: Array, + date: number + }; +} + +/** + * @link https://core.telegram.org/type/messages.VotesList + */ +export type MessagesVotesList = MessagesVotesList.messagesVotesList; + +export namespace MessagesVotesList { + export type messagesVotesList = { + _: 'messages.votesList', + flags?: number, + count: number, + votes: Array, + users: Array, + next_offset?: string + }; +} + +/** + * @link https://core.telegram.org/type/BankCardOpenUrl + */ +export type BankCardOpenUrl = BankCardOpenUrl.bankCardOpenUrl; + +export namespace BankCardOpenUrl { + export type bankCardOpenUrl = { + _: 'bankCardOpenUrl', + url: string, + name: string + }; +} + +/** + * @link https://core.telegram.org/type/payments.BankCardData + */ +export type PaymentsBankCardData = PaymentsBankCardData.paymentsBankCardData; + +export namespace PaymentsBankCardData { + export type paymentsBankCardData = { + _: 'payments.bankCardData', + title: string, + open_urls: Array + }; +} + +/** + * @link https://core.telegram.org/type/DialogFilter + */ +export type DialogFilter = DialogFilter.dialogFilter; + +export namespace DialogFilter { + export type dialogFilter = { + _: 'dialogFilter', + flags?: number, + pFlags?: Partial<{ + contacts?: true, + non_contacts?: true, + groups?: true, + broadcasts?: true, + bots?: true, + exclude_muted?: true, + exclude_read?: true, + exclude_archived?: true, + }>, + id: number, + title: string, + emoticon?: string, + pinned_peers: Array, + include_peers: Array, + exclude_peers: Array + }; +} + +/** + * @link https://core.telegram.org/type/DialogFilterSuggested + */ +export type DialogFilterSuggested = DialogFilterSuggested.dialogFilterSuggested; + +export namespace DialogFilterSuggested { + export type dialogFilterSuggested = { + _: 'dialogFilterSuggested', + filter: DialogFilter, + description: string + }; +} + +/** + * @link https://core.telegram.org/type/StatsDateRangeDays + */ +export type StatsDateRangeDays = StatsDateRangeDays.statsDateRangeDays; + +export namespace StatsDateRangeDays { + export type statsDateRangeDays = { + _: 'statsDateRangeDays', + min_date: number, + max_date: number + }; +} + +/** + * @link https://core.telegram.org/type/StatsAbsValueAndPrev + */ +export type StatsAbsValueAndPrev = StatsAbsValueAndPrev.statsAbsValueAndPrev; + +export namespace StatsAbsValueAndPrev { + export type statsAbsValueAndPrev = { + _: 'statsAbsValueAndPrev', + current: number, + previous: number + }; +} + +/** + * @link https://core.telegram.org/type/StatsPercentValue + */ +export type StatsPercentValue = StatsPercentValue.statsPercentValue; + +export namespace StatsPercentValue { + export type statsPercentValue = { + _: 'statsPercentValue', + part: number, + total: number + }; +} + +/** + * @link https://core.telegram.org/type/StatsGraph + */ +export type StatsGraph = StatsGraph.statsGraphAsync | StatsGraph.statsGraphError | StatsGraph.statsGraph; + +export namespace StatsGraph { + export type statsGraphAsync = { + _: 'statsGraphAsync', + token: string + }; + + export type statsGraphError = { + _: 'statsGraphError', + error: string + }; + + export type statsGraph = { + _: 'statsGraph', + flags?: number, + json: DataJSON, + zoom_token?: string + }; +} + +/** + * @link https://core.telegram.org/type/MessageInteractionCounters + */ +export type MessageInteractionCounters = MessageInteractionCounters.messageInteractionCounters; + +export namespace MessageInteractionCounters { + export type messageInteractionCounters = { + _: 'messageInteractionCounters', + msg_id: number, + views: number, + forwards: number + }; +} + +/** + * @link https://core.telegram.org/type/stats.BroadcastStats + */ +export type StatsBroadcastStats = StatsBroadcastStats.statsBroadcastStats; + +export namespace StatsBroadcastStats { + export type statsBroadcastStats = { + _: 'stats.broadcastStats', + period: StatsDateRangeDays, + followers: StatsAbsValueAndPrev, + views_per_post: StatsAbsValueAndPrev, + shares_per_post: StatsAbsValueAndPrev, + enabled_notifications: StatsPercentValue, + growth_graph: StatsGraph, + followers_graph: StatsGraph, + mute_graph: StatsGraph, + top_hours_graph: StatsGraph, + interactions_graph: StatsGraph, + iv_interactions_graph: StatsGraph, + views_by_source_graph: StatsGraph, + new_followers_by_source_graph: StatsGraph, + languages_graph: StatsGraph, + recent_message_interactions: Array + }; +} + +/** + * @link https://core.telegram.org/type/help.PromoData + */ +export type HelpPromoData = HelpPromoData.helpPromoDataEmpty | HelpPromoData.helpPromoData; + +export namespace HelpPromoData { + export type helpPromoDataEmpty = { + _: 'help.promoDataEmpty', + expires: number + }; + + export type helpPromoData = { + _: 'help.promoData', + flags?: number, + pFlags?: Partial<{ + proxy?: true, + }>, + expires: number, + peer: Peer, + chats: Array, + users: Array, + psa_type?: string, + psa_message?: string + }; +} + +export interface ConstructorDeclMap { + 'error': Error.error, + 'inputPeerEmpty': InputPeer.inputPeerEmpty, + 'inputPeerSelf': InputPeer.inputPeerSelf, + 'inputPeerChat': InputPeer.inputPeerChat, + 'inputPeerUser': InputPeer.inputPeerUser, + 'inputPeerChannel': InputPeer.inputPeerChannel, + 'inputPeerUserFromMessage': InputPeer.inputPeerUserFromMessage, + 'inputPeerChannelFromMessage': InputPeer.inputPeerChannelFromMessage, + 'inputUserEmpty': InputUser.inputUserEmpty, + 'inputUserSelf': InputUser.inputUserSelf, + 'inputUser': InputUser.inputUser, + 'inputUserFromMessage': InputUser.inputUserFromMessage, + 'inputPhoneContact': InputContact.inputPhoneContact, + 'inputFile': InputFile.inputFile, + 'inputFileBig': InputFile.inputFileBig, + 'inputMediaEmpty': InputMedia.inputMediaEmpty, + 'inputMediaUploadedPhoto': InputMedia.inputMediaUploadedPhoto, + 'inputMediaPhoto': InputMedia.inputMediaPhoto, + 'inputMediaGeoPoint': InputMedia.inputMediaGeoPoint, + 'inputMediaContact': InputMedia.inputMediaContact, + 'inputMediaUploadedDocument': InputMedia.inputMediaUploadedDocument, + 'inputMediaDocument': InputMedia.inputMediaDocument, + 'inputMediaVenue': InputMedia.inputMediaVenue, + 'inputMediaGifExternal': InputMedia.inputMediaGifExternal, + 'inputMediaPhotoExternal': InputMedia.inputMediaPhotoExternal, + 'inputMediaDocumentExternal': InputMedia.inputMediaDocumentExternal, + 'inputMediaGame': InputMedia.inputMediaGame, + 'inputMediaInvoice': InputMedia.inputMediaInvoice, + 'inputMediaGeoLive': InputMedia.inputMediaGeoLive, + 'inputMediaPoll': InputMedia.inputMediaPoll, + 'inputMediaDice': InputMedia.inputMediaDice, + 'inputChatPhotoEmpty': InputChatPhoto.inputChatPhotoEmpty, + 'inputChatUploadedPhoto': InputChatPhoto.inputChatUploadedPhoto, + 'inputChatPhoto': InputChatPhoto.inputChatPhoto, + 'inputGeoPointEmpty': InputGeoPoint.inputGeoPointEmpty, + 'inputGeoPoint': InputGeoPoint.inputGeoPoint, + 'inputPhotoEmpty': InputPhoto.inputPhotoEmpty, + 'inputPhoto': InputPhoto.inputPhoto, + 'inputFileLocation': InputFileLocation.inputFileLocation, + 'inputEncryptedFileLocation': InputFileLocation.inputEncryptedFileLocation, + 'inputDocumentFileLocation': InputFileLocation.inputDocumentFileLocation, + 'inputSecureFileLocation': InputFileLocation.inputSecureFileLocation, + 'inputTakeoutFileLocation': InputFileLocation.inputTakeoutFileLocation, + 'inputPhotoFileLocation': InputFileLocation.inputPhotoFileLocation, + 'inputPhotoLegacyFileLocation': InputFileLocation.inputPhotoLegacyFileLocation, + 'inputPeerPhotoFileLocation': InputFileLocation.inputPeerPhotoFileLocation, + 'inputStickerSetThumb': InputFileLocation.inputStickerSetThumb, + 'peerUser': Peer.peerUser, + 'peerChat': Peer.peerChat, + 'peerChannel': Peer.peerChannel, + 'storage.fileUnknown': StorageFileType.storageFileUnknown, + 'storage.filePartial': StorageFileType.storageFilePartial, + 'storage.fileJpeg': StorageFileType.storageFileJpeg, + 'storage.fileGif': StorageFileType.storageFileGif, + 'storage.filePng': StorageFileType.storageFilePng, + 'storage.filePdf': StorageFileType.storageFilePdf, + 'storage.fileMp3': StorageFileType.storageFileMp3, + 'storage.fileMov': StorageFileType.storageFileMov, + 'storage.fileMp4': StorageFileType.storageFileMp4, + 'storage.fileWebp': StorageFileType.storageFileWebp, + 'userEmpty': User.userEmpty, + 'user': User.user, + 'userProfilePhotoEmpty': UserProfilePhoto.userProfilePhotoEmpty, + 'userProfilePhoto': UserProfilePhoto.userProfilePhoto, + 'userStatusEmpty': UserStatus.userStatusEmpty, + 'userStatusOnline': UserStatus.userStatusOnline, + 'userStatusOffline': UserStatus.userStatusOffline, + 'userStatusRecently': UserStatus.userStatusRecently, + 'userStatusLastWeek': UserStatus.userStatusLastWeek, + 'userStatusLastMonth': UserStatus.userStatusLastMonth, + 'chatEmpty': Chat.chatEmpty, + 'chat': Chat.chat, + 'chatForbidden': Chat.chatForbidden, + 'channel': Chat.channel, + 'channelForbidden': Chat.channelForbidden, + 'chatFull': ChatFull.chatFull, + 'channelFull': ChatFull.channelFull, + 'chatParticipant': ChatParticipant.chatParticipant, + 'chatParticipantCreator': ChatParticipant.chatParticipantCreator, + 'chatParticipantAdmin': ChatParticipant.chatParticipantAdmin, + 'chatParticipantsForbidden': ChatParticipants.chatParticipantsForbidden, + 'chatParticipants': ChatParticipants.chatParticipants, + 'chatPhotoEmpty': ChatPhoto.chatPhotoEmpty, + 'chatPhoto': ChatPhoto.chatPhoto, + 'messageEmpty': Message.messageEmpty, + 'message': Message.message, + 'messageService': Message.messageService, + 'messageMediaEmpty': MessageMedia.messageMediaEmpty, + 'messageMediaPhoto': MessageMedia.messageMediaPhoto, + 'messageMediaGeo': MessageMedia.messageMediaGeo, + 'messageMediaContact': MessageMedia.messageMediaContact, + 'messageMediaUnsupported': MessageMedia.messageMediaUnsupported, + 'messageMediaDocument': MessageMedia.messageMediaDocument, + 'messageMediaWebPage': MessageMedia.messageMediaWebPage, + 'messageMediaVenue': MessageMedia.messageMediaVenue, + 'messageMediaGame': MessageMedia.messageMediaGame, + 'messageMediaInvoice': MessageMedia.messageMediaInvoice, + 'messageMediaGeoLive': MessageMedia.messageMediaGeoLive, + 'messageMediaPoll': MessageMedia.messageMediaPoll, + 'messageMediaDice': MessageMedia.messageMediaDice, + 'messageActionEmpty': MessageAction.messageActionEmpty, + 'messageActionChatCreate': MessageAction.messageActionChatCreate, + 'messageActionChatEditTitle': MessageAction.messageActionChatEditTitle, + 'messageActionChatEditPhoto': MessageAction.messageActionChatEditPhoto, + 'messageActionChatDeletePhoto': MessageAction.messageActionChatDeletePhoto, + 'messageActionChatAddUser': MessageAction.messageActionChatAddUser, + 'messageActionChatDeleteUser': MessageAction.messageActionChatDeleteUser, + 'messageActionChatJoinedByLink': MessageAction.messageActionChatJoinedByLink, + 'messageActionChannelCreate': MessageAction.messageActionChannelCreate, + 'messageActionChatMigrateTo': MessageAction.messageActionChatMigrateTo, + 'messageActionChannelMigrateFrom': MessageAction.messageActionChannelMigrateFrom, + 'messageActionPinMessage': MessageAction.messageActionPinMessage, + 'messageActionHistoryClear': MessageAction.messageActionHistoryClear, + 'messageActionGameScore': MessageAction.messageActionGameScore, + 'messageActionPaymentSentMe': MessageAction.messageActionPaymentSentMe, + 'messageActionPaymentSent': MessageAction.messageActionPaymentSent, + 'messageActionPhoneCall': MessageAction.messageActionPhoneCall, + 'messageActionScreenshotTaken': MessageAction.messageActionScreenshotTaken, + 'messageActionCustomAction': MessageAction.messageActionCustomAction, + 'messageActionBotAllowed': MessageAction.messageActionBotAllowed, + 'messageActionSecureValuesSentMe': MessageAction.messageActionSecureValuesSentMe, + 'messageActionSecureValuesSent': MessageAction.messageActionSecureValuesSent, + 'messageActionContactSignUp': MessageAction.messageActionContactSignUp, + 'dialog': Dialog.dialog, + 'dialogFolder': Dialog.dialogFolder, + 'photoEmpty': Photo.photoEmpty, + 'photo': Photo.photo, + 'photoSizeEmpty': PhotoSize.photoSizeEmpty, + 'photoSize': PhotoSize.photoSize, + 'photoCachedSize': PhotoSize.photoCachedSize, + 'photoStrippedSize': PhotoSize.photoStrippedSize, + 'geoPointEmpty': GeoPoint.geoPointEmpty, + 'geoPoint': GeoPoint.geoPoint, + 'auth.sentCode': AuthSentCode.authSentCode, + 'auth.authorization': AuthAuthorization.authAuthorization, + 'auth.authorizationSignUpRequired': AuthAuthorization.authAuthorizationSignUpRequired, + 'auth.exportedAuthorization': AuthExportedAuthorization.authExportedAuthorization, + 'inputNotifyPeer': InputNotifyPeer.inputNotifyPeer, + 'inputNotifyUsers': InputNotifyPeer.inputNotifyUsers, + 'inputNotifyChats': InputNotifyPeer.inputNotifyChats, + 'inputNotifyBroadcasts': InputNotifyPeer.inputNotifyBroadcasts, + 'inputPeerNotifySettings': InputPeerNotifySettings.inputPeerNotifySettings, + 'peerNotifySettings': PeerNotifySettings.peerNotifySettings, + 'peerSettings': PeerSettings.peerSettings, + 'wallPaper': WallPaper.wallPaper, + 'wallPaperNoFile': WallPaper.wallPaperNoFile, + 'inputReportReasonSpam': ReportReason.inputReportReasonSpam, + 'inputReportReasonViolence': ReportReason.inputReportReasonViolence, + 'inputReportReasonPornography': ReportReason.inputReportReasonPornography, + 'inputReportReasonChildAbuse': ReportReason.inputReportReasonChildAbuse, + 'inputReportReasonOther': ReportReason.inputReportReasonOther, + 'inputReportReasonCopyright': ReportReason.inputReportReasonCopyright, + 'inputReportReasonGeoIrrelevant': ReportReason.inputReportReasonGeoIrrelevant, + 'userFull': UserFull.userFull, + 'contact': Contact.contact, + 'importedContact': ImportedContact.importedContact, + 'contactBlocked': ContactBlocked.contactBlocked, + 'contactStatus': ContactStatus.contactStatus, + 'contacts.contactsNotModified': ContactsContacts.contactsContactsNotModified, + 'contacts.contacts': ContactsContacts.contactsContacts, + 'contacts.importedContacts': ContactsImportedContacts.contactsImportedContacts, + 'contacts.blocked': ContactsBlocked.contactsBlocked, + 'contacts.blockedSlice': ContactsBlocked.contactsBlockedSlice, + 'messages.dialogs': MessagesDialogs.messagesDialogs, + 'messages.dialogsSlice': MessagesDialogs.messagesDialogsSlice, + 'messages.dialogsNotModified': MessagesDialogs.messagesDialogsNotModified, + 'messages.messages': MessagesMessages.messagesMessages, + 'messages.messagesSlice': MessagesMessages.messagesMessagesSlice, + 'messages.channelMessages': MessagesMessages.messagesChannelMessages, + 'messages.messagesNotModified': MessagesMessages.messagesMessagesNotModified, + 'messages.chats': MessagesChats.messagesChats, + 'messages.chatsSlice': MessagesChats.messagesChatsSlice, + 'messages.chatFull': MessagesChatFull.messagesChatFull, + 'messages.affectedHistory': MessagesAffectedHistory.messagesAffectedHistory, + 'inputMessagesFilterEmpty': MessagesFilter.inputMessagesFilterEmpty, + 'inputMessagesFilterPhotos': MessagesFilter.inputMessagesFilterPhotos, + 'inputMessagesFilterVideo': MessagesFilter.inputMessagesFilterVideo, + 'inputMessagesFilterPhotoVideo': MessagesFilter.inputMessagesFilterPhotoVideo, + 'inputMessagesFilterDocument': MessagesFilter.inputMessagesFilterDocument, + 'inputMessagesFilterUrl': MessagesFilter.inputMessagesFilterUrl, + 'inputMessagesFilterGif': MessagesFilter.inputMessagesFilterGif, + 'inputMessagesFilterVoice': MessagesFilter.inputMessagesFilterVoice, + 'inputMessagesFilterMusic': MessagesFilter.inputMessagesFilterMusic, + 'inputMessagesFilterChatPhotos': MessagesFilter.inputMessagesFilterChatPhotos, + 'inputMessagesFilterPhoneCalls': MessagesFilter.inputMessagesFilterPhoneCalls, + 'inputMessagesFilterRoundVoice': MessagesFilter.inputMessagesFilterRoundVoice, + 'inputMessagesFilterRoundVideo': MessagesFilter.inputMessagesFilterRoundVideo, + 'inputMessagesFilterMyMentions': MessagesFilter.inputMessagesFilterMyMentions, + 'inputMessagesFilterGeo': MessagesFilter.inputMessagesFilterGeo, + 'inputMessagesFilterContacts': MessagesFilter.inputMessagesFilterContacts, + 'updateNewMessage': Update.updateNewMessage, + 'updateMessageID': Update.updateMessageID, + 'updateDeleteMessages': Update.updateDeleteMessages, + 'updateUserTyping': Update.updateUserTyping, + 'updateChatUserTyping': Update.updateChatUserTyping, + 'updateChatParticipants': Update.updateChatParticipants, + 'updateUserStatus': Update.updateUserStatus, + 'updateUserName': Update.updateUserName, + 'updateUserPhoto': Update.updateUserPhoto, + 'updateNewEncryptedMessage': Update.updateNewEncryptedMessage, + 'updateEncryptedChatTyping': Update.updateEncryptedChatTyping, + 'updateEncryption': Update.updateEncryption, + 'updateEncryptedMessagesRead': Update.updateEncryptedMessagesRead, + 'updateChatParticipantAdd': Update.updateChatParticipantAdd, + 'updateChatParticipantDelete': Update.updateChatParticipantDelete, + 'updateDcOptions': Update.updateDcOptions, + 'updateUserBlocked': Update.updateUserBlocked, + 'updateNotifySettings': Update.updateNotifySettings, + 'updateServiceNotification': Update.updateServiceNotification, + 'updatePrivacy': Update.updatePrivacy, + 'updateUserPhone': Update.updateUserPhone, + 'updateReadHistoryInbox': Update.updateReadHistoryInbox, + 'updateReadHistoryOutbox': Update.updateReadHistoryOutbox, + 'updateWebPage': Update.updateWebPage, + 'updateReadMessagesContents': Update.updateReadMessagesContents, + 'updateChannelTooLong': Update.updateChannelTooLong, + 'updateChannel': Update.updateChannel, + 'updateNewChannelMessage': Update.updateNewChannelMessage, + 'updateReadChannelInbox': Update.updateReadChannelInbox, + 'updateDeleteChannelMessages': Update.updateDeleteChannelMessages, + 'updateChannelMessageViews': Update.updateChannelMessageViews, + 'updateChatParticipantAdmin': Update.updateChatParticipantAdmin, + 'updateNewStickerSet': Update.updateNewStickerSet, + 'updateStickerSetsOrder': Update.updateStickerSetsOrder, + 'updateStickerSets': Update.updateStickerSets, + 'updateSavedGifs': Update.updateSavedGifs, + 'updateBotInlineQuery': Update.updateBotInlineQuery, + 'updateBotInlineSend': Update.updateBotInlineSend, + 'updateEditChannelMessage': Update.updateEditChannelMessage, + 'updateChannelPinnedMessage': Update.updateChannelPinnedMessage, + 'updateBotCallbackQuery': Update.updateBotCallbackQuery, + 'updateEditMessage': Update.updateEditMessage, + 'updateInlineBotCallbackQuery': Update.updateInlineBotCallbackQuery, + 'updateReadChannelOutbox': Update.updateReadChannelOutbox, + 'updateDraftMessage': Update.updateDraftMessage, + 'updateReadFeaturedStickers': Update.updateReadFeaturedStickers, + 'updateRecentStickers': Update.updateRecentStickers, + 'updateConfig': Update.updateConfig, + 'updatePtsChanged': Update.updatePtsChanged, + 'updateChannelWebPage': Update.updateChannelWebPage, + 'updateDialogPinned': Update.updateDialogPinned, + 'updatePinnedDialogs': Update.updatePinnedDialogs, + 'updateBotWebhookJSON': Update.updateBotWebhookJSON, + 'updateBotWebhookJSONQuery': Update.updateBotWebhookJSONQuery, + 'updateBotShippingQuery': Update.updateBotShippingQuery, + 'updateBotPrecheckoutQuery': Update.updateBotPrecheckoutQuery, + 'updatePhoneCall': Update.updatePhoneCall, + 'updateLangPackTooLong': Update.updateLangPackTooLong, + 'updateLangPack': Update.updateLangPack, + 'updateFavedStickers': Update.updateFavedStickers, + 'updateChannelReadMessagesContents': Update.updateChannelReadMessagesContents, + 'updateContactsReset': Update.updateContactsReset, + 'updateChannelAvailableMessages': Update.updateChannelAvailableMessages, + 'updateDialogUnreadMark': Update.updateDialogUnreadMark, + 'updateUserPinnedMessage': Update.updateUserPinnedMessage, + 'updateChatPinnedMessage': Update.updateChatPinnedMessage, + 'updateMessagePoll': Update.updateMessagePoll, + 'updateChatDefaultBannedRights': Update.updateChatDefaultBannedRights, + 'updateFolderPeers': Update.updateFolderPeers, + 'updatePeerSettings': Update.updatePeerSettings, + 'updatePeerLocated': Update.updatePeerLocated, + 'updateNewScheduledMessage': Update.updateNewScheduledMessage, + 'updateDeleteScheduledMessages': Update.updateDeleteScheduledMessages, + 'updateTheme': Update.updateTheme, + 'updateGeoLiveViewed': Update.updateGeoLiveViewed, + 'updateLoginToken': Update.updateLoginToken, + 'updateMessagePollVote': Update.updateMessagePollVote, + 'updateDialogFilter': Update.updateDialogFilter, + 'updateDialogFilterOrder': Update.updateDialogFilterOrder, + 'updateDialogFilters': Update.updateDialogFilters, + 'updates.state': UpdatesState.updatesState, + 'updates.differenceEmpty': UpdatesDifference.updatesDifferenceEmpty, + 'updates.difference': UpdatesDifference.updatesDifference, + 'updates.differenceSlice': UpdatesDifference.updatesDifferenceSlice, + 'updates.differenceTooLong': UpdatesDifference.updatesDifferenceTooLong, + 'updatesTooLong': Updates.updatesTooLong, + 'updateShortMessage': Updates.updateShortMessage, + 'updateShortChatMessage': Updates.updateShortChatMessage, + 'updateShort': Updates.updateShort, + 'updatesCombined': Updates.updatesCombined, + 'updates': Updates.updates, + 'updateShortSentMessage': Updates.updateShortSentMessage, + 'photos.photos': PhotosPhotos.photosPhotos, + 'photos.photosSlice': PhotosPhotos.photosPhotosSlice, + 'photos.photo': PhotosPhoto.photosPhoto, + 'upload.file': UploadFile.uploadFile, + 'upload.fileCdnRedirect': UploadFile.uploadFileCdnRedirect, + 'dcOption': DcOption.dcOption, + 'config': Config.config, + 'nearestDc': NearestDc.nearestDc, + 'help.appUpdate': HelpAppUpdate.helpAppUpdate, + 'help.noAppUpdate': HelpAppUpdate.helpNoAppUpdate, + 'help.inviteText': HelpInviteText.helpInviteText, + 'encryptedChatEmpty': EncryptedChat.encryptedChatEmpty, + 'encryptedChatWaiting': EncryptedChat.encryptedChatWaiting, + 'encryptedChatRequested': EncryptedChat.encryptedChatRequested, + 'encryptedChat': EncryptedChat.encryptedChat, + 'encryptedChatDiscarded': EncryptedChat.encryptedChatDiscarded, + 'inputEncryptedChat': InputEncryptedChat.inputEncryptedChat, + 'encryptedFileEmpty': EncryptedFile.encryptedFileEmpty, + 'encryptedFile': EncryptedFile.encryptedFile, + 'inputEncryptedFileEmpty': InputEncryptedFile.inputEncryptedFileEmpty, + 'inputEncryptedFileUploaded': InputEncryptedFile.inputEncryptedFileUploaded, + 'inputEncryptedFile': InputEncryptedFile.inputEncryptedFile, + 'inputEncryptedFileBigUploaded': InputEncryptedFile.inputEncryptedFileBigUploaded, + 'encryptedMessage': EncryptedMessage.encryptedMessage, + 'encryptedMessageService': EncryptedMessage.encryptedMessageService, + 'messages.dhConfigNotModified': MessagesDhConfig.messagesDhConfigNotModified, + 'messages.dhConfig': MessagesDhConfig.messagesDhConfig, + 'messages.sentEncryptedMessage': MessagesSentEncryptedMessage.messagesSentEncryptedMessage, + 'messages.sentEncryptedFile': MessagesSentEncryptedMessage.messagesSentEncryptedFile, + 'inputDocumentEmpty': InputDocument.inputDocumentEmpty, + 'inputDocument': InputDocument.inputDocument, + 'documentEmpty': Document.documentEmpty, + 'document': Document.document, + 'help.support': HelpSupport.helpSupport, + 'notifyPeer': NotifyPeer.notifyPeer, + 'notifyUsers': NotifyPeer.notifyUsers, + 'notifyChats': NotifyPeer.notifyChats, + 'notifyBroadcasts': NotifyPeer.notifyBroadcasts, + 'sendMessageTypingAction': SendMessageAction.sendMessageTypingAction, + 'sendMessageCancelAction': SendMessageAction.sendMessageCancelAction, + 'sendMessageRecordVideoAction': SendMessageAction.sendMessageRecordVideoAction, + 'sendMessageUploadVideoAction': SendMessageAction.sendMessageUploadVideoAction, + 'sendMessageRecordAudioAction': SendMessageAction.sendMessageRecordAudioAction, + 'sendMessageUploadAudioAction': SendMessageAction.sendMessageUploadAudioAction, + 'sendMessageUploadPhotoAction': SendMessageAction.sendMessageUploadPhotoAction, + 'sendMessageUploadDocumentAction': SendMessageAction.sendMessageUploadDocumentAction, + 'sendMessageGeoLocationAction': SendMessageAction.sendMessageGeoLocationAction, + 'sendMessageChooseContactAction': SendMessageAction.sendMessageChooseContactAction, + 'sendMessageGamePlayAction': SendMessageAction.sendMessageGamePlayAction, + 'sendMessageRecordRoundAction': SendMessageAction.sendMessageRecordRoundAction, + 'sendMessageUploadRoundAction': SendMessageAction.sendMessageUploadRoundAction, + 'contacts.found': ContactsFound.contactsFound, + 'inputPrivacyKeyStatusTimestamp': InputPrivacyKey.inputPrivacyKeyStatusTimestamp, + 'inputPrivacyKeyChatInvite': InputPrivacyKey.inputPrivacyKeyChatInvite, + 'inputPrivacyKeyPhoneCall': InputPrivacyKey.inputPrivacyKeyPhoneCall, + 'inputPrivacyKeyPhoneP2P': InputPrivacyKey.inputPrivacyKeyPhoneP2P, + 'inputPrivacyKeyForwards': InputPrivacyKey.inputPrivacyKeyForwards, + 'inputPrivacyKeyProfilePhoto': InputPrivacyKey.inputPrivacyKeyProfilePhoto, + 'inputPrivacyKeyPhoneNumber': InputPrivacyKey.inputPrivacyKeyPhoneNumber, + 'inputPrivacyKeyAddedByPhone': InputPrivacyKey.inputPrivacyKeyAddedByPhone, + 'privacyKeyStatusTimestamp': PrivacyKey.privacyKeyStatusTimestamp, + 'privacyKeyChatInvite': PrivacyKey.privacyKeyChatInvite, + 'privacyKeyPhoneCall': PrivacyKey.privacyKeyPhoneCall, + 'privacyKeyPhoneP2P': PrivacyKey.privacyKeyPhoneP2P, + 'privacyKeyForwards': PrivacyKey.privacyKeyForwards, + 'privacyKeyProfilePhoto': PrivacyKey.privacyKeyProfilePhoto, + 'privacyKeyPhoneNumber': PrivacyKey.privacyKeyPhoneNumber, + 'privacyKeyAddedByPhone': PrivacyKey.privacyKeyAddedByPhone, + 'inputPrivacyValueAllowContacts': InputPrivacyRule.inputPrivacyValueAllowContacts, + 'inputPrivacyValueAllowAll': InputPrivacyRule.inputPrivacyValueAllowAll, + 'inputPrivacyValueAllowUsers': InputPrivacyRule.inputPrivacyValueAllowUsers, + 'inputPrivacyValueDisallowContacts': InputPrivacyRule.inputPrivacyValueDisallowContacts, + 'inputPrivacyValueDisallowAll': InputPrivacyRule.inputPrivacyValueDisallowAll, + 'inputPrivacyValueDisallowUsers': InputPrivacyRule.inputPrivacyValueDisallowUsers, + 'inputPrivacyValueAllowChatParticipants': InputPrivacyRule.inputPrivacyValueAllowChatParticipants, + 'inputPrivacyValueDisallowChatParticipants': InputPrivacyRule.inputPrivacyValueDisallowChatParticipants, + 'privacyValueAllowContacts': PrivacyRule.privacyValueAllowContacts, + 'privacyValueAllowAll': PrivacyRule.privacyValueAllowAll, + 'privacyValueAllowUsers': PrivacyRule.privacyValueAllowUsers, + 'privacyValueDisallowContacts': PrivacyRule.privacyValueDisallowContacts, + 'privacyValueDisallowAll': PrivacyRule.privacyValueDisallowAll, + 'privacyValueDisallowUsers': PrivacyRule.privacyValueDisallowUsers, + 'privacyValueAllowChatParticipants': PrivacyRule.privacyValueAllowChatParticipants, + 'privacyValueDisallowChatParticipants': PrivacyRule.privacyValueDisallowChatParticipants, + 'account.privacyRules': AccountPrivacyRules.accountPrivacyRules, + 'accountDaysTTL': AccountDaysTTL.accountDaysTTL, + 'documentAttributeImageSize': DocumentAttribute.documentAttributeImageSize, + 'documentAttributeAnimated': DocumentAttribute.documentAttributeAnimated, + 'documentAttributeSticker': DocumentAttribute.documentAttributeSticker, + 'documentAttributeVideo': DocumentAttribute.documentAttributeVideo, + 'documentAttributeAudio': DocumentAttribute.documentAttributeAudio, + 'documentAttributeFilename': DocumentAttribute.documentAttributeFilename, + 'documentAttributeHasStickers': DocumentAttribute.documentAttributeHasStickers, + 'messages.stickersNotModified': MessagesStickers.messagesStickersNotModified, + 'messages.stickers': MessagesStickers.messagesStickers, + 'stickerPack': StickerPack.stickerPack, + 'messages.allStickersNotModified': MessagesAllStickers.messagesAllStickersNotModified, + 'messages.allStickers': MessagesAllStickers.messagesAllStickers, + 'messages.affectedMessages': MessagesAffectedMessages.messagesAffectedMessages, + 'webPageEmpty': WebPage.webPageEmpty, + 'webPagePending': WebPage.webPagePending, + 'webPage': WebPage.webPage, + 'webPageNotModified': WebPage.webPageNotModified, + 'authorization': Authorization.authorization, + 'account.authorizations': AccountAuthorizations.accountAuthorizations, + 'account.password': AccountPassword.accountPassword, + 'account.passwordSettings': AccountPasswordSettings.accountPasswordSettings, + 'account.passwordInputSettings': AccountPasswordInputSettings.accountPasswordInputSettings, + 'auth.passwordRecovery': AuthPasswordRecovery.authPasswordRecovery, + 'receivedNotifyMessage': ReceivedNotifyMessage.receivedNotifyMessage, + 'chatInviteEmpty': ExportedChatInvite.chatInviteEmpty, + 'chatInviteExported': ExportedChatInvite.chatInviteExported, + 'chatInviteAlready': ChatInvite.chatInviteAlready, + 'chatInvite': ChatInvite.chatInvite, + 'inputStickerSetEmpty': InputStickerSet.inputStickerSetEmpty, + 'inputStickerSetID': InputStickerSet.inputStickerSetID, + 'inputStickerSetShortName': InputStickerSet.inputStickerSetShortName, + 'inputStickerSetAnimatedEmoji': InputStickerSet.inputStickerSetAnimatedEmoji, + 'inputStickerSetDice': InputStickerSet.inputStickerSetDice, + 'stickerSet': StickerSet.stickerSet, + 'messages.stickerSet': MessagesStickerSet.messagesStickerSet, + 'botCommand': BotCommand.botCommand, + 'botInfo': BotInfo.botInfo, + 'keyboardButton': KeyboardButton.keyboardButton, + 'keyboardButtonUrl': KeyboardButton.keyboardButtonUrl, + 'keyboardButtonCallback': KeyboardButton.keyboardButtonCallback, + 'keyboardButtonRequestPhone': KeyboardButton.keyboardButtonRequestPhone, + 'keyboardButtonRequestGeoLocation': KeyboardButton.keyboardButtonRequestGeoLocation, + 'keyboardButtonSwitchInline': KeyboardButton.keyboardButtonSwitchInline, + 'keyboardButtonGame': KeyboardButton.keyboardButtonGame, + 'keyboardButtonBuy': KeyboardButton.keyboardButtonBuy, + 'keyboardButtonUrlAuth': KeyboardButton.keyboardButtonUrlAuth, + 'inputKeyboardButtonUrlAuth': KeyboardButton.inputKeyboardButtonUrlAuth, + 'keyboardButtonRequestPoll': KeyboardButton.keyboardButtonRequestPoll, + 'keyboardButtonRow': KeyboardButtonRow.keyboardButtonRow, + 'replyKeyboardHide': ReplyMarkup.replyKeyboardHide, + 'replyKeyboardForceReply': ReplyMarkup.replyKeyboardForceReply, + 'replyKeyboardMarkup': ReplyMarkup.replyKeyboardMarkup, + 'replyInlineMarkup': ReplyMarkup.replyInlineMarkup, + 'messageEntityUnknown': MessageEntity.messageEntityUnknown, + 'messageEntityMention': MessageEntity.messageEntityMention, + 'messageEntityHashtag': MessageEntity.messageEntityHashtag, + 'messageEntityBotCommand': MessageEntity.messageEntityBotCommand, + 'messageEntityUrl': MessageEntity.messageEntityUrl, + 'messageEntityEmail': MessageEntity.messageEntityEmail, + 'messageEntityBold': MessageEntity.messageEntityBold, + 'messageEntityItalic': MessageEntity.messageEntityItalic, + 'messageEntityCode': MessageEntity.messageEntityCode, + 'messageEntityPre': MessageEntity.messageEntityPre, + 'messageEntityTextUrl': MessageEntity.messageEntityTextUrl, + 'messageEntityMentionName': MessageEntity.messageEntityMentionName, + 'inputMessageEntityMentionName': MessageEntity.inputMessageEntityMentionName, + 'messageEntityPhone': MessageEntity.messageEntityPhone, + 'messageEntityCashtag': MessageEntity.messageEntityCashtag, + 'messageEntityUnderline': MessageEntity.messageEntityUnderline, + 'messageEntityStrike': MessageEntity.messageEntityStrike, + 'messageEntityBlockquote': MessageEntity.messageEntityBlockquote, + 'messageEntityBankCard': MessageEntity.messageEntityBankCard, + 'inputChannelEmpty': InputChannel.inputChannelEmpty, + 'inputChannel': InputChannel.inputChannel, + 'inputChannelFromMessage': InputChannel.inputChannelFromMessage, + 'contacts.resolvedPeer': ContactsResolvedPeer.contactsResolvedPeer, + 'messageRange': MessageRange.messageRange, + 'updates.channelDifferenceEmpty': UpdatesChannelDifference.updatesChannelDifferenceEmpty, + 'updates.channelDifferenceTooLong': UpdatesChannelDifference.updatesChannelDifferenceTooLong, + 'updates.channelDifference': UpdatesChannelDifference.updatesChannelDifference, + 'channelMessagesFilterEmpty': ChannelMessagesFilter.channelMessagesFilterEmpty, + 'channelMessagesFilter': ChannelMessagesFilter.channelMessagesFilter, + 'channelParticipant': ChannelParticipant.channelParticipant, + 'channelParticipantSelf': ChannelParticipant.channelParticipantSelf, + 'channelParticipantCreator': ChannelParticipant.channelParticipantCreator, + 'channelParticipantAdmin': ChannelParticipant.channelParticipantAdmin, + 'channelParticipantBanned': ChannelParticipant.channelParticipantBanned, + 'channelParticipantsRecent': ChannelParticipantsFilter.channelParticipantsRecent, + 'channelParticipantsAdmins': ChannelParticipantsFilter.channelParticipantsAdmins, + 'channelParticipantsKicked': ChannelParticipantsFilter.channelParticipantsKicked, + 'channelParticipantsBots': ChannelParticipantsFilter.channelParticipantsBots, + 'channelParticipantsBanned': ChannelParticipantsFilter.channelParticipantsBanned, + 'channelParticipantsSearch': ChannelParticipantsFilter.channelParticipantsSearch, + 'channelParticipantsContacts': ChannelParticipantsFilter.channelParticipantsContacts, + 'channels.channelParticipants': ChannelsChannelParticipants.channelsChannelParticipants, + 'channels.channelParticipantsNotModified': ChannelsChannelParticipants.channelsChannelParticipantsNotModified, + 'channels.channelParticipant': ChannelsChannelParticipant.channelsChannelParticipant, + 'help.termsOfService': HelpTermsOfService.helpTermsOfService, + 'foundGif': FoundGif.foundGif, + 'foundGifCached': FoundGif.foundGifCached, + 'messages.foundGifs': MessagesFoundGifs.messagesFoundGifs, + 'messages.savedGifsNotModified': MessagesSavedGifs.messagesSavedGifsNotModified, + 'messages.savedGifs': MessagesSavedGifs.messagesSavedGifs, + 'inputBotInlineMessageMediaAuto': InputBotInlineMessage.inputBotInlineMessageMediaAuto, + 'inputBotInlineMessageText': InputBotInlineMessage.inputBotInlineMessageText, + 'inputBotInlineMessageMediaGeo': InputBotInlineMessage.inputBotInlineMessageMediaGeo, + 'inputBotInlineMessageMediaVenue': InputBotInlineMessage.inputBotInlineMessageMediaVenue, + 'inputBotInlineMessageMediaContact': InputBotInlineMessage.inputBotInlineMessageMediaContact, + 'inputBotInlineMessageGame': InputBotInlineMessage.inputBotInlineMessageGame, + 'inputBotInlineResult': InputBotInlineResult.inputBotInlineResult, + 'inputBotInlineResultPhoto': InputBotInlineResult.inputBotInlineResultPhoto, + 'inputBotInlineResultDocument': InputBotInlineResult.inputBotInlineResultDocument, + 'inputBotInlineResultGame': InputBotInlineResult.inputBotInlineResultGame, + 'botInlineMessageMediaAuto': BotInlineMessage.botInlineMessageMediaAuto, + 'botInlineMessageText': BotInlineMessage.botInlineMessageText, + 'botInlineMessageMediaGeo': BotInlineMessage.botInlineMessageMediaGeo, + 'botInlineMessageMediaVenue': BotInlineMessage.botInlineMessageMediaVenue, + 'botInlineMessageMediaContact': BotInlineMessage.botInlineMessageMediaContact, + 'botInlineResult': BotInlineResult.botInlineResult, + 'botInlineMediaResult': BotInlineResult.botInlineMediaResult, + 'messages.botResults': MessagesBotResults.messagesBotResults, + 'exportedMessageLink': ExportedMessageLink.exportedMessageLink, + 'messageFwdHeader': MessageFwdHeader.messageFwdHeader, + 'auth.codeTypeSms': AuthCodeType.authCodeTypeSms, + 'auth.codeTypeCall': AuthCodeType.authCodeTypeCall, + 'auth.codeTypeFlashCall': AuthCodeType.authCodeTypeFlashCall, + 'auth.sentCodeTypeApp': AuthSentCodeType.authSentCodeTypeApp, + 'auth.sentCodeTypeSms': AuthSentCodeType.authSentCodeTypeSms, + 'auth.sentCodeTypeCall': AuthSentCodeType.authSentCodeTypeCall, + 'auth.sentCodeTypeFlashCall': AuthSentCodeType.authSentCodeTypeFlashCall, + 'messages.botCallbackAnswer': MessagesBotCallbackAnswer.messagesBotCallbackAnswer, + 'messages.messageEditData': MessagesMessageEditData.messagesMessageEditData, + 'inputBotInlineMessageID': InputBotInlineMessageID.inputBotInlineMessageID, + 'inlineBotSwitchPM': InlineBotSwitchPM.inlineBotSwitchPM, + 'messages.peerDialogs': MessagesPeerDialogs.messagesPeerDialogs, + 'topPeer': TopPeer.topPeer, + 'topPeerCategoryBotsPM': TopPeerCategory.topPeerCategoryBotsPM, + 'topPeerCategoryBotsInline': TopPeerCategory.topPeerCategoryBotsInline, + 'topPeerCategoryCorrespondents': TopPeerCategory.topPeerCategoryCorrespondents, + 'topPeerCategoryGroups': TopPeerCategory.topPeerCategoryGroups, + 'topPeerCategoryChannels': TopPeerCategory.topPeerCategoryChannels, + 'topPeerCategoryPhoneCalls': TopPeerCategory.topPeerCategoryPhoneCalls, + 'topPeerCategoryForwardUsers': TopPeerCategory.topPeerCategoryForwardUsers, + 'topPeerCategoryForwardChats': TopPeerCategory.topPeerCategoryForwardChats, + 'topPeerCategoryPeers': TopPeerCategoryPeers.topPeerCategoryPeers, + 'contacts.topPeersNotModified': ContactsTopPeers.contactsTopPeersNotModified, + 'contacts.topPeers': ContactsTopPeers.contactsTopPeers, + 'contacts.topPeersDisabled': ContactsTopPeers.contactsTopPeersDisabled, + 'draftMessageEmpty': DraftMessage.draftMessageEmpty, + 'draftMessage': DraftMessage.draftMessage, + 'messages.featuredStickersNotModified': MessagesFeaturedStickers.messagesFeaturedStickersNotModified, + 'messages.featuredStickers': MessagesFeaturedStickers.messagesFeaturedStickers, + 'messages.recentStickersNotModified': MessagesRecentStickers.messagesRecentStickersNotModified, + 'messages.recentStickers': MessagesRecentStickers.messagesRecentStickers, + 'messages.archivedStickers': MessagesArchivedStickers.messagesArchivedStickers, + 'messages.stickerSetInstallResultSuccess': MessagesStickerSetInstallResult.messagesStickerSetInstallResultSuccess, + 'messages.stickerSetInstallResultArchive': MessagesStickerSetInstallResult.messagesStickerSetInstallResultArchive, + 'stickerSetCovered': StickerSetCovered.stickerSetCovered, + 'stickerSetMultiCovered': StickerSetCovered.stickerSetMultiCovered, + 'maskCoords': MaskCoords.maskCoords, + 'inputStickeredMediaPhoto': InputStickeredMedia.inputStickeredMediaPhoto, + 'inputStickeredMediaDocument': InputStickeredMedia.inputStickeredMediaDocument, + 'game': Game.game, + 'inputGameID': InputGame.inputGameID, + 'inputGameShortName': InputGame.inputGameShortName, + 'highScore': HighScore.highScore, + 'messages.highScores': MessagesHighScores.messagesHighScores, + 'textEmpty': RichText.textEmpty, + 'textPlain': RichText.textPlain, + 'textBold': RichText.textBold, + 'textItalic': RichText.textItalic, + 'textUnderline': RichText.textUnderline, + 'textStrike': RichText.textStrike, + 'textFixed': RichText.textFixed, + 'textUrl': RichText.textUrl, + 'textEmail': RichText.textEmail, + 'textConcat': RichText.textConcat, + 'textSubscript': RichText.textSubscript, + 'textSuperscript': RichText.textSuperscript, + 'textMarked': RichText.textMarked, + 'textPhone': RichText.textPhone, + 'textImage': RichText.textImage, + 'textAnchor': RichText.textAnchor, + 'pageBlockUnsupported': PageBlock.pageBlockUnsupported, + 'pageBlockTitle': PageBlock.pageBlockTitle, + 'pageBlockSubtitle': PageBlock.pageBlockSubtitle, + 'pageBlockAuthorDate': PageBlock.pageBlockAuthorDate, + 'pageBlockHeader': PageBlock.pageBlockHeader, + 'pageBlockSubheader': PageBlock.pageBlockSubheader, + 'pageBlockParagraph': PageBlock.pageBlockParagraph, + 'pageBlockPreformatted': PageBlock.pageBlockPreformatted, + 'pageBlockFooter': PageBlock.pageBlockFooter, + 'pageBlockDivider': PageBlock.pageBlockDivider, + 'pageBlockAnchor': PageBlock.pageBlockAnchor, + 'pageBlockList': PageBlock.pageBlockList, + 'pageBlockBlockquote': PageBlock.pageBlockBlockquote, + 'pageBlockPullquote': PageBlock.pageBlockPullquote, + 'pageBlockPhoto': PageBlock.pageBlockPhoto, + 'pageBlockVideo': PageBlock.pageBlockVideo, + 'pageBlockCover': PageBlock.pageBlockCover, + 'pageBlockEmbed': PageBlock.pageBlockEmbed, + 'pageBlockEmbedPost': PageBlock.pageBlockEmbedPost, + 'pageBlockCollage': PageBlock.pageBlockCollage, + 'pageBlockSlideshow': PageBlock.pageBlockSlideshow, + 'pageBlockChannel': PageBlock.pageBlockChannel, + 'pageBlockAudio': PageBlock.pageBlockAudio, + 'pageBlockKicker': PageBlock.pageBlockKicker, + 'pageBlockTable': PageBlock.pageBlockTable, + 'pageBlockOrderedList': PageBlock.pageBlockOrderedList, + 'pageBlockDetails': PageBlock.pageBlockDetails, + 'pageBlockRelatedArticles': PageBlock.pageBlockRelatedArticles, + 'pageBlockMap': PageBlock.pageBlockMap, + 'phoneCallDiscardReasonMissed': PhoneCallDiscardReason.phoneCallDiscardReasonMissed, + 'phoneCallDiscardReasonDisconnect': PhoneCallDiscardReason.phoneCallDiscardReasonDisconnect, + 'phoneCallDiscardReasonHangup': PhoneCallDiscardReason.phoneCallDiscardReasonHangup, + 'phoneCallDiscardReasonBusy': PhoneCallDiscardReason.phoneCallDiscardReasonBusy, + 'dataJSON': DataJSON.dataJSON, + 'labeledPrice': LabeledPrice.labeledPrice, + 'invoice': Invoice.invoice, + 'paymentCharge': PaymentCharge.paymentCharge, + 'postAddress': PostAddress.postAddress, + 'paymentRequestedInfo': PaymentRequestedInfo.paymentRequestedInfo, + 'paymentSavedCredentialsCard': PaymentSavedCredentials.paymentSavedCredentialsCard, + 'webDocument': WebDocument.webDocument, + 'webDocumentNoProxy': WebDocument.webDocumentNoProxy, + 'inputWebDocument': InputWebDocument.inputWebDocument, + 'inputWebFileLocation': InputWebFileLocation.inputWebFileLocation, + 'inputWebFileGeoPointLocation': InputWebFileLocation.inputWebFileGeoPointLocation, + 'upload.webFile': UploadWebFile.uploadWebFile, + 'payments.paymentForm': PaymentsPaymentForm.paymentsPaymentForm, + 'payments.validatedRequestedInfo': PaymentsValidatedRequestedInfo.paymentsValidatedRequestedInfo, + 'payments.paymentResult': PaymentsPaymentResult.paymentsPaymentResult, + 'payments.paymentVerificationNeeded': PaymentsPaymentResult.paymentsPaymentVerificationNeeded, + 'payments.paymentReceipt': PaymentsPaymentReceipt.paymentsPaymentReceipt, + 'payments.savedInfo': PaymentsSavedInfo.paymentsSavedInfo, + 'inputPaymentCredentialsSaved': InputPaymentCredentials.inputPaymentCredentialsSaved, + 'inputPaymentCredentials': InputPaymentCredentials.inputPaymentCredentials, + 'inputPaymentCredentialsApplePay': InputPaymentCredentials.inputPaymentCredentialsApplePay, + 'inputPaymentCredentialsAndroidPay': InputPaymentCredentials.inputPaymentCredentialsAndroidPay, + 'account.tmpPassword': AccountTmpPassword.accountTmpPassword, + 'shippingOption': ShippingOption.shippingOption, + 'inputStickerSetItem': InputStickerSetItem.inputStickerSetItem, + 'inputPhoneCall': InputPhoneCall.inputPhoneCall, + 'phoneCallEmpty': PhoneCall.phoneCallEmpty, + 'phoneCallWaiting': PhoneCall.phoneCallWaiting, + 'phoneCallRequested': PhoneCall.phoneCallRequested, + 'phoneCallAccepted': PhoneCall.phoneCallAccepted, + 'phoneCall': PhoneCall.phoneCall, + 'phoneCallDiscarded': PhoneCall.phoneCallDiscarded, + 'phoneConnection': PhoneConnection.phoneConnection, + 'phoneCallProtocol': PhoneCallProtocol.phoneCallProtocol, + 'phone.phoneCall': PhonePhoneCall.phonePhoneCall, + 'upload.cdnFileReuploadNeeded': UploadCdnFile.uploadCdnFileReuploadNeeded, + 'upload.cdnFile': UploadCdnFile.uploadCdnFile, + 'cdnPublicKey': CdnPublicKey.cdnPublicKey, + 'cdnConfig': CdnConfig.cdnConfig, + 'langPackString': LangPackString.langPackString, + 'langPackStringPluralized': LangPackString.langPackStringPluralized, + 'langPackStringDeleted': LangPackString.langPackStringDeleted, + 'langPackDifference': LangPackDifference.langPackDifference, + 'langPackLanguage': LangPackLanguage.langPackLanguage, + 'channelAdminLogEventActionChangeTitle': ChannelAdminLogEventAction.channelAdminLogEventActionChangeTitle, + 'channelAdminLogEventActionChangeAbout': ChannelAdminLogEventAction.channelAdminLogEventActionChangeAbout, + 'channelAdminLogEventActionChangeUsername': ChannelAdminLogEventAction.channelAdminLogEventActionChangeUsername, + 'channelAdminLogEventActionChangePhoto': ChannelAdminLogEventAction.channelAdminLogEventActionChangePhoto, + 'channelAdminLogEventActionToggleInvites': ChannelAdminLogEventAction.channelAdminLogEventActionToggleInvites, + 'channelAdminLogEventActionToggleSignatures': ChannelAdminLogEventAction.channelAdminLogEventActionToggleSignatures, + 'channelAdminLogEventActionUpdatePinned': ChannelAdminLogEventAction.channelAdminLogEventActionUpdatePinned, + 'channelAdminLogEventActionEditMessage': ChannelAdminLogEventAction.channelAdminLogEventActionEditMessage, + 'channelAdminLogEventActionDeleteMessage': ChannelAdminLogEventAction.channelAdminLogEventActionDeleteMessage, + 'channelAdminLogEventActionParticipantJoin': ChannelAdminLogEventAction.channelAdminLogEventActionParticipantJoin, + 'channelAdminLogEventActionParticipantLeave': ChannelAdminLogEventAction.channelAdminLogEventActionParticipantLeave, + 'channelAdminLogEventActionParticipantInvite': ChannelAdminLogEventAction.channelAdminLogEventActionParticipantInvite, + 'channelAdminLogEventActionParticipantToggleBan': ChannelAdminLogEventAction.channelAdminLogEventActionParticipantToggleBan, + 'channelAdminLogEventActionParticipantToggleAdmin': ChannelAdminLogEventAction.channelAdminLogEventActionParticipantToggleAdmin, + 'channelAdminLogEventActionChangeStickerSet': ChannelAdminLogEventAction.channelAdminLogEventActionChangeStickerSet, + 'channelAdminLogEventActionTogglePreHistoryHidden': ChannelAdminLogEventAction.channelAdminLogEventActionTogglePreHistoryHidden, + 'channelAdminLogEventActionDefaultBannedRights': ChannelAdminLogEventAction.channelAdminLogEventActionDefaultBannedRights, + 'channelAdminLogEventActionStopPoll': ChannelAdminLogEventAction.channelAdminLogEventActionStopPoll, + 'channelAdminLogEventActionChangeLinkedChat': ChannelAdminLogEventAction.channelAdminLogEventActionChangeLinkedChat, + 'channelAdminLogEventActionChangeLocation': ChannelAdminLogEventAction.channelAdminLogEventActionChangeLocation, + 'channelAdminLogEventActionToggleSlowMode': ChannelAdminLogEventAction.channelAdminLogEventActionToggleSlowMode, + 'channelAdminLogEvent': ChannelAdminLogEvent.channelAdminLogEvent, + 'channels.adminLogResults': ChannelsAdminLogResults.channelsAdminLogResults, + 'channelAdminLogEventsFilter': ChannelAdminLogEventsFilter.channelAdminLogEventsFilter, + 'popularContact': PopularContact.popularContact, + 'messages.favedStickersNotModified': MessagesFavedStickers.messagesFavedStickersNotModified, + 'messages.favedStickers': MessagesFavedStickers.messagesFavedStickers, + 'recentMeUrlUnknown': RecentMeUrl.recentMeUrlUnknown, + 'recentMeUrlUser': RecentMeUrl.recentMeUrlUser, + 'recentMeUrlChat': RecentMeUrl.recentMeUrlChat, + 'recentMeUrlChatInvite': RecentMeUrl.recentMeUrlChatInvite, + 'recentMeUrlStickerSet': RecentMeUrl.recentMeUrlStickerSet, + 'help.recentMeUrls': HelpRecentMeUrls.helpRecentMeUrls, + 'inputSingleMedia': InputSingleMedia.inputSingleMedia, + 'webAuthorization': WebAuthorization.webAuthorization, + 'account.webAuthorizations': AccountWebAuthorizations.accountWebAuthorizations, + 'inputMessageID': InputMessage.inputMessageID, + 'inputMessageReplyTo': InputMessage.inputMessageReplyTo, + 'inputMessagePinned': InputMessage.inputMessagePinned, + 'inputDialogPeer': InputDialogPeer.inputDialogPeer, + 'inputDialogPeerFolder': InputDialogPeer.inputDialogPeerFolder, + 'dialogPeer': DialogPeer.dialogPeer, + 'dialogPeerFolder': DialogPeer.dialogPeerFolder, + 'messages.foundStickerSetsNotModified': MessagesFoundStickerSets.messagesFoundStickerSetsNotModified, + 'messages.foundStickerSets': MessagesFoundStickerSets.messagesFoundStickerSets, + 'fileHash': FileHash.fileHash, + 'inputClientProxy': InputClientProxy.inputClientProxy, + 'help.termsOfServiceUpdateEmpty': HelpTermsOfServiceUpdate.helpTermsOfServiceUpdateEmpty, + 'help.termsOfServiceUpdate': HelpTermsOfServiceUpdate.helpTermsOfServiceUpdate, + 'inputSecureFileUploaded': InputSecureFile.inputSecureFileUploaded, + 'inputSecureFile': InputSecureFile.inputSecureFile, + 'secureFileEmpty': SecureFile.secureFileEmpty, + 'secureFile': SecureFile.secureFile, + 'secureData': SecureData.secureData, + 'securePlainPhone': SecurePlainData.securePlainPhone, + 'securePlainEmail': SecurePlainData.securePlainEmail, + 'secureValueTypePersonalDetails': SecureValueType.secureValueTypePersonalDetails, + 'secureValueTypePassport': SecureValueType.secureValueTypePassport, + 'secureValueTypeDriverLicense': SecureValueType.secureValueTypeDriverLicense, + 'secureValueTypeIdentityCard': SecureValueType.secureValueTypeIdentityCard, + 'secureValueTypeInternalPassport': SecureValueType.secureValueTypeInternalPassport, + 'secureValueTypeAddress': SecureValueType.secureValueTypeAddress, + 'secureValueTypeUtilityBill': SecureValueType.secureValueTypeUtilityBill, + 'secureValueTypeBankStatement': SecureValueType.secureValueTypeBankStatement, + 'secureValueTypeRentalAgreement': SecureValueType.secureValueTypeRentalAgreement, + 'secureValueTypePassportRegistration': SecureValueType.secureValueTypePassportRegistration, + 'secureValueTypeTemporaryRegistration': SecureValueType.secureValueTypeTemporaryRegistration, + 'secureValueTypePhone': SecureValueType.secureValueTypePhone, + 'secureValueTypeEmail': SecureValueType.secureValueTypeEmail, + 'secureValue': SecureValue.secureValue, + 'inputSecureValue': InputSecureValue.inputSecureValue, + 'secureValueHash': SecureValueHash.secureValueHash, + 'secureValueErrorData': SecureValueError.secureValueErrorData, + 'secureValueErrorFrontSide': SecureValueError.secureValueErrorFrontSide, + 'secureValueErrorReverseSide': SecureValueError.secureValueErrorReverseSide, + 'secureValueErrorSelfie': SecureValueError.secureValueErrorSelfie, + 'secureValueErrorFile': SecureValueError.secureValueErrorFile, + 'secureValueErrorFiles': SecureValueError.secureValueErrorFiles, + 'secureValueError': SecureValueError.secureValueError, + 'secureValueErrorTranslationFile': SecureValueError.secureValueErrorTranslationFile, + 'secureValueErrorTranslationFiles': SecureValueError.secureValueErrorTranslationFiles, + 'secureCredentialsEncrypted': SecureCredentialsEncrypted.secureCredentialsEncrypted, + 'account.authorizationForm': AccountAuthorizationForm.accountAuthorizationForm, + 'account.sentEmailCode': AccountSentEmailCode.accountSentEmailCode, + 'help.deepLinkInfoEmpty': HelpDeepLinkInfo.helpDeepLinkInfoEmpty, + 'help.deepLinkInfo': HelpDeepLinkInfo.helpDeepLinkInfo, + 'savedPhoneContact': SavedContact.savedPhoneContact, + 'account.takeout': AccountTakeout.accountTakeout, + 'passwordKdfAlgoUnknown': PasswordKdfAlgo.passwordKdfAlgoUnknown, + 'passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow': PasswordKdfAlgo.passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow, + 'securePasswordKdfAlgoUnknown': SecurePasswordKdfAlgo.securePasswordKdfAlgoUnknown, + 'securePasswordKdfAlgoPBKDF2HMACSHA512iter100000': SecurePasswordKdfAlgo.securePasswordKdfAlgoPBKDF2HMACSHA512iter100000, + 'securePasswordKdfAlgoSHA512': SecurePasswordKdfAlgo.securePasswordKdfAlgoSHA512, + 'secureSecretSettings': SecureSecretSettings.secureSecretSettings, + 'inputCheckPasswordEmpty': InputCheckPasswordSRP.inputCheckPasswordEmpty, + 'inputCheckPasswordSRP': InputCheckPasswordSRP.inputCheckPasswordSRP, + 'secureRequiredType': SecureRequiredType.secureRequiredType, + 'secureRequiredTypeOneOf': SecureRequiredType.secureRequiredTypeOneOf, + 'help.passportConfigNotModified': HelpPassportConfig.helpPassportConfigNotModified, + 'help.passportConfig': HelpPassportConfig.helpPassportConfig, + 'inputAppEvent': InputAppEvent.inputAppEvent, + 'jsonObjectValue': JSONObjectValue.jsonObjectValue, + 'jsonNull': JSONValue.jsonNull, + 'jsonBool': JSONValue.jsonBool, + 'jsonNumber': JSONValue.jsonNumber, + 'jsonString': JSONValue.jsonString, + 'jsonArray': JSONValue.jsonArray, + 'jsonObject': JSONValue.jsonObject, + 'pageTableCell': PageTableCell.pageTableCell, + 'pageTableRow': PageTableRow.pageTableRow, + 'pageCaption': PageCaption.pageCaption, + 'pageListItemText': PageListItem.pageListItemText, + 'pageListItemBlocks': PageListItem.pageListItemBlocks, + 'pageListOrderedItemText': PageListOrderedItem.pageListOrderedItemText, + 'pageListOrderedItemBlocks': PageListOrderedItem.pageListOrderedItemBlocks, + 'pageRelatedArticle': PageRelatedArticle.pageRelatedArticle, + 'page': Page.page, + 'help.supportName': HelpSupportName.helpSupportName, + 'help.userInfoEmpty': HelpUserInfo.helpUserInfoEmpty, + 'help.userInfo': HelpUserInfo.helpUserInfo, + 'pollAnswer': PollAnswer.pollAnswer, + 'poll': Poll.poll, + 'pollAnswerVoters': PollAnswerVoters.pollAnswerVoters, + 'pollResults': PollResults.pollResults, + 'chatOnlines': ChatOnlines.chatOnlines, + 'statsURL': StatsURL.statsURL, + 'chatAdminRights': ChatAdminRights.chatAdminRights, + 'chatBannedRights': ChatBannedRights.chatBannedRights, + 'inputWallPaper': InputWallPaper.inputWallPaper, + 'inputWallPaperSlug': InputWallPaper.inputWallPaperSlug, + 'inputWallPaperNoFile': InputWallPaper.inputWallPaperNoFile, + 'account.wallPapersNotModified': AccountWallPapers.accountWallPapersNotModified, + 'account.wallPapers': AccountWallPapers.accountWallPapers, + 'codeSettings': CodeSettings.codeSettings, + 'wallPaperSettings': WallPaperSettings.wallPaperSettings, + 'autoDownloadSettings': AutoDownloadSettings.autoDownloadSettings, + 'account.autoDownloadSettings': AccountAutoDownloadSettings.accountAutoDownloadSettings, + 'emojiKeyword': EmojiKeyword.emojiKeyword, + 'emojiKeywordDeleted': EmojiKeyword.emojiKeywordDeleted, + 'emojiKeywordsDifference': EmojiKeywordsDifference.emojiKeywordsDifference, + 'emojiURL': EmojiURL.emojiURL, + 'emojiLanguage': EmojiLanguage.emojiLanguage, + 'fileLocationToBeDeprecated': FileLocation.fileLocationToBeDeprecated, + 'folder': Folder.folder, + 'inputFolderPeer': InputFolderPeer.inputFolderPeer, + 'folderPeer': FolderPeer.folderPeer, + 'messages.searchCounter': MessagesSearchCounter.messagesSearchCounter, + 'urlAuthResultRequest': UrlAuthResult.urlAuthResultRequest, + 'urlAuthResultAccepted': UrlAuthResult.urlAuthResultAccepted, + 'urlAuthResultDefault': UrlAuthResult.urlAuthResultDefault, + 'channelLocationEmpty': ChannelLocation.channelLocationEmpty, + 'channelLocation': ChannelLocation.channelLocation, + 'peerLocated': PeerLocated.peerLocated, + 'peerSelfLocated': PeerLocated.peerSelfLocated, + 'restrictionReason': RestrictionReason.restrictionReason, + 'inputTheme': InputTheme.inputTheme, + 'inputThemeSlug': InputTheme.inputThemeSlug, + 'theme': Theme.theme, + 'account.themesNotModified': AccountThemes.accountThemesNotModified, + 'account.themes': AccountThemes.accountThemes, + 'auth.loginToken': AuthLoginToken.authLoginToken, + 'auth.loginTokenMigrateTo': AuthLoginToken.authLoginTokenMigrateTo, + 'auth.loginTokenSuccess': AuthLoginToken.authLoginTokenSuccess, + 'account.contentSettings': AccountContentSettings.accountContentSettings, + 'messages.inactiveChats': MessagesInactiveChats.messagesInactiveChats, + 'baseThemeClassic': BaseTheme.baseThemeClassic, + 'baseThemeDay': BaseTheme.baseThemeDay, + 'baseThemeNight': BaseTheme.baseThemeNight, + 'baseThemeTinted': BaseTheme.baseThemeTinted, + 'baseThemeArctic': BaseTheme.baseThemeArctic, + 'inputThemeSettings': InputThemeSettings.inputThemeSettings, + 'themeSettings': ThemeSettings.themeSettings, + 'webPageAttributeTheme': WebPageAttribute.webPageAttributeTheme, + 'messageUserVote': MessageUserVote.messageUserVote, + 'messageUserVoteInputOption': MessageUserVote.messageUserVoteInputOption, + 'messageUserVoteMultiple': MessageUserVote.messageUserVoteMultiple, + 'messages.votesList': MessagesVotesList.messagesVotesList, + 'bankCardOpenUrl': BankCardOpenUrl.bankCardOpenUrl, + 'payments.bankCardData': PaymentsBankCardData.paymentsBankCardData, + 'dialogFilter': DialogFilter.dialogFilter, + 'dialogFilterSuggested': DialogFilterSuggested.dialogFilterSuggested, + 'statsDateRangeDays': StatsDateRangeDays.statsDateRangeDays, + 'statsAbsValueAndPrev': StatsAbsValueAndPrev.statsAbsValueAndPrev, + 'statsPercentValue': StatsPercentValue.statsPercentValue, + 'statsGraphAsync': StatsGraph.statsGraphAsync, + 'statsGraphError': StatsGraph.statsGraphError, + 'statsGraph': StatsGraph.statsGraph, + 'messageInteractionCounters': MessageInteractionCounters.messageInteractionCounters, + 'stats.broadcastStats': StatsBroadcastStats.statsBroadcastStats, + 'help.promoDataEmpty': HelpPromoData.helpPromoDataEmpty, + 'help.promoData': HelpPromoData.helpPromoData, +} + +export type InvokeAfterMsg = { + msg_id: string, + query: any +}; + +export type InvokeAfterMsgs = { + msg_ids: Array, + query: any +}; + +export type InitConnection = { + flags?: number, + api_id: number, + device_model: string, + system_version: string, + app_version: string, + system_lang_code: string, + lang_pack: string, + lang_code: string, + proxy?: InputClientProxy, + params?: JSONValue, + query: any +}; + +export type InvokeWithLayer = { + layer: number, + query: any +}; + +export type InvokeWithoutUpdates = { + query: any +}; + +export type InvokeWithMessagesRange = { + range: MessageRange, + query: any +}; + +export type InvokeWithTakeout = { + takeout_id: string, + query: any +}; + +export type AuthSendCode = { + phone_number: string, + api_id: number, + api_hash: string, + settings: CodeSettings +}; + +export type AuthSignUp = { + phone_number: string, + phone_code_hash: string, + first_name: string, + last_name: string +}; + +export type AuthSignIn = { + phone_number: string, + phone_code_hash: string, + phone_code: string +}; + +export type AuthLogOut = { + +}; + +export type AuthResetAuthorizations = { + +}; + +export type AuthExportAuthorization = { + dc_id: number +}; + +export type AuthImportAuthorization = { + id: number, + bytes: Uint8Array | number[] +}; + +export type AuthBindTempAuthKey = { + perm_auth_key_id: string, + nonce: string, + expires_at: number, + encrypted_message: Uint8Array | number[] +}; + +export type AuthImportBotAuthorization = { + flags?: number, + api_id: number, + api_hash: string, + bot_auth_token: string +}; + +export type AuthCheckPassword = { + password: InputCheckPasswordSRP +}; + +export type AuthRequestPasswordRecovery = { + +}; + +export type AuthRecoverPassword = { + code: string +}; + +export type AuthResendCode = { + phone_number: string, + phone_code_hash: string +}; + +export type AuthCancelCode = { + phone_number: string, + phone_code_hash: string +}; + +export type AuthDropTempAuthKeys = { + except_auth_keys: Array +}; + +export type AuthExportLoginToken = { + api_id: number, + api_hash: string, + except_ids: Array +}; + +export type AuthImportLoginToken = { + token: Uint8Array | number[] +}; + +export type AuthAcceptLoginToken = { + token: Uint8Array | number[] +}; + +export type AccountRegisterDevice = { + flags?: number, + no_muted?: true, + token_type: number, + token: string, + app_sandbox: boolean, + secret: Uint8Array | number[], + other_uids: Array +}; + +export type AccountUnregisterDevice = { + token_type: number, + token: string, + other_uids: Array +}; + +export type AccountUpdateNotifySettings = { + peer: InputNotifyPeer, + settings: InputPeerNotifySettings +}; + +export type AccountGetNotifySettings = { + peer: InputNotifyPeer +}; + +export type AccountResetNotifySettings = { + +}; + +export type AccountUpdateProfile = { + flags?: number, + first_name?: string, + last_name?: string, + about?: string +}; + +export type AccountUpdateStatus = { + offline: boolean +}; + +export type AccountGetWallPapers = { + hash: number +}; + +export type AccountReportPeer = { + peer: InputPeer, + reason: ReportReason +}; + +export type AccountCheckUsername = { + username: string +}; + +export type AccountUpdateUsername = { + username: string +}; + +export type AccountGetPrivacy = { + key: InputPrivacyKey +}; + +export type AccountSetPrivacy = { + key: InputPrivacyKey, + rules: Array +}; + +export type AccountDeleteAccount = { + reason: string +}; + +export type AccountGetAccountTTL = { + +}; + +export type AccountSetAccountTTL = { + ttl: AccountDaysTTL +}; + +export type AccountSendChangePhoneCode = { + phone_number: string, + settings: CodeSettings +}; + +export type AccountChangePhone = { + phone_number: string, + phone_code_hash: string, + phone_code: string +}; + +export type AccountUpdateDeviceLocked = { + period: number +}; + +export type AccountGetAuthorizations = { + +}; + +export type AccountResetAuthorization = { + hash: string +}; + +export type AccountGetPassword = { + +}; + +export type AccountGetPasswordSettings = { + password: InputCheckPasswordSRP +}; + +export type AccountUpdatePasswordSettings = { + password: InputCheckPasswordSRP, + new_settings: AccountPasswordInputSettings +}; + +export type AccountSendConfirmPhoneCode = { + hash: string, + settings: CodeSettings +}; + +export type AccountConfirmPhone = { + phone_code_hash: string, + phone_code: string +}; + +export type AccountGetTmpPassword = { + password: InputCheckPasswordSRP, + period: number +}; + +export type AccountGetWebAuthorizations = { + +}; + +export type AccountResetWebAuthorization = { + hash: string +}; + +export type AccountResetWebAuthorizations = { + +}; + +export type AccountGetAllSecureValues = { + +}; + +export type AccountGetSecureValue = { + types: Array +}; + +export type AccountSaveSecureValue = { + value: InputSecureValue, + secure_secret_id: string +}; + +export type AccountDeleteSecureValue = { + types: Array +}; + +export type AccountGetAuthorizationForm = { + bot_id: number, + scope: string, + public_key: string +}; + +export type AccountAcceptAuthorization = { + bot_id: number, + scope: string, + public_key: string, + value_hashes: Array, + credentials: SecureCredentialsEncrypted +}; + +export type AccountSendVerifyPhoneCode = { + phone_number: string, + settings: CodeSettings +}; + +export type AccountVerifyPhone = { + phone_number: string, + phone_code_hash: string, + phone_code: string +}; + +export type AccountSendVerifyEmailCode = { + email: string +}; + +export type AccountVerifyEmail = { + email: string, + code: string +}; + +export type AccountInitTakeoutSession = { + flags?: number, + contacts?: true, + message_users?: true, + message_chats?: true, + message_megagroups?: true, + message_channels?: true, + files?: true, + file_max_size?: number +}; + +export type AccountFinishTakeoutSession = { + flags?: number, + success?: true +}; + +export type AccountConfirmPasswordEmail = { + code: string +}; + +export type AccountResendPasswordEmail = { + +}; + +export type AccountCancelPasswordEmail = { + +}; + +export type AccountGetContactSignUpNotification = { + +}; + +export type AccountSetContactSignUpNotification = { + silent: boolean +}; + +export type AccountGetNotifyExceptions = { + flags?: number, + compare_sound?: true, + peer?: InputNotifyPeer +}; + +export type AccountGetWallPaper = { + wallpaper: InputWallPaper +}; + +export type AccountUploadWallPaper = { + file: InputFile, + mime_type: string, + settings: WallPaperSettings +}; + +export type AccountSaveWallPaper = { + wallpaper: InputWallPaper, + unsave: boolean, + settings: WallPaperSettings +}; + +export type AccountInstallWallPaper = { + wallpaper: InputWallPaper, + settings: WallPaperSettings +}; + +export type AccountResetWallPapers = { + +}; + +export type AccountGetAutoDownloadSettings = { + +}; + +export type AccountSaveAutoDownloadSettings = { + flags?: number, + low?: true, + high?: true, + settings: AutoDownloadSettings +}; + +export type AccountUploadTheme = { + flags?: number, + file: InputFile, + thumb?: InputFile, + file_name: string, + mime_type: string +}; + +export type AccountCreateTheme = { + flags?: number, + slug: string, + title: string, + document?: InputDocument, + settings?: InputThemeSettings +}; + +export type AccountUpdateTheme = { + flags?: number, + format: string, + theme: InputTheme, + slug?: string, + title?: string, + document?: InputDocument, + settings?: InputThemeSettings +}; + +export type AccountSaveTheme = { + theme: InputTheme, + unsave: boolean +}; + +export type AccountInstallTheme = { + flags?: number, + dark?: true, + format?: string, + theme?: InputTheme +}; + +export type AccountGetTheme = { + format: string, + theme: InputTheme, + document_id: string +}; + +export type AccountGetThemes = { + format: string, + hash: number +}; + +export type AccountSetContentSettings = { + flags?: number, + sensitive_enabled?: true +}; + +export type AccountGetContentSettings = { + +}; + +export type AccountGetMultiWallPapers = { + wallpapers: Array +}; + +export type UsersGetUsers = { + id: Array +}; + +export type UsersGetFullUser = { + id: InputUser +}; + +export type UsersSetSecureValueErrors = { + id: InputUser, + errors: Array +}; + +export type ContactsGetContactIDs = { + hash: number +}; + +export type ContactsGetStatuses = { + +}; + +export type ContactsGetContacts = { + hash: number +}; + +export type ContactsImportContacts = { + contacts: Array +}; + +export type ContactsDeleteContacts = { + id: Array +}; + +export type ContactsDeleteByPhones = { + phones: Array +}; + +export type ContactsBlock = { + id: InputUser +}; + +export type ContactsUnblock = { + id: InputUser +}; + +export type ContactsGetBlocked = { + offset: number, + limit: number +}; + +export type ContactsSearch = { + q: string, + limit: number +}; + +export type ContactsResolveUsername = { + username: string +}; + +export type ContactsGetTopPeers = { + flags?: number, + correspondents?: true, + bots_pm?: true, + bots_inline?: true, + phone_calls?: true, + forward_users?: true, + forward_chats?: true, + groups?: true, + channels?: true, + offset: number, + limit: number, + hash: number +}; + +export type ContactsResetTopPeerRating = { + category: TopPeerCategory, + peer: InputPeer +}; + +export type ContactsResetSaved = { + +}; + +export type ContactsGetSaved = { + +}; + +export type ContactsToggleTopPeers = { + enabled: boolean +}; + +export type ContactsAddContact = { + flags?: number, + add_phone_privacy_exception?: true, + id: InputUser, + first_name: string, + last_name: string, + phone: string +}; + +export type ContactsAcceptContact = { + id: InputUser +}; + +export type ContactsGetLocated = { + flags?: number, + background?: true, + geo_point: InputGeoPoint, + self_expires?: number +}; + +export type MessagesGetMessages = { + id: Array +}; + +export type MessagesGetDialogs = { + flags?: number, + exclude_pinned?: true, + folder_id?: number, + offset_date: number, + offset_id: number, + offset_peer: InputPeer, + limit: number, + hash: number +}; + +export type MessagesGetHistory = { + peer: InputPeer, + offset_id: number, + offset_date: number, + add_offset: number, + limit: number, + max_id: number, + min_id: number, + hash: number +}; + +export type MessagesSearch = { + flags?: number, + peer: InputPeer, + q: string, + from_id?: InputUser, + filter: MessagesFilter, + min_date: number, + max_date: number, + offset_id: number, + add_offset: number, + limit: number, + max_id: number, + min_id: number, + hash: number +}; + +export type MessagesReadHistory = { + peer: InputPeer, + max_id: number +}; + +export type MessagesDeleteHistory = { + flags?: number, + just_clear?: true, + revoke?: true, + peer: InputPeer, + max_id: number +}; + +export type MessagesDeleteMessages = { + flags?: number, + revoke?: true, + id: Array +}; + +export type MessagesReceivedMessages = { + max_id: number +}; + +export type MessagesSetTyping = { + peer: InputPeer, + action: SendMessageAction +}; + +export type MessagesSendMessage = { + flags?: number, + no_webpage?: true, + silent?: true, + background?: true, + clear_draft?: true, + peer: InputPeer, + reply_to_msg_id?: number, + message: string, + random_id: string, + reply_markup?: ReplyMarkup, + entities?: Array, + schedule_date?: number +}; + +export type MessagesSendMedia = { + flags?: number, + silent?: true, + background?: true, + clear_draft?: true, + peer: InputPeer, + reply_to_msg_id?: number, + media: InputMedia, + message: string, + random_id: string, + reply_markup?: ReplyMarkup, + entities?: Array, + schedule_date?: number +}; + +export type MessagesForwardMessages = { + flags?: number, + silent?: true, + background?: true, + with_my_score?: true, + grouped?: true, + from_peer: InputPeer, + id: Array, + random_id: Array, + to_peer: InputPeer, + schedule_date?: number +}; + +export type MessagesReportSpam = { + peer: InputPeer +}; + +export type MessagesGetPeerSettings = { + peer: InputPeer +}; + +export type MessagesReport = { + peer: InputPeer, + id: Array, + reason: ReportReason +}; + +export type MessagesGetChats = { + id: Array +}; + +export type MessagesGetFullChat = { + chat_id: number +}; + +export type MessagesEditChatTitle = { + chat_id: number, + title: string +}; + +export type MessagesEditChatPhoto = { + chat_id: number, + photo: InputChatPhoto +}; + +export type MessagesAddChatUser = { + chat_id: number, + user_id: InputUser, + fwd_limit: number +}; + +export type MessagesDeleteChatUser = { + chat_id: number, + user_id: InputUser +}; + +export type MessagesCreateChat = { + users: Array, + title: string +}; + +export type MessagesGetDhConfig = { + version: number, + random_length: number +}; + +export type MessagesRequestEncryption = { + user_id: InputUser, + random_id: number, + g_a: Uint8Array | number[] +}; + +export type MessagesAcceptEncryption = { + peer: InputEncryptedChat, + g_b: Uint8Array | number[], + key_fingerprint: string +}; + +export type MessagesDiscardEncryption = { + chat_id: number +}; + +export type MessagesSetEncryptedTyping = { + peer: InputEncryptedChat, + typing: boolean +}; + +export type MessagesReadEncryptedHistory = { + peer: InputEncryptedChat, + max_date: number +}; + +export type MessagesSendEncrypted = { + peer: InputEncryptedChat, + random_id: string, + data: Uint8Array | number[] +}; + +export type MessagesSendEncryptedFile = { + peer: InputEncryptedChat, + random_id: string, + data: Uint8Array | number[], + file: InputEncryptedFile +}; + +export type MessagesSendEncryptedService = { + peer: InputEncryptedChat, + random_id: string, + data: Uint8Array | number[] +}; + +export type MessagesReceivedQueue = { + max_qts: number +}; + +export type MessagesReportEncryptedSpam = { + peer: InputEncryptedChat +}; + +export type MessagesReadMessageContents = { + id: Array +}; + +export type MessagesGetStickers = { + emoticon: string, + hash: number +}; + +export type MessagesGetAllStickers = { + hash: number +}; + +export type MessagesGetWebPagePreview = { + flags?: number, + message: string, + entities?: Array +}; + +export type MessagesExportChatInvite = { + peer: InputPeer +}; + +export type MessagesCheckChatInvite = { + hash: string +}; + +export type MessagesImportChatInvite = { + hash: string +}; + +export type MessagesGetStickerSet = { + stickerset: InputStickerSet +}; + +export type MessagesInstallStickerSet = { + stickerset: InputStickerSet, + archived: boolean +}; + +export type MessagesUninstallStickerSet = { + stickerset: InputStickerSet +}; + +export type MessagesStartBot = { + bot: InputUser, + peer: InputPeer, + random_id: string, + start_param: string +}; + +export type MessagesGetMessagesViews = { + peer: InputPeer, + id: Array, + increment: boolean +}; + +export type MessagesEditChatAdmin = { + chat_id: number, + user_id: InputUser, + is_admin: boolean +}; + +export type MessagesMigrateChat = { + chat_id: number +}; + +export type MessagesSearchGlobal = { + flags?: number, + folder_id?: number, + q: string, + offset_rate: number, + offset_peer: InputPeer, + offset_id: number, + limit: number +}; + +export type MessagesReorderStickerSets = { + flags?: number, + masks?: true, + order: Array +}; + +export type MessagesGetDocumentByHash = { + sha256: Uint8Array | number[], + size: number, + mime_type: string +}; + +export type MessagesSearchGifs = { + q: string, + offset: number +}; + +export type MessagesGetSavedGifs = { + hash: number +}; + +export type MessagesSaveGif = { + id: InputDocument, + unsave: boolean +}; + +export type MessagesGetInlineBotResults = { + flags?: number, + bot: InputUser, + peer: InputPeer, + geo_point?: InputGeoPoint, + query: string, + offset: string +}; + +export type MessagesSetInlineBotResults = { + flags?: number, + gallery?: true, + private?: true, + query_id: string, + results: Array, + cache_time: number, + next_offset?: string, + switch_pm?: InlineBotSwitchPM +}; + +export type MessagesSendInlineBotResult = { + flags?: number, + silent?: true, + background?: true, + clear_draft?: true, + hide_via?: true, + peer: InputPeer, + reply_to_msg_id?: number, + random_id: string, + query_id: string, + id: string, + schedule_date?: number +}; + +export type MessagesGetMessageEditData = { + peer: InputPeer, + id: number +}; + +export type MessagesEditMessage = { + flags?: number, + no_webpage?: true, + peer: InputPeer, + id: number, + message?: string, + media?: InputMedia, + reply_markup?: ReplyMarkup, + entities?: Array, + schedule_date?: number +}; + +export type MessagesEditInlineBotMessage = { + flags?: number, + no_webpage?: true, + id: InputBotInlineMessageID, + message?: string, + media?: InputMedia, + reply_markup?: ReplyMarkup, + entities?: Array +}; + +export type MessagesGetBotCallbackAnswer = { + flags?: number, + game?: true, + peer: InputPeer, + msg_id: number, + data?: Uint8Array | number[] +}; + +export type MessagesSetBotCallbackAnswer = { + flags?: number, + alert?: true, + query_id: string, + message?: string, + url?: string, + cache_time: number +}; + +export type MessagesGetPeerDialogs = { + peers: Array +}; + +export type MessagesSaveDraft = { + flags?: number, + no_webpage?: true, + reply_to_msg_id?: number, + peer: InputPeer, + message: string, + entities?: Array +}; + +export type MessagesGetAllDrafts = { + +}; + +export type MessagesGetFeaturedStickers = { + hash: number +}; + +export type MessagesReadFeaturedStickers = { + id: Array +}; + +export type MessagesGetRecentStickers = { + flags?: number, + attached?: true, + hash: number +}; + +export type MessagesSaveRecentSticker = { + flags?: number, + attached?: true, + id: InputDocument, + unsave: boolean +}; + +export type MessagesClearRecentStickers = { + flags?: number, + attached?: true +}; + +export type MessagesGetArchivedStickers = { + flags?: number, + masks?: true, + offset_id: string, + limit: number +}; + +export type MessagesGetMaskStickers = { + hash: number +}; + +export type MessagesGetAttachedStickers = { + media: InputStickeredMedia +}; + +export type MessagesSetGameScore = { + flags?: number, + edit_message?: true, + force?: true, + peer: InputPeer, + id: number, + user_id: InputUser, + score: number +}; + +export type MessagesSetInlineGameScore = { + flags?: number, + edit_message?: true, + force?: true, + id: InputBotInlineMessageID, + user_id: InputUser, + score: number +}; + +export type MessagesGetGameHighScores = { + peer: InputPeer, + id: number, + user_id: InputUser +}; + +export type MessagesGetInlineGameHighScores = { + id: InputBotInlineMessageID, + user_id: InputUser +}; + +export type MessagesGetCommonChats = { + user_id: InputUser, + max_id: number, + limit: number +}; + +export type MessagesGetAllChats = { + except_ids: Array +}; + +export type MessagesGetWebPage = { + url: string, + hash: number +}; + +export type MessagesToggleDialogPin = { + flags?: number, + pinned?: true, + peer: InputDialogPeer +}; + +export type MessagesReorderPinnedDialogs = { + flags?: number, + force?: true, + folder_id: number, + order: Array +}; + +export type MessagesGetPinnedDialogs = { + folder_id: number +}; + +export type MessagesSetBotShippingResults = { + flags?: number, + query_id: string, + error?: string, + shipping_options?: Array +}; + +export type MessagesSetBotPrecheckoutResults = { + flags?: number, + success?: true, + query_id: string, + error?: string +}; + +export type MessagesUploadMedia = { + peer: InputPeer, + media: InputMedia +}; + +export type MessagesSendScreenshotNotification = { + peer: InputPeer, + reply_to_msg_id: number, + random_id: string +}; + +export type MessagesGetFavedStickers = { + hash: number +}; + +export type MessagesFaveSticker = { + id: InputDocument, + unfave: boolean +}; + +export type MessagesGetUnreadMentions = { + peer: InputPeer, + offset_id: number, + add_offset: number, + limit: number, + max_id: number, + min_id: number +}; + +export type MessagesReadMentions = { + peer: InputPeer +}; + +export type MessagesGetRecentLocations = { + peer: InputPeer, + limit: number, + hash: number +}; + +export type MessagesSendMultiMedia = { + flags?: number, + silent?: true, + background?: true, + clear_draft?: true, + peer: InputPeer, + reply_to_msg_id?: number, + multi_media: Array, + schedule_date?: number +}; + +export type MessagesUploadEncryptedFile = { + peer: InputEncryptedChat, + file: InputEncryptedFile +}; + +export type MessagesSearchStickerSets = { + flags?: number, + exclude_featured?: true, + q: string, + hash: number +}; + +export type MessagesGetSplitRanges = { + +}; + +export type MessagesMarkDialogUnread = { + flags?: number, + unread?: true, + peer: InputDialogPeer +}; + +export type MessagesGetDialogUnreadMarks = { + +}; + +export type MessagesClearAllDrafts = { + +}; + +export type MessagesUpdatePinnedMessage = { + flags?: number, + silent?: true, + peer: InputPeer, + id: number +}; + +export type MessagesSendVote = { + peer: InputPeer, + msg_id: number, + options: Array +}; + +export type MessagesGetPollResults = { + peer: InputPeer, + msg_id: number +}; + +export type MessagesGetOnlines = { + peer: InputPeer +}; + +export type MessagesGetStatsURL = { + flags?: number, + dark?: true, + peer: InputPeer, + params: string +}; + +export type MessagesEditChatAbout = { + peer: InputPeer, + about: string +}; + +export type MessagesEditChatDefaultBannedRights = { + peer: InputPeer, + banned_rights: ChatBannedRights +}; + +export type MessagesGetEmojiKeywords = { + lang_code: string +}; + +export type MessagesGetEmojiKeywordsDifference = { + lang_code: string, + from_version: number +}; + +export type MessagesGetEmojiKeywordsLanguages = { + lang_codes: Array +}; + +export type MessagesGetEmojiURL = { + lang_code: string +}; + +export type MessagesGetSearchCounters = { + peer: InputPeer, + filters: Array +}; + +export type MessagesRequestUrlAuth = { + peer: InputPeer, + msg_id: number, + button_id: number +}; + +export type MessagesAcceptUrlAuth = { + flags?: number, + write_allowed?: true, + peer: InputPeer, + msg_id: number, + button_id: number +}; + +export type MessagesHidePeerSettingsBar = { + peer: InputPeer +}; + +export type MessagesGetScheduledHistory = { + peer: InputPeer, + hash: number +}; + +export type MessagesGetScheduledMessages = { + peer: InputPeer, + id: Array +}; + +export type MessagesSendScheduledMessages = { + peer: InputPeer, + id: Array +}; + +export type MessagesDeleteScheduledMessages = { + peer: InputPeer, + id: Array +}; + +export type MessagesGetPollVotes = { + flags?: number, + peer: InputPeer, + id: number, + option?: Uint8Array | number[], + offset?: string, + limit: number +}; + +export type MessagesToggleStickerSets = { + flags?: number, + uninstall?: true, + archive?: true, + unarchive?: true, + stickersets: Array +}; + +export type MessagesGetDialogFilters = { + +}; + +export type MessagesGetSuggestedDialogFilters = { + +}; + +export type MessagesUpdateDialogFilter = { + flags?: number, + id: number, + filter?: DialogFilter +}; + +export type MessagesUpdateDialogFiltersOrder = { + order: Array +}; + +export type MessagesGetOldFeaturedStickers = { + offset: number, + limit: number, + hash: number +}; + +export type UpdatesGetState = { + +}; + +export type UpdatesGetDifference = { + flags?: number, + pts: number, + pts_total_limit?: number, + date: number, + qts: number +}; + +export type UpdatesGetChannelDifference = { + flags?: number, + force?: true, + channel: InputChannel, + filter: ChannelMessagesFilter, + pts: number, + limit: number +}; + +export type PhotosUpdateProfilePhoto = { + id: InputPhoto +}; + +export type PhotosUploadProfilePhoto = { + file: InputFile +}; + +export type PhotosDeletePhotos = { + id: Array +}; + +export type PhotosGetUserPhotos = { + user_id: InputUser, + offset: number, + max_id: string, + limit: number +}; + +export type UploadSaveFilePart = { + file_id: string, + file_part: number, + bytes: Uint8Array | number[] +}; + +export type UploadGetFile = { + flags?: number, + precise?: true, + cdn_supported?: true, + location: InputFileLocation, + offset: number, + limit: number +}; + +export type UploadSaveBigFilePart = { + file_id: string, + file_part: number, + file_total_parts: number, + bytes: Uint8Array | number[] +}; + +export type UploadGetWebFile = { + location: InputWebFileLocation, + offset: number, + limit: number +}; + +export type UploadGetCdnFile = { + file_token: Uint8Array | number[], + offset: number, + limit: number +}; + +export type UploadReuploadCdnFile = { + file_token: Uint8Array | number[], + request_token: Uint8Array | number[] +}; + +export type UploadGetCdnFileHashes = { + file_token: Uint8Array | number[], + offset: number +}; + +export type UploadGetFileHashes = { + location: InputFileLocation, + offset: number +}; + +export type HelpGetConfig = { + +}; + +export type HelpGetNearestDc = { + +}; + +export type HelpGetAppUpdate = { + source: string +}; + +export type HelpGetInviteText = { + +}; + +export type HelpGetSupport = { + +}; + +export type HelpGetAppChangelog = { + prev_app_version: string +}; + +export type HelpSetBotUpdatesStatus = { + pending_updates_count: number, + message: string +}; + +export type HelpGetCdnConfig = { + +}; + +export type HelpGetRecentMeUrls = { + referer: string +}; + +export type HelpGetTermsOfServiceUpdate = { + +}; + +export type HelpAcceptTermsOfService = { + id: DataJSON +}; + +export type HelpGetDeepLinkInfo = { + path: string +}; + +export type HelpGetAppConfig = { + +}; + +export type HelpSaveAppLog = { + events: Array +}; + +export type HelpGetPassportConfig = { + hash: number +}; + +export type HelpGetSupportName = { + +}; + +export type HelpGetUserInfo = { + user_id: InputUser +}; + +export type HelpEditUserInfo = { + user_id: InputUser, + message: string, + entities: Array +}; + +export type HelpGetPromoData = { + +}; + +export type HelpHidePromoData = { + peer: InputPeer +}; + +export type ChannelsReadHistory = { + channel: InputChannel, + max_id: number +}; + +export type ChannelsDeleteMessages = { + channel: InputChannel, + id: Array +}; + +export type ChannelsDeleteUserHistory = { + channel: InputChannel, + user_id: InputUser +}; + +export type ChannelsReportSpam = { + channel: InputChannel, + user_id: InputUser, + id: Array +}; + +export type ChannelsGetMessages = { + channel: InputChannel, + id: Array +}; + +export type ChannelsGetParticipants = { + channel: InputChannel, + filter: ChannelParticipantsFilter, + offset: number, + limit: number, + hash: number +}; + +export type ChannelsGetParticipant = { + channel: InputChannel, + user_id: InputUser +}; + +export type ChannelsGetChannels = { + id: Array +}; + +export type ChannelsGetFullChannel = { + channel: InputChannel +}; + +export type ChannelsCreateChannel = { + flags?: number, + broadcast?: true, + megagroup?: true, + title: string, + about: string, + geo_point?: InputGeoPoint, + address?: string +}; + +export type ChannelsEditAdmin = { + channel: InputChannel, + user_id: InputUser, + admin_rights: ChatAdminRights, + rank: string +}; + +export type ChannelsEditTitle = { + channel: InputChannel, + title: string +}; + +export type ChannelsEditPhoto = { + channel: InputChannel, + photo: InputChatPhoto +}; + +export type ChannelsCheckUsername = { + channel: InputChannel, + username: string +}; + +export type ChannelsUpdateUsername = { + channel: InputChannel, + username: string +}; + +export type ChannelsJoinChannel = { + channel: InputChannel +}; + +export type ChannelsLeaveChannel = { + channel: InputChannel +}; + +export type ChannelsInviteToChannel = { + channel: InputChannel, + users: Array +}; + +export type ChannelsDeleteChannel = { + channel: InputChannel +}; + +export type ChannelsExportMessageLink = { + channel: InputChannel, + id: number, + grouped: boolean +}; + +export type ChannelsToggleSignatures = { + channel: InputChannel, + enabled: boolean +}; + +export type ChannelsGetAdminedPublicChannels = { + flags?: number, + by_location?: true, + check_limit?: true +}; + +export type ChannelsEditBanned = { + channel: InputChannel, + user_id: InputUser, + banned_rights: ChatBannedRights +}; + +export type ChannelsGetAdminLog = { + flags?: number, + channel: InputChannel, + q: string, + events_filter?: ChannelAdminLogEventsFilter, + admins?: Array, + max_id: string, + min_id: string, + limit: number +}; + +export type ChannelsSetStickers = { + channel: InputChannel, + stickerset: InputStickerSet +}; + +export type ChannelsReadMessageContents = { + channel: InputChannel, + id: Array +}; + +export type ChannelsDeleteHistory = { + channel: InputChannel, + max_id: number +}; + +export type ChannelsTogglePreHistoryHidden = { + channel: InputChannel, + enabled: boolean +}; + +export type ChannelsGetLeftChannels = { + offset: number +}; + +export type ChannelsGetGroupsForDiscussion = { + +}; + +export type ChannelsSetDiscussionGroup = { + broadcast: InputChannel, + group: InputChannel +}; + +export type ChannelsEditCreator = { + channel: InputChannel, + user_id: InputUser, + password: InputCheckPasswordSRP +}; + +export type ChannelsEditLocation = { + channel: InputChannel, + geo_point: InputGeoPoint, + address: string +}; + +export type ChannelsToggleSlowMode = { + channel: InputChannel, + seconds: number +}; + +export type ChannelsGetInactiveChannels = { + +}; + +export type BotsSendCustomRequest = { + custom_method: string, + params: DataJSON +}; + +export type BotsAnswerWebhookJSONQuery = { + query_id: string, + data: DataJSON +}; + +export type BotsSetBotCommands = { + commands: Array +}; + +export type PaymentsGetPaymentForm = { + msg_id: number +}; + +export type PaymentsGetPaymentReceipt = { + msg_id: number +}; + +export type PaymentsValidateRequestedInfo = { + flags?: number, + save?: true, + msg_id: number, + info: PaymentRequestedInfo +}; + +export type PaymentsSendPaymentForm = { + flags?: number, + msg_id: number, + requested_info_id?: string, + shipping_option_id?: string, + credentials: InputPaymentCredentials +}; + +export type PaymentsGetSavedInfo = { + +}; + +export type PaymentsClearSavedInfo = { + flags?: number, + credentials?: true, + info?: true +}; + +export type PaymentsGetBankCardData = { + number: string +}; + +export type StickersCreateStickerSet = { + flags?: number, + masks?: true, + animated?: true, + user_id: InputUser, + title: string, + short_name: string, + thumb?: InputDocument, + stickers: Array +}; + +export type StickersRemoveStickerFromSet = { + sticker: InputDocument +}; + +export type StickersChangeStickerPosition = { + sticker: InputDocument, + position: number +}; + +export type StickersAddStickerToSet = { + stickerset: InputStickerSet, + sticker: InputStickerSetItem +}; + +export type StickersSetStickerSetThumb = { + stickerset: InputStickerSet, + thumb: InputDocument +}; + +export type PhoneGetCallConfig = { + +}; + +export type PhoneRequestCall = { + flags?: number, + video?: true, + user_id: InputUser, + random_id: number, + g_a_hash: Uint8Array | number[], + protocol: PhoneCallProtocol +}; + +export type PhoneAcceptCall = { + peer: InputPhoneCall, + g_b: Uint8Array | number[], + protocol: PhoneCallProtocol +}; + +export type PhoneConfirmCall = { + peer: InputPhoneCall, + g_a: Uint8Array | number[], + key_fingerprint: string, + protocol: PhoneCallProtocol +}; + +export type PhoneReceivedCall = { + peer: InputPhoneCall +}; + +export type PhoneDiscardCall = { + flags?: number, + video?: true, + peer: InputPhoneCall, + duration: number, + reason: PhoneCallDiscardReason, + connection_id: string +}; + +export type PhoneSetCallRating = { + flags?: number, + user_initiative?: true, + peer: InputPhoneCall, + rating: number, + comment: string +}; + +export type PhoneSaveCallDebug = { + peer: InputPhoneCall, + debug: DataJSON +}; + +export type LangpackGetLangPack = { + lang_pack: string, + lang_code: string +}; + +export type LangpackGetStrings = { + lang_pack: string, + lang_code: string, + keys: Array +}; + +export type LangpackGetDifference = { + lang_pack: string, + lang_code: string, + from_version: number +}; + +export type LangpackGetLanguages = { + lang_pack: string +}; + +export type LangpackGetLanguage = { + lang_pack: string, + lang_code: string +}; + +export type FoldersEditPeerFolders = { + folder_peers: Array +}; + +export type FoldersDeleteFolder = { + folder_id: number +}; + +export type StatsGetBroadcastStats = { + flags?: number, + dark?: true, + channel: InputChannel +}; + +export type StatsLoadAsyncGraph = { + flags?: number, + token: string, + x?: string +}; + +export interface MethodDeclMap { + 'invokeAfterMsg': {req: InvokeAfterMsg, res: any}, + 'invokeAfterMsgs': {req: InvokeAfterMsgs, res: any}, + 'initConnection': {req: InitConnection, res: any}, + 'invokeWithLayer': {req: InvokeWithLayer, res: any}, + 'invokeWithoutUpdates': {req: InvokeWithoutUpdates, res: any}, + 'invokeWithMessagesRange': {req: InvokeWithMessagesRange, res: any}, + 'invokeWithTakeout': {req: InvokeWithTakeout, res: any}, + 'auth.sendCode': {req: AuthSendCode, res: AuthSentCode}, + 'auth.signUp': {req: AuthSignUp, res: AuthAuthorization}, + 'auth.signIn': {req: AuthSignIn, res: AuthAuthorization}, + 'auth.logOut': {req: AuthLogOut, res: boolean}, + 'auth.resetAuthorizations': {req: AuthResetAuthorizations, res: boolean}, + 'auth.exportAuthorization': {req: AuthExportAuthorization, res: AuthExportedAuthorization}, + 'auth.importAuthorization': {req: AuthImportAuthorization, res: AuthAuthorization}, + 'auth.bindTempAuthKey': {req: AuthBindTempAuthKey, res: boolean}, + 'auth.importBotAuthorization': {req: AuthImportBotAuthorization, res: AuthAuthorization}, + 'auth.checkPassword': {req: AuthCheckPassword, res: AuthAuthorization}, + 'auth.requestPasswordRecovery': {req: AuthRequestPasswordRecovery, res: AuthPasswordRecovery}, + 'auth.recoverPassword': {req: AuthRecoverPassword, res: AuthAuthorization}, + 'auth.resendCode': {req: AuthResendCode, res: AuthSentCode}, + 'auth.cancelCode': {req: AuthCancelCode, res: boolean}, + 'auth.dropTempAuthKeys': {req: AuthDropTempAuthKeys, res: boolean}, + 'auth.exportLoginToken': {req: AuthExportLoginToken, res: AuthLoginToken}, + 'auth.importLoginToken': {req: AuthImportLoginToken, res: AuthLoginToken}, + 'auth.acceptLoginToken': {req: AuthAcceptLoginToken, res: Authorization}, + 'account.registerDevice': {req: AccountRegisterDevice, res: boolean}, + 'account.unregisterDevice': {req: AccountUnregisterDevice, res: boolean}, + 'account.updateNotifySettings': {req: AccountUpdateNotifySettings, res: boolean}, + 'account.getNotifySettings': {req: AccountGetNotifySettings, res: PeerNotifySettings}, + 'account.resetNotifySettings': {req: AccountResetNotifySettings, res: boolean}, + 'account.updateProfile': {req: AccountUpdateProfile, res: User}, + 'account.updateStatus': {req: AccountUpdateStatus, res: boolean}, + 'account.getWallPapers': {req: AccountGetWallPapers, res: AccountWallPapers}, + 'account.reportPeer': {req: AccountReportPeer, res: boolean}, + 'account.checkUsername': {req: AccountCheckUsername, res: boolean}, + 'account.updateUsername': {req: AccountUpdateUsername, res: User}, + 'account.getPrivacy': {req: AccountGetPrivacy, res: AccountPrivacyRules}, + 'account.setPrivacy': {req: AccountSetPrivacy, res: AccountPrivacyRules}, + 'account.deleteAccount': {req: AccountDeleteAccount, res: boolean}, + 'account.getAccountTTL': {req: AccountGetAccountTTL, res: AccountDaysTTL}, + 'account.setAccountTTL': {req: AccountSetAccountTTL, res: boolean}, + 'account.sendChangePhoneCode': {req: AccountSendChangePhoneCode, res: AuthSentCode}, + 'account.changePhone': {req: AccountChangePhone, res: User}, + 'account.updateDeviceLocked': {req: AccountUpdateDeviceLocked, res: boolean}, + 'account.getAuthorizations': {req: AccountGetAuthorizations, res: AccountAuthorizations}, + 'account.resetAuthorization': {req: AccountResetAuthorization, res: boolean}, + 'account.getPassword': {req: AccountGetPassword, res: AccountPassword}, + 'account.getPasswordSettings': {req: AccountGetPasswordSettings, res: AccountPasswordSettings}, + 'account.updatePasswordSettings': {req: AccountUpdatePasswordSettings, res: boolean}, + 'account.sendConfirmPhoneCode': {req: AccountSendConfirmPhoneCode, res: AuthSentCode}, + 'account.confirmPhone': {req: AccountConfirmPhone, res: boolean}, + 'account.getTmpPassword': {req: AccountGetTmpPassword, res: AccountTmpPassword}, + 'account.getWebAuthorizations': {req: AccountGetWebAuthorizations, res: AccountWebAuthorizations}, + 'account.resetWebAuthorization': {req: AccountResetWebAuthorization, res: boolean}, + 'account.resetWebAuthorizations': {req: AccountResetWebAuthorizations, res: boolean}, + 'account.getAllSecureValues': {req: AccountGetAllSecureValues, res: Array}, + 'account.getSecureValue': {req: AccountGetSecureValue, res: Array}, + 'account.saveSecureValue': {req: AccountSaveSecureValue, res: SecureValue}, + 'account.deleteSecureValue': {req: AccountDeleteSecureValue, res: boolean}, + 'account.getAuthorizationForm': {req: AccountGetAuthorizationForm, res: AccountAuthorizationForm}, + 'account.acceptAuthorization': {req: AccountAcceptAuthorization, res: boolean}, + 'account.sendVerifyPhoneCode': {req: AccountSendVerifyPhoneCode, res: AuthSentCode}, + 'account.verifyPhone': {req: AccountVerifyPhone, res: boolean}, + 'account.sendVerifyEmailCode': {req: AccountSendVerifyEmailCode, res: AccountSentEmailCode}, + 'account.verifyEmail': {req: AccountVerifyEmail, res: boolean}, + 'account.initTakeoutSession': {req: AccountInitTakeoutSession, res: AccountTakeout}, + 'account.finishTakeoutSession': {req: AccountFinishTakeoutSession, res: boolean}, + 'account.confirmPasswordEmail': {req: AccountConfirmPasswordEmail, res: boolean}, + 'account.resendPasswordEmail': {req: AccountResendPasswordEmail, res: boolean}, + 'account.cancelPasswordEmail': {req: AccountCancelPasswordEmail, res: boolean}, + 'account.getContactSignUpNotification': {req: AccountGetContactSignUpNotification, res: boolean}, + 'account.setContactSignUpNotification': {req: AccountSetContactSignUpNotification, res: boolean}, + 'account.getNotifyExceptions': {req: AccountGetNotifyExceptions, res: Updates}, + 'account.getWallPaper': {req: AccountGetWallPaper, res: WallPaper}, + 'account.uploadWallPaper': {req: AccountUploadWallPaper, res: WallPaper}, + 'account.saveWallPaper': {req: AccountSaveWallPaper, res: boolean}, + 'account.installWallPaper': {req: AccountInstallWallPaper, res: boolean}, + 'account.resetWallPapers': {req: AccountResetWallPapers, res: boolean}, + 'account.getAutoDownloadSettings': {req: AccountGetAutoDownloadSettings, res: AccountAutoDownloadSettings}, + 'account.saveAutoDownloadSettings': {req: AccountSaveAutoDownloadSettings, res: boolean}, + 'account.uploadTheme': {req: AccountUploadTheme, res: Document}, + 'account.createTheme': {req: AccountCreateTheme, res: Theme}, + 'account.updateTheme': {req: AccountUpdateTheme, res: Theme}, + 'account.saveTheme': {req: AccountSaveTheme, res: boolean}, + 'account.installTheme': {req: AccountInstallTheme, res: boolean}, + 'account.getTheme': {req: AccountGetTheme, res: Theme}, + 'account.getThemes': {req: AccountGetThemes, res: AccountThemes}, + 'account.setContentSettings': {req: AccountSetContentSettings, res: boolean}, + 'account.getContentSettings': {req: AccountGetContentSettings, res: AccountContentSettings}, + 'account.getMultiWallPapers': {req: AccountGetMultiWallPapers, res: Array}, + 'users.getUsers': {req: UsersGetUsers, res: Array}, + 'users.getFullUser': {req: UsersGetFullUser, res: UserFull}, + 'users.setSecureValueErrors': {req: UsersSetSecureValueErrors, res: boolean}, + 'contacts.getContactIDs': {req: ContactsGetContactIDs, res: Array}, + 'contacts.getStatuses': {req: ContactsGetStatuses, res: Array}, + 'contacts.getContacts': {req: ContactsGetContacts, res: ContactsContacts}, + 'contacts.importContacts': {req: ContactsImportContacts, res: ContactsImportedContacts}, + 'contacts.deleteContacts': {req: ContactsDeleteContacts, res: Updates}, + 'contacts.deleteByPhones': {req: ContactsDeleteByPhones, res: boolean}, + 'contacts.block': {req: ContactsBlock, res: boolean}, + 'contacts.unblock': {req: ContactsUnblock, res: boolean}, + 'contacts.getBlocked': {req: ContactsGetBlocked, res: ContactsBlocked}, + 'contacts.search': {req: ContactsSearch, res: ContactsFound}, + 'contacts.resolveUsername': {req: ContactsResolveUsername, res: ContactsResolvedPeer}, + 'contacts.getTopPeers': {req: ContactsGetTopPeers, res: ContactsTopPeers}, + 'contacts.resetTopPeerRating': {req: ContactsResetTopPeerRating, res: boolean}, + 'contacts.resetSaved': {req: ContactsResetSaved, res: boolean}, + 'contacts.getSaved': {req: ContactsGetSaved, res: Array}, + 'contacts.toggleTopPeers': {req: ContactsToggleTopPeers, res: boolean}, + 'contacts.addContact': {req: ContactsAddContact, res: Updates}, + 'contacts.acceptContact': {req: ContactsAcceptContact, res: Updates}, + 'contacts.getLocated': {req: ContactsGetLocated, res: Updates}, + 'messages.getMessages': {req: MessagesGetMessages, res: MessagesMessages}, + 'messages.getDialogs': {req: MessagesGetDialogs, res: MessagesDialogs}, + 'messages.getHistory': {req: MessagesGetHistory, res: MessagesMessages}, + 'messages.search': {req: MessagesSearch, res: MessagesMessages}, + 'messages.readHistory': {req: MessagesReadHistory, res: MessagesAffectedMessages}, + 'messages.deleteHistory': {req: MessagesDeleteHistory, res: MessagesAffectedHistory}, + 'messages.deleteMessages': {req: MessagesDeleteMessages, res: MessagesAffectedMessages}, + 'messages.receivedMessages': {req: MessagesReceivedMessages, res: Array}, + 'messages.setTyping': {req: MessagesSetTyping, res: boolean}, + 'messages.sendMessage': {req: MessagesSendMessage, res: Updates}, + 'messages.sendMedia': {req: MessagesSendMedia, res: Updates}, + 'messages.forwardMessages': {req: MessagesForwardMessages, res: Updates}, + 'messages.reportSpam': {req: MessagesReportSpam, res: boolean}, + 'messages.getPeerSettings': {req: MessagesGetPeerSettings, res: PeerSettings}, + 'messages.report': {req: MessagesReport, res: boolean}, + 'messages.getChats': {req: MessagesGetChats, res: MessagesChats}, + 'messages.getFullChat': {req: MessagesGetFullChat, res: MessagesChatFull}, + 'messages.editChatTitle': {req: MessagesEditChatTitle, res: Updates}, + 'messages.editChatPhoto': {req: MessagesEditChatPhoto, res: Updates}, + 'messages.addChatUser': {req: MessagesAddChatUser, res: Updates}, + 'messages.deleteChatUser': {req: MessagesDeleteChatUser, res: Updates}, + 'messages.createChat': {req: MessagesCreateChat, res: Updates}, + 'messages.getDhConfig': {req: MessagesGetDhConfig, res: MessagesDhConfig}, + 'messages.requestEncryption': {req: MessagesRequestEncryption, res: EncryptedChat}, + 'messages.acceptEncryption': {req: MessagesAcceptEncryption, res: EncryptedChat}, + 'messages.discardEncryption': {req: MessagesDiscardEncryption, res: boolean}, + 'messages.setEncryptedTyping': {req: MessagesSetEncryptedTyping, res: boolean}, + 'messages.readEncryptedHistory': {req: MessagesReadEncryptedHistory, res: boolean}, + 'messages.sendEncrypted': {req: MessagesSendEncrypted, res: MessagesSentEncryptedMessage}, + 'messages.sendEncryptedFile': {req: MessagesSendEncryptedFile, res: MessagesSentEncryptedMessage}, + 'messages.sendEncryptedService': {req: MessagesSendEncryptedService, res: MessagesSentEncryptedMessage}, + 'messages.receivedQueue': {req: MessagesReceivedQueue, res: Array}, + 'messages.reportEncryptedSpam': {req: MessagesReportEncryptedSpam, res: boolean}, + 'messages.readMessageContents': {req: MessagesReadMessageContents, res: MessagesAffectedMessages}, + 'messages.getStickers': {req: MessagesGetStickers, res: MessagesStickers}, + 'messages.getAllStickers': {req: MessagesGetAllStickers, res: MessagesAllStickers}, + 'messages.getWebPagePreview': {req: MessagesGetWebPagePreview, res: MessageMedia}, + 'messages.exportChatInvite': {req: MessagesExportChatInvite, res: ExportedChatInvite}, + 'messages.checkChatInvite': {req: MessagesCheckChatInvite, res: ChatInvite}, + 'messages.importChatInvite': {req: MessagesImportChatInvite, res: Updates}, + 'messages.getStickerSet': {req: MessagesGetStickerSet, res: MessagesStickerSet}, + 'messages.installStickerSet': {req: MessagesInstallStickerSet, res: MessagesStickerSetInstallResult}, + 'messages.uninstallStickerSet': {req: MessagesUninstallStickerSet, res: boolean}, + 'messages.startBot': {req: MessagesStartBot, res: Updates}, + 'messages.getMessagesViews': {req: MessagesGetMessagesViews, res: Array}, + 'messages.editChatAdmin': {req: MessagesEditChatAdmin, res: boolean}, + 'messages.migrateChat': {req: MessagesMigrateChat, res: Updates}, + 'messages.searchGlobal': {req: MessagesSearchGlobal, res: MessagesMessages}, + 'messages.reorderStickerSets': {req: MessagesReorderStickerSets, res: boolean}, + 'messages.getDocumentByHash': {req: MessagesGetDocumentByHash, res: Document}, + 'messages.searchGifs': {req: MessagesSearchGifs, res: MessagesFoundGifs}, + 'messages.getSavedGifs': {req: MessagesGetSavedGifs, res: MessagesSavedGifs}, + 'messages.saveGif': {req: MessagesSaveGif, res: boolean}, + 'messages.getInlineBotResults': {req: MessagesGetInlineBotResults, res: MessagesBotResults}, + 'messages.setInlineBotResults': {req: MessagesSetInlineBotResults, res: boolean}, + 'messages.sendInlineBotResult': {req: MessagesSendInlineBotResult, res: Updates}, + 'messages.getMessageEditData': {req: MessagesGetMessageEditData, res: MessagesMessageEditData}, + 'messages.editMessage': {req: MessagesEditMessage, res: Updates}, + 'messages.editInlineBotMessage': {req: MessagesEditInlineBotMessage, res: boolean}, + 'messages.getBotCallbackAnswer': {req: MessagesGetBotCallbackAnswer, res: MessagesBotCallbackAnswer}, + 'messages.setBotCallbackAnswer': {req: MessagesSetBotCallbackAnswer, res: boolean}, + 'messages.getPeerDialogs': {req: MessagesGetPeerDialogs, res: MessagesPeerDialogs}, + 'messages.saveDraft': {req: MessagesSaveDraft, res: boolean}, + 'messages.getAllDrafts': {req: MessagesGetAllDrafts, res: Updates}, + 'messages.getFeaturedStickers': {req: MessagesGetFeaturedStickers, res: MessagesFeaturedStickers}, + 'messages.readFeaturedStickers': {req: MessagesReadFeaturedStickers, res: boolean}, + 'messages.getRecentStickers': {req: MessagesGetRecentStickers, res: MessagesRecentStickers}, + 'messages.saveRecentSticker': {req: MessagesSaveRecentSticker, res: boolean}, + 'messages.clearRecentStickers': {req: MessagesClearRecentStickers, res: boolean}, + 'messages.getArchivedStickers': {req: MessagesGetArchivedStickers, res: MessagesArchivedStickers}, + 'messages.getMaskStickers': {req: MessagesGetMaskStickers, res: MessagesAllStickers}, + 'messages.getAttachedStickers': {req: MessagesGetAttachedStickers, res: Array}, + 'messages.setGameScore': {req: MessagesSetGameScore, res: Updates}, + 'messages.setInlineGameScore': {req: MessagesSetInlineGameScore, res: boolean}, + 'messages.getGameHighScores': {req: MessagesGetGameHighScores, res: MessagesHighScores}, + 'messages.getInlineGameHighScores': {req: MessagesGetInlineGameHighScores, res: MessagesHighScores}, + 'messages.getCommonChats': {req: MessagesGetCommonChats, res: MessagesChats}, + 'messages.getAllChats': {req: MessagesGetAllChats, res: MessagesChats}, + 'messages.getWebPage': {req: MessagesGetWebPage, res: WebPage}, + 'messages.toggleDialogPin': {req: MessagesToggleDialogPin, res: boolean}, + 'messages.reorderPinnedDialogs': {req: MessagesReorderPinnedDialogs, res: boolean}, + 'messages.getPinnedDialogs': {req: MessagesGetPinnedDialogs, res: MessagesPeerDialogs}, + 'messages.setBotShippingResults': {req: MessagesSetBotShippingResults, res: boolean}, + 'messages.setBotPrecheckoutResults': {req: MessagesSetBotPrecheckoutResults, res: boolean}, + 'messages.uploadMedia': {req: MessagesUploadMedia, res: MessageMedia}, + 'messages.sendScreenshotNotification': {req: MessagesSendScreenshotNotification, res: Updates}, + 'messages.getFavedStickers': {req: MessagesGetFavedStickers, res: MessagesFavedStickers}, + 'messages.faveSticker': {req: MessagesFaveSticker, res: boolean}, + 'messages.getUnreadMentions': {req: MessagesGetUnreadMentions, res: MessagesMessages}, + 'messages.readMentions': {req: MessagesReadMentions, res: MessagesAffectedHistory}, + 'messages.getRecentLocations': {req: MessagesGetRecentLocations, res: MessagesMessages}, + 'messages.sendMultiMedia': {req: MessagesSendMultiMedia, res: Updates}, + 'messages.uploadEncryptedFile': {req: MessagesUploadEncryptedFile, res: EncryptedFile}, + 'messages.searchStickerSets': {req: MessagesSearchStickerSets, res: MessagesFoundStickerSets}, + 'messages.getSplitRanges': {req: MessagesGetSplitRanges, res: Array}, + 'messages.markDialogUnread': {req: MessagesMarkDialogUnread, res: boolean}, + 'messages.getDialogUnreadMarks': {req: MessagesGetDialogUnreadMarks, res: Array}, + 'messages.clearAllDrafts': {req: MessagesClearAllDrafts, res: boolean}, + 'messages.updatePinnedMessage': {req: MessagesUpdatePinnedMessage, res: Updates}, + 'messages.sendVote': {req: MessagesSendVote, res: Updates}, + 'messages.getPollResults': {req: MessagesGetPollResults, res: Updates}, + 'messages.getOnlines': {req: MessagesGetOnlines, res: ChatOnlines}, + 'messages.getStatsURL': {req: MessagesGetStatsURL, res: StatsURL}, + 'messages.editChatAbout': {req: MessagesEditChatAbout, res: boolean}, + 'messages.editChatDefaultBannedRights': {req: MessagesEditChatDefaultBannedRights, res: Updates}, + 'messages.getEmojiKeywords': {req: MessagesGetEmojiKeywords, res: EmojiKeywordsDifference}, + 'messages.getEmojiKeywordsDifference': {req: MessagesGetEmojiKeywordsDifference, res: EmojiKeywordsDifference}, + 'messages.getEmojiKeywordsLanguages': {req: MessagesGetEmojiKeywordsLanguages, res: Array}, + 'messages.getEmojiURL': {req: MessagesGetEmojiURL, res: EmojiURL}, + 'messages.getSearchCounters': {req: MessagesGetSearchCounters, res: Array}, + 'messages.requestUrlAuth': {req: MessagesRequestUrlAuth, res: UrlAuthResult}, + 'messages.acceptUrlAuth': {req: MessagesAcceptUrlAuth, res: UrlAuthResult}, + 'messages.hidePeerSettingsBar': {req: MessagesHidePeerSettingsBar, res: boolean}, + 'messages.getScheduledHistory': {req: MessagesGetScheduledHistory, res: MessagesMessages}, + 'messages.getScheduledMessages': {req: MessagesGetScheduledMessages, res: MessagesMessages}, + 'messages.sendScheduledMessages': {req: MessagesSendScheduledMessages, res: Updates}, + 'messages.deleteScheduledMessages': {req: MessagesDeleteScheduledMessages, res: Updates}, + 'messages.getPollVotes': {req: MessagesGetPollVotes, res: MessagesVotesList}, + 'messages.toggleStickerSets': {req: MessagesToggleStickerSets, res: boolean}, + 'messages.getDialogFilters': {req: MessagesGetDialogFilters, res: Array}, + 'messages.getSuggestedDialogFilters': {req: MessagesGetSuggestedDialogFilters, res: Array}, + 'messages.updateDialogFilter': {req: MessagesUpdateDialogFilter, res: boolean}, + 'messages.updateDialogFiltersOrder': {req: MessagesUpdateDialogFiltersOrder, res: boolean}, + 'messages.getOldFeaturedStickers': {req: MessagesGetOldFeaturedStickers, res: MessagesFeaturedStickers}, + 'updates.getState': {req: UpdatesGetState, res: UpdatesState}, + 'updates.getDifference': {req: UpdatesGetDifference, res: UpdatesDifference}, + 'updates.getChannelDifference': {req: UpdatesGetChannelDifference, res: UpdatesChannelDifference}, + 'photos.updateProfilePhoto': {req: PhotosUpdateProfilePhoto, res: UserProfilePhoto}, + 'photos.uploadProfilePhoto': {req: PhotosUploadProfilePhoto, res: PhotosPhoto}, + 'photos.deletePhotos': {req: PhotosDeletePhotos, res: Array}, + 'photos.getUserPhotos': {req: PhotosGetUserPhotos, res: PhotosPhotos}, + 'upload.saveFilePart': {req: UploadSaveFilePart, res: boolean}, + 'upload.getFile': {req: UploadGetFile, res: UploadFile}, + 'upload.saveBigFilePart': {req: UploadSaveBigFilePart, res: boolean}, + 'upload.getWebFile': {req: UploadGetWebFile, res: UploadWebFile}, + 'upload.getCdnFile': {req: UploadGetCdnFile, res: UploadCdnFile}, + 'upload.reuploadCdnFile': {req: UploadReuploadCdnFile, res: Array}, + 'upload.getCdnFileHashes': {req: UploadGetCdnFileHashes, res: Array}, + 'upload.getFileHashes': {req: UploadGetFileHashes, res: Array}, + 'help.getConfig': {req: HelpGetConfig, res: Config}, + 'help.getNearestDc': {req: HelpGetNearestDc, res: NearestDc}, + 'help.getAppUpdate': {req: HelpGetAppUpdate, res: HelpAppUpdate}, + 'help.getInviteText': {req: HelpGetInviteText, res: HelpInviteText}, + 'help.getSupport': {req: HelpGetSupport, res: HelpSupport}, + 'help.getAppChangelog': {req: HelpGetAppChangelog, res: Updates}, + 'help.setBotUpdatesStatus': {req: HelpSetBotUpdatesStatus, res: boolean}, + 'help.getCdnConfig': {req: HelpGetCdnConfig, res: CdnConfig}, + 'help.getRecentMeUrls': {req: HelpGetRecentMeUrls, res: HelpRecentMeUrls}, + 'help.getTermsOfServiceUpdate': {req: HelpGetTermsOfServiceUpdate, res: HelpTermsOfServiceUpdate}, + 'help.acceptTermsOfService': {req: HelpAcceptTermsOfService, res: boolean}, + 'help.getDeepLinkInfo': {req: HelpGetDeepLinkInfo, res: HelpDeepLinkInfo}, + 'help.getAppConfig': {req: HelpGetAppConfig, res: JSONValue}, + 'help.saveAppLog': {req: HelpSaveAppLog, res: boolean}, + 'help.getPassportConfig': {req: HelpGetPassportConfig, res: HelpPassportConfig}, + 'help.getSupportName': {req: HelpGetSupportName, res: HelpSupportName}, + 'help.getUserInfo': {req: HelpGetUserInfo, res: HelpUserInfo}, + 'help.editUserInfo': {req: HelpEditUserInfo, res: HelpUserInfo}, + 'help.getPromoData': {req: HelpGetPromoData, res: HelpPromoData}, + 'help.hidePromoData': {req: HelpHidePromoData, res: boolean}, + 'channels.readHistory': {req: ChannelsReadHistory, res: boolean}, + 'channels.deleteMessages': {req: ChannelsDeleteMessages, res: MessagesAffectedMessages}, + 'channels.deleteUserHistory': {req: ChannelsDeleteUserHistory, res: MessagesAffectedHistory}, + 'channels.reportSpam': {req: ChannelsReportSpam, res: boolean}, + 'channels.getMessages': {req: ChannelsGetMessages, res: MessagesMessages}, + 'channels.getParticipants': {req: ChannelsGetParticipants, res: ChannelsChannelParticipants}, + 'channels.getParticipant': {req: ChannelsGetParticipant, res: ChannelsChannelParticipant}, + 'channels.getChannels': {req: ChannelsGetChannels, res: MessagesChats}, + 'channels.getFullChannel': {req: ChannelsGetFullChannel, res: MessagesChatFull}, + 'channels.createChannel': {req: ChannelsCreateChannel, res: Updates}, + 'channels.editAdmin': {req: ChannelsEditAdmin, res: Updates}, + 'channels.editTitle': {req: ChannelsEditTitle, res: Updates}, + 'channels.editPhoto': {req: ChannelsEditPhoto, res: Updates}, + 'channels.checkUsername': {req: ChannelsCheckUsername, res: boolean}, + 'channels.updateUsername': {req: ChannelsUpdateUsername, res: boolean}, + 'channels.joinChannel': {req: ChannelsJoinChannel, res: Updates}, + 'channels.leaveChannel': {req: ChannelsLeaveChannel, res: Updates}, + 'channels.inviteToChannel': {req: ChannelsInviteToChannel, res: Updates}, + 'channels.deleteChannel': {req: ChannelsDeleteChannel, res: Updates}, + 'channels.exportMessageLink': {req: ChannelsExportMessageLink, res: ExportedMessageLink}, + 'channels.toggleSignatures': {req: ChannelsToggleSignatures, res: Updates}, + 'channels.getAdminedPublicChannels': {req: ChannelsGetAdminedPublicChannels, res: MessagesChats}, + 'channels.editBanned': {req: ChannelsEditBanned, res: Updates}, + 'channels.getAdminLog': {req: ChannelsGetAdminLog, res: ChannelsAdminLogResults}, + 'channels.setStickers': {req: ChannelsSetStickers, res: boolean}, + 'channels.readMessageContents': {req: ChannelsReadMessageContents, res: boolean}, + 'channels.deleteHistory': {req: ChannelsDeleteHistory, res: boolean}, + 'channels.togglePreHistoryHidden': {req: ChannelsTogglePreHistoryHidden, res: Updates}, + 'channels.getLeftChannels': {req: ChannelsGetLeftChannels, res: MessagesChats}, + 'channels.getGroupsForDiscussion': {req: ChannelsGetGroupsForDiscussion, res: MessagesChats}, + 'channels.setDiscussionGroup': {req: ChannelsSetDiscussionGroup, res: boolean}, + 'channels.editCreator': {req: ChannelsEditCreator, res: Updates}, + 'channels.editLocation': {req: ChannelsEditLocation, res: boolean}, + 'channels.toggleSlowMode': {req: ChannelsToggleSlowMode, res: Updates}, + 'channels.getInactiveChannels': {req: ChannelsGetInactiveChannels, res: MessagesInactiveChats}, + 'bots.sendCustomRequest': {req: BotsSendCustomRequest, res: DataJSON}, + 'bots.answerWebhookJSONQuery': {req: BotsAnswerWebhookJSONQuery, res: boolean}, + 'bots.setBotCommands': {req: BotsSetBotCommands, res: boolean}, + 'payments.getPaymentForm': {req: PaymentsGetPaymentForm, res: PaymentsPaymentForm}, + 'payments.getPaymentReceipt': {req: PaymentsGetPaymentReceipt, res: PaymentsPaymentReceipt}, + 'payments.validateRequestedInfo': {req: PaymentsValidateRequestedInfo, res: PaymentsValidatedRequestedInfo}, + 'payments.sendPaymentForm': {req: PaymentsSendPaymentForm, res: PaymentsPaymentResult}, + 'payments.getSavedInfo': {req: PaymentsGetSavedInfo, res: PaymentsSavedInfo}, + 'payments.clearSavedInfo': {req: PaymentsClearSavedInfo, res: boolean}, + 'payments.getBankCardData': {req: PaymentsGetBankCardData, res: PaymentsBankCardData}, + 'stickers.createStickerSet': {req: StickersCreateStickerSet, res: MessagesStickerSet}, + 'stickers.removeStickerFromSet': {req: StickersRemoveStickerFromSet, res: MessagesStickerSet}, + 'stickers.changeStickerPosition': {req: StickersChangeStickerPosition, res: MessagesStickerSet}, + 'stickers.addStickerToSet': {req: StickersAddStickerToSet, res: MessagesStickerSet}, + 'stickers.setStickerSetThumb': {req: StickersSetStickerSetThumb, res: MessagesStickerSet}, + 'phone.getCallConfig': {req: PhoneGetCallConfig, res: DataJSON}, + 'phone.requestCall': {req: PhoneRequestCall, res: PhonePhoneCall}, + 'phone.acceptCall': {req: PhoneAcceptCall, res: PhonePhoneCall}, + 'phone.confirmCall': {req: PhoneConfirmCall, res: PhonePhoneCall}, + 'phone.receivedCall': {req: PhoneReceivedCall, res: boolean}, + 'phone.discardCall': {req: PhoneDiscardCall, res: Updates}, + 'phone.setCallRating': {req: PhoneSetCallRating, res: Updates}, + 'phone.saveCallDebug': {req: PhoneSaveCallDebug, res: boolean}, + 'langpack.getLangPack': {req: LangpackGetLangPack, res: LangPackDifference}, + 'langpack.getStrings': {req: LangpackGetStrings, res: Array}, + 'langpack.getDifference': {req: LangpackGetDifference, res: LangPackDifference}, + 'langpack.getLanguages': {req: LangpackGetLanguages, res: Array}, + 'langpack.getLanguage': {req: LangpackGetLanguage, res: LangPackLanguage}, + 'folders.editPeerFolders': {req: FoldersEditPeerFolders, res: Updates}, + 'folders.deleteFolder': {req: FoldersDeleteFolder, res: Updates}, + 'stats.getBroadcastStats': {req: StatsGetBroadcastStats, res: StatsBroadcastStats}, + 'stats.loadAsyncGraph': {req: StatsLoadAsyncGraph, res: StatsGraph}, +} + diff --git a/src/lib/appManagers/AppInlineBotsManager.ts b/src/lib/appManagers/AppInlineBotsManager.ts index fe36a98b..fe00596d 100644 --- a/src/lib/appManagers/AppInlineBotsManager.ts +++ b/src/lib/appManagers/AppInlineBotsManager.ts @@ -4,41 +4,10 @@ import appPeersManager from "../appManagers/appPeersManager"; import appMessagesIDsManager from "./appMessagesIDsManager"; import { RichTextProcessor } from "../richtextprocessor"; import { toast } from "../../components/toast"; -import appUsersManager, { User } from "./appUsersManager"; -import appPhotosManager, { MTPhoto } from "./appPhotosManager"; -import { MTDocument } from "../../types"; +import appUsersManager from "./appUsersManager"; +import appPhotosManager from "./appPhotosManager"; import appDocsManager from "./appDocsManager"; - -type botInlineResult = { - _: 'botInlineResult', - flags: number, - id: string, - type: string, - title?: string, - description?: string, - url?: string, - thumb: any, - content: any, - send_message: any -}; -type botInlineMediaResult = { - _: 'botInlineMediaResult', - flags: number, - id: string, - type: string, - photo?: MTPhoto, - document?: MTDocument, - title?: string, - description?: string, - send_message: any -}; -type BotInlineResult = (botInlineResult | botInlineMediaResult) & Partial<{ - qID: string, - botID: number, - rTitle: string, - rDescription: string, - initials: string -}>; +import { BotInlineResult } from "../../layer"; export class AppInlineBotsManager { private inlineResults: {[qID: string]: BotInlineResult} = {}; @@ -51,39 +20,30 @@ export class AppInlineBotsManager { query: query, geo_point: geo && {_: 'inputGeoPoint', lat: geo['lat'], long: geo['long']}, offset - }, {timeout: 1, stopTime: -1, noErrorBox: true}).then((botResults: { - _: 'messages.botResults', - flags: number, - pFlags: Partial<{gallery: true}>, - query_id: string, - next_offset?: string, - switch_pm?: any, - results: BotInlineResult[], - cache_time: number, - users: User[] - }) => { + }, {timeout: 1, stopTime: -1, noErrorBox: true}).then(botResults => { const queryID = botResults.query_id; /* delete botResults._; delete botResults.flags; delete botResults.query_id; */ - if(botResults.switch_pm) { + /* if(botResults.switch_pm) { botResults.switch_pm.rText = RichTextProcessor.wrapRichText(botResults.switch_pm.text, {noLinebreaks: true, noLinks: true}); - } + } */ - botResults.results.forEach((result: BotInlineResult) => { + botResults.results.forEach(result => { const qID = queryID + '_' + result.id; - result.qID = qID; + /* result.qID = qID; result.botID = botID; result.rTitle = RichTextProcessor.wrapRichText(result.title, {noLinebreaks: true, noLinks: true}); result.rDescription = RichTextProcessor.wrapRichText(result.description, {noLinebreaks: true, noLinks: true}); - result.initials = ((result as botInlineResult).url || result.title || result.type || '').substr(0, 1); + result.initials = ((result as botInlineResult).url || result.title || result.type || '').substr(0, 1); */ if(result._ == 'botInlineMediaResult') { if(result.document) { result.document = appDocsManager.saveDoc(result.document); } + if(result.photo) { result.photo = appPhotosManager.savePhoto(result.photo); } @@ -321,7 +281,7 @@ export class AppInlineBotsManager { peer: appPeersManager.getInputPeerByID(peerID), msg_id: appMessagesIDsManager.getMessageLocalID(mid), data: button.data - }, {timeout: 1, stopTime: -1, noErrorBox: true}).then((callbackAnswer: any) => { + }, {timeout: 1, stopTime: -1, noErrorBox: true}).then((callbackAnswer) => { if(typeof callbackAnswer.message === 'string' && callbackAnswer.message.length) { toast(RichTextProcessor.wrapRichText(callbackAnswer.message, {noLinks: true, noLinebreaks: true})); } diff --git a/src/lib/appManagers/apiUpdatesManager.ts b/src/lib/appManagers/apiUpdatesManager.ts index d29252a0..0c204509 100644 --- a/src/lib/appManagers/apiUpdatesManager.ts +++ b/src/lib/appManagers/apiUpdatesManager.ts @@ -6,6 +6,7 @@ import appPeersManager from "./appPeersManager"; import appUsersManager from "./appUsersManager"; import appChatsManager from "./appChatsManager"; import { logger, LogLevels } from '../logger'; +import { Updates, UpdatesState } from '../../layer'; export class ApiUpdatesManager { public updatesState: { @@ -192,12 +193,13 @@ export class ApiUpdatesManager { } return apiManager.invokeApi('updates.getDifference', { + flags: 0, pts: updatesState.pts, date: updatesState.date, qts: -1 }, { timeout: 0x7fffffff - }).then((differenceResult: any) => { + }).then((differenceResult) => { if(differenceResult._ == 'updates.differenceEmpty') { this.log('apply empty diff', differenceResult.seq); updatesState.date = differenceResult.date; @@ -206,39 +208,45 @@ export class ApiUpdatesManager { $rootScope.$broadcast('stateSynchronized'); return false; } - - appUsersManager.saveApiUsers(differenceResult.users); - appChatsManager.saveApiChats(differenceResult.chats); - - // Should be first because of updateMessageID - // this.log('applying', differenceResult.other_updates.length, 'other updates') - - differenceResult.other_updates.forEach((update: any) => { - switch(update._) { - case 'updateChannelTooLong': - case 'updateNewChannelMessage': - case 'updateEditChannelMessage': - this.processUpdate(update); - return; - } - - this.saveUpdate(update); - }); - - // this.log('applying', differenceResult.new_messages.length, 'new messages') - differenceResult.new_messages.forEach((apiMessage: any) => { - this.saveUpdate({ - _: 'updateNewMessage', - message: apiMessage, - pts: updatesState.pts, - pts_count: 0 + + if(differenceResult._ != 'updates.differenceTooLong') { + appUsersManager.saveApiUsers(differenceResult.users); + appChatsManager.saveApiChats(differenceResult.chats); + + // Should be first because of updateMessageID + // this.log('applying', differenceResult.other_updates.length, 'other updates') + + differenceResult.other_updates.forEach((update: any) => { + switch(update._) { + case 'updateChannelTooLong': + case 'updateNewChannelMessage': + case 'updateEditChannelMessage': + this.processUpdate(update); + return; + } + + this.saveUpdate(update); }); - }); - - const nextState = differenceResult.intermediate_state || differenceResult.state; - updatesState.seq = nextState.seq; - updatesState.pts = nextState.pts; - updatesState.date = nextState.date; + + // this.log('applying', differenceResult.new_messages.length, 'new messages') + differenceResult.new_messages.forEach((apiMessage: any) => { + this.saveUpdate({ + _: 'updateNewMessage', + message: apiMessage, + pts: updatesState.pts, + pts_count: 0 + }); + }); + + const nextState = differenceResult._ == 'updates.difference' ? differenceResult.state : differenceResult.intermediate_state; + updatesState.seq = nextState.seq; + updatesState.pts = nextState.pts; + updatesState.date = nextState.date; + } else { + updatesState.pts = differenceResult.pts; + delete updatesState.seq; + delete updatesState.date; + } // this.log('apply diff', updatesState.seq, updatesState.pts) @@ -254,27 +262,29 @@ export class ApiUpdatesManager { }); } - public getChannelDifference(channelID: any) { - var channelState = this.getChannelState(channelID); + public getChannelDifference(channelID: number) { + const channelState = this.getChannelState(channelID); if(!channelState.syncLoading) { channelState.syncLoading = true; channelState.pendingPtsUpdates = []; } + if(channelState.syncPending) { clearTimeout(channelState.syncPending.timeout); channelState.syncPending = false; } + // this.log('Get channel diff', appChatsManager.getChat(channelID), channelState.pts) apiManager.invokeApi('updates.getChannelDifference', { channel: appChatsManager.getChannelInput(channelID), filter: {_: 'channelMessagesFilterEmpty'}, pts: channelState.pts, limit: 30 - }, {timeout: 0x7fffffff}).then((differenceResult: any) => { + }, {timeout: 0x7fffffff}).then((differenceResult) => { // this.log('channel diff result', differenceResult) - channelState.pts = differenceResult.pts; + channelState.pts = 'pts' in differenceResult ? differenceResult.pts : undefined; - if (differenceResult._ == 'updates.channelDifferenceEmpty') { + if(differenceResult._ == 'updates.channelDifferenceEmpty') { this.log('apply channel empty diff', differenceResult); channelState.syncLoading = false; $rootScope.$broadcast('stateSynchronized'); @@ -327,6 +337,7 @@ export class ApiUpdatesManager { if(!pts) { throw new Error('Add channel state without pts ' + channelID); } + if(!(channelID in this.channelStates)) { this.channelStates[channelID] = { pts: pts, @@ -334,8 +345,10 @@ export class ApiUpdatesManager { syncPending: false, syncLoading: false }; + return true; } + return false; } @@ -343,6 +356,7 @@ export class ApiUpdatesManager { if(this.channelStates[channelID] === undefined) { this.addChannelState(channelID, pts); } + return this.channelStates[channelID]; } diff --git a/src/lib/appManagers/appChatsManager.ts b/src/lib/appManagers/appChatsManager.ts index 49f2b946..0418e5f7 100644 --- a/src/lib/appManagers/appChatsManager.ts +++ b/src/lib/appManagers/appChatsManager.ts @@ -5,6 +5,7 @@ import apiManager from '../mtproto/mtprotoworker'; import apiUpdatesManager from "./apiUpdatesManager"; import appProfileManager from "./appProfileManager"; import searchIndexManager from "../searchIndexManager"; +import { InputPeer, InputChannel, Updates, InputChatPhoto } from "../../layer"; export type Channel = { _: 'channel', @@ -265,11 +266,7 @@ export class AppChatsManager { return this.isChannel(id) && !this.isMegagroup(id); } - public getChannelInput(id: number) { - if(!id) { - return {_: 'inputChannelEmpty'}; - } - + public getChannelInput(id: number): InputChannel { if(id < 0) id = -id; return { _: 'inputChannel', @@ -278,18 +275,14 @@ export class AppChatsManager { }; } - public getChatInputPeer(id: number) { + public getChatInputPeer(id: number): InputPeer.inputPeerChat { return { _: 'inputPeerChat', chat_id: id }; } - public getChannelInputPeer(id: number) { - if(!id) { - return {_: 'inputPeerEmpty'}; - } - + public getChannelInputPeer(id: number): InputPeer.inputPeerChannel { return { _: 'inputPeerChannel', channel_id: id, @@ -380,7 +373,7 @@ export class AppChatsManager { return participants; } - public createChannel(title: string, about: String): Promise { + public createChannel(title: string, about: string): Promise { return apiManager.invokeApi('channels.createChannel', { flags: 1, broadcast: true, @@ -412,21 +405,21 @@ export class AppChatsManager { }).then(updates => { apiUpdatesManager.processUpdateMessage(updates); - return updates.chats[0].id; + return (updates as any as Updates.updates).chats[0].id; }); } public editPhoto(id: number, inputFile: any) { - let isChannel = this.isChannel(id); + const isChannel = this.isChannel(id); - let inputChatPhoto = { + const inputChatPhoto: InputChatPhoto.inputChatUploadedPhoto = { _: 'inputChatUploadedPhoto', file: inputFile }; if(isChannel) { return apiManager.invokeApi('channels.editPhoto', { - channel: this.getChannelInputPeer(id), + channel: this.getChannelInput(id), photo: inputChatPhoto }).then(updates => { apiUpdatesManager.processUpdateMessage(updates); diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index 5b370654..4747dce4 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -1,7 +1,7 @@ -import { findUpClassName, $rootScope, escapeRegExp, whichChild, findUpTag, cancelEvent, positionElementByIndex } from "../utils"; +import { findUpClassName, $rootScope, escapeRegExp, findUpTag, cancelEvent, positionElementByIndex } from "../utils"; import appImManager, { AppImManager } from "./appImManager"; import appPeersManager from './appPeersManager'; -import appMessagesManager, { AppMessagesManager, Dialog, DialogFilter } from "./appMessagesManager"; +import appMessagesManager, { Dialog, MyDialogFilter as DialogFilter } from "./appMessagesManager"; import appUsersManager, { User } from "./appUsersManager"; import { RichTextProcessor } from "../richtextprocessor"; import { putPreloader, positionMenu, openBtnMenu, parseMenuButtonsTo, attachContextMenuListener } from "../../components/misc"; @@ -1168,9 +1168,10 @@ export class AppDialogsManager { if(!container) { let peer: any; + // for muted icon + titleSpan.classList.add('tgico'); + if(peerID < 0) { - titleSpan.classList.add('tgico'); - peer = appChatsManager.getChat(-peerID); } else { peer = appUsersManager.getUser(peerID); diff --git a/src/lib/appManagers/appDocsManager.ts b/src/lib/appManagers/appDocsManager.ts index 4131063c..02c87d17 100644 --- a/src/lib/appManagers/appDocsManager.ts +++ b/src/lib/appManagers/appDocsManager.ts @@ -1,30 +1,40 @@ import {RichTextProcessor} from '../richtextprocessor'; import { isObject, getFileURL, FileURLType } from '../utils'; import opusDecodeController from '../opusDecodeController'; -import { MTDocument, inputDocumentFileLocation, MTPhotoSize } from '../../types'; import { getFileNameByLocation } from '../bin_utils'; import appDownloadManager, { DownloadBlob } from './appDownloadManager'; import appPhotosManager from './appPhotosManager'; import { isServiceWorkerSupported } from '../config'; +import { InputFileLocation, Document, PhotoSize } from '../../layer'; + +export type MyDocument = Document.document; class AppDocsManager { - private docs: {[docID: string]: MTDocument} = {}; + private docs: {[docID: string]: MyDocument} = {}; - public saveDoc(doc: MTDocument, context?: any) { + public saveDoc(doc: Document, context?: any): MyDocument { + if(doc._ == 'documentEmpty') { + return undefined; + } + //console.log('saveDoc', apiDoc, this.docs[apiDoc.id]); if(this.docs[doc.id]) { const d = this.docs[doc.id]; - if(doc.thumbs) { - if(!d.thumbs) d.thumbs = doc.thumbs; - /* else if(apiDoc.thumbs[0].bytes && !d.thumbs[0].bytes) { - d.thumbs.unshift(apiDoc.thumbs[0]); - } else if(d.thumbs[0].url) { // fix for converted thumb in safari - apiDoc.thumbs[0] = d.thumbs[0]; - } */ - } + //if(doc._ != 'documentEmpty' && doc._ == d._) { + if(doc.thumbs) { + if(!d.thumbs) d.thumbs = doc.thumbs; + /* else if(apiDoc.thumbs[0].bytes && !d.thumbs[0].bytes) { + d.thumbs.unshift(apiDoc.thumbs[0]); + } else if(d.thumbs[0].url) { // fix for converted thumb in safari + apiDoc.thumbs[0] = d.thumbs[0]; + } */ + } + + d.file_reference = doc.file_reference; + //} - d.file_reference = doc.file_reference; + return d; //return Object.assign(d, apiDoc, context); @@ -37,7 +47,7 @@ class AppDocsManager { this.docs[doc.id] = doc; - doc.attributes.forEach((attribute: any) => { + doc.attributes.forEach(attribute => { switch(attribute._) { case 'documentAttributeFilename': doc.file_name = RichTextProcessor.wrapPlainText(attribute.file_name); @@ -145,10 +155,6 @@ class AppDocsManager { doc.animated = true; doc.sticker = 2; } - - if(doc._ == 'documentEmpty') { - doc.size = 0; - } /* if(!doc.url) { doc.url = this.getFileURL(doc); @@ -157,11 +163,11 @@ class AppDocsManager { return doc; } - public getDoc(docID: string | MTDocument): MTDocument { - return isObject(docID) && typeof(docID) !== 'string' ? docID : this.docs[docID as string]; + public getDoc(docID: string | MyDocument): MyDocument { + return isObject(docID) && typeof(docID) !== 'string' ? docID as any : this.docs[docID as string] as any; } - public getMediaInput(doc: MTDocument) { + public getMediaInput(doc: MyDocument) { return { _: 'inputMediaDocument', flags: 0, @@ -175,7 +181,7 @@ class AppDocsManager { }; } - public getInput(doc: MTDocument, thumbSize?: string): inputDocumentFileLocation { + public getInput(doc: MyDocument, thumbSize?: string): InputFileLocation.inputDocumentFileLocation { return { _: 'inputDocumentFileLocation', id: doc.id, @@ -185,7 +191,7 @@ class AppDocsManager { }; } - public getFileDownloadOptions(doc: MTDocument, thumb?: MTPhotoSize) { + public getFileDownloadOptions(doc: MyDocument, thumb?: PhotoSize.photoSize) { const inputFileLocation = this.getInput(doc, thumb?.type); let mimeType: string; @@ -204,7 +210,7 @@ class AppDocsManager { }; } - public getFileURL(doc: MTDocument, download = false, thumb?: MTPhotoSize) { + public getFileURL(doc: MyDocument, download = false, thumb?: PhotoSize.photoSize) { let type: FileURLType; if(download) { type = 'download'; @@ -219,11 +225,11 @@ class AppDocsManager { return getFileURL(type, this.getFileDownloadOptions(doc, thumb)); } - public getThumbURL(doc: MTDocument, thumb: MTPhotoSize) { + public getThumbURL(doc: MyDocument, thumb: PhotoSize.photoSize | PhotoSize.photoCachedSize | PhotoSize.photoStrippedSize) { let promise: Promise = Promise.resolve(); if(!thumb.url) { - if(thumb.bytes) { + if('bytes' in thumb) { thumb.url = appPhotosManager.getPreviewURLFromBytes(thumb.bytes, !!doc.sticker); } else { //return this.getFileURL(doc, false, thumb); @@ -234,34 +240,28 @@ class AppDocsManager { return {thumb, promise}; } - public getThumb(doc: MTDocument, useBytes = true) { + public getThumb(doc: MyDocument, useBytes = true) { if(doc.thumbs?.length) { - let thumb: MTPhotoSize; + let thumb: PhotoSize; if(!useBytes) { - thumb = doc.thumbs.find(t => !t.bytes); + thumb = doc.thumbs.find(t => !('bytes' in t)); } if(!thumb) { thumb = doc.thumbs[0]; } - return this.getThumbURL(doc, thumb); + return this.getThumbURL(doc, thumb as any); } return null; } - public getInputFileName(doc: MTDocument, thumbSize?: string) { + public getInputFileName(doc: MyDocument, thumbSize?: string) { return getFileNameByLocation(this.getInput(doc, thumbSize), {fileName: doc.file_name}); } - public downloadDocNew(docID: string | MTDocument, thumb?: MTPhotoSize): DownloadBlob { - const doc = this.getDoc(docID); - - if(doc._ == 'documentEmpty') { - throw new Error('Document empty!'); - } - + public downloadDocNew(doc: MyDocument, thumb?: PhotoSize.photoSize): DownloadBlob { const fileName = this.getInputFileName(doc, thumb?.type); let download: DownloadBlob = appDownloadManager.getDownload(fileName); @@ -311,7 +311,7 @@ class AppDocsManager { return download; } - public saveDocFile(doc: MTDocument) { + public saveDocFile(doc: MyDocument) { const options = this.getFileDownloadOptions(doc); return appDownloadManager.downloadToDisc(options, doc.file_name); } diff --git a/src/lib/appManagers/appDownloadManager.ts b/src/lib/appManagers/appDownloadManager.ts index 103e2eb7..fd390155 100644 --- a/src/lib/appManagers/appDownloadManager.ts +++ b/src/lib/appManagers/appDownloadManager.ts @@ -3,7 +3,7 @@ import apiManager from "../mtproto/mtprotoworker"; import { deferredPromise, CancellablePromise } from "../polyfill"; import type { DownloadOptions } from "../mtproto/apiFileManager"; import { getFileNameByLocation } from "../bin_utils"; -import { InputFile } from "../../types"; +import { InputFile } from "../../layer"; export type ResponseMethodBlob = 'blob'; export type ResponseMethodJson = 'json'; diff --git a/src/lib/appManagers/appImManager.ts b/src/lib/appManagers/appImManager.ts index 1413f4ae..73ba7539 100644 --- a/src/lib/appManagers/appImManager.ts +++ b/src/lib/appManagers/appImManager.ts @@ -40,6 +40,7 @@ import appPollsManager from './appPollsManager'; import { ripple } from '../../components/ripple'; import { horizontalMenu } from '../../components/horizontalMenu'; import AudioElement from '../../components/audio'; +import { InputNotifyPeer, InputPeerNotifySettings } from '../../layer'; //console.log('appImManager included33!'); @@ -650,14 +651,14 @@ export class AppImManager { if(message.media) { if(message.media.photo) { const photo = appPhotosManager.getPhoto(tempID); - if(photo) { + //if(photo._ != 'photoEmpty') { const newPhoto = message.media.photo; newPhoto.downloaded = photo.downloaded; newPhoto.url = photo.url; - } + //} } else if(message.media.document) { const doc = appDocsManager.getDoc(tempID); - if(doc && doc.type && doc.type != 'sticker') { + if(/* doc._ != 'documentEmpty' && */doc.type && doc.type != 'sticker') { const newDoc = message.media.document; newDoc.downloaded = doc.downloaded; newDoc.url = doc.url; @@ -2216,10 +2217,12 @@ export class AppImManager { case 'photo': { //if(pending.size < 5e6) { - this.log('will wrap pending photo:', pending, message, appPhotosManager.getPhoto(message.id)); + const photo = appPhotosManager.getPhoto(message.id); + //if(photo._ == 'photoEmpty') break; + this.log('will wrap pending photo:', pending, message, photo); const tailSupported = !isAndroid; if(tailSupported) bubble.classList.add('with-media-tail'); - wrapPhoto(appPhotosManager.getPhoto(message.id), message, attachmentDiv, undefined, undefined, tailSupported, true, this.lazyLoadQueue, null); + wrapPhoto(photo, message, attachmentDiv, undefined, undefined, tailSupported, true, this.lazyLoadQueue, null); bubble.classList.add('hide-name', 'photo'); //} @@ -2230,6 +2233,7 @@ export class AppImManager { case 'video': { //if(pending.size < 5e6) { let doc = appDocsManager.getDoc(message.id); + //if(doc._ == 'documentEmpty') break; this.log('will wrap pending video:', pending, message, doc); const tailSupported = !isAndroid && !isApple && doc.type != 'round'; if(tailSupported) bubble.classList.add('with-media-tail'); @@ -2256,6 +2260,7 @@ export class AppImManager { case 'voice': case 'document': { const doc = appDocsManager.getDoc(message.id); + //if(doc._ == 'documentEmpty') break; this.log('will wrap pending doc:', doc); const docDiv = wrapDocument(doc, false, true, message.id); @@ -2948,12 +2953,12 @@ export class AppImManager { public mutePeer(peerID: number) { let inputPeer = appPeersManager.getInputPeerByID(peerID); - let inputNotifyPeer = { + let inputNotifyPeer: InputNotifyPeer.inputNotifyPeer = { _: 'inputNotifyPeer', peer: inputPeer }; - let settings = { + let settings: InputPeerNotifySettings = { _: 'inputPeerNotifySettings', flags: 0, mute_until: 0 diff --git a/src/lib/appManagers/appMediaViewer.ts b/src/lib/appManagers/appMediaViewer.ts index e5724e63..ded36116 100644 --- a/src/lib/appManagers/appMediaViewer.ts +++ b/src/lib/appManagers/appMediaViewer.ts @@ -5,7 +5,7 @@ import { RichTextProcessor } from "../richtextprocessor"; import { logger } from "../logger"; import ProgressivePreloader from "../../components/preloader"; import { findUpClassName, $rootScope, generatePathData, fillPropertyValue, cancelEvent } from "../utils"; -import appDocsManager from "./appDocsManager"; +import appDocsManager, {MyDocument} from "./appDocsManager"; import VideoPlayer from "../mediaPlayer"; import { renderImageFromUrl, parseMenuButtonsTo } from "../../components/misc"; import AvatarElement from "../../components/avatar"; @@ -13,7 +13,6 @@ import LazyLoadQueue from "../../components/lazyLoadQueue"; import appForward from "../../components/appForward"; import { isSafari, mediaSizes, touchSupport } from "../config"; import { deferredPromise } from "../polyfill"; -import { MTDocument } from "../../types"; import appMediaPlaybackController from "../../components/appMediaPlaybackController"; // TODO: масштабирование картинок (не SVG) при ресайзе, и правильный возврат на исходную позицию @@ -246,7 +245,7 @@ export class AppMediaViewer { if(message.media.photo) { appPhotosManager.savePhotoFile(message.media.photo); } else { - let document: MTDocument = null; + let document: MyDocument = null; if(message.media.webpage) document = message.media.webpage.document; else document = message.media.document; @@ -840,7 +839,7 @@ export class AppMediaViewer { this.log('openMedia doc:', message); const media = message.media.photo || message.media.document || message.media.webpage.document || message.media.webpage.photo; - const isVideo = (media as MTDocument).type == 'video' || (media as MTDocument).type == 'gif'; + const isVideo = (media as MyDocument).type == 'video' || (media as MyDocument).type == 'gif'; const isFirstOpen = !this.peerID; if(isFirstOpen) { diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 70b59156..676ea5db 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -11,7 +11,7 @@ import appPhotosManager from "./appPhotosManager"; import AppStorage from '../storage'; import appPeersManager from "./appPeersManager"; import ServerTimeManager from "../mtproto/serverTimeManager"; -import appDocsManager from "./appDocsManager"; +import appDocsManager, {MyDocument} from "./appDocsManager"; import ProgressivePreloader from "../../components/preloader"; import serverTimeManager from "../mtproto/serverTimeManager"; //import apiManager from '../mtproto/apiManager'; @@ -20,10 +20,11 @@ import appWebPagesManager from "./appWebPagesManager"; import { CancellablePromise, deferredPromise } from "../polyfill"; import appPollsManager from "./appPollsManager"; import searchIndexManager from '../searchIndexManager'; -import { MTDocument, MTPhotoSize } from "../../types"; +import { Modify } from "../../types"; import { logger, LogLevels } from "../logger"; import type {ApiFileManager} from '../mtproto/apiFileManager'; import appDownloadManager from "./appDownloadManager"; +import { DialogFilter, InputDialogPeer, InputMessage, MethodDeclMap, MessagesFilter, PhotoSize } from "../../layer"; //console.trace('include'); @@ -237,30 +238,15 @@ export class DialogsStorage { } } -export type DialogFilter = { - _: 'dialogFilter', - flags: number, - pFlags: Partial<{ - contacts: true, - non_contacts: true, - groups: true, - broadcasts: true, - bots: true, - exclude_muted: true, - exclude_read: true, - exclude_archived: true - }>, - id: number, - title: string, - emoticon?: string, +export type MyDialogFilter = Modify; + export class FiltersStorage { - public filters: {[filterID: string]: DialogFilter} = {}; + public filters: {[filterID: string]: MyDialogFilter} = {}; public orderIndex = 0; constructor() { @@ -286,7 +272,7 @@ export class FiltersStorage { } } - public testDialogForFilter(dialog: Dialog, filter: DialogFilter) { + public testDialogForFilter(dialog: Dialog, filter: MyDialogFilter) { // exclude_peers for(const peerID of filter.exclude_peers) { if(peerID == dialog.peerID) { @@ -352,39 +338,6 @@ export class FiltersStorage { return false; } - /* public processDialog(dialog: Dialog) { - for(const filterID in this.filters) { - const filter = this.filters[filterID]; - const good = this.testDialogForFilter(dialog, filter); - - const folder = appMessagesManager.dialogsStorage.getFolder(+filterID); - if(good) { - folder.push(dialog); - } - - console.log('processDialog:', dialog, filter, good); - } - } */ - - /* public initFilters() { - return Promise.all([ - appUsersManager.getContacts(), - - this.getDialogFilters(), - - appMessagesManager.getConversations('', 0, 20, 0), - appMessagesManager.getConversations('', 0, 20, 1) - ]).then(() => { - const dialogs = appMessagesManager.dialogsStorage.dialogs; - for(const peerID in dialogs) { - const dialog = dialogs[peerID]; - this.processDialog(dialog); - } - - this.inited = true; - }); - } */ - public toggleDialogPin(peerID: number, filterID: number) { const filter = this.filters[filterID]; @@ -396,14 +349,14 @@ export class FiltersStorage { return this.updateDialogFilter(filter); } - public createDialogFilter(filter: DialogFilter) { + public createDialogFilter(filter: MyDialogFilter) { let maxID = Math.max(1, ...Object.keys(this.filters).map(i => +i)); filter = copy(filter); filter.id = maxID + 1; return this.updateDialogFilter(filter); } - public updateDialogFilter(filter: DialogFilter, remove = false) { + public updateDialogFilter(filter: MyDialogFilter, remove = false) { const flags = remove ? 0 : 1; if(!remove) { @@ -456,8 +409,8 @@ export class FiltersStorage { }); } - public getOutputDialogFilter(filter: DialogFilter) { - const c: DialogFilter = copy(filter); + public getOutputDialogFilter(filter: MyDialogFilter) { + const c: MyDialogFilter = copy(filter); ['pinned_peers', 'exclude_peers', 'include_peers'].forEach(key => { // @ts-ignore c[key] = c[key].map((peerID: number) => appPeersManager.getInputPeerByID(peerID)); @@ -469,31 +422,24 @@ export class FiltersStorage { } }); - return c; + return c as any as DialogFilter; } public async getDialogFilters(overwrite = false) { if(Object.keys(this.filters).length && !overwrite) { - /* // УБРАТЬ НА ПРОДЕ!!!!!!!!!!!! - for(const folderID in this.filters) { - const filter = this.filters[folderID]; - if(typeof(filter.pinned_peers[0]) !== 'number') filter.pinned_peers = filter.pinned_peers.map(peer => appPeersManager.getPeerID(peer)); - if(typeof(filter.exclude_peers[0]) !== 'number') filter.exclude_peers = filter.exclude_peers.map(peer => appPeersManager.getPeerID(peer)); - if(typeof(filter.include_peers[0]) !== 'number') filter.include_peers = filter.include_peers.map(peer => appPeersManager.getPeerID(peer)); - } */ return this.filters; } - const filters = await (apiManager.invokeApi('messages.getDialogFilters') as Promise); + const filters = await apiManager.invokeApi('messages.getDialogFilters'); for(const filter of filters) { - this.saveDialogFilter(filter, false); + this.saveDialogFilter(filter as any as MyDialogFilter, false); } //console.log(this.filters); return this.filters; } - public saveDialogFilter(filter: DialogFilter, update = true) { + public saveDialogFilter(filter: MyDialogFilter, update = true) { ['pinned_peers', 'exclude_peers', 'include_peers'].forEach(key => { // @ts-ignore filter[key] = filter[key].map((peer: any) => appPeersManager.getPeerID(peer)); @@ -507,40 +453,7 @@ export class FiltersStorage { filter.include_peers = filter.pinned_peers.concat(filter.include_peers); - /* if(this.filters[filter.id]) { - // ну давай же найдём различия теперь, раз они сами не хотят приходить - const oldFilter = this.filters[filter.id]; - - const updateDialogs: {[peerID: number]: Dialog} = {}; - - const pinnedChanged = !deepEqual(oldFilter.pinned_peers, filter.pinned_peers); - if(pinnedChanged) { - for(const peerID of oldFilter.pinned_peers) { - updateDialogs[peerID] = appMessagesManager.getDialogByPeerID(peerID)[0]; - } - - for(const peerID of filter.pinned_peers) { - updateDialogs[peerID] = appMessagesManager.getDialogByPeerID(peerID)[0]; - } - } - - // это и так отфильтрует - //const excludeChanged = !deepEqual(oldFilter.exclude_peers, filter.exclude_peers); - - const includeChanged = !deepEqual(oldFilter.include_peers, filter.include_peers); - if(includeChanged) { - for(const peerID of filter.include_peers) { - updateDialogs[peerID] = appMessagesManager.getDialogByPeerID(peerID)[0]; - } - } - - Object.assign(this.filters[filter.id], filter); - if(pinnedChanged) { - $rootScope.$broadcast('filter_pinned_order', {id: filter.id, order: filter.pinned_peers}); - } - - $rootScope.$broadcast('dialogs_multiupdate', updateDialogs); - } */if(this.filters[filter.id]) { + if(this.filters[filter.id]) { Object.assign(this.filters[filter.id], filter); } else { this.filters[filter.id] = filter; @@ -553,7 +466,7 @@ export class FiltersStorage { } } - public setOrderIndex(filter: DialogFilter) { + public setOrderIndex(filter: MyDialogFilter) { if(filter.hasOwnProperty('orderIndex')) { if(filter.orderIndex > this.orderIndex) { this.orderIndex = filter.orderIndex; @@ -734,7 +647,7 @@ export class AppMessagesManager { message: text, media: message.media, entities: this.getInputEntities(entities), - no_webpage: noWebPage, + no_webpage: noWebPage || undefined, }).then((updates) => { apiUpdatesManager.processUpdateMessage(updates); }, (error) => { @@ -753,8 +666,8 @@ export class AppMessagesManager { entities: any[], replyToMsgID: number, viaBotID: number, - queryID: number, - resultID: number, + queryID: string, + resultID: string, noWebPage: boolean, reply_markup: any, clearDraft: boolean, @@ -877,7 +790,7 @@ export class AppMessagesManager { apiPromise = apiManager.invokeApi('messages.sendInlineBotResult', { flags: flags, peer: appPeersManager.getInputPeerByID(peerID), - random_id: randomID, + random_id: randomID as any, reply_to_msg_id: appMessagesIDsManager.getMessageLocalID(replyToMsgID), query_id: options.queryID, id: options.resultID @@ -889,10 +802,10 @@ export class AppMessagesManager { apiPromise = apiManager.invokeApi('messages.sendMessage', { flags: flags, - no_webpage: noWebPage, + no_webpage: noWebPage || undefined, peer: appPeersManager.getInputPeerByID(peerID), message: text, - random_id: randomID, + random_id: randomID as any, reply_to_msg_id: appMessagesIDsManager.getMessageLocalID(replyToMsgID), entities: sendEntites }, sentRequestOptions); @@ -967,7 +880,7 @@ export class AppMessagesManager { this.pendingByRandomID[randomIDS] = [peerID, messageID]; } - public sendFile(peerID: number, file: File | Blob | MTDocument, options: Partial<{ + public sendFile(peerID: number, file: File | Blob | MyDocument, options: Partial<{ isMedia: boolean, replyToMsgID: number, caption: string, @@ -1033,7 +946,7 @@ export class AppMessagesManager { h: options.height, type: 'm', size: file.size - } as MTPhotoSize], + } as PhotoSize], w: options.width, h: options.height, downloaded: file.size, @@ -1190,12 +1103,12 @@ export class AppMessagesManager { return apiManager.invokeApi('messages.sendMedia', { flags: flags, - background: options.background, + background: options.background || undefined, clear_draft: true, peer: appPeersManager.getInputPeerByID(peerID), media: inputMedia, message: caption, - random_id: randomID, + random_id: randomID as any, reply_to_msg_id: appMessagesIDsManager.getMessageLocalID(replyToMsgID) }).then((updates) => { apiUpdatesManager.processUpdateMessage(updates); @@ -1225,7 +1138,7 @@ export class AppMessagesManager { flags |= 128; // clear_draft if(isDocument) { - const {id, access_hash, file_reference} = file as MTDocument; + const {id, access_hash, file_reference} = file as MyDocument; const inputMedia = { _: 'inputMediaDocument', @@ -1421,7 +1334,7 @@ export class AppMessagesManager { h: details.height, type: 'm', size: file.size - } as MTPhotoSize], + } as PhotoSize], w: details.width, h: details.height, downloaded: file.size, @@ -1573,13 +1486,11 @@ export class AppMessagesManager { } let inputMedia: any; - if(messageMedia.photo) { - let photo = messageMedia.photo; - appPhotosManager.savePhoto(photo); + if(messageMedia._ == 'messageMediaPhoto') { + const photo = appPhotosManager.savePhoto(messageMedia.photo); inputMedia = appPhotosManager.getInput(photo); - } else { - let doc = messageMedia.document; - appDocsManager.saveDoc(doc); + } else if(messageMedia._ == 'messageMediaDocument') { + const doc = appDocsManager.saveDoc(messageMedia.document); inputMedia = appDocsManager.getMediaInput(doc); } @@ -1613,8 +1524,8 @@ export class AppMessagesManager { viaBotID: number, reply_markup: any, clearDraft: boolean, - queryID: number - resultID: number + queryID: string + resultID: string }> = {}) { peerID = appPeersManager.getPeerMigratedTo(peerID) || peerID; @@ -1785,7 +1696,7 @@ export class AppMessagesManager { apiPromise = apiManager.invokeApi('messages.sendInlineBotResult', { flags: flags, peer: appPeersManager.getInputPeerByID(peerID), - random_id: randomID, + random_id: randomID as any, reply_to_msg_id: appMessagesIDsManager.getMessageLocalID(replyToMsgID), query_id: options.queryID, id: options.resultID @@ -1795,8 +1706,9 @@ export class AppMessagesManager { flags: flags, peer: appPeersManager.getInputPeerByID(peerID), media: inputMedia, - random_id: randomID, - reply_to_msg_id: appMessagesIDsManager.getMessageLocalID(replyToMsgID) + random_id: randomID as any, + reply_to_msg_id: appMessagesIDsManager.getMessageLocalID(replyToMsgID), + message: '' }, sentRequestOptions); } apiPromise.then((updates) => { @@ -2076,7 +1988,7 @@ export class AppMessagesManager { flags: flags, from_peer: appPeersManager.getInputPeerByID(-channelID), id: msgIDs, - random_id: randomIDs, + random_id: randomIDs as any, to_peer: appPeersManager.getInputPeerByID(peerID) }, sentRequestOptions).then((updates) => { apiUpdatesManager.processUpdateMessage(updates); @@ -2127,7 +2039,7 @@ export class AppMessagesManager { if(this.reloadConversationsPromise) return this.reloadConversationsPromise; return this.reloadConversationsPromise = new Promise((resolve, reject) => { setTimeout(() => { - let peers = this.reloadConversationsPeers.map(peerID => appPeersManager.getInputPeerByID(peerID)); + const peers = this.reloadConversationsPeers.map(peerID => appPeersManager.getInputDialogPeerByID(peerID)); this.reloadConversationsPeers.length = 0; apiManager.invokeApi('messages.getPeerDialogs', {peers}).then((result) => { @@ -2576,10 +2488,7 @@ export class AppMessagesManager { const dialog = this.getDialogByPeerID(peerID)[0]; if(!dialog) return Promise.reject(); - const peer = { - _: 'inputDialogPeer', - peer: appPeersManager.getInputPeerByID(peerID) - }; + const peer = appPeersManager.getInputDialogPeerByID(peerID); const flags = dialog.pFlags?.pinned ? 0 : 1; return apiManager.invokeApi('messages.toggleDialogPin', { @@ -2599,15 +2508,12 @@ export class AppMessagesManager { } public markDialogUnread(peerID: number, read?: boolean) { - let dialog = this.getDialogByPeerID(peerID)[0]; + const dialog = this.getDialogByPeerID(peerID)[0]; if(!dialog) return Promise.reject(); - let peer = { - _: 'inputDialogPeer', - peer: appPeersManager.getInputPeerByID(peerID) - }; + const peer = appPeersManager.getInputDialogPeerByID(peerID); - let flags = read || dialog.pFlags?.unread_mark ? 0 : 1; + const flags = read || dialog.pFlags?.unread_mark ? 0 : 1; return apiManager.invokeApi('messages.markDialogUnread', { flags, peer @@ -3040,14 +2946,15 @@ export class AppMessagesManager { flags: 0, peer: appPeersManager.getInputPeerByID(peerID), q: query || '', - filter: inputFilter || {_: 'inputMessagesFilterEmpty'}, + filter: (inputFilter || {_: 'inputMessagesFilterEmpty'}) as any as MessagesFilter, min_date: 0, max_date: 0, limit: limit, offset_id: appMessagesIDsManager.getMessageLocalID(maxID) || 0, add_offset: backLimit ? -backLimit : 0, max_id: 0, - min_id: 0 + min_id: 0, + hash: 0 }, { timeout: APITIMEOUT, noErrorBox: true @@ -3065,6 +2972,7 @@ export class AppMessagesManager { } apiPromise = apiManager.invokeApi('messages.searchGlobal', { + flags: 0, q: query, offset_rate: offsetRate, offset_peer: appPeersManager.getInputPeerByID(offsetPeerID), @@ -4370,14 +4278,14 @@ export class AppMessagesManager { Object.keys(splitted.msgIDs).forEach((channelID: number | string) => { channelID = +channelID; - let msgIDs = splitted.msgIDs[channelID].map((msgID: number) => { + const msgIDs: InputMessage[] = splitted.msgIDs[channelID].map((msgID: number) => { return { _: 'inputMessageID', id: msgID }; }); - var promise; + let promise: Promise; if(channelID > 0) { promise = apiManager.invokeApi('channels.getMessages', { channel: appChatsManager.getChannelInput(channelID), @@ -4389,10 +4297,12 @@ export class AppMessagesManager { }); } - promises.push(promise.then((getMessagesResult: any) => { - appUsersManager.saveApiUsers(getMessagesResult.users); - appChatsManager.saveApiChats(getMessagesResult.chats); - this.saveMessages(getMessagesResult.messages); + promises.push(promise.then(getMessagesResult => { + if(getMessagesResult._ != 'messages.messagesNotModified') { + appUsersManager.saveApiUsers(getMessagesResult.users); + appChatsManager.saveApiChats(getMessagesResult.chats); + this.saveMessages(getMessagesResult.messages); + } $rootScope.$broadcast('messages_downloaded', splitted.mids[+channelID]); })); diff --git a/src/lib/appManagers/appPeersManager.ts b/src/lib/appManagers/appPeersManager.ts index ad711d9d..f714573f 100644 --- a/src/lib/appManagers/appPeersManager.ts +++ b/src/lib/appManagers/appPeersManager.ts @@ -2,6 +2,7 @@ import appUsersManager from "./appUsersManager"; import appChatsManager from "./appChatsManager"; import { isObject } from "../utils"; import { RichTextProcessor } from "../richtextprocessor"; +import { InputPeer, InputDialogPeer } from "../../layer"; // https://github.com/eelcohn/Telegram-API/wiki/Calculating-color-for-a-Telegram-user-on-IRC /* @@ -161,13 +162,13 @@ const AppPeersManager = { } }, - getInputPeerByID: (peerID: number) => { + getInputPeerByID: (peerID: number): InputPeer => { if(!peerID) { return {_: 'inputPeerEmpty'}; } if(peerID < 0) { - let chatID = -peerID; + const chatID = -peerID; if(!appChatsManager.isChannel(chatID)) { return appChatsManager.getChatInputPeer(chatID); } else { @@ -178,13 +179,20 @@ const AppPeersManager = { return { _: 'inputPeerUser', user_id: peerID, - access_hash: appUsersManager.getUser(peerID).access_hash || 0 + access_hash: appUsersManager.getUser(peerID).access_hash }; }, + getInputDialogPeerByID: (peerID: number): InputDialogPeer => { + return { + _: 'inputDialogPeer', + peer: AppPeersManager.getInputPeerByID(peerID) + } + }, + getPeerColorByID: (peerID: number, pic = true) => { - let idx = DialogColorsMap[(peerID < 0 ? -peerID : peerID) % 7]; - let color = (pic ? DialogColors : DialogColorsFg)[idx]; + const idx = DialogColorsMap[(peerID < 0 ? -peerID : peerID) % 7]; + const color = (pic ? DialogColors : DialogColorsFg)[idx]; return color; }, @@ -193,7 +201,7 @@ const AppPeersManager = { if(peerID > 0) { text = '%pu ' + appUsersManager.getUserSearchText(peerID); } else if(peerID < 0) { - let chat = appChatsManager.getChat(-peerID); + const chat = appChatsManager.getChat(-peerID); text = '%pg ' + (chat.title || ''); } return text; diff --git a/src/lib/appManagers/appPhotosManager.ts b/src/lib/appManagers/appPhotosManager.ts index 76618020..b22769d6 100644 --- a/src/lib/appManagers/appPhotosManager.ts +++ b/src/lib/appManagers/appPhotosManager.ts @@ -1,29 +1,16 @@ import { calcImageInBox, isObject } from "../utils"; import { bytesFromHex, getFileNameByLocation } from "../bin_utils"; -import { MTPhotoSize, inputPhotoFileLocation, inputDocumentFileLocation, FileLocation, MTDocument } from "../../types"; import appDownloadManager from "./appDownloadManager"; import { CancellablePromise } from "../polyfill"; import { isSafari } from "../../helpers/userAgent"; +import { FileLocation, InputFileLocation, Photo, PhotoSize } from "../../layer"; +import { MyDocument } from "./appDocsManager"; -export type MTPhoto = { - _: 'photo' | 'photoEmpty', - pFlags: any, - flags: number, - id: string, - access_hash: string, - file_reference: Uint8Array, - date: number, - sizes: Array, - dc_id: number, - user_id: number, - - downloaded?: boolean | number, - url?: string -}; +export type MyPhoto = Photo.photo; export class AppPhotosManager { private photos: { - [id: string]: MTPhoto + [id: string]: MyPhoto } = {}; private documentThumbsCache: { [docID: string]: { @@ -47,7 +34,9 @@ export class AppPhotosManager { this.windowH = document.body.scrollHeight; } - public savePhoto(photo: MTPhoto, context?: any) { + public savePhoto(photo: Photo, context?: any) { + if(photo._ == 'photoEmpty') return undefined; + if(this.photos[photo.id]) return Object.assign(this.photos[photo.id], photo); /* if(context) { @@ -56,12 +45,12 @@ export class AppPhotosManager { if(!photo.id) { console.warn('no apiPhoto.id', photo); - } else this.photos[photo.id] = photo as any; + } else this.photos[photo.id] = photo; return photo; } - public choosePhotoSize(photo: MTPhoto | MTDocument, width = 0, height = 0) { + public choosePhotoSize(photo: MyPhoto | MyDocument, width = 0, height = 0) { //if(Config.Navigator.retina) { if(window.devicePixelRatio > 1) { width *= 2; @@ -79,11 +68,11 @@ export class AppPhotosManager { c crop 640x640 d crop 1280x1280 */ - let bestPhotoSize: MTPhotoSize = {_: 'photoSizeEmpty'}; - const sizes = ((photo as MTPhoto).sizes || (photo as MTDocument).thumbs) as typeof bestPhotoSize[]; + let bestPhotoSize: PhotoSize = {_: 'photoSizeEmpty', type: ''}; + const sizes = ((photo as MyPhoto).sizes || (photo as MyDocument).thumbs) as PhotoSize[]; if(sizes) { for(const photoSize of sizes) { - if(!photoSize.w || !photoSize.h) continue; + if(!('w' in photoSize) && !('h' in photoSize)) continue; bestPhotoSize = photoSize; @@ -142,7 +131,7 @@ export class AppPhotosManager { return URL.createObjectURL(blob); } - public getPreviewURLFromThumb(thumb: MTPhotoSize, isSticker = false) { + public getPreviewURLFromThumb(thumb: PhotoSize.photoCachedSize | PhotoSize.photoStrippedSize, isSticker = false) { return thumb.url ?? (thumb.url = this.getPreviewURLFromBytes(thumb.bytes, isSticker)); } @@ -171,26 +160,30 @@ export class AppPhotosManager { } } - public setAttachmentSize(photo: MTPhoto | MTDocument, element: HTMLElement | SVGForeignObjectElement, boxWidth: number, boxHeight: number, isSticker = false, dontRenderPreview = false) { - let photoSize = this.choosePhotoSize(photo, boxWidth, boxHeight); + public setAttachmentSize(photo: MyPhoto | MyDocument, element: HTMLElement | SVGForeignObjectElement, boxWidth: number, boxHeight: number, isSticker = false, dontRenderPreview = false) { + const photoSize = this.choosePhotoSize(photo, boxWidth, boxHeight); //console.log('setAttachmentSize', photo, photo.sizes[0].bytes, div); - let sizes = (photo as MTPhoto).sizes || (photo as MTDocument).thumbs; - if((!photo.downloaded || (photo as MTDocument).type == 'video' || (photo as MTDocument).type == 'gif') && !isSticker && sizes?.length && sizes[0].bytes && !dontRenderPreview) { - this.setAttachmentPreview(sizes[0].bytes, element, isSticker); + const sizes = (photo as MyPhoto).sizes || (photo as MyDocument).thumbs; + const thumb = sizes?.length ? sizes[0] : null; + if(thumb && ('bytes' in thumb)) { + if((!photo.downloaded || (photo as MyDocument).type == 'video' || (photo as MyDocument).type == 'gif') && !isSticker && !dontRenderPreview) { + this.setAttachmentPreview(thumb.bytes, element, isSticker); + } } + let width: number; let height: number; if(photo._ == 'document') { width = photo.w || 512; height = photo.h || 512; } else { - width = photoSize.w || 100; - height = photoSize.h || 100; + width = 'w' in photoSize ? photoSize.w : 100; + height = 'h' in photoSize ? photoSize.h : 100; } - let {w, h} = calcImageInBox(width, height, boxWidth, boxHeight); + const {w, h} = calcImageInBox(width, height, boxWidth, boxHeight); if(element instanceof SVGForeignObjectElement) { element.setAttributeNS(null, 'width', '' + w); element.setAttributeNS(null, 'height', '' + h); @@ -204,8 +197,8 @@ export class AppPhotosManager { return photoSize; } - public getPhotoDownloadOptions(photo: MTPhoto | MTDocument, photoSize: MTPhotoSize) { - const isDocument = photo._ == 'document'; + public getPhotoDownloadOptions(photo: MyPhoto | MyDocument, photoSize: PhotoSize) { + const isMyDocument = photo._ == 'document'; if(!photoSize || photoSize._ == 'photoSizeEmpty') { //console.error('no photoSize by photo:', photo); @@ -213,27 +206,32 @@ export class AppPhotosManager { } // maybe it's a thumb - const isPhoto = photoSize.size && photo.access_hash && photo.file_reference; - const location: inputPhotoFileLocation | inputDocumentFileLocation | FileLocation = isPhoto ? { - _: isDocument ? 'inputDocumentFileLocation' : 'inputPhotoFileLocation', + const isPhoto = photoSize._ == 'photoSize' && photo.access_hash && photo.file_reference; + const location: InputFileLocation.inputPhotoFileLocation | InputFileLocation.inputDocumentFileLocation | FileLocation = isPhoto ? { + _: isMyDocument ? 'inputDocumentFileLocation' : 'inputPhotoFileLocation', id: photo.id, access_hash: photo.access_hash, file_reference: photo.file_reference, thumb_size: photoSize.type - } : photoSize.location; + } : (photoSize as PhotoSize.photoSize).location; - return {dcID: photo.dc_id, location, size: isPhoto ? photoSize.size : undefined}; + return {dcID: photo.dc_id, location, size: isPhoto ? (photoSize as PhotoSize.photoSize).size : undefined}; } - /* public getPhotoURL(photo: MTPhoto | MTDocument, photoSize: MTPhotoSize) { + /* public getPhotoURL(photo: MTPhoto | MTMyDocument, photoSize: MTPhotoSize) { const downloadOptions = this.getPhotoDownloadOptions(photo, photoSize); return {url: getFileURL('photo', downloadOptions), location: downloadOptions.location}; } */ - public preloadPhoto(photoID: any, photoSize?: MTPhotoSize): CancellablePromise { + public preloadPhoto(photoID: any, photoSize?: PhotoSize): CancellablePromise { const photo = this.getPhoto(photoID); + // @ts-ignore + if(photo._ == 'photoEmpty') { + throw new Error('preloadPhoto photoEmpty!'); + } + if(!photoSize) { const fullWidth = this.windowW; const fullHeight = this.windowH; @@ -242,7 +240,7 @@ export class AppPhotosManager { } const cacheContext = this.getCacheContext(photo); - if(cacheContext.downloaded >= photoSize.size && cacheContext.url) { + if(cacheContext.downloaded >= ('size' in photoSize ? photoSize.size : 0) && cacheContext.url) { return Promise.resolve() as any; } @@ -277,11 +275,11 @@ export class AppPhotosManager { return this.documentThumbsCache[docID] ?? (this.documentThumbsCache[docID] = {downloaded: 0, url: ''}); } - public getPhoto(photoID: any): MTPhoto { + public getPhoto(photoID: any): MyPhoto { return isObject(photoID) ? photoID : this.photos[photoID]; } - public getInput(photo: MTPhoto) { + public getInput(photo: MyPhoto) { return { _: 'inputMediaPhoto', flags: 0, @@ -295,11 +293,13 @@ export class AppPhotosManager { }; } - public savePhotoFile(photo: MTPhoto | MTDocument) { - const fullWidth = this.windowW; - const fullHeight = this.windowH; - const fullPhotoSize = this.choosePhotoSize(photo, fullWidth, fullHeight); - const location: inputDocumentFileLocation | inputPhotoFileLocation = { + public savePhotoFile(photo: MyPhoto | MyDocument) { + const fullPhotoSize = this.choosePhotoSize(photo, 0xFFFF, 0xFFFF); + if(fullPhotoSize._ != 'photoSize') { + return; + } + + const location: InputFileLocation.inputDocumentFileLocation | InputFileLocation.inputPhotoFileLocation = { _: photo._ == 'document' ? 'inputDocumentFileLocation' : 'inputPhotoFileLocation', id: photo.id, access_hash: photo.access_hash, diff --git a/src/lib/appManagers/appPollsManager.ts b/src/lib/appManagers/appPollsManager.ts index 945c28da..3841be08 100644 --- a/src/lib/appManagers/appPollsManager.ts +++ b/src/lib/appManagers/appPollsManager.ts @@ -5,7 +5,7 @@ import apiManager from "../mtproto/mtprotoworker"; import apiUpdatesManager from "./apiUpdatesManager"; import { $rootScope } from "../utils"; import { logger, LogLevels } from "../logger"; -import appUsersManager, { User } from "./appUsersManager"; +import appUsersManager from "./appUsersManager"; export type PollAnswer = { _: 'pollAnswer', @@ -195,19 +195,7 @@ class AppPollsManager { option, offset, limit - }).then((votesList: { - _: 'messages.votesList', - flags: number, - count: number, - next_offset: string, - pFlags: {}, - users: User[], - votes: { - _: 'messageUserVoteInputOption', - date: number, - user_id: number - }[] - }) => { + }).then((votesList) => { this.log('getPollVotes messages:', votesList); appUsersManager.saveApiUsers(votesList.users); diff --git a/src/lib/appManagers/appStateManager.ts b/src/lib/appManagers/appStateManager.ts index 4edd9d80..eb684725 100644 --- a/src/lib/appManagers/appStateManager.ts +++ b/src/lib/appManagers/appStateManager.ts @@ -26,7 +26,7 @@ type State = Partial<{ }>; export class AppStateManager { - public loaded: Promise; + public loaded: Promise; private log = logger('STATE'/* , LogLevels.error */); private state: State = {}; diff --git a/src/lib/appManagers/appStickersManager.ts b/src/lib/appManagers/appStickersManager.ts index 0ab9e58a..cd1a18eb 100644 --- a/src/lib/appManagers/appStickersManager.ts +++ b/src/lib/appManagers/appStickersManager.ts @@ -2,76 +2,23 @@ import AppStorage from '../storage'; //import apiManager from '../mtproto/apiManager'; import apiManager from '../mtproto/mtprotoworker'; import appDocsManager from './appDocsManager'; -import { MTDocument, inputStickerSetThumb } from '../../types'; import { $rootScope } from '../utils'; - -export type MTStickerSet = { - _: 'stickerSet', - flags: number, - archived?: true, - official?: true, - masks?: true, - animated?: true, - installed_date?: number, - id: string, // long - access_hash: string, // long, - title: string, - short_name: string, // Short name of stickerset to use in tg://addstickers?set=short_name - thumb?: { - _: 'photoSize', - type: 'm', - location: { - _: string, - volume_id: string, - local_id: number - }, - w: number, - h: number, - size: number - }, - pFlags: { - animated?: boolean - } - thumb_dc_id?: number, - count: number, - hash: number -}; - -export type MTStickerSetFull = { - set: MTStickerSet, - packs: any[], - documents: MTDocument[] -}; - -export type MTStickerSetCovered = { - _: 'stickerSetCovered', - set: MTStickerSet, - cover: MTDocument -}; - -export type MTStickerSetMultiCovered = { - _: 'stickerSetMultiCovered', - set: MTStickerSet, - covers: MTDocument[] -}; +import { StickerSet, InputStickerSet, StickerSetCovered, MessagesRecentStickers, Document, InputFileLocation, MessagesStickerSet, PhotoSize } from '../../layer'; +import { Modify } from '../../types'; class AppStickersManager { - private documents: { - [fileID: string]: MTDocument - } = {}; - private stickerSets: { - [stickerSetID: string]: MTStickerSetFull + [stickerSetID: string]: MessagesStickerSet } = {}; private saveSetsTimeout: number; private hashes: Partial<{ - featured: Partial<{hash: number, result: (MTStickerSetCovered | MTStickerSetMultiCovered)[]}>, + featured: Partial<{hash: number, result: StickerSetCovered[]}>, search: { [query: string]: Partial<{ hash: number, - result: (MTStickerSetCovered | MTStickerSetMultiCovered)[] + result: StickerSetCovered[] }> } }> = { @@ -80,9 +27,7 @@ class AppStickersManager { }; constructor() { - AppStorage.get<{ - [stickerSetID: string]: MTStickerSetFull - }>('stickerSets').then((sets) => { + AppStorage.get('stickerSets').then((sets) => { if(sets) { for(let id in sets) { let set = sets[id]; @@ -109,63 +54,43 @@ class AppStickersManager { } }); } - - public saveSticker(doc: MTDocument) { - if(this.documents[doc.id]) return this.documents[doc.id]; - doc = appDocsManager.saveDoc(doc); - this.documents[doc.id] = doc; + public saveStickers(docs: Document[]) { + docs.forEachReverse((doc, idx) => { + doc = appDocsManager.saveDoc(doc); - return doc; - } - - public saveStickers(docs: MTDocument[]) { - docs.forEach((doc, idx) => { - docs[idx] = this.saveSticker(doc); + if(!doc) docs.splice(idx, 1); + else docs[idx] = doc; }); } - - public getSticker(fileID: string) { - return this.documents[fileID]; - } - + public async getStickerSet(set: { id: string, access_hash: string }, params: Partial<{ overwrite: boolean - }> = {}) { + }> = {}): Promise { if(this.stickerSets[set.id] && !params.overwrite && this.stickerSets[set.id].documents?.length) return this.stickerSets[set.id]; - - let promise = apiManager.invokeApi('messages.getStickerSet', { + + const stickerSet = await apiManager.invokeApi('messages.getStickerSet', { stickerset: this.getStickerSetInput(set) }); - - let res = await promise; - let stickerSet: { - _: "messages.stickerSet", - set: MTStickerSet, - packs: any[], - documents: MTDocument[] - } = res as any; this.saveStickerSet(stickerSet, set.id); - return stickerSet; + return stickerSet as any; } - public async getRecentStickers() { - let res: { - _: string, - hash: number, - packs: any[], - stickers: MTDocument[], - dates: number[] - } = await apiManager.invokeApi('messages.getRecentStickers', {flags: 0, hash: 0}); + public async getRecentStickers(): Promise> { + const res = await apiManager.invokeApi('messages.getRecentStickers', {flags: 0, hash: 0}) as MessagesRecentStickers.messagesRecentStickers; - this.saveStickers(res.stickers); + if(res._ == 'messages.recentStickers') { + this.saveStickers(res.stickers); + } - return res; + return res as any; } public getAnimatedEmojiSticker(emoji: string) { @@ -173,21 +98,17 @@ class AppStickersManager { if(!stickerSet || !stickerSet.documents) return undefined; emoji = emoji.replace(/\ufe0f/g, '').replace(/🏻|🏼|🏽|🏾|🏿/g, ''); - return stickerSet.documents.find(doc => doc.stickerEmojiRaw == emoji); + return stickerSet.documents.find(doc => (doc as Document.document).stickerEmojiRaw == emoji); } - public saveStickerSet(res: { - //_: "messages.stickerSet", - set: MTStickerSet, - packs: any[], - documents: MTDocument[] - }, id: string) { + public saveStickerSet(res: Omit, id: string) { //console.log('stickers save set', res);w - const newSet = { + const newSet: MessagesStickerSet = { + _: 'messages.stickerSet', set: res.set, packs: res.packs, - documents: res.documents + documents: res.documents as Document[] }; if(this.stickerSets[id]) { @@ -201,7 +122,7 @@ class AppStickersManager { //console.log('stickers wrote', this.stickerSets); if(this.saveSetsTimeout) return; this.saveSetsTimeout = setTimeout(() => { - const savedSets: {[id: string]: MTStickerSetFull} = {}; + const savedSets: {[id: string]: MessagesStickerSet} = {}; for(const id in this.stickerSets) { const set = this.stickerSets[id]; if(set.set.installed_date || id == 'emoji') { @@ -217,13 +138,13 @@ class AppStickersManager { }, 100); } - public getStickerSetThumbDownloadOptions(stickerSet: MTStickerSet) { - const thumb = stickerSet.thumb; + public getStickerSetThumbDownloadOptions(stickerSet: StickerSet.stickerSet) { + const thumb = stickerSet.thumb as PhotoSize.photoSize; const dcID = stickerSet.thumb_dc_id; const isAnimated = stickerSet.pFlags?.animated; - const input: inputStickerSetThumb = { + const input: InputFileLocation.inputStickerSetThumb = { _: 'inputStickerSetThumb', stickerset: this.getStickerSetInput(stickerSet), volume_id: thumb.location.volume_id, @@ -252,7 +173,7 @@ class AppStickersManager { //return promise; } */ - public getStickerSetInput(set: {id: string, access_hash: string}) { + public getStickerSetInput(set: {id: string, access_hash: string}): InputStickerSet { return set.id == 'emoji' ? { _: 'inputStickerSetAnimatedEmoji' } : { @@ -263,18 +184,9 @@ class AppStickersManager { } public async getFeaturedStickers() { - const res = (await apiManager.invokeApi('messages.getFeaturedStickers', { + const res = await apiManager.invokeApi('messages.getFeaturedStickers', { hash: this.hashes.featured?.hash || 0 - })) as { - _: 'messages.featuredStickers', - unread: string[], - count: number, - hash: number, - sets: (MTStickerSetMultiCovered | MTStickerSetCovered)[] - } | { - _: 'messages.featuredStickersNotModified', - count: number - }; + }); const hashed = this.hashes.featured ?? (this.hashes.featured = {}); if(res._ != 'messages.featuredStickersNotModified') { @@ -289,7 +201,7 @@ class AppStickersManager { return hashed.result; } - public async toggleStickerSet(set: MTStickerSet) { + public async toggleStickerSet(set: StickerSet.stickerSet) { if(set.installed_date) { const res = await apiManager.invokeApi('messages.uninstallStickerSet', { stickerset: this.getStickerSetInput(set) @@ -320,16 +232,10 @@ class AppStickersManager { const flags = excludeFeatured ? 1 : 0; const res = await apiManager.invokeApi('messages.searchStickerSets', { flags, - exclude_featured: excludeFeatured, + exclude_featured: excludeFeatured || undefined, q: query, hash: this.hashes.search[query]?.hash || 0 - }) as { - _: 'messages.foundStickerSets', - hash: number, - sets: Array - } | { - _: 'messages.foundStickerSetsNotModified' - }; + }); const hashed = this.hashes.search[query] ?? (this.hashes.search[query] = {}); if(res._ != 'messages.foundStickerSetsNotModified') { @@ -341,7 +247,7 @@ class AppStickersManager { this.saveStickerSet({set: covered.set, documents: [], packs: []}, covered.set.id); }); - const foundSaved: MTStickerSetCovered[] = []; + const foundSaved: StickerSetCovered[] = []; for(let id in this.stickerSets) { const {set} = this.stickerSets[id]; diff --git a/src/lib/appManagers/appUsersManager.ts b/src/lib/appManagers/appUsersManager.ts index b7bd4799..0d56f595 100644 --- a/src/lib/appManagers/appUsersManager.ts +++ b/src/lib/appManagers/appUsersManager.ts @@ -8,8 +8,9 @@ import { formatPhoneNumber } from "../../components/misc"; import searchIndexManager from "../searchIndexManager"; import appPeersManager from "./appPeersManager"; import appStateManager from "./appStateManager"; +import { InputUser, User as MTUser } from "../../layer"; -export type User = { +/* export type User = { _: 'user', access_hash: string, first_name: string, @@ -35,7 +36,16 @@ export type User = { rPhone?: string, sortName?: string, sortStatus?: number, -}; +}; */ +export interface User extends MTUser.user { + initials?: string, + num?: number, + rFirstName?: string, + rFullName?: string, + rPhone?: string, + sortName?: string, + sortStatus?: number, +} export class AppUsersManager { public users: {[userID: number]: User} = {}; @@ -73,11 +83,11 @@ export class AppUsersManager { if(user) { user.status = update.status; if(user.status) { - if(user.status.expires) { + if('expires' in user.status) { user.status.expires -= serverTimeManager.serverTimeOffset; } - if(user.status.was_online) { + if('was_online' in user.status) { user.status.was_online -= serverTimeManager.serverTimeOffset; } } @@ -284,12 +294,13 @@ export class AppUsersManager { public getUserStatusForSort(status: User['status']) { if(status) { - var expires = status.expires || status.was_online; + const expires = status._ == 'userStatusOnline' ? status.expires : (status._ == 'userStatusOffline' ? status.was_online : 0); if(expires) { return expires; } - var timeNow = tsNow(true); - switch (status._) { + + const timeNow = tsNow(true); + switch(status._) { case 'userStatusRecently': return timeNow - 86400 * 3; case 'userStatusLastWeek': @@ -411,12 +422,12 @@ export class AppUsersManager { } public getUserString(id: number) { - var user = this.getUser(id); + const user = this.getUser(id); return 'u' + id + (user.access_hash ? '_' + user.access_hash : ''); } - public getUserInput(id: number) { - var user = this.getUser(id); + public getUserInput(id: number): InputUser { + const user = this.getUser(id); if(user.pFlags && user.pFlags.self) { return {_: 'inputUserSelf'}; } @@ -424,21 +435,20 @@ export class AppUsersManager { return { _: 'inputUser', user_id: id, - access_hash: user.access_hash || 0 + access_hash: user.access_hash }; } public updateUsersStatuses() { - var timestampNow = tsNow(true); - for(let i in this.users) { - let user = this.users[i]; + const timestampNow = tsNow(true); + for(const i in this.users) { + const user = this.users[i]; if(user.status && user.status._ == 'userStatusOnline' && user.status.expires < timestampNow) { - user.status = user.status.wasStatus || {_: 'userStatusOffline', was_online: user.status.expires}; - delete user.status.wasStatus; + user.status = {_: 'userStatusOffline', was_online: user.status.expires}; $rootScope.$broadcast('user_update', user.id); } } @@ -449,22 +459,18 @@ export class AppUsersManager { return; } - var user = this.getUser(id); + const user = this.getUser(id); if(user && user.status && user.status._ != 'userStatusOnline' && - user.status._ != 'userStatusEmpty') { - var wasStatus; - if(user.status._ != 'userStatusOffline') { - delete user.status.wasStatus - wasStatus = copy(user.status); - } + user.status._ != 'userStatusEmpty' && + !user.pFlags.support) { user.status = { _: 'userStatusOnline', - expires: tsNow(true) + 60, - wasStatus: wasStatus + expires: tsNow(true) + 60 }; + user.sortStatus = this.getUserStatusForSort(user.status); $rootScope.$broadcast('user_update', id); } @@ -554,20 +560,23 @@ export class AppUsersManager { offset: 0, limit: 30, hash: 0, - }).then((result: any) => { - //console.log(result); - this.saveApiUsers(result.users); - appChatsManager.saveApiChats(result.chats); - - const peerIDs = result.categories[0].peers.map((topPeer: { - _: 'topPeer', - peer: any, - rating: number - }) => { - const peerID = appPeersManager.getPeerID(topPeer.peer); - appStateManager.pushPeer(peerID); - return peerID; - }); + }).then((result) => { + let peerIDs: number[]; + if(result._ == 'contacts.topPeers') { + //console.log(result); + this.saveApiUsers(result.users); + appChatsManager.saveApiChats(result.chats); + + peerIDs = result.categories[0].peers.map((topPeer: { + _: 'topPeer', + peer: any, + rating: number + }) => { + const peerID = appPeersManager.getPeerID(topPeer.peer); + appStateManager.pushPeer(peerID); + return peerID; + }); + } appStateManager.pushToState('topPeers', peerIDs); diff --git a/src/lib/bin_utils.ts b/src/lib/bin_utils.ts index de7f4c0e..109fa7ef 100644 --- a/src/lib/bin_utils.ts +++ b/src/lib/bin_utils.ts @@ -7,7 +7,7 @@ // @ts-ignore import {BigInteger, SecureRandom} from 'jsbn'; -import { InputFileLocation, FileLocation } from '../types'; +import { InputFileLocation, FileLocation } from '../layer'; /// #if !MTPROTO_WORKER // @ts-ignore diff --git a/src/lib/crypto/crypto_methods.ts b/src/lib/crypto/crypto_methods.ts index c81b984a..833c2100 100644 --- a/src/lib/crypto/crypto_methods.ts +++ b/src/lib/crypto/crypto_methods.ts @@ -1,4 +1,5 @@ import { convertToArrayBuffer, convertToByteArray } from "../bin_utils"; +import { InputCheckPasswordSRP } from "../../layer"; export default abstract class CryptoWorkerMethods { abstract performTaskWorker(task: string, ...args: any[]): Promise; @@ -44,7 +45,7 @@ export default abstract class CryptoWorkerMethods { return this.performTaskWorker('gzipUncompress', bytes, toString); } - public computeSRP(password: string, state: any) { + public computeSRP(password: string, state: any): Promise { return this.performTaskWorker('computeSRP', password, state); } } \ No newline at end of file diff --git a/src/lib/crypto/srp.ts b/src/lib/crypto/srp.ts index 1c993950..157bf398 100644 --- a/src/lib/crypto/srp.ts +++ b/src/lib/crypto/srp.ts @@ -5,7 +5,7 @@ import {str2bigInt, isZero, bigInt2str, powMod, int2bigInt, mult, mod, sub, bitSize, negative, add, greater} from 'leemon'; import {logger, LogLevels} from '../logger'; -import { AccountPassword } from "../../types"; +import { AccountPassword, PasswordKdfAlgo } from "../../layer"; const log = logger('SRP', LogLevels.error); @@ -35,7 +35,7 @@ export async function makePasswordHash(password: string, client_salt: Uint8Array export async function computeSRP(password: string, state: AccountPassword) { //console.log('computeCheck:', password, state); - let algo = state.current_algo; + let algo = state.current_algo as PasswordKdfAlgo.passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow; let p = str2bigInt(bytesToHex(algo.p), 16); let B = str2bigInt(bytesToHex(state.srp_B), 16); @@ -109,7 +109,7 @@ export async function computeSRP(password: string, state: AccountPassword) { return true; }; - var flipper = (arr: Uint8Array) => { + var flipper = (arr: Uint8Array | number[]) => { let out = new Uint8Array(arr.length); for(let i = 0; i < arr.length; i += 4) { out[i] = arr[i + 3]; diff --git a/src/lib/mtproto/apiFileManager.ts b/src/lib/mtproto/apiFileManager.ts index 4c572939..807c4906 100644 --- a/src/lib/mtproto/apiFileManager.ts +++ b/src/lib/mtproto/apiFileManager.ts @@ -5,10 +5,10 @@ import FileManager from "../filemanager"; import apiManager from "./apiManager"; import { deferredPromise, CancellablePromise } from "../polyfill"; import { logger, LogLevels } from "../logger"; -import { InputFileLocation, FileLocation, UploadFile, InputFile } from "../../types"; import { isSafari } from "../../helpers/userAgent"; import cryptoWorker from "../crypto/cryptoworker"; import { notifySomeone, notifyAll } from "../../helpers/context"; +import { InputFileLocation, FileLocation, InputFile, UploadFile } from "../../layer"; type Delayed = { offset: number, @@ -26,6 +26,8 @@ export type DownloadOptions = { processPart?: (bytes: Uint8Array, offset?: number, queue?: Delayed[]) => Promise }; +type MyUploadFile = UploadFile.uploadFile; + const MAX_FILE_SAVE_SIZE = 20e6; export class ApiFileManager { @@ -39,7 +41,7 @@ export class ApiFileManager { public downloadPulls: { [x: string]: Array<{ - cb: () => Promise, + cb: () => Promise, deferred: { resolve: (...args: any[]) => void, reject: (...args: any[]) => void @@ -54,8 +56,8 @@ export class ApiFileManager { private log: ReturnType = logger('AFM', LogLevels.error); public downloadRequest(dcID: 'upload', cb: () => Promise, activeDelta: number): Promise; - public downloadRequest(dcID: number, cb: () => Promise, activeDelta: number): Promise; - public downloadRequest(dcID: number | string, cb: () => Promise, activeDelta: number) { + public downloadRequest(dcID: number, cb: () => Promise, activeDelta: number): Promise; + public downloadRequest(dcID: number | string, cb: () => Promise, activeDelta: number) { if(this.downloadPulls[dcID] === undefined) { this.downloadPulls[dcID] = []; this.downloadActives[dcID] = 0; @@ -63,7 +65,7 @@ export class ApiFileManager { const downloadPull = this.downloadPulls[dcID]; - const promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { downloadPull.push({cb, deferred: {resolve, reject}, activeDelta}); }); @@ -135,7 +137,7 @@ export class ApiFileManager { dcID, fileDownload: true/* , singleInRequest: 'safari' in window */ - }) as Promise; + }) as Promise; }, delta); } @@ -330,22 +332,24 @@ export class ApiFileManager { try { const result = await this.requestFilePart(dcID, location, offset, limit, checkCancel); + const bytes: Uint8Array = result.bytes as any; + if(delayed.length) { superpuper(); } this.log('downloadFile requestFilePart result:', fileName, result); - const isFinal = offset + limit >= size || !result.bytes.byteLength; - if(result.bytes.byteLength) { + const isFinal = offset + limit >= size || !bytes.byteLength; + if(bytes.byteLength) { //done += limit; - done += result.bytes.byteLength; + done += bytes.byteLength; //if(!isFinal) { ////this.log('deferred notify 2:', {done: offset + limit, total: size}, deferred); deferred.notify({done, offset, total: size}); //} - const processedResult = await processDownloaded(result.bytes, offset); + const processedResult = await processDownloaded(bytes, offset); checkCancel(); await writeFilePromise; @@ -430,7 +434,7 @@ export class ApiFileManager { const resultInputFile: InputFile = { _: isBigFile ? 'inputFileBig' : 'inputFile', - id: fileID, + id: fileID as any, parts: totalParts, name: fileName, md5_checksum: '' diff --git a/src/lib/mtproto/mtproto.service.ts b/src/lib/mtproto/mtproto.service.ts index fa4bb0ab..7fc88366 100644 --- a/src/lib/mtproto/mtproto.service.ts +++ b/src/lib/mtproto/mtproto.service.ts @@ -1,9 +1,10 @@ import { isSafari } from '../../helpers/userAgent'; import { logger, LogLevels } from '../logger'; import type { DownloadOptions } from './apiFileManager'; -import type { InputFileLocation, FileLocation, UploadFile, WorkerTaskTemplate } from '../../types'; +import type { WorkerTaskTemplate } from '../../types'; import { deferredPromise, CancellablePromise } from '../polyfill'; import { notifySomeone } from '../../helpers/context'; +import { InputFileLocation, FileLocation, UploadFile } from '../../layer'; const log = logger('SW', LogLevels.error/* | LogLevels.debug | LogLevels.log */); const ctx = self as any as ServiceWorkerGlobalScope; @@ -32,7 +33,7 @@ export interface ServiceWorkerTask extends WorkerTaskTemplate { export interface ServiceWorkerTaskResponse extends WorkerTaskTemplate { type: 'requestFilePart', - payload: UploadFile + payload: UploadFile.uploadFile }; const onFetch = (event: FetchEvent): void => { @@ -81,9 +82,9 @@ const onFetch = (event: FetchEvent): void => { }; - const deferred = deferredPromises[task.id] = deferredPromise(); + const deferred = deferredPromises[task.id] = deferredPromise(); deferred.then(result => { - let ab = result.bytes; + let ab = result.bytes as Uint8Array; log.debug('[stream] requestFilePart result:', result); diff --git a/src/lib/mtproto/mtproto.worker.ts b/src/lib/mtproto/mtproto.worker.ts index a5edaeeb..9ed667b8 100644 --- a/src/lib/mtproto/mtproto.worker.ts +++ b/src/lib/mtproto/mtproto.worker.ts @@ -9,6 +9,7 @@ import networkerFactory from "./networkerFactory"; import apiFileManager, { ApiFileManager } from './apiFileManager'; import { logger, LogLevels } from '../logger'; import type { ServiceWorkerTask, ServiceWorkerTaskResponse } from './mtproto.service'; +import { UploadFile } from '../../layer'; const log = logger('DW', LogLevels.error); diff --git a/src/lib/mtproto/mtprotoworker.ts b/src/lib/mtproto/mtprotoworker.ts index 4497f99a..b037f2ed 100644 --- a/src/lib/mtproto/mtprotoworker.ts +++ b/src/lib/mtproto/mtprotoworker.ts @@ -7,6 +7,7 @@ import MTProtoWorker from 'worker-loader!./mtproto.worker'; import type { DownloadOptions } from './apiFileManager'; import type { ServiceWorkerTask, ServiceWorkerTaskResponse } from './mtproto.service'; import { isServiceWorkerSupported } from '../config'; +import { MethodDeclMap } from '../../layer'; type Task = { taskID: number, @@ -175,7 +176,7 @@ class ApiManagerProxy extends CryptoWorkerMethods { this.updatesProcessor = callback; } - public invokeApi(method: string, params: any = {}, options: { + public invokeApi(method: T, params: MethodDeclMap[T]['req'] = {}, options: { dcID?: number, timeout?: number, noErrorBox?: boolean, @@ -189,7 +190,7 @@ class ApiManagerProxy extends CryptoWorkerMethods { waitTime?: number, stopTime?: number, rawError?: any - } = {}): Promise { + } = {}): Promise { //console.log('will invokeApi:', method, params, options); return this.performTaskWorker('invokeApi', method, params, options); } diff --git a/src/lib/mtproto/passwordManager.ts b/src/lib/mtproto/passwordManager.ts index d39e14b3..b1d279ff 100644 --- a/src/lib/mtproto/passwordManager.ts +++ b/src/lib/mtproto/passwordManager.ts @@ -1,5 +1,5 @@ import apiManager from './mtprotoworker'; -import { AccountPassword } from '../../types'; +import { AccountPassword } from '../../layer'; //import { computeCheck } from "../crypto/srp"; export class PasswordManager { diff --git a/src/pages/pagePassword.ts b/src/pages/pagePassword.ts index a68f131c..03200e73 100644 --- a/src/pages/pagePassword.ts +++ b/src/pages/pagePassword.ts @@ -9,8 +9,8 @@ import apiManager from '../lib/mtproto/mtprotoworker'; import Page from './page'; import { mediaSizes } from '../lib/config'; import passwordManager from '../lib/mtproto/passwordManager'; -import { AccountPassword } from '../types'; import { cancelEvent } from '../lib/utils'; +import { AccountPassword } from '../layer'; let onFirstMount = (): Promise => { let needFrame = 0; diff --git a/src/pages/pageSignQR.ts b/src/pages/pageSignQR.ts index e31505a9..2c165474 100644 --- a/src/pages/pageSignQR.ts +++ b/src/pages/pageSignQR.ts @@ -7,48 +7,7 @@ import pageSignIn from './pageSignIn'; import { App } from '../lib/mtproto/mtproto_config'; import { bytesToBase64, bytesCmp } from '../lib/bin_utils'; import serverTimeManager from '../lib/mtproto/serverTimeManager'; -import { User } from '../lib/appManagers/appUsersManager'; - -/* interface Authorization { - _: 'authorization', - flags: number, - pFlags: Partial<{current: true, official_app: true, password_pending: true}>, - hash: number[], - device_model: string, - platform: string, - system_version: string, - api_id: number, - app_name: string, - app_version: string, - date_created: number, - date_active: number, - ip: string, - country: string, - region: string -}; */ - -interface AuthAuthorization { - flags: number, - pFlags: Partial<{tmp_sessions: number}>, - user: User -} - -interface LoginToken { - _: 'auth.loginToken', - expires: number, - token: Uint8Array -}; - -interface LoginTokenMigrateTo { - _: 'auth.loginTokenMigrateTo', - dc_id: number, - token: Uint8Array -}; - -interface LoginTokenSuccess { - _: 'auth.loginTokenSuccess', - authorization: AuthAuthorization -}; +import { AuthAuthorization, AuthLoginToken } from '../layer'; let onFirstMount = async() => { const pageElement = page.pageEl; @@ -71,7 +30,7 @@ let onFirstMount = async() => { }, {once: true}); let options: {dcID?: number, ignoreErrors: true} = {ignoreErrors: true}; - let prevToken: Uint8Array; + let prevToken: Uint8Array | number[]; return async() => { stop = false; @@ -82,7 +41,7 @@ let onFirstMount = async() => { } try { - let loginToken: LoginToken | LoginTokenMigrateTo | LoginTokenSuccess = await apiManager.invokeApi('auth.exportLoginToken', { + let loginToken = await apiManager.invokeApi('auth.exportLoginToken', { api_id: App.id, api_hash: App.hash, except_ids: [] @@ -97,11 +56,11 @@ let onFirstMount = async() => { loginToken = await apiManager.invokeApi('auth.importLoginToken', { token: loginToken.token - }, options) as LoginToken; + }, options) as AuthLoginToken.authLoginToken; } if(loginToken._ == 'auth.loginTokenSuccess') { - let authorization = loginToken.authorization; + const authorization = loginToken.authorization as any as AuthAuthorization.authAuthorization; apiManager.setUserAuth({ id: authorization.user.id }); diff --git a/src/scripts/format_jsons.js b/src/scripts/format_jsons.js index 99433a9e..104e895f 100644 --- a/src/scripts/format_jsons.js +++ b/src/scripts/format_jsons.js @@ -1,7 +1,7 @@ -let emoji = require('./emoji_pretty.json'); +let emoji = require('./in/emoji_pretty.json'); //let countries = require('./countries_pretty.json'); -let countries = require('fs').readFileSync('./countries.dat').toString(); +let countries = require('fs').readFileSync('./in/countries.dat').toString(); //console.log(countries); //console.log(emoji, countries); @@ -77,7 +77,7 @@ if(false) { }; }); - require('fs').writeFileSync('./emoji.json', JSON.stringify(obj)); + require('fs').writeFileSync('./out/emoji.json', JSON.stringify(obj)); } { @@ -153,7 +153,7 @@ if(false) { console.log(obj); - require('fs').writeFileSync('./emoji.json', JSON.stringify(obj)); + require('fs').writeFileSync('./out/emoji.json', JSON.stringify(obj)); } /* { @@ -203,5 +203,5 @@ if(false) { //console.log(item); }); - require('fs').writeFileSync('./countries.json', JSON.stringify(arr)); + require('fs').writeFileSync('./out/countries.json', JSON.stringify(arr)); } diff --git a/src/scripts/format_schema.js b/src/scripts/format_schema.js index 15d7496b..8a61174e 100644 --- a/src/scripts/format_schema.js +++ b/src/scripts/format_schema.js @@ -1,4 +1,4 @@ -let json = require('./schema'); +let json = require('./in/schema'); let top = {}; /* ['MTProto', 'API'].forEach(key => { @@ -65,4 +65,4 @@ top = json; //console.log(out); -require('fs').writeFileSync('./schema_pretty.json', JSON.stringify(top/* , null, '\t' */)); \ No newline at end of file +require('fs').writeFileSync('./out/schema.json', JSON.stringify(top/* , null, '\t' */)); \ No newline at end of file diff --git a/src/scripts/generate_mtproto_types.js b/src/scripts/generate_mtproto_types.js new file mode 100644 index 00000000..db1c1f7c --- /dev/null +++ b/src/scripts/generate_mtproto_types.js @@ -0,0 +1,241 @@ +// @ts-check +const schema = require('./in/schema.json'); +const additional = require('./in/schema_additional_params.json'); + +const mtproto = schema.API; + +for(const constructor of additional) { + constructor.params.forEach(param => { + param.type = 'flags.-1?' + param.type; + }); + + const realConstructor = mtproto.constructors.find(c => c.predicate == constructor.predicate); + realConstructor.params.splice(realConstructor.params.length, 0, ...constructor.params); +} + +['Vector t', 'Bool', 'True', 'Null'].forEach(key => { + let idx = -1; + do { + idx = mtproto.constructors.findIndex(c => c.type == key); + if(idx !== -1) { + mtproto.constructors.splice(idx, 1); + } else { + break; + } + } while(true); + + //delete types[key]; +}); + +/** @type {(string: string) => string} */ +function capitalizeFirstLetter(string) { + return string[0].toUpperCase() + string.slice(1); +} + +/** @type {(string: string, camelizeFirstLetterIfFound: boolean, camelizeFirstLetterIfNotFound: boolean) => string} */ +function camelizeName(string, camelizeFirstLetterIfFound, camelizeFirstLetterIfNotFound = false) { + if(!string.includes('.')) { + if(camelizeFirstLetterIfNotFound) { + string = capitalizeFirstLetter(string); + } + + return string; + } + + if(camelizeFirstLetterIfFound) { + string = capitalizeFirstLetter(string); + } + + return string.replace(/\../g, (match, index) => { + return match[1].toUpperCase(); + }); +} + +/** @type {(type: string) => any} */ +const processParamType = (type) => { + const isAdditional = type.indexOf('flags.-1?') === 0; + if(type.includes('?')) { + type = type.split('?')[1]; + } + + if(type.includes('Vector')) { + return `Array<${processParamType(type.slice(7, -1))}>`; + } + + switch(type) { + case '#': + case 'int': + return 'number'; + + case 'true': + return 'true'; + + case 'Bool': + return 'boolean'; + + case 'double': + return 'number'; + + case 'long': + return 'string'; + + case 'bytes': + return 'Uint8Array | number[]'; + + case 'string': + return 'string'; + + case 'X': + case '!X': + return 'any'; + + default: + //console.log('no such type', type); + //throw new Error('no such type: ' + type); + return isAdditional ? type : camelizeName(type, true); + } +}; + +/** @type {(params: {name: string, type: string}[], object: any, parseBooleanFlags: boolean) => any} */ +const processParams = (params, object = {}, parseBooleanFlags = true) => { + for(const param of params) { + let {name, type} = param; + + if(type.includes('?') || name == 'flags') { + name += '?'; + } + + const processed = processParamType(type); + if(type.includes('?true') && parseBooleanFlags) { + if(!object.pFlags) object.pFlags = {}; + object.pFlags[name] = processed; + } else { + object[name] = processed; + } + } + + return object; +}; + +/** @type {(object: any) => boolean} */ +function isObject(object) { + return typeof(object) === 'object' && object !== null; +} + +/** @type {(object: any, outArray: string[], space: string) => string[]} */ +function serializeObject(object, outArray, space) { + for(const key in object) { + const value = object[key]; + + if(isObject(value)) { // only pFlags + outArray.push(`${space}${key}?: Partial<{`); + serializeObject(value, outArray, space + '\t'); + outArray.push(`${space}}>`); + } else { + outArray.push(`${space}${key}: ${value}`); + } + } + + return outArray; +} + +let out = ''; +/** @type {Array<{key: 'predicate' | 'method', instanceKey: 'constructors' | 'methods', name: string}>} */ +/* const lol = [{key: 'predicate', instanceKey: 'constructors', name: 'Constructor'}, {key: 'method', instanceKey: 'methods', name: 'Method'}]; +lol.forEach(info => { + const {key: keyName, instanceKey, name: mapName} = info; */ + +/** @type {{[type: string]: string[]}} */ +const types = {}; +/** @type {{[predicate: string]: any}} */ +const constructors = {}; +/** @type {{[predicate: string]: string}} */ +const constructorsTypes = {}; + +mtproto.constructors.forEach((constructor) => { + const {type, predicate, params} = constructor; + + if(!types.hasOwnProperty(type)) { + types[type] = []; + } + + types[type].push(predicate); + + constructorsTypes[predicate] = camelizeName(type, true) + '.' + camelizeName(predicate, false); + + // type end + + /** @type {any} */ + const c = { + _: `'${predicate}'` + }; + constructors[predicate] = c; + + processParams(params, c, true); + + /* if(predicate == 'inputFileLocation') { + console.log(c); + } */ +}); + +for(const type in types) { + const cs = types[type]; + + const camelizedType = camelizeName(type, true); + + const csTypes = cs.map(name => { + const str = `export type ${camelizeName(name, false)} = {\n`; + + const params = serializeObject(constructors[name], [], '\t\t'); + + return str + params.join(',\n').replace(/\{,/g, '{') + '\n\t};'; + }); + + + out += `/** + * @link https://core.telegram.org/type/${type} + */ +export type ${camelizedType} = ${cs.map(name => camelizedType + '.' + camelizeName(name, false)).join(' | ')}; + +export namespace ${camelizedType} { + ${csTypes.join('\n\n\t')} +} + +`; + +} + + //console.log(types['InputUser']); + +out += `export interface ConstructorDeclMap {\n`; +for(const predicate in constructorsTypes) { + out += `\t'${predicate}': ${constructorsTypes[predicate]},\n`; +} +out += `}\n\n`; + +/** @type {{[method: string]: {req: string, res: string}}} */ +const methodsMap = {}; +mtproto.methods.forEach((_method) => { + const {method, type, params} = _method; + + const camelizedMethod = camelizeName(method, true, true); + + methodsMap[method] = {req: camelizedMethod, res: processParamType(type)}; + + let str = `export type ${camelizedMethod} = {\n`; + + const object = processParams(params, {}, false); + + const serialized = serializeObject(object, [], '\t'); + + str += serialized.join(',\n').replace(/\{,/g, '{') + '\n};\n\n'; + out += str; +}); + +out += `export interface MethodDeclMap {\n`; +for(const method in methodsMap) { + out += `\t'${method}': {req: ${methodsMap[method].req}, res: ${methodsMap[method].res}},\n`; +} +out += `}\n\n`; + +require('fs').writeFileSync('./out/layer.d.ts', out); \ No newline at end of file diff --git a/src/scripts/countries.dat b/src/scripts/in/countries.dat similarity index 100% rename from src/scripts/countries.dat rename to src/scripts/in/countries.dat diff --git a/src/scripts/countries_pretty.json b/src/scripts/in/countries_pretty.json similarity index 100% rename from src/scripts/countries_pretty.json rename to src/scripts/in/countries_pretty.json diff --git a/src/scripts/emoji_pretty.json b/src/scripts/in/emoji_pretty.json similarity index 100% rename from src/scripts/emoji_pretty.json rename to src/scripts/in/emoji_pretty.json diff --git a/src/scripts/schema.json b/src/scripts/in/schema.json similarity index 100% rename from src/scripts/schema.json rename to src/scripts/in/schema.json diff --git a/src/scripts/in/schema_additional_params.json b/src/scripts/in/schema_additional_params.json new file mode 100644 index 00000000..6a305b38 --- /dev/null +++ b/src/scripts/in/schema_additional_params.json @@ -0,0 +1,44 @@ +[{ + "predicate": "document", + "params": [ + {"name": "thumbs", "type": "Array"}, + {"name": "type", "type": "'gif' | 'sticker' | 'audio' | 'voice' | 'video' | 'round' | 'photo'"}, + {"name": "h", "type": "number"}, + {"name": "w", "type": "number"}, + {"name": "file_name", "type": "string"}, + {"name": "file", "type": "File"}, + {"name": "duration", "type": "number"}, + {"name": "downloaded", "type": "boolean"}, + {"name": "url", "type": "string"}, + {"name": "audioTitle", "type": "string"}, + {"name": "audioPerformer", "type": "string"}, + {"name": "sticker", "type": "number"}, + {"name": "stickerEmoji", "type": "string"}, + {"name": "stickerEmojiRaw", "type": "string"}, + {"name": "stickerSetInput", "type": "InputStickerSet.inputStickerSetID"}, + {"name": "stickerThumbConverted", "type": "true"}, + {"name": "animated", "type": "boolean"}, + {"name": "supportsStreaming", "type": "boolean"} + ] +}, { + "predicate": "photo", + "params": [ + {"name": "downloaded", "type": "boolean | number"}, + {"name": "url", "type": "string"} + ] +}, { + "predicate": "photoSize", + "params": [ + {"name": "url", "type": "string"} + ] +}, { + "predicate": "photoCachedSize", + "params": [ + {"name": "url", "type": "string"} + ] +}, { + "predicate": "photoStrippedSize", + "params": [ + {"name": "url", "type": "string"} + ] +}] \ No newline at end of file diff --git a/src/scripts/countries.json b/src/scripts/out/countries.json similarity index 100% rename from src/scripts/countries.json rename to src/scripts/out/countries.json diff --git a/src/scripts/emoji.json b/src/scripts/out/emoji.json similarity index 100% rename from src/scripts/emoji.json rename to src/scripts/out/emoji.json diff --git a/src/scripts/schema_pretty.json b/src/scripts/out/schema.json similarity index 100% rename from src/scripts/schema_pretty.json rename to src/scripts/out/schema.json diff --git a/src/tests/srp.test.ts b/src/tests/srp.test.ts index 762b3c9e..8c4870cf 100644 --- a/src/tests/srp.test.ts +++ b/src/tests/srp.test.ts @@ -8,7 +8,9 @@ test('2FA hash', async() => { test('2FA whole (with negative)', async() => { return await computeSRP(password, { + _: 'account.password', current_algo: { + _: 'passwordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow', salt1, salt2, p, @@ -16,7 +18,10 @@ test('2FA whole (with negative)', async() => { }, srp_id, srp_B, - secure_random + secure_random, + + new_algo: null, + new_secure_algo: null }).then(res => { expect(res.srp_id).toEqual(srp_id); expect(res.A).toEqual(A); diff --git a/src/types.d.ts b/src/types.d.ts index d73c1e1b..e896ffff 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,54 +1,3 @@ -export type MTDocument = { - _: 'document' | 'documentEmpty', - pFlags: any, - flags: number, - id: string, - access_hash: string, - file_reference: Uint8Array | number[], - date: number, - mime_type: string, - size: number, - thumbs: MTPhotoSize[], - video_thumbs?: MTVideoSize[], - dc_id: number, - attributes: any[], - - type?: 'gif' | 'sticker' | 'audio' | 'voice' | 'video' | 'round' | 'photo', - h?: number, - w?: number, - file_name?: string, - file?: File, - duration?: number, - downloaded?: boolean, - url?: string, - - audioTitle?: string, - audioPerformer?: string, - - sticker?: number, - stickerEmoji?: string, - stickerEmojiRaw?: string, - stickerSetInput?: any, - stickerThumbConverted?: true, - - animated?: boolean, - supportsStreaming?: boolean -}; - -export type MTPhotoSize = { - _: string, - w?: number, - h?: number, - size?: number, - type?: string, // i, m, x, y, w by asc - location?: FileLocation, - bytes?: Uint8Array, // if type == 'i', - - url?: string -}; - -export type MTVideoSize = Omit & {_: 'videoSize'}; - export type InvokeApiOptions = Partial<{ dcID: number, timeout: number, @@ -68,98 +17,10 @@ export type InvokeApiOptions = Partial<{ rawError: any }>; -type Algo = { - salt1: Uint8Array, - salt2: Uint8Array, - p: Uint8Array, - g: number -}; - -export type AccountPassword = { - _?: 'accont.password', - flags?: number, - pFlags?: Partial<{ - has_recovery: true, - has_secure_values: true, - has_password: true - }>, - current_algo: Algo, - new_algo?: Algo, - new_secure_algo?: Algo, - hint?: string, - email_unconfirmed_pattern?: string, - srp_B?: Uint8Array, - srp_id?: string, - secure_random: Uint8Array, -}; - -export type storageFileType = 'storage.fileUnknown' | 'storage.filePartial' | 'storage.fileJpeg' | - 'storage.fileGif' | 'storage.filePng' | 'storage.filePdf' | 'storage.fileMp3' | 'storage.fileMov' | - 'storage.fileMp4' | 'storage.fileWebp'; - -export type UploadFile = { - _: 'upload.file', - type: storageFileType, - mtime: number, - bytes: Uint8Array -}; - -export type FileLocation = { - _: 'fileLocationToBeDeprecated', - volume_id: string, - local_id: number -}; - -export type inputFileLocation = { - _: 'inputFileLocation', - volume_id: string, - local_id: number, - secret: string, - file_reference: Uint8Array | number[] -}; - -export type inputDocumentFileLocation = { - _: 'inputDocumentFileLocation', - id: string, - access_hash: string, - file_reference: Uint8Array | number[], - thumb_size: string -}; - -export type inputPhotoFileLocation = Omit & {_: 'inputPhotoFileLocation'}; - -export type inputPeerPhotoFileLocation = { - _: 'inputPeerPhotoFileLocation', - flags: number, - big?: true, - peer: any, - volume_id: string, - local_id: number -}; - -export type inputStickerSetThumb = { - _: 'inputStickerSetThumb', - stickerset: any, - volume_id: string, - local_id: number -}; - -export type InputFileLocation = inputFileLocation | inputDocumentFileLocation | inputPhotoFileLocation | inputPeerPhotoFileLocation | inputStickerSetThumb; - export type WorkerTaskTemplate = { type: string, id: number, payload: any }; -export type inputFile = { - _: 'inputFile', - parts: number, - id: [number, number], - name: string, - md5_checksum: string -}; - -export type inputFileBig = Omit & {_: 'inputFileBig'}; - -export type InputFile = inputFile | inputFileBig; \ No newline at end of file +export type Modify = Omit & R; diff --git a/tsconfig.json b/tsconfig.json index 3aac26bf..74792780 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -63,6 +63,7 @@ }, "exclude": [ "node_modules", + "./public/recorder.min.js", "public", "coverage", "./public/*.js",