@mtkruto/node 0.0.923 → 0.0.930

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/esm/client/3_client.d.ts +2 -0
  2. package/esm/client/3_client.js +17 -4
  3. package/esm/constants.d.ts +2 -1
  4. package/esm/constants.js +2 -1
  5. package/esm/storage/0_storage.d.ts +3 -0
  6. package/esm/storage/0_storage.js +19 -0
  7. package/esm/types/0_audio.d.ts +13 -0
  8. package/esm/types/0_audio.js +14 -0
  9. package/esm/types/0_contact.d.ts +9 -0
  10. package/esm/types/0_contact.js +9 -0
  11. package/esm/types/0_dice.d.ts +6 -0
  12. package/esm/types/0_dice.js +3 -0
  13. package/esm/types/0_mask_position.d.ts +8 -0
  14. package/esm/types/0_mask_position.js +8 -0
  15. package/esm/types/0_thumbnail.d.ts +1 -1
  16. package/esm/types/0_thumbnail.js +15 -1
  17. package/esm/types/0_voice.d.ts +9 -0
  18. package/esm/types/0_voice.js +9 -0
  19. package/esm/types/1_animation.d.ts +13 -0
  20. package/esm/types/1_animation.js +14 -0
  21. package/esm/types/1_document.d.ts +11 -0
  22. package/esm/types/1_document.js +12 -0
  23. package/esm/types/1_photo.js +1 -13
  24. package/esm/types/1_sticker.d.ts +23 -0
  25. package/esm/types/1_sticker.js +28 -0
  26. package/esm/types/1_video.d.ts +14 -0
  27. package/esm/types/1_video.js +15 -0
  28. package/esm/types/1_video_note.d.ts +12 -0
  29. package/esm/types/1_video_note.js +12 -0
  30. package/esm/types/3_message.d.ts +19 -1
  31. package/esm/types/3_message.js +65 -2
  32. package/package.json +1 -1
  33. package/script/client/3_client.d.ts +2 -0
  34. package/script/client/3_client.js +17 -4
  35. package/script/constants.d.ts +2 -1
  36. package/script/constants.js +3 -2
  37. package/script/storage/0_storage.d.ts +3 -0
  38. package/script/storage/0_storage.js +19 -0
  39. package/script/types/0_audio.d.ts +13 -0
  40. package/script/types/0_audio.js +41 -0
  41. package/script/types/0_contact.d.ts +9 -0
  42. package/script/types/0_contact.js +13 -0
  43. package/script/types/0_dice.d.ts +6 -0
  44. package/script/types/0_dice.js +7 -0
  45. package/script/types/0_mask_position.d.ts +8 -0
  46. package/script/types/0_mask_position.js +12 -0
  47. package/script/types/0_thumbnail.d.ts +1 -1
  48. package/script/types/0_thumbnail.js +38 -1
  49. package/script/types/0_voice.d.ts +9 -0
  50. package/script/types/0_voice.js +13 -0
  51. package/script/types/1_animation.d.ts +13 -0
  52. package/script/types/1_animation.js +41 -0
  53. package/script/types/1_document.d.ts +11 -0
  54. package/script/types/1_document.js +39 -0
  55. package/script/types/1_photo.js +1 -13
  56. package/script/types/1_sticker.d.ts +23 -0
  57. package/script/types/1_sticker.js +55 -0
  58. package/script/types/1_video.d.ts +14 -0
  59. package/script/types/1_video.js +42 -0
  60. package/script/types/1_video_note.d.ts +12 -0
  61. package/script/types/1_video_note.js +39 -0
  62. package/script/types/3_message.d.ts +19 -1
  63. package/script/types/3_message.js +65 -2
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Client = exports.ParseMode = exports.restartAuth = exports.getEntity = void 0;
26
+ exports.Client = exports.ParseMode = exports.restartAuth = exports.getStickerSetName = exports.getEntity = void 0;
27
27
  const deps_js_1 = require("../deps.js");
28
28
  const constants_js_1 = require("../constants.js");
29
29
  const _0_bigint_js_1 = require("../utilities/0_bigint.js");
@@ -56,6 +56,7 @@ const dAuth = (0, deps_js_1.debug)("Client/authorize");
56
56
  const dRecv = (0, deps_js_1.debug)("Client/receiveLoop");
57
57
  const UPDATE_GAP = Symbol();
58
58
  exports.getEntity = Symbol();
59
+ exports.getStickerSetName = Symbol();
59
60
  exports.restartAuth = Symbol();
60
61
  var ParseMode;
61
62
  (function (ParseMode) {
@@ -1108,10 +1109,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1108
1109
  if (result instanceof types.Updates) {
1109
1110
  for (const update of result.updates) {
1110
1111
  if (update instanceof types.UpdateNewMessage) {
1111
- return (0, _3_message_js_1.constructMessage)(update.message[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), this.getMessage.bind(this));
1112
+ return (0, _3_message_js_1.constructMessage)(update.message[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1112
1113
  }
1113
1114
  else if (update instanceof types.UpdateNewChannelMessage) {
1114
- return (0, _3_message_js_1.constructMessage)(update.message[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), this.getMessage.bind(this));
1115
+ return (0, _3_message_js_1.constructMessage)(update.message[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this));
1115
1116
  }
1116
1117
  }
1117
1118
  }
@@ -1139,7 +1140,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1139
1140
  }
1140
1141
  const messages = new Array();
1141
1142
  for (const message_ of messages_.messages) {
1142
- messages.push(await (0, _3_message_js_1.constructMessage)(message_[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), null));
1143
+ messages.push(await (0, _3_message_js_1.constructMessage)(message_[_1_tl_object_js_1.as](types.Message), this[exports.getEntity].bind(this), null, this[exports.getStickerSetName].bind(this)));
1143
1144
  }
1144
1145
  return messages;
1145
1146
  }
@@ -1211,5 +1212,17 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1211
1212
  (0, _0_control_js_1.UNREACHABLE)();
1212
1213
  }
1213
1214
  }
1215
+ async [exports.getStickerSetName](inputStickerSet, hash = 0) {
1216
+ const maybeStickerSetName = await this.storage.getStickerSetName(inputStickerSet.id, inputStickerSet.accessHash);
1217
+ if (maybeStickerSetName != null && Date.now() - maybeStickerSetName[1].getTime() < constants_js_1.STICKER_SET_NAME_TTL) {
1218
+ return maybeStickerSetName[0];
1219
+ }
1220
+ else {
1221
+ const stickerSet = await this.invoke(new functions.MessagesGetStickerSet({ stickerset: inputStickerSet, hash }));
1222
+ const name = stickerSet[_1_tl_object_js_1.as](types.MessagesStickerSet).set[_1_tl_object_js_1.as](types.StickerSet).shortName;
1223
+ await this.storage.updateStickerSetName(inputStickerSet.id, inputStickerSet.accessHash, name);
1224
+ return name;
1225
+ }
1226
+ }
1214
1227
  }
1215
1228
  exports.Client = Client;
@@ -4,13 +4,14 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
4
4
  export declare const VECTOR_CONSTRUCTOR = 481674261;
5
5
  export declare const DEFAULT_INITIAL_DC: DC;
6
6
  export declare const LAYER = 158;
7
- export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.923";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.930";
8
8
  export declare const DEFAULT_DEVICE_MODEL: string;
9
9
  export declare const DEFAULT_LANG_CODE: string;
10
10
  export declare const DEFAULT_LANG_PACK = "";
11
11
  export declare const DEFAULT_SYSTEM_LANG_CODE: string;
12
12
  export declare const DEFAULT_SYSTEM_VERSION: string;
13
13
  export declare const USERNAME_TTL = 86400;
14
+ export declare const STICKER_SET_NAME_TTL = 172800;
14
15
  export declare const MAX_CHAT_ID = 999999999999;
15
16
  export declare const MAX_CHANNEL_ID = 997852516352;
16
17
  export declare const ZERO_CHANNEL_ID = -1000000000000;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.CHANNEL_DIFFERENCE_LIMIT_BOT = exports.CHANNEL_DIFFERENCE_LIMIT_USER = exports.ZERO_CHANNEL_ID = exports.MAX_CHANNEL_ID = exports.MAX_CHAT_ID = exports.USERNAME_TTL = exports.DEFAULT_SYSTEM_VERSION = exports.DEFAULT_SYSTEM_LANG_CODE = exports.DEFAULT_LANG_PACK = exports.DEFAULT_LANG_CODE = exports.DEFAULT_DEVICE_MODEL = exports.DEFAULT_APP_VERSION = exports.LAYER = exports.DEFAULT_INITIAL_DC = exports.VECTOR_CONSTRUCTOR = exports.publicKeys = exports.ackThreshold = void 0;
26
+ exports.CHANNEL_DIFFERENCE_LIMIT_BOT = exports.CHANNEL_DIFFERENCE_LIMIT_USER = exports.ZERO_CHANNEL_ID = exports.MAX_CHANNEL_ID = exports.MAX_CHAT_ID = exports.STICKER_SET_NAME_TTL = exports.USERNAME_TTL = exports.DEFAULT_SYSTEM_VERSION = exports.DEFAULT_SYSTEM_LANG_CODE = exports.DEFAULT_LANG_PACK = exports.DEFAULT_LANG_CODE = exports.DEFAULT_DEVICE_MODEL = exports.DEFAULT_APP_VERSION = exports.LAYER = exports.DEFAULT_INITIAL_DC = exports.VECTOR_CONSTRUCTOR = exports.publicKeys = exports.ackThreshold = void 0;
27
27
  const dntShim = __importStar(require("./_dnt.shims.js"));
28
28
  exports.ackThreshold = 10;
29
29
  exports.publicKeys = new Map([
@@ -88,7 +88,7 @@ exports.publicKeys = new Map([
88
88
  exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
89
89
  exports.DEFAULT_INITIAL_DC = "2-test";
90
90
  exports.LAYER = 158;
91
- exports.DEFAULT_APP_VERSION = "MTKruto 0.0.923";
91
+ exports.DEFAULT_APP_VERSION = "MTKruto 0.0.930";
92
92
  // @ts-ignore: lib
93
93
  exports.DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
94
94
  exports.DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -97,6 +97,7 @@ exports.DEFAULT_SYSTEM_LANG_CODE = typeof navigator === "undefined" ? "en" : nav
97
97
  // @ts-ignore: lib
98
98
  exports.DEFAULT_SYSTEM_VERSION = typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : "Node.js/" + process.versions.node : navigator.userAgent;
99
99
  exports.USERNAME_TTL = 86400;
100
+ exports.STICKER_SET_NAME_TTL = 172800;
100
101
  exports.MAX_CHAT_ID = 999999999999;
101
102
  exports.MAX_CHANNEL_ID = 997852516352;
102
103
  exports.ZERO_CHANNEL_ID = -1000000000000;
@@ -38,4 +38,7 @@ export declare abstract class Storage {
38
38
  private readonly accountType__;
39
39
  setAccountType(type: "user" | "bot"): Promise<void>;
40
40
  getAccountType(): Promise<"bot" | "user">;
41
+ private readonly stickerSetName__;
42
+ updateStickerSetName(id: bigint, accessHash: bigint, name: string): Promise<void>;
43
+ getStickerSetName(id: bigint, accessHash: bigint): Promise<[string, Date] | null>;
41
44
  }
@@ -82,6 +82,12 @@ class Storage {
82
82
  writable: true,
83
83
  value: "accountType__"
84
84
  });
85
+ Object.defineProperty(this, "stickerSetName__", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: "stickerSetName__"
90
+ });
85
91
  }
86
92
  setDc(dc) {
87
93
  return this.set("dc", dc);
@@ -225,5 +231,18 @@ class Storage {
225
231
  (0, _0_control_js_1.UNREACHABLE)();
226
232
  }
227
233
  }
234
+ async updateStickerSetName(id, accessHash, name) {
235
+ await this.set(`${this.stickerSetName__}${id}${accessHash}`, JSON.stringify([name, new Date()]));
236
+ }
237
+ async getStickerSetName(id, accessHash) {
238
+ const stickerSetName_ = await this.get(`${this.stickerSetName__}${id}${accessHash}`);
239
+ if (stickerSetName_ != null) {
240
+ const [name, updatedAt] = JSON.parse(stickerSetName_);
241
+ return [name, new Date(updatedAt)];
242
+ }
243
+ else {
244
+ return null;
245
+ }
246
+ }
228
247
  }
229
248
  exports.Storage = Storage;
@@ -0,0 +1,13 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { Thumbnail } from "./0_thumbnail.js";
3
+ export interface Audio {
4
+ fileId: string;
5
+ fileUniqueId: string;
6
+ duration: number;
7
+ performer?: string;
8
+ title?: string;
9
+ mimeType: string;
10
+ fileSize: number;
11
+ thumbnails: Thumbnail[];
12
+ }
13
+ export declare function constructAudio(document: types.Document, audioAttribute: types.DocumentAttributeAudio | undefined, fileId: string, fileUniqueId: string): Audio;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.constructAudio = void 0;
27
+ const types = __importStar(require("../tl/2_types.js"));
28
+ const _0_thumbnail_js_1 = require("./0_thumbnail.js");
29
+ function constructAudio(document, audioAttribute, fileId, fileUniqueId) {
30
+ return {
31
+ fileId,
32
+ fileUniqueId,
33
+ duration: audioAttribute?.duration ?? 0,
34
+ performer: audioAttribute?.performer,
35
+ title: audioAttribute?.title,
36
+ mimeType: document.mimeType,
37
+ fileSize: Number(document.size),
38
+ thumbnails: document.thumbs ? document.thumbs.map((v) => v instanceof types.PhotoSize ? (0, _0_thumbnail_js_1.constructThumbnail)(v, document) : null).filter((v) => v) : [],
39
+ };
40
+ }
41
+ exports.constructAudio = constructAudio;
@@ -0,0 +1,9 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export interface Contact {
3
+ phoneNumber: string;
4
+ firstName: string;
5
+ lastName?: string;
6
+ userId?: number;
7
+ vcard?: string;
8
+ }
9
+ export declare function constructContact(contact: types.MessageMediaContact): Contact;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructContact = void 0;
4
+ function constructContact(contact) {
5
+ return {
6
+ phoneNumber: contact.phoneNumber,
7
+ firstName: contact.firstName,
8
+ lastName: contact.lastName || undefined,
9
+ userId: Number(contact.userId) || undefined,
10
+ vcard: contact.vcard || undefined,
11
+ };
12
+ }
13
+ exports.constructContact = constructContact;
@@ -0,0 +1,6 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export interface Dice {
3
+ emoji: string;
4
+ value: number;
5
+ }
6
+ export declare function constructDice(dice_: types.MessageMediaDice): Dice;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructDice = void 0;
4
+ function constructDice(dice_) {
5
+ return { emoji: dice_.emoticon, value: dice_.value };
6
+ }
7
+ exports.constructDice = constructDice;
@@ -0,0 +1,8 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export interface MaskPosition {
3
+ point: "forehead" | "eyes" | "mouth" | "chin";
4
+ xShift: number;
5
+ yShift: number;
6
+ scale: number;
7
+ }
8
+ export declare function constructMaskPosition({ n, x, y, zoom }: types.MaskCoords): MaskPosition;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructMaskPosition = void 0;
4
+ function constructMaskPosition({ n, x, y, zoom }) {
5
+ return {
6
+ point: n == 0 ? "forehead" : n == 1 ? "eyes" : n == 2 ? "mouth" : "chin",
7
+ xShift: x,
8
+ yShift: y,
9
+ scale: zoom,
10
+ };
11
+ }
12
+ exports.constructMaskPosition = constructMaskPosition;
@@ -6,4 +6,4 @@ export interface Thumbnail {
6
6
  height: number;
7
7
  fileSize: number;
8
8
  }
9
- export declare function constructThumbnail(size: types.PhotoSize, fileId: string, fileUniqueId: string): Thumbnail;
9
+ export declare function constructThumbnail(size: types.PhotoSize, file: types.Document | types.Photo): Thumbnail;
@@ -1,7 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.constructThumbnail = void 0;
4
- function constructThumbnail(size, fileId, fileUniqueId) {
27
+ const types = __importStar(require("../tl/2_types.js"));
28
+ const _0_file_id_js_1 = require("./!0_file_id.js");
29
+ function constructThumbnail(size, file) {
30
+ const fileType = file instanceof types.Photo ? _0_file_id_js_1.FileType.Photo : _0_file_id_js_1.FileType.Document;
31
+ const fileId = new _0_file_id_js_1.FileID(null, null, fileType, file.dcId, {
32
+ mediaId: file.id,
33
+ accessHash: file.accessHash,
34
+ fileReference: file.fileReference,
35
+ thumbnailFileType: fileType,
36
+ thumbnailSource: _0_file_id_js_1.ThumbnailSource.Thumbnail,
37
+ thumbnailSize: size.type,
38
+ volumeId: 0n,
39
+ localId: 0,
40
+ }).encode();
41
+ const fileUniqueId = new _0_file_id_js_1.FileUniqueID(_0_file_id_js_1.FileUniqueType.Document, { mediaId: file.id }).encode();
5
42
  return {
6
43
  fileId,
7
44
  fileUniqueId,
@@ -0,0 +1,9 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export interface Voice {
3
+ fileId: string;
4
+ fileUniqueId: string;
5
+ duration: number;
6
+ mimeType: string;
7
+ fileSize: number;
8
+ }
9
+ export declare function constructVoice(document: types.Document, audioAttributes: types.DocumentAttributeAudio, fileId: string, fileUniqueId: string): Voice;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructVoice = void 0;
4
+ function constructVoice(document, audioAttributes, fileId, fileUniqueId) {
5
+ return {
6
+ fileId,
7
+ fileUniqueId,
8
+ duration: audioAttributes.duration,
9
+ mimeType: document.mimeType,
10
+ fileSize: Number(document.size),
11
+ };
12
+ }
13
+ exports.constructVoice = constructVoice;
@@ -0,0 +1,13 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { Thumbnail } from "./0_thumbnail.js";
3
+ export interface Animation {
4
+ fileId: string;
5
+ fileUniqueId: string;
6
+ width: number;
7
+ height: number;
8
+ duration: number;
9
+ thumbnails: Thumbnail[];
10
+ mimeType: string;
11
+ fileSize: number;
12
+ }
13
+ export declare function constructAnimation(document: types.Document, videoAttribute: types.DocumentAttributeVideo | undefined, fileId: string, fileUniqueId: string): Animation;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.constructAnimation = void 0;
27
+ const types = __importStar(require("../tl/2_types.js"));
28
+ const _0_thumbnail_js_1 = require("./0_thumbnail.js");
29
+ function constructAnimation(document, videoAttribute, fileId, fileUniqueId) {
30
+ return {
31
+ fileId,
32
+ fileUniqueId,
33
+ width: videoAttribute?.w ?? 0,
34
+ height: videoAttribute?.h ?? 0,
35
+ duration: videoAttribute?.duration ?? 0,
36
+ thumbnails: document.thumbs ? document.thumbs.map((v) => v instanceof types.PhotoSize ? (0, _0_thumbnail_js_1.constructThumbnail)(v, document) : null).filter((v) => v) : [],
37
+ mimeType: document.mimeType,
38
+ fileSize: Number(document.size),
39
+ };
40
+ }
41
+ exports.constructAnimation = constructAnimation;
@@ -0,0 +1,11 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { Thumbnail } from "./0_thumbnail.js";
3
+ export interface Document {
4
+ fileId: string;
5
+ fileUniqueId: string;
6
+ thumbnails: Thumbnail[];
7
+ fileName: string;
8
+ mimeType: string;
9
+ fileSize: number;
10
+ }
11
+ export declare function constructDocument(document: types.Document, fileNameAttribute: types.DocumentAttributeFilename, fileId: string, fileUniqueId: string): Document;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.constructDocument = void 0;
27
+ const types = __importStar(require("../tl/2_types.js"));
28
+ const _0_thumbnail_js_1 = require("./0_thumbnail.js");
29
+ function constructDocument(document, fileNameAttribute, fileId, fileUniqueId) {
30
+ return {
31
+ fileId,
32
+ fileUniqueId,
33
+ thumbnails: document.thumbs ? document.thumbs.map((v) => v instanceof types.PhotoSize ? (0, _0_thumbnail_js_1.constructThumbnail)(v, document) : null).filter((v) => v) : [],
34
+ fileName: fileNameAttribute.fileName,
35
+ mimeType: document.mimeType,
36
+ fileSize: Number(document.size),
37
+ };
38
+ }
39
+ exports.constructDocument = constructDocument;
@@ -58,19 +58,7 @@ function constructPhoto(photo) {
58
58
  width: largest.w,
59
59
  height: largest.h,
60
60
  fileSize: largest.size,
61
- thumbnails: sizes.slice(0, -1).map((v) => {
62
- const fileId = new _0_file_id_js_1.FileID(null, null, _0_file_id_js_1.FileType.Photo, dcId, {
63
- mediaId,
64
- accessHash,
65
- fileReference,
66
- thumbnailSource: _0_file_id_js_1.ThumbnailSource.Thumbnail,
67
- thumbnailFileType: _0_file_id_js_1.FileType.Photo,
68
- thumbnailSize: v.type,
69
- volumeId: 0n,
70
- localId: 0,
71
- }).encode();
72
- return (0, _0_thumbnail_js_1.constructThumbnail)(v, fileId, fileUniqueId);
73
- }),
61
+ thumbnails: sizes.slice(0, -1).map((v) => (0, _0_thumbnail_js_1.constructThumbnail)(v, photo)),
74
62
  };
75
63
  }
76
64
  exports.constructPhoto = constructPhoto;
@@ -0,0 +1,23 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { MaybePromise } from "../utilities/0_types.js";
3
+ import { Thumbnail } from "./0_thumbnail.js";
4
+ import { MaskPosition } from "./0_mask_position.js";
5
+ export interface Sticker {
6
+ fileId: string;
7
+ fileUniqueId: string;
8
+ type: "regular" | "mask" | "custom_emoji";
9
+ width: number;
10
+ height: number;
11
+ isAnimated: boolean;
12
+ isVideo: boolean;
13
+ thumbnails: Thumbnail[];
14
+ emoji?: string;
15
+ setName?: string;
16
+ premiumAnimation?: File;
17
+ maskPosition?: MaskPosition;
18
+ customEmojiId?: string;
19
+ needsRepainting?: boolean;
20
+ fileSize?: number;
21
+ }
22
+ export type StickerSetNameGetter = (inputStickerSet: types.InputStickerSetID) => MaybePromise<string>;
23
+ export declare function constructSticker(document: types.Document, fileId: string, fileUniqueId: string, getStickerSetName: StickerSetNameGetter): Promise<Sticker>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.constructSticker = void 0;
27
+ const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
28
+ const types = __importStar(require("../tl/2_types.js"));
29
+ const _0_thumbnail_js_1 = require("./0_thumbnail.js");
30
+ const _0_mask_position_js_1 = require("./0_mask_position.js");
31
+ async function constructSticker(document, fileId, fileUniqueId, getStickerSetName) {
32
+ const stickerAttribute = document.attributes.find((v) => v instanceof types.DocumentAttributeSticker);
33
+ const imageSizeAttribute = document.attributes.find((v) => v instanceof types.DocumentAttributeImageSize);
34
+ const videoAttribute = document.attributes.find((v) => v instanceof types.DocumentAttributeVideo);
35
+ const setName = await getStickerSetName(stickerAttribute.stickerset[_1_tl_object_js_1.as](types.InputStickerSetID));
36
+ return {
37
+ fileId,
38
+ fileUniqueId,
39
+ // TODO: custom_emoji type?
40
+ type: stickerAttribute.mask ? "mask" : "regular",
41
+ width: imageSizeAttribute ? imageSizeAttribute.w : videoAttribute ? videoAttribute.w : 512,
42
+ height: imageSizeAttribute ? imageSizeAttribute.h : videoAttribute ? videoAttribute.h : 512,
43
+ isAnimated: document.mimeType == "application/x-tgsticker",
44
+ isVideo: document.mimeType == "video/webm",
45
+ thumbnails: document.thumbs ? document.thumbs.map((v) => v instanceof types.PhotoSize ? (0, _0_thumbnail_js_1.constructThumbnail)(v, document) : null).filter((v) => v) : [],
46
+ emoji: stickerAttribute.alt || undefined,
47
+ setName,
48
+ premiumAnimation: undefined,
49
+ maskPosition: stickerAttribute.maskCoords ? (0, _0_mask_position_js_1.constructMaskPosition)(stickerAttribute.maskCoords[_1_tl_object_js_1.as](types.MaskCoords)) : undefined,
50
+ customEmojiId: undefined,
51
+ needsRepainting: undefined,
52
+ fileSize: Number(document.size),
53
+ };
54
+ }
55
+ exports.constructSticker = constructSticker;
@@ -0,0 +1,14 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { Thumbnail } from "./0_thumbnail.js";
3
+ export interface Video {
4
+ fileId: string;
5
+ fileUniqueId: string;
6
+ width: number;
7
+ height: number;
8
+ duration: number;
9
+ thumbnails: Thumbnail[];
10
+ fileName?: string;
11
+ mimeType: string;
12
+ fileSize: number;
13
+ }
14
+ export declare function constructVideo(document: types.Document, videoAttribute: types.DocumentAttributeVideo, fileName: string | undefined, fileId: string, fileUniqueId: string): Video;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.constructVideo = void 0;
27
+ const types = __importStar(require("../tl/2_types.js"));
28
+ const _0_thumbnail_js_1 = require("./0_thumbnail.js");
29
+ function constructVideo(document, videoAttribute, fileName, fileId, fileUniqueId) {
30
+ return {
31
+ fileId,
32
+ fileUniqueId,
33
+ width: videoAttribute.w,
34
+ height: videoAttribute.h,
35
+ duration: videoAttribute.duration,
36
+ thumbnails: document.thumbs ? document.thumbs.map((v) => v instanceof types.PhotoSize ? (0, _0_thumbnail_js_1.constructThumbnail)(v, document) : null).filter((v) => v) : [],
37
+ fileName,
38
+ mimeType: document.mimeType,
39
+ fileSize: Number(document.size),
40
+ };
41
+ }
42
+ exports.constructVideo = constructVideo;
@@ -0,0 +1,12 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { Thumbnail } from "./0_thumbnail.js";
3
+ export interface VideoNote {
4
+ fileId: string;
5
+ fileUniqueId: string;
6
+ length: number;
7
+ duration: number;
8
+ thumbnails: Thumbnail[];
9
+ fileName?: string;
10
+ fileSize: number;
11
+ }
12
+ export declare function constructVideoNote(document: types.Document, videoAttribute: types.DocumentAttributeVideo, fileId: string, fileUniqueId: string): VideoNote;