@mtkruto/node 0.1.123 → 0.1.125
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.
- package/esm/0_deps.d.ts +1 -0
- package/esm/0_deps.js +1 -0
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/1_client_abstract.d.ts +1 -1
- package/esm/client/3_types.d.ts +56 -0
- package/esm/client/5_client.d.ts +17 -2
- package/esm/client/5_client.js +165 -57
- package/esm/connection/0_connection.d.ts +4 -0
- package/esm/connection/0_connection.js +6 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_db.js +33 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/_util.js +122 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/content_type.js +60 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/format_media_type.js +61 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/get_charset.js +37 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +122 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
- package/esm/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8555 -0
- package/esm/storage/0_storage.d.ts +1 -0
- package/esm/storage/1_storage_indexed_db.d.ts +4 -3
- package/esm/storage/1_storage_indexed_db.js +17 -8
- package/esm/storage/1_storage_local_storage.d.ts +2 -2
- package/esm/storage/1_storage_local_storage.js +3 -0
- package/esm/storage/1_storage_memory.d.ts +1 -0
- package/esm/storage/1_storage_memory.js +3 -0
- package/esm/storage/1_storage_session_storage.d.ts +1 -0
- package/esm/storage/1_storage_session_storage.js +3 -0
- package/esm/transport/0_transport.d.ts +1 -1
- package/esm/transport/0_transport.js +0 -6
- package/esm/transport/1_transport_abridged.d.ts +1 -0
- package/esm/transport/1_transport_abridged.js +9 -5
- package/esm/transport/1_transport_intermediate.d.ts +1 -0
- package/esm/transport/1_transport_intermediate.js +8 -4
- package/esm/types/1_chat.d.ts +2 -15
- package/esm/types/1_chat.js +3 -14
- package/esm/types/1_user.js +4 -2
- package/esm/types/3_message.d.ts +2 -2
- package/esm/types/3_message.js +6 -6
- package/esm/utilities/{0_base64.js → 1_base64.js} +2 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -0
- package/script/0_deps.js +3 -1
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.js +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/1_client_abstract.d.ts +1 -1
- package/script/client/3_types.d.ts +56 -0
- package/script/client/5_client.d.ts +17 -2
- package/script/client/5_client.js +164 -56
- package/script/connection/0_connection.d.ts +4 -0
- package/script/connection/0_connection.js +6 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_db.d.ts +5 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_db.js +39 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_util.d.ts +21 -0
- package/script/deps/deno.land/std@0.208.0/media_types/_util.js +132 -0
- package/script/deps/deno.land/std@0.208.0/media_types/content_type.d.ts +38 -0
- package/script/deps/deno.land/std@0.208.0/media_types/content_type.js +64 -0
- package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.d.ts +16 -0
- package/script/deps/deno.land/std@0.208.0/media_types/format_media_type.js +65 -0
- package/script/deps/deno.land/std@0.208.0/media_types/get_charset.d.ts +15 -0
- package/script/deps/deno.land/std@0.208.0/media_types/get_charset.js +41 -0
- package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.d.ts +37 -0
- package/script/deps/deno.land/std@0.208.0/media_types/parse_media_type.js +126 -0
- package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.d.ts +8518 -0
- package/script/deps/deno.land/std@0.208.0/media_types/vendor/mime-db.v1.52.0.js +8557 -0
- package/script/storage/0_storage.d.ts +1 -0
- package/script/storage/1_storage_indexed_db.d.ts +4 -3
- package/script/storage/1_storage_indexed_db.js +17 -8
- package/script/storage/1_storage_local_storage.d.ts +2 -2
- package/script/storage/1_storage_local_storage.js +3 -0
- package/script/storage/1_storage_memory.d.ts +1 -0
- package/script/storage/1_storage_memory.js +3 -0
- package/script/storage/1_storage_session_storage.d.ts +1 -0
- package/script/storage/1_storage_session_storage.js +3 -0
- package/script/transport/0_transport.d.ts +1 -1
- package/script/transport/0_transport.js +0 -6
- package/script/transport/1_transport_abridged.d.ts +1 -0
- package/script/transport/1_transport_abridged.js +9 -5
- package/script/transport/1_transport_intermediate.d.ts +1 -0
- package/script/transport/1_transport_intermediate.js +8 -4
- package/script/types/1_chat.d.ts +2 -15
- package/script/types/1_chat.js +3 -14
- package/script/types/1_user.js +4 -2
- package/script/types/3_message.d.ts +2 -2
- package/script/types/3_message.js +6 -6
- package/script/utilities/{0_base64.js → 1_base64.js} +2 -1
- /package/esm/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
- /package/script/utilities/{0_base64.d.ts → 1_base64.d.ts} +0 -0
|
@@ -6,6 +6,7 @@ export declare abstract class Storage {
|
|
|
6
6
|
#private;
|
|
7
7
|
abstract init(): MaybePromise<void>;
|
|
8
8
|
abstract set(key: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
9
|
+
abstract incr(key: readonly StorageKeyPart[], by: number): MaybePromise<void>;
|
|
9
10
|
abstract get<T>(key: readonly StorageKeyPart[]): MaybePromise<T | null>;
|
|
10
11
|
abstract getMany<T>(prefix: readonly StorageKeyPart[]): MaybePromise<Generator<[readonly StorageKeyPart[], T]> | AsyncGenerator<[readonly StorageKeyPart[], T]>>;
|
|
11
12
|
setDc(dc: DC | null): MaybePromise<void>;
|
|
@@ -4,7 +4,8 @@ export declare class StorageIndexedDB extends Storage {
|
|
|
4
4
|
database: IDBDatabase | null;
|
|
5
5
|
constructor(name: string);
|
|
6
6
|
init(): Promise<void>;
|
|
7
|
-
set(k: StorageKeyPart[], v: unknown): Promise<void>;
|
|
8
|
-
get<T>(k: readonly StorageKeyPart[]): Promise<T | null>;
|
|
9
|
-
getMany<T>(prefix: readonly StorageKeyPart[]): AsyncGenerator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
7
|
+
set(k: readonly StorageKeyPart[], v: unknown, tx_?: IDBTransaction): Promise<void>;
|
|
8
|
+
get<T>(k: readonly StorageKeyPart[], tx_?: IDBTransaction): Promise<T | null>;
|
|
9
|
+
getMany<T>(prefix: readonly StorageKeyPart[], tx_?: IDBTransaction): AsyncGenerator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
10
|
+
incr(key: readonly StorageKeyPart[], by: number): Promise<void>;
|
|
10
11
|
}
|
|
@@ -38,12 +38,12 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
set(k, v) {
|
|
41
|
+
set(k, v, tx_) {
|
|
42
42
|
if (!this.database) {
|
|
43
43
|
throw new Error("Not initialized");
|
|
44
44
|
}
|
|
45
|
-
const store = this.database
|
|
46
|
-
.transaction(KV_OBJECT_STORE, "readwrite")
|
|
45
|
+
const store = (tx_ ?? this.database
|
|
46
|
+
.transaction(KV_OBJECT_STORE, "readwrite"))
|
|
47
47
|
.objectStore(KV_OBJECT_STORE);
|
|
48
48
|
// deno-lint-ignore no-explicit-any
|
|
49
49
|
let tx;
|
|
@@ -60,12 +60,12 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
60
60
|
};
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
get(k) {
|
|
63
|
+
get(k, tx_) {
|
|
64
64
|
if (!this.database) {
|
|
65
65
|
throw new Error("Not initialized");
|
|
66
66
|
}
|
|
67
|
-
const tx = this.database
|
|
68
|
-
.transaction(KV_OBJECT_STORE, "readonly")
|
|
67
|
+
const tx = (tx_ ?? this.database
|
|
68
|
+
.transaction(KV_OBJECT_STORE, "readonly"))
|
|
69
69
|
.objectStore(KV_OBJECT_STORE)
|
|
70
70
|
.get((0, _0_utilities_js_1.fixKey)(k));
|
|
71
71
|
return new Promise((res, rej) => {
|
|
@@ -75,12 +75,12 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
75
75
|
};
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
async *getMany(prefix) {
|
|
78
|
+
async *getMany(prefix, tx_) {
|
|
79
79
|
if (!this.database) {
|
|
80
80
|
throw new Error("Not initialized");
|
|
81
81
|
}
|
|
82
82
|
const keys = await new Promise((res, rej) => {
|
|
83
|
-
const tx = this.database.transaction(KV_OBJECT_STORE, "readonly")
|
|
83
|
+
const tx = (tx_ ?? this.database.transaction(KV_OBJECT_STORE, "readonly"))
|
|
84
84
|
.objectStore(KV_OBJECT_STORE)
|
|
85
85
|
.getAllKeys((0, _0_utilities_js_1.getPrefixKeyRange)(prefix));
|
|
86
86
|
tx.onerror = rej;
|
|
@@ -92,5 +92,14 @@ class StorageIndexedDB extends _0_storage_js_1.Storage {
|
|
|
92
92
|
yield [key, await this.get(key)];
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
+
async incr(key, by) {
|
|
96
|
+
if (!this.database) {
|
|
97
|
+
throw new Error("Not initialized");
|
|
98
|
+
}
|
|
99
|
+
const tx = this.database
|
|
100
|
+
.transaction(KV_OBJECT_STORE, "readwrite");
|
|
101
|
+
const currentValue = await this.get(key, tx);
|
|
102
|
+
await this.set(key, (currentValue || 0) + by, tx);
|
|
103
|
+
}
|
|
95
104
|
}
|
|
96
105
|
exports.StorageIndexedDB = StorageIndexedDB;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MaybePromise } from "../1_utilities.js";
|
|
2
1
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
2
|
export declare class StorageLocalStorage extends Storage implements Storage {
|
|
4
3
|
private readonly prefix;
|
|
@@ -6,5 +5,6 @@ export declare class StorageLocalStorage extends Storage implements Storage {
|
|
|
6
5
|
init(): void;
|
|
7
6
|
get<T>(key_: readonly StorageKeyPart[]): T | null;
|
|
8
7
|
getMany<T>(prefix: readonly StorageKeyPart[]): Generator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
9
|
-
set(key_: readonly StorageKeyPart[], value: unknown):
|
|
8
|
+
set(key_: readonly StorageKeyPart[], value: unknown): void;
|
|
9
|
+
incr(key: readonly StorageKeyPart[], by: number): void;
|
|
10
10
|
}
|
|
@@ -6,4 +6,5 @@ export declare class StorageMemory extends Storage implements Storage {
|
|
|
6
6
|
get<T>(key: readonly StorageKeyPart[]): NonNullable<T> | null;
|
|
7
7
|
getMany<T>(prefix: readonly StorageKeyPart[]): Generator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
8
8
|
set(key_: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
9
|
+
incr(key: readonly StorageKeyPart[], by: number): void;
|
|
9
10
|
}
|
|
@@ -7,4 +7,5 @@ export declare class StorageSessionStorage extends Storage implements Storage {
|
|
|
7
7
|
get<T>(key_: readonly StorageKeyPart[]): T | null;
|
|
8
8
|
getMany<T>(prefix: readonly StorageKeyPart[]): Generator<[readonly StorageKeyPart[], T], void, unknown>;
|
|
9
9
|
set(key_: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
10
|
+
incr(key: readonly StorageKeyPart[], by: number): void;
|
|
10
11
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CTR, MaybePromise } from "../1_utilities.js";
|
|
2
2
|
export declare abstract class Transport {
|
|
3
|
-
protected initialized: boolean;
|
|
4
3
|
protected obfuscationParameters: {
|
|
5
4
|
encryptionCTR: CTR;
|
|
6
5
|
decryptionCTR: CTR;
|
|
7
6
|
} | null;
|
|
8
7
|
protected encrypt(buffer: Uint8Array): void;
|
|
9
8
|
protected decrypt(buffer: Uint8Array): void;
|
|
9
|
+
abstract get initialized(): boolean;
|
|
10
10
|
abstract initialize(): MaybePromise<void>;
|
|
11
11
|
abstract receive(): MaybePromise<Uint8Array>;
|
|
12
12
|
abstract send(buffer: Uint8Array): MaybePromise<void>;
|
|
@@ -3,12 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Transport = void 0;
|
|
4
4
|
class Transport {
|
|
5
5
|
constructor() {
|
|
6
|
-
Object.defineProperty(this, "initialized", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
value: false
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(this, "obfuscationParameters", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
configurable: true,
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _TransportAbridged_connection, _TransportAbridged_obfuscated;
|
|
13
|
+
var _TransportAbridged_initialized, _TransportAbridged_connection, _TransportAbridged_obfuscated;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.TransportAbridged = void 0;
|
|
16
16
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
@@ -19,20 +19,21 @@ const _0_transport_js_1 = require("./0_transport.js");
|
|
|
19
19
|
class TransportAbridged extends _0_transport_js_1.Transport {
|
|
20
20
|
constructor(connection, obfuscated = false) {
|
|
21
21
|
super();
|
|
22
|
+
_TransportAbridged_initialized.set(this, false);
|
|
22
23
|
_TransportAbridged_connection.set(this, void 0);
|
|
23
24
|
_TransportAbridged_obfuscated.set(this, void 0);
|
|
24
25
|
__classPrivateFieldSet(this, _TransportAbridged_connection, connection, "f");
|
|
25
26
|
__classPrivateFieldSet(this, _TransportAbridged_obfuscated, obfuscated, "f");
|
|
26
27
|
}
|
|
27
28
|
async initialize() {
|
|
28
|
-
if (!this
|
|
29
|
+
if (!__classPrivateFieldGet(this, _TransportAbridged_initialized, "f")) {
|
|
29
30
|
if (__classPrivateFieldGet(this, _TransportAbridged_obfuscated, "f")) {
|
|
30
31
|
this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEFEFEFEF, __classPrivateFieldGet(this, _TransportAbridged_connection, "f"));
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
34
|
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(new Uint8Array([0xEF]));
|
|
34
35
|
}
|
|
35
|
-
this
|
|
36
|
+
__classPrivateFieldSet(this, _TransportAbridged_initialized, true, "f");
|
|
36
37
|
}
|
|
37
38
|
else {
|
|
38
39
|
throw new Error("Transport already initialized");
|
|
@@ -73,8 +74,11 @@ class TransportAbridged extends _0_transport_js_1.Transport {
|
|
|
73
74
|
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(data);
|
|
74
75
|
}
|
|
75
76
|
deinitialize() {
|
|
76
|
-
this
|
|
77
|
+
__classPrivateFieldSet(this, _TransportAbridged_initialized, false, "f");
|
|
78
|
+
}
|
|
79
|
+
get initialized() {
|
|
80
|
+
return __classPrivateFieldGet(this, _TransportAbridged_initialized, "f");
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
exports.TransportAbridged = TransportAbridged;
|
|
80
|
-
_TransportAbridged_connection = new WeakMap(), _TransportAbridged_obfuscated = new WeakMap();
|
|
84
|
+
_TransportAbridged_initialized = new WeakMap(), _TransportAbridged_connection = new WeakMap(), _TransportAbridged_obfuscated = new WeakMap();
|
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _TransportIntermediate_connection, _TransportIntermediate_obfuscated;
|
|
13
|
+
var _TransportIntermediate_connection, _TransportIntermediate_initialized, _TransportIntermediate_obfuscated;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.TransportIntermediate = void 0;
|
|
16
16
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
@@ -20,6 +20,7 @@ class TransportIntermediate extends _0_transport_js_1.Transport {
|
|
|
20
20
|
constructor(connection, obfuscated = false) {
|
|
21
21
|
super();
|
|
22
22
|
_TransportIntermediate_connection.set(this, void 0);
|
|
23
|
+
_TransportIntermediate_initialized.set(this, false);
|
|
23
24
|
_TransportIntermediate_obfuscated.set(this, void 0);
|
|
24
25
|
__classPrivateFieldSet(this, _TransportIntermediate_connection, connection, "f");
|
|
25
26
|
__classPrivateFieldSet(this, _TransportIntermediate_obfuscated, obfuscated, "f");
|
|
@@ -32,7 +33,7 @@ class TransportIntermediate extends _0_transport_js_1.Transport {
|
|
|
32
33
|
else {
|
|
33
34
|
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
|
|
34
35
|
}
|
|
35
|
-
this
|
|
36
|
+
__classPrivateFieldSet(this, _TransportIntermediate_initialized, true, "f");
|
|
36
37
|
}
|
|
37
38
|
else {
|
|
38
39
|
throw new Error("Transport already initialized");
|
|
@@ -62,8 +63,11 @@ class TransportIntermediate extends _0_transport_js_1.Transport {
|
|
|
62
63
|
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(data);
|
|
63
64
|
}
|
|
64
65
|
deinitialize() {
|
|
65
|
-
this
|
|
66
|
+
__classPrivateFieldSet(this, _TransportIntermediate_initialized, false, "f");
|
|
67
|
+
}
|
|
68
|
+
get initialized() {
|
|
69
|
+
return __classPrivateFieldGet(this, _TransportIntermediate_initialized, "f");
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
exports.TransportIntermediate = TransportIntermediate;
|
|
69
|
-
_TransportIntermediate_connection = new WeakMap(), _TransportIntermediate_obfuscated = new WeakMap();
|
|
73
|
+
_TransportIntermediate_connection = new WeakMap(), _TransportIntermediate_initialized = new WeakMap(), _TransportIntermediate_obfuscated = new WeakMap();
|
package/script/types/1_chat.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { types } from "../2_tl.js";
|
|
2
|
-
import { ChatPhoto } from "./0_chat_photo.js";
|
|
3
2
|
import { RestrictionReason } from "./0_restriction_reason.js";
|
|
4
3
|
export type ChatType = "private" | "group" | "supergroup" | "channel";
|
|
5
4
|
export declare namespace Chat {
|
|
6
5
|
interface Base {
|
|
7
|
-
/** The type of the chat. */
|
|
8
|
-
type: ChatType;
|
|
9
6
|
/** The identifier of the chat. */
|
|
10
7
|
id: number;
|
|
8
|
+
/** The type of the chat. */
|
|
9
|
+
type: ChatType;
|
|
11
10
|
/** Identifier of a color that can be displayed instead of the chat's photo. */
|
|
12
11
|
color: number;
|
|
13
|
-
/** The chat's photo. */
|
|
14
|
-
photo?: ChatPhoto;
|
|
15
12
|
}
|
|
16
13
|
interface Private extends Base {
|
|
17
14
|
type: "private";
|
|
@@ -23,10 +20,6 @@ export declare namespace Chat {
|
|
|
23
20
|
lastName?: string;
|
|
24
21
|
/** The user's main username. */
|
|
25
22
|
username?: string;
|
|
26
|
-
/** The user's other usernames. */
|
|
27
|
-
also?: string[];
|
|
28
|
-
/** The user's profile photo. */
|
|
29
|
-
photo?: ChatPhoto.User;
|
|
30
23
|
/** Whether the user has been identified as scam. */
|
|
31
24
|
isScam: boolean;
|
|
32
25
|
/** Whether the user has been identified as an impersonator. */
|
|
@@ -44,8 +37,6 @@ export declare namespace Chat {
|
|
|
44
37
|
type: "group";
|
|
45
38
|
/** The title of the chat. */
|
|
46
39
|
title: string;
|
|
47
|
-
/** The chat's photo. */
|
|
48
|
-
photo?: ChatPhoto.Chat;
|
|
49
40
|
/** Whether the current user is the owner of the chat. */
|
|
50
41
|
isCreator: boolean;
|
|
51
42
|
}
|
|
@@ -54,10 +45,6 @@ export declare namespace Chat {
|
|
|
54
45
|
title: string;
|
|
55
46
|
/** The main username of the chat or channel. */
|
|
56
47
|
username?: string;
|
|
57
|
-
/** The other usernames of the chat or channel. */
|
|
58
|
-
also?: string[];
|
|
59
|
-
/** The chat or channel's photo. */
|
|
60
|
-
photo?: ChatPhoto.Chat;
|
|
61
48
|
/** Whether the chat or channel has been identified as scam. */
|
|
62
49
|
isScam: boolean;
|
|
63
50
|
/** Whether the chat or channel has been identified as an impersonator. */
|
package/script/types/1_chat.js
CHANGED
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.constructChat = void 0;
|
|
4
4
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
5
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
6
|
-
const _0_chat_photo_js_1 = require("./0_chat_photo.js");
|
|
7
6
|
const _0_restriction_reason_js_1 = require("./0_restriction_reason.js");
|
|
8
7
|
function constructChat(chat) {
|
|
9
8
|
if (chat instanceof _2_tl_js_1.types.User) {
|
|
10
9
|
const id = Number(chat.id);
|
|
11
10
|
const chat_ = {
|
|
11
|
+
id,
|
|
12
12
|
type: "private",
|
|
13
13
|
isBot: chat.bot || false,
|
|
14
|
-
id,
|
|
15
14
|
color: chat.color?.color !== undefined ? chat.color.color : (0, _1_utilities_js_1.getColorFromPeerId)(id),
|
|
16
15
|
firstName: chat.first_name || "",
|
|
17
16
|
lastName: chat.last_name,
|
|
@@ -24,23 +23,17 @@ function constructChat(chat) {
|
|
|
24
23
|
chat_.isRestricted = chat.restricted || false;
|
|
25
24
|
chat_.restrictionReason = chat.restriction_reason;
|
|
26
25
|
}
|
|
27
|
-
if (chat.photo instanceof _2_tl_js_1.types.UserProfilePhoto) {
|
|
28
|
-
chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo, chat_.id, chat.access_hash ?? 0n);
|
|
29
|
-
}
|
|
30
26
|
return (0, _1_utilities_js_1.cleanObject)(chat_);
|
|
31
27
|
}
|
|
32
28
|
else if (chat instanceof _2_tl_js_1.types.Chat) {
|
|
33
29
|
const id = Number(-chat.id);
|
|
34
30
|
const chat_ = {
|
|
35
|
-
type: "group",
|
|
36
31
|
id,
|
|
32
|
+
type: "group",
|
|
37
33
|
color: (0, _1_utilities_js_1.getColorFromPeerId)(id),
|
|
38
34
|
title: chat.title,
|
|
39
35
|
isCreator: chat.creator || false,
|
|
40
36
|
};
|
|
41
|
-
if (chat.photo instanceof _2_tl_js_1.types.ChatPhoto) {
|
|
42
|
-
chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo, chat_.id, 0n);
|
|
43
|
-
}
|
|
44
37
|
return (0, _1_utilities_js_1.cleanObject)(chat_);
|
|
45
38
|
}
|
|
46
39
|
else if (chat instanceof _2_tl_js_1.types.Channel) {
|
|
@@ -73,14 +66,10 @@ function constructChat(chat) {
|
|
|
73
66
|
isRestricted,
|
|
74
67
|
};
|
|
75
68
|
}
|
|
76
|
-
chat_.username = chat.username;
|
|
77
|
-
chat_.also = chat.usernames?.map((v) => v.username);
|
|
69
|
+
chat_.username = chat.username ?? chat.usernames?.[0].username;
|
|
78
70
|
if (chat_.isRestricted) {
|
|
79
71
|
chat_.restrictionReason = (chat.restriction_reason ?? []).map(_0_restriction_reason_js_1.constructRestrictionReason);
|
|
80
72
|
}
|
|
81
|
-
if (chat.photo instanceof _2_tl_js_1.types.ChatPhoto) {
|
|
82
|
-
chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo, chat_.id, chat.access_hash ?? 0n);
|
|
83
|
-
}
|
|
84
73
|
return (0, _1_utilities_js_1.cleanObject)(chat_);
|
|
85
74
|
}
|
|
86
75
|
else {
|
package/script/types/1_user.js
CHANGED
|
@@ -6,14 +6,16 @@ const _2_tl_js_1 = require("../2_tl.js");
|
|
|
6
6
|
const _0_chat_photo_js_1 = require("./0_chat_photo.js");
|
|
7
7
|
function constructUser(user_) {
|
|
8
8
|
const id = Number(user_.id);
|
|
9
|
+
const usernames = user_.usernames?.map((v) => v.username);
|
|
10
|
+
const username = user_.username ?? usernames?.shift();
|
|
9
11
|
const user = {
|
|
10
12
|
id,
|
|
11
13
|
color: user_.color?.color !== undefined ? user_.color.color : (0, _1_utilities_js_1.getColorFromPeerId)(id),
|
|
12
14
|
isBot: user_.bot || false,
|
|
13
15
|
firstName: user_.first_name || "",
|
|
14
16
|
lastName: user_.last_name,
|
|
15
|
-
username:
|
|
16
|
-
also:
|
|
17
|
+
username: username,
|
|
18
|
+
also: usernames?.filter((v) => v != username),
|
|
17
19
|
languageCode: user_.lang_code,
|
|
18
20
|
isScam: user_.scam || false,
|
|
19
21
|
isFake: user_.fake || false,
|
|
@@ -57,7 +57,7 @@ export interface Message {
|
|
|
57
57
|
/** True, if the message is a channel post that was automatically forwarded to the connected discussion group */
|
|
58
58
|
isAutomaticForward?: boolean;
|
|
59
59
|
/** For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. */
|
|
60
|
-
replyToMessage?: Omit<Message, "
|
|
60
|
+
replyToMessage?: Omit<Message, "replyToMessage">;
|
|
61
61
|
/** Bot through which the message was sent */
|
|
62
62
|
viaBot?: User;
|
|
63
63
|
/** Date the message was last edited in Unix time */
|
|
@@ -172,7 +172,7 @@ export interface Message {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
export interface MessageGetter<O extends keyof Message | null = null> {
|
|
175
|
-
(chatId: number, messageId: number): MaybePromise<(O extends null ? Message : Omit<Message, "
|
|
175
|
+
(chatId: number, messageId: number): MaybePromise<(O extends null ? Message : Omit<Message, "replyToMessage">) | null>;
|
|
176
176
|
}
|
|
177
177
|
type Message_MessageGetter = MessageGetter<"replyToMessage"> | null;
|
|
178
178
|
export declare function constructMessage(message_: enums.Message, getEntity: EntityGetter, getMessage: Message_MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<Message>;
|
|
@@ -53,15 +53,15 @@ async function getReply(message_, chat, getMessage) {
|
|
|
53
53
|
if (message_.reply_to.forum_topic) {
|
|
54
54
|
isTopicMessage = true;
|
|
55
55
|
}
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
return {
|
|
56
|
+
const replyToMessage = await getMessage(chat.id, message_.reply_to.reply_to_msg_id);
|
|
57
|
+
if (replyToMessage) {
|
|
58
|
+
return { replyToMessage, threadId: message_.reply_to.reply_to_top_id, isTopicMessage };
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
d("couldn't get replied message");
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return {
|
|
64
|
+
return { replyToMessage: undefined, threadId: undefined, isTopicMessage: undefined };
|
|
65
65
|
}
|
|
66
66
|
async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
67
67
|
const message = {
|
|
@@ -136,8 +136,8 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
136
136
|
message.chatMigratedFrom = Number(-message_.action.chat_id);
|
|
137
137
|
}
|
|
138
138
|
else if (message_.action instanceof _2_tl_js_1.types.MessageActionPinMessage) {
|
|
139
|
-
const {
|
|
140
|
-
message.pinnedMessage =
|
|
139
|
+
const { replyToMessage } = await getReply(message_, chat, getMessage);
|
|
140
|
+
message.pinnedMessage = replyToMessage;
|
|
141
141
|
}
|
|
142
142
|
else if (message_.action instanceof _2_tl_js_1.types.MessageActionRequestedPeer) {
|
|
143
143
|
const user = message_.action.peer[_2_tl_js_1.as](_2_tl_js_1.types.PeerUser);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.base64DecodeUrlSafe = exports.base64EncodeUrlSafe = void 0;
|
|
4
4
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
|
+
const _0_bigint_js_1 = require("./0_bigint.js");
|
|
5
6
|
function base64EncodeUrlSafe(data) {
|
|
6
7
|
return (0, _0_deps_js_1.encodeBase64)(data).replace(/=*$/, "").replaceAll("+", "-").replaceAll("/", "_");
|
|
7
8
|
}
|
|
@@ -9,7 +10,7 @@ exports.base64EncodeUrlSafe = base64EncodeUrlSafe;
|
|
|
9
10
|
function base64DecodeUrlSafe(data) {
|
|
10
11
|
data = data.replaceAll("_", "/").replaceAll("-", "+");
|
|
11
12
|
if (data.length != 4) {
|
|
12
|
-
data += "=".repeat(
|
|
13
|
+
data += "=".repeat((0, _0_bigint_js_1.mod)(-data.length, 4));
|
|
13
14
|
}
|
|
14
15
|
return (0, _0_deps_js_1.decodeBase64)(data);
|
|
15
16
|
}
|
|
File without changes
|
|
File without changes
|