@mtkruto/node 0.0.938 → 0.0.939

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.938";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.939";
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.938";
65
+ export const DEFAULT_APP_VERSION = "MTKruto 0.0.939";
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];
@@ -1,3 +1,4 @@
1
+ import * as types from "../tl/2_types.js";
1
2
  export interface Location {
2
3
  latitude: number;
3
4
  longitude: number;
@@ -6,3 +7,4 @@ export interface Location {
6
7
  heading?: number;
7
8
  proximityAlertRadius?: number;
8
9
  }
10
+ export declare function constructLocation(geo_: types.MessageMediaGeo | types.MessageMediaGeoLive | types.GeoPoint): Location;
@@ -1 +1,31 @@
1
- export {};
1
+ import { as } from "../tl/1_tl_object.js";
2
+ import * as types from "../tl/2_types.js";
3
+ export function constructLocation(geo_) {
4
+ if (geo_ instanceof types.MessageMediaGeo) {
5
+ const geo = geo_.geo[as](types.GeoPoint);
6
+ return {
7
+ latitude: geo.lat,
8
+ longitude: geo.long,
9
+ horizontalAccuracy: geo.accuracyRadius,
10
+ };
11
+ }
12
+ else if (geo_ instanceof types.MessageMediaGeoLive) {
13
+ const media = geo_;
14
+ const geo = media.geo[as](types.GeoPoint);
15
+ return {
16
+ latitude: geo.lat,
17
+ longitude: geo.long,
18
+ horizontalAccuracy: geo.accuracyRadius,
19
+ livePeriod: media.period,
20
+ heading: media.heading,
21
+ proximityAlertRadius: media.proximityNotificationRadius,
22
+ };
23
+ }
24
+ else {
25
+ return {
26
+ latitude: geo_.lat,
27
+ longitude: geo_.long,
28
+ horizontalAccuracy: geo_.accuracyRadius,
29
+ };
30
+ }
31
+ }
@@ -1,4 +1,4 @@
1
- import { as } from "../mod.js";
1
+ import { as } from "../tl/1_tl_object.js";
2
2
  import * as types from "../tl/2_types.js";
3
3
  export function constructVenue(media_) {
4
4
  const geo = media_.geo[as](types.GeoPoint);
@@ -19,6 +19,7 @@ import { Dice } from "./0_dice.js";
19
19
  import { Contact } from "./0_contact.js";
20
20
  import { Game } from "./2_game.js";
21
21
  import { Venue } from "./0_venue.js";
22
+ import { Location } from "./0_location.js";
22
23
  /** This object represents a message. */
23
24
  export interface Message {
24
25
  /** Unique message identifier inside this chat */
@@ -88,6 +89,7 @@ export interface Message {
88
89
  contact?: Contact;
89
90
  game?: Game;
90
91
  venue?: Venue;
92
+ location?: Location;
91
93
  }
92
94
  interface EntityGetter {
93
95
  (peer: types.PeerUser): MaybePromise<types.User | null>;
@@ -22,6 +22,7 @@ import { FileID, FileType, FileUniqueID, FileUniqueType } from "./!0_file_id.js"
22
22
  import { constructContact } from "./0_contact.js";
23
23
  import { constructGame } from "./2_game.js";
24
24
  import { constructVenue } from "./0_venue.js";
25
+ import { constructLocation } from "./0_location.js";
25
26
  const d = debug("types/Message");
26
27
  async function getSender(message_, getEntity) {
27
28
  if (message_.fromId instanceof types.PeerUser) {
@@ -273,6 +274,9 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
273
274
  else if (message_.media instanceof types.MessageMediaVenue) {
274
275
  message.venue = constructVenue(message_.media);
275
276
  }
277
+ else if (message_.media instanceof types.MessageMediaGeo || message_.media instanceof types.MessageMediaGeoLive) {
278
+ message.location = constructLocation(message_.media);
279
+ }
276
280
  else {
277
281
  console.log(message_.media);
278
282
  // not implemented
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.938",
5
+ "version": "0.0.939",
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.938";
7
+ export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.939";
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.938";
91
+ exports.DEFAULT_APP_VERSION = "MTKruto 0.0.939";
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];
@@ -1,3 +1,4 @@
1
+ import * as types from "../tl/2_types.js";
1
2
  export interface Location {
2
3
  latitude: number;
3
4
  longitude: number;
@@ -6,3 +7,4 @@ export interface Location {
6
7
  heading?: number;
7
8
  proximityAlertRadius?: number;
8
9
  }
10
+ export declare function constructLocation(geo_: types.MessageMediaGeo | types.MessageMediaGeoLive | types.GeoPoint): Location;
@@ -1,2 +1,58 @@
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 });
26
+ exports.constructLocation = 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
+ function constructLocation(geo_) {
30
+ if (geo_ instanceof types.MessageMediaGeo) {
31
+ const geo = geo_.geo[_1_tl_object_js_1.as](types.GeoPoint);
32
+ return {
33
+ latitude: geo.lat,
34
+ longitude: geo.long,
35
+ horizontalAccuracy: geo.accuracyRadius,
36
+ };
37
+ }
38
+ else if (geo_ instanceof types.MessageMediaGeoLive) {
39
+ const media = geo_;
40
+ const geo = media.geo[_1_tl_object_js_1.as](types.GeoPoint);
41
+ return {
42
+ latitude: geo.lat,
43
+ longitude: geo.long,
44
+ horizontalAccuracy: geo.accuracyRadius,
45
+ livePeriod: media.period,
46
+ heading: media.heading,
47
+ proximityAlertRadius: media.proximityNotificationRadius,
48
+ };
49
+ }
50
+ else {
51
+ return {
52
+ latitude: geo_.lat,
53
+ longitude: geo_.long,
54
+ horizontalAccuracy: geo_.accuracyRadius,
55
+ };
56
+ }
57
+ }
58
+ exports.constructLocation = constructLocation;
@@ -24,10 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.constructVenue = void 0;
27
- const mod_js_1 = require("../mod.js");
27
+ const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
28
28
  const types = __importStar(require("../tl/2_types.js"));
29
29
  function constructVenue(media_) {
30
- const geo = media_.geo[mod_js_1.as](types.GeoPoint);
30
+ const geo = media_.geo[_1_tl_object_js_1.as](types.GeoPoint);
31
31
  return {
32
32
  location: {
33
33
  latitude: geo.lat,
@@ -19,6 +19,7 @@ import { Dice } from "./0_dice.js";
19
19
  import { Contact } from "./0_contact.js";
20
20
  import { Game } from "./2_game.js";
21
21
  import { Venue } from "./0_venue.js";
22
+ import { Location } from "./0_location.js";
22
23
  /** This object represents a message. */
23
24
  export interface Message {
24
25
  /** Unique message identifier inside this chat */
@@ -88,6 +89,7 @@ export interface Message {
88
89
  contact?: Contact;
89
90
  game?: Game;
90
91
  venue?: Venue;
92
+ location?: Location;
91
93
  }
92
94
  interface EntityGetter {
93
95
  (peer: types.PeerUser): MaybePromise<types.User | null>;
@@ -48,6 +48,7 @@ const _0_file_id_js_1 = require("./!0_file_id.js");
48
48
  const _0_contact_js_1 = require("./0_contact.js");
49
49
  const _2_game_js_1 = require("./2_game.js");
50
50
  const _0_venue_js_1 = require("./0_venue.js");
51
+ const _0_location_js_1 = require("./0_location.js");
51
52
  const d = (0, deps_js_1.debug)("types/Message");
52
53
  async function getSender(message_, getEntity) {
53
54
  if (message_.fromId instanceof types.PeerUser) {
@@ -299,6 +300,9 @@ async function constructMessage(message_, getEntity, getMessage, getStickerSetNa
299
300
  else if (message_.media instanceof types.MessageMediaVenue) {
300
301
  message.venue = (0, _0_venue_js_1.constructVenue)(message_.media);
301
302
  }
303
+ else if (message_.media instanceof types.MessageMediaGeo || message_.media instanceof types.MessageMediaGeoLive) {
304
+ message.location = (0, _0_location_js_1.constructLocation)(message_.media);
305
+ }
302
306
  else {
303
307
  console.log(message_.media);
304
308
  // not implemented