@mtkruto/node 0.0.931 → 0.0.934

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.
@@ -4,7 +4,7 @@ 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.931";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.934";
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 = "";
package/esm/constants.js CHANGED
@@ -62,7 +62,7 @@ export const publicKeys = new Map([
62
62
  export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
63
63
  export const DEFAULT_INITIAL_DC = "2-test";
64
64
  export const LAYER = 158;
65
- export const DEFAULT_APP_VERSION = "MTKruto 0.0.931";
65
+ export const DEFAULT_APP_VERSION = "MTKruto 0.0.934";
66
66
  // @ts-ignore: lib
67
67
  export const 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;
68
68
  export const DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -7,7 +7,8 @@ export interface Animation {
7
7
  height: number;
8
8
  duration: number;
9
9
  thumbnails: Thumbnail[];
10
+ fileName?: string;
10
11
  mimeType: string;
11
12
  fileSize: number;
12
13
  }
13
- export declare function constructAnimation(document: types.Document, videoAttribute: types.DocumentAttributeVideo | undefined, fileId: string, fileUniqueId: string): Animation;
14
+ export declare function constructAnimation(document: types.Document, videoAttribute: types.DocumentAttributeVideo | undefined, fileAttribute: types.DocumentAttributeFilename | undefined, fileId: string, fileUniqueId: string): Animation;
@@ -1,6 +1,6 @@
1
1
  import * as types from "../tl/2_types.js";
2
2
  import { constructThumbnail } from "./0_thumbnail.js";
3
- export function constructAnimation(document, videoAttribute, fileId, fileUniqueId) {
3
+ export function constructAnimation(document, videoAttribute, fileAttribute, fileId, fileUniqueId) {
4
4
  return {
5
5
  fileId,
6
6
  fileUniqueId,
@@ -8,6 +8,7 @@ export function constructAnimation(document, videoAttribute, fileId, fileUniqueI
8
8
  height: videoAttribute?.h ?? 0,
9
9
  duration: videoAttribute?.duration ?? 0,
10
10
  thumbnails: document.thumbs ? document.thumbs.map((v) => v instanceof types.PhotoSize ? constructThumbnail(v, document) : null).filter((v) => v) : [],
11
+ fileName: fileAttribute?.fileName,
11
12
  mimeType: document.mimeType,
12
13
  fileSize: Number(document.size),
13
14
  };
@@ -25,7 +25,7 @@ export declare namespace InlineKeyboardButton {
25
25
  switchInlineQueryCurrentChat: string;
26
26
  }
27
27
  interface Game extends Base {
28
- callbackGame: {};
28
+ callbackGame: Record<never, never>;
29
29
  }
30
30
  interface Pay extends Base {
31
31
  pay: boolean;
@@ -0,0 +1,13 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { MessageEntity } from "./0_message_entity.js";
3
+ import { Animation } from "./1_animation.js";
4
+ import { Photo } from "./1_photo.js";
5
+ export interface Game {
6
+ title: string;
7
+ description: string;
8
+ photo: Photo;
9
+ text?: string;
10
+ textEntities?: MessageEntity[];
11
+ animation?: Animation;
12
+ }
13
+ export declare function constructGame(media_: types.MessageMediaGame): Game;
@@ -0,0 +1,22 @@
1
+ import { as } from "../tl/1_tl_object.js";
2
+ import * as types from "../tl/2_types.js";
3
+ import { cleanObject } from "../utilities/0_object.js";
4
+ import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js";
5
+ import { constructAnimation } from "./1_animation.js";
6
+ import { constructPhoto } from "./1_photo.js";
7
+ export function constructGame(media_) {
8
+ const game_ = media_.game[as](types.Game);
9
+ const document_ = game_.document ? game_.document[as](types.Document) : undefined;
10
+ return cleanObject({
11
+ title: game_.title,
12
+ description: game_.description,
13
+ photo: constructPhoto(game_.photo[as](types.Photo)),
14
+ animation: document_
15
+ ? constructAnimation(document_, document_.attributes.find((v) => v instanceof types.DocumentAttributeVideo), document_.attributes.find((v) => v instanceof types.DocumentAttributeFilename), new FileID(null, null, FileType.Animation, document_.dcId, {
16
+ mediaId: document_.id,
17
+ accessHash: document_.accessHash,
18
+ fileReference: document_.fileReference,
19
+ }).encode(), new FileUniqueID(FileUniqueType.Document, { mediaId: document_.id }).encode())
20
+ : undefined,
21
+ });
22
+ }
@@ -17,6 +17,7 @@ import { Audio } from "./0_audio.js";
17
17
  import { Voice } from "./0_voice.js";
18
18
  import { Dice } from "./0_dice.js";
19
19
  import { Contact } from "./0_contact.js";
20
+ import { Game } from "./2_game.js";
20
21
  export interface Message {
21
22
  id: number;
22
23
  threadId?: number;
@@ -55,6 +56,7 @@ export interface Message {
55
56
  dice?: Dice;
56
57
  videoNote?: VideoNote;
57
58
  contact?: Contact;
59
+ game?: Game;
58
60
  }
59
61
  export declare function constructMessage(message_: types.Message, getEntity: {
60
62
  (peer: types.PeerUser): MaybePromise<types.User | null>;
@@ -20,6 +20,7 @@ import { constructVoice } from "./0_voice.js";
20
20
  import { constructDice } from "./0_dice.js";
21
21
  import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js";
22
22
  import { constructContact } from "./0_contact.js";
23
+ import { constructGame } from "./2_game.js";
23
24
  const d = debug("types/Message");
24
25
  export async function constructMessage(message_, getEntity, getMessage, getStickerSetName) {
25
26
  let chat_ = null;
@@ -207,7 +208,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
207
208
  const sticker = document.attributes.find((v) => v instanceof types.DocumentAttributeSticker);
208
209
  const video = document.attributes.find((v) => v instanceof types.DocumentAttributeVideo);
209
210
  if (animated) {
210
- message.animation = constructAnimation(document, video, getFileId(FileType.Animation), fileUniqueId);
211
+ message.animation = constructAnimation(document, video, fileName, getFileId(FileType.Animation), fileUniqueId);
211
212
  }
212
213
  else if (video) {
213
214
  if (video.roundMessage) {
@@ -239,7 +240,11 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
239
240
  else if (message_.media instanceof types.MessageMediaContact) {
240
241
  message.contact = constructContact(message_.media);
241
242
  }
243
+ else if (message_.media instanceof types.MessageMediaGame) {
244
+ message.game = constructGame(message_.media);
245
+ }
242
246
  else {
247
+ console.log(message_.media);
243
248
  // not implemented
244
249
  UNREACHABLE();
245
250
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "main": "./script/mod.js",
4
4
  "name": "@mtkruto/node",
5
- "version": "0.0.931",
5
+ "version": "0.0.934",
6
6
  "description": "MTKruto for Node.js",
7
7
  "author": "Roj <rojvv@icloud.com>",
8
8
  "license": "LGPL-3.0-or-later",
@@ -4,7 +4,7 @@ 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.931";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.934";
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 = "";
@@ -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.931";
91
+ exports.DEFAULT_APP_VERSION = "MTKruto 0.0.934";
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];
@@ -7,7 +7,8 @@ export interface Animation {
7
7
  height: number;
8
8
  duration: number;
9
9
  thumbnails: Thumbnail[];
10
+ fileName?: string;
10
11
  mimeType: string;
11
12
  fileSize: number;
12
13
  }
13
- export declare function constructAnimation(document: types.Document, videoAttribute: types.DocumentAttributeVideo | undefined, fileId: string, fileUniqueId: string): Animation;
14
+ export declare function constructAnimation(document: types.Document, videoAttribute: types.DocumentAttributeVideo | undefined, fileAttribute: types.DocumentAttributeFilename | undefined, fileId: string, fileUniqueId: string): Animation;
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.constructAnimation = void 0;
27
27
  const types = __importStar(require("../tl/2_types.js"));
28
28
  const _0_thumbnail_js_1 = require("./0_thumbnail.js");
29
- function constructAnimation(document, videoAttribute, fileId, fileUniqueId) {
29
+ function constructAnimation(document, videoAttribute, fileAttribute, fileId, fileUniqueId) {
30
30
  return {
31
31
  fileId,
32
32
  fileUniqueId,
@@ -34,6 +34,7 @@ function constructAnimation(document, videoAttribute, fileId, fileUniqueId) {
34
34
  height: videoAttribute?.h ?? 0,
35
35
  duration: videoAttribute?.duration ?? 0,
36
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: fileAttribute?.fileName,
37
38
  mimeType: document.mimeType,
38
39
  fileSize: Number(document.size),
39
40
  };
@@ -25,7 +25,7 @@ export declare namespace InlineKeyboardButton {
25
25
  switchInlineQueryCurrentChat: string;
26
26
  }
27
27
  interface Game extends Base {
28
- callbackGame: {};
28
+ callbackGame: Record<never, never>;
29
29
  }
30
30
  interface Pay extends Base {
31
31
  pay: boolean;
@@ -0,0 +1,13 @@
1
+ import * as types from "../tl/2_types.js";
2
+ import { MessageEntity } from "./0_message_entity.js";
3
+ import { Animation } from "./1_animation.js";
4
+ import { Photo } from "./1_photo.js";
5
+ export interface Game {
6
+ title: string;
7
+ description: string;
8
+ photo: Photo;
9
+ text?: string;
10
+ textEntities?: MessageEntity[];
11
+ animation?: Animation;
12
+ }
13
+ export declare function constructGame(media_: types.MessageMediaGame): Game;
@@ -0,0 +1,49 @@
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.constructGame = 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_object_js_1 = require("../utilities/0_object.js");
30
+ const _0_file_id_js_1 = require("./!0_file_id.js");
31
+ const _1_animation_js_1 = require("./1_animation.js");
32
+ const _1_photo_js_1 = require("./1_photo.js");
33
+ function constructGame(media_) {
34
+ const game_ = media_.game[_1_tl_object_js_1.as](types.Game);
35
+ const document_ = game_.document ? game_.document[_1_tl_object_js_1.as](types.Document) : undefined;
36
+ return (0, _0_object_js_1.cleanObject)({
37
+ title: game_.title,
38
+ description: game_.description,
39
+ photo: (0, _1_photo_js_1.constructPhoto)(game_.photo[_1_tl_object_js_1.as](types.Photo)),
40
+ animation: document_
41
+ ? (0, _1_animation_js_1.constructAnimation)(document_, document_.attributes.find((v) => v instanceof types.DocumentAttributeVideo), document_.attributes.find((v) => v instanceof types.DocumentAttributeFilename), new _0_file_id_js_1.FileID(null, null, _0_file_id_js_1.FileType.Animation, document_.dcId, {
42
+ mediaId: document_.id,
43
+ accessHash: document_.accessHash,
44
+ fileReference: document_.fileReference,
45
+ }).encode(), new _0_file_id_js_1.FileUniqueID(_0_file_id_js_1.FileUniqueType.Document, { mediaId: document_.id }).encode())
46
+ : undefined,
47
+ });
48
+ }
49
+ exports.constructGame = constructGame;
@@ -17,6 +17,7 @@ import { Audio } from "./0_audio.js";
17
17
  import { Voice } from "./0_voice.js";
18
18
  import { Dice } from "./0_dice.js";
19
19
  import { Contact } from "./0_contact.js";
20
+ import { Game } from "./2_game.js";
20
21
  export interface Message {
21
22
  id: number;
22
23
  threadId?: number;
@@ -55,6 +56,7 @@ export interface Message {
55
56
  dice?: Dice;
56
57
  videoNote?: VideoNote;
57
58
  contact?: Contact;
59
+ game?: Game;
58
60
  }
59
61
  export declare function constructMessage(message_: types.Message, getEntity: {
60
62
  (peer: types.PeerUser): MaybePromise<types.User | null>;
@@ -46,6 +46,7 @@ const _0_voice_js_1 = require("./0_voice.js");
46
46
  const _0_dice_js_1 = require("./0_dice.js");
47
47
  const _0_file_id_js_1 = require("./!0_file_id.js");
48
48
  const _0_contact_js_1 = require("./0_contact.js");
49
+ const _2_game_js_1 = require("./2_game.js");
49
50
  const d = (0, deps_js_1.debug)("types/Message");
50
51
  async function constructMessage(message_, getEntity, getMessage, getStickerSetName) {
51
52
  let chat_ = null;
@@ -233,7 +234,7 @@ async function constructMessage(message_, getEntity, getMessage, getStickerSetNa
233
234
  const sticker = document.attributes.find((v) => v instanceof types.DocumentAttributeSticker);
234
235
  const video = document.attributes.find((v) => v instanceof types.DocumentAttributeVideo);
235
236
  if (animated) {
236
- message.animation = (0, _1_animation_js_1.constructAnimation)(document, video, getFileId(_0_file_id_js_1.FileType.Animation), fileUniqueId);
237
+ message.animation = (0, _1_animation_js_1.constructAnimation)(document, video, fileName, getFileId(_0_file_id_js_1.FileType.Animation), fileUniqueId);
237
238
  }
238
239
  else if (video) {
239
240
  if (video.roundMessage) {
@@ -265,7 +266,11 @@ async function constructMessage(message_, getEntity, getMessage, getStickerSetNa
265
266
  else if (message_.media instanceof types.MessageMediaContact) {
266
267
  message.contact = (0, _0_contact_js_1.constructContact)(message_.media);
267
268
  }
269
+ else if (message_.media instanceof types.MessageMediaGame) {
270
+ message.game = (0, _2_game_js_1.constructGame)(message_.media);
271
+ }
268
272
  else {
273
+ console.log(message_.media);
269
274
  // not implemented
270
275
  (0, _0_control_js_1.UNREACHABLE)();
271
276
  }