@mtkruto/node 0.0.988 → 0.0.990
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/client/1_client_abstract.d.ts +6 -0
- package/esm/client/2_client_plain.d.ts +1 -1
- package/esm/client/3_client.d.ts +17 -15
- package/esm/client/3_client.js +75 -38
- package/esm/constants.d.ts +1 -1
- package/esm/constants.js +1 -1
- package/esm/tl/2_types.d.ts +2055 -1617
- package/esm/tl/2_types.js +3447 -3447
- package/esm/tl/3_functions.d.ts +154 -154
- package/esm/tl/3_functions.js +988 -988
- package/esm/types/0_poll_option.d.ts +8 -0
- package/esm/types/0_poll_option.js +6 -0
- package/esm/types/1_chat.js +3 -4
- package/esm/types/1_keyboard_button.js +4 -5
- package/esm/types/1_photo.js +0 -2
- package/esm/types/1_poll.d.ts +32 -0
- package/esm/types/1_poll.js +23 -0
- package/esm/types/1_sticker.js +1 -1
- package/esm/types/1_user.js +1 -2
- package/esm/types/2_game.js +2 -2
- package/esm/types/2_inline_keyboard_markup.js +1 -2
- package/esm/types/2_reply_keyboard_markup.js +1 -2
- package/esm/types/3_message.d.ts +2 -0
- package/esm/types/3_message.js +4 -0
- package/esm/utilities/0_queue.d.ts +2 -0
- package/esm/utilities/0_queue.js +14 -2
- package/esm/utilities/1_misc.js +1 -1
- package/package.json +1 -1
- package/script/client/1_client_abstract.d.ts +6 -0
- package/script/client/2_client_plain.d.ts +1 -1
- package/script/client/3_client.d.ts +17 -15
- package/script/client/3_client.js +75 -38
- package/script/constants.d.ts +1 -1
- package/script/constants.js +1 -1
- package/script/tl/2_types.d.ts +2055 -1617
- package/script/tl/2_types.js +3894 -3894
- package/script/tl/3_functions.d.ts +154 -154
- package/script/tl/3_functions.js +988 -988
- package/script/types/0_poll_option.d.ts +8 -0
- package/script/types/0_poll_option.js +10 -0
- package/script/types/1_chat.js +3 -4
- package/script/types/1_keyboard_button.js +4 -5
- package/script/types/1_photo.js +0 -2
- package/script/types/1_poll.d.ts +32 -0
- package/script/types/1_poll.js +27 -0
- package/script/types/1_sticker.js +1 -1
- package/script/types/1_user.js +1 -2
- package/script/types/2_game.js +2 -2
- package/script/types/2_inline_keyboard_markup.js +1 -2
- package/script/types/2_reply_keyboard_markup.js +1 -2
- package/script/types/3_message.d.ts +2 -0
- package/script/types/3_message.js +4 -0
- package/script/utilities/0_queue.d.ts +2 -0
- package/script/utilities/0_queue.js +14 -2
- package/script/utilities/1_misc.js +1 -1
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { MaybePromise } from "../utilities/0_types.js";
|
|
2
2
|
import { DC, TransportProvider } from "../transport/2_transport_provider.js";
|
|
3
3
|
export interface ClientAbstractParams {
|
|
4
|
+
/**
|
|
5
|
+
* The first DC to connect to. This is commonly used to decide whether to connect to test or production servers. It is not necessarily the DC that the client will directly connect to or is currently connected to. Defaults to the default initial DC.
|
|
6
|
+
*/
|
|
4
7
|
initialDc?: DC;
|
|
5
8
|
/**
|
|
6
9
|
* The transport provider to use. Defaults to `webSocketTransportProvider` with its default options.
|
|
7
10
|
*/
|
|
8
11
|
transportProvider?: TransportProvider;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the connection is with a CDN server. Defaults to false.
|
|
14
|
+
*/
|
|
9
15
|
cdn?: boolean;
|
|
10
16
|
}
|
|
11
17
|
export declare abstract class ClientAbstract {
|
|
@@ -3,7 +3,7 @@ import { Function } from "../tl/3_functions.js";
|
|
|
3
3
|
import { ClientAbstract, ClientAbstractParams } from "./1_client_abstract.js";
|
|
4
4
|
export interface ClientPlainParams extends ClientAbstractParams {
|
|
5
5
|
/**
|
|
6
|
-
* MTProto public keys to use in the `[keyId, [key, exponent]][]` format. Don't set this unless you know what you are doing.
|
|
6
|
+
* MTProto public keys to use in the `[keyId, [key, exponent]][]` format. Don't set this unless you know what you are doing. Defaults to Telegram servers' public keys.
|
|
7
7
|
*/
|
|
8
8
|
publicKeys?: PublicKeys;
|
|
9
9
|
}
|
package/esm/client/3_client.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { MaybePromise } from "../utilities/0_types.js";
|
|
2
|
+
import { DC } from "../transport/2_transport_provider.js";
|
|
2
3
|
import * as types from "../tl/2_types.js";
|
|
3
|
-
import * as functions from "../tl/3_functions.js";
|
|
4
4
|
import { ReadObject } from "../tl/3_tl_reader.js";
|
|
5
|
-
import
|
|
6
|
-
import { DC } from "../transport/2_transport_provider.js";
|
|
7
|
-
import { MessageEntity } from "../types/0_message_entity.js";
|
|
5
|
+
import * as functions from "../tl/3_functions.js";
|
|
8
6
|
import { ReplyKeyboardRemove } from "../types/0_reply_keyboard_remove.js";
|
|
7
|
+
import { MessageEntity } from "../types/0_message_entity.js";
|
|
9
8
|
import { ForceReply } from "../types/0_force_reply.js";
|
|
10
|
-
import { ReplyKeyboardMarkup } from "../types/2_reply_keyboard_markup.js";
|
|
11
9
|
import { InlineKeyboardMarkup } from "../types/2_inline_keyboard_markup.js";
|
|
10
|
+
import { ReplyKeyboardMarkup } from "../types/2_reply_keyboard_markup.js";
|
|
12
11
|
import { Message } from "../types/3_message.js";
|
|
13
|
-
import {
|
|
12
|
+
import { Storage } from "../storage/0_storage.js";
|
|
14
13
|
import { ClientPlainParams } from "./2_client_plain.js";
|
|
14
|
+
import { ClientAbstract } from "./1_client_abstract.js";
|
|
15
15
|
export declare const getEntity: unique symbol;
|
|
16
16
|
export declare const getStickerSetName: unique symbol;
|
|
17
17
|
export declare const handleMigrationError: unique symbol;
|
|
@@ -27,35 +27,35 @@ export interface AuthorizeUserParams<S = string> {
|
|
|
27
27
|
}
|
|
28
28
|
export interface ClientParams extends ClientPlainParams {
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* A parse mode to use when the `parseMode` parameter is not specified when sending or editing messages. Defauls to `ParseMode.None`.
|
|
31
31
|
*/
|
|
32
32
|
parseMode?: ParseMode;
|
|
33
33
|
/**
|
|
34
|
-
* The app_version parameter to be passed to initConnection when calling `authorize`.
|
|
34
|
+
* The app_version parameter to be passed to initConnection when calling `authorize`. It is recommended that this parameter is changed if users are authorized. Defaults to "MTKruto" followed by this version of MTKruto.
|
|
35
35
|
*/
|
|
36
36
|
appVersion?: string;
|
|
37
37
|
/**
|
|
38
|
-
* The device_version parameter to be passed to initConnection when calling `authorize`.
|
|
38
|
+
* The device_version parameter to be passed to initConnection when calling `authorize`. The default varies by the current runtime.
|
|
39
39
|
*/
|
|
40
40
|
deviceModel?: string;
|
|
41
41
|
/**
|
|
42
|
-
* The lang_code parameter to be passed to initConnection when calling `authorize`.
|
|
42
|
+
* The lang_code parameter to be passed to initConnection when calling `authorize`. Defaults to the runtime's language or `"en"`.
|
|
43
43
|
*/
|
|
44
44
|
langCode?: string;
|
|
45
45
|
/**
|
|
46
|
-
* The lang_pack parameter to be passed to initConnection when calling `authorize`.
|
|
46
|
+
* The lang_pack parameter to be passed to initConnection when calling `authorize`. Defaults to an empty string.
|
|
47
47
|
*/
|
|
48
48
|
langPack?: string;
|
|
49
49
|
/**
|
|
50
|
-
* The system_lang_cde parameter to be passed to initConnection when calling `authorize`.
|
|
50
|
+
* The system_lang_cde parameter to be passed to initConnection when calling `authorize`. Defaults to the runtime's language or `"en"`.
|
|
51
51
|
*/
|
|
52
52
|
systemLangCode?: string;
|
|
53
53
|
/**
|
|
54
|
-
* The system_version parameter to be passed to initConnection when calling `authorize`.
|
|
54
|
+
* The system_version parameter to be passed to initConnection when calling `authorize`. The default varies by the current runtime.
|
|
55
55
|
*/
|
|
56
56
|
systemVersion?: string;
|
|
57
57
|
/**
|
|
58
|
-
* Whether to automatically call `start` with no parameters in the first `invoke` call.
|
|
58
|
+
* Whether to automatically call `start` with no parameters in the first `invoke` call. Defaults to `true`.
|
|
59
59
|
*/
|
|
60
60
|
autoStart?: boolean;
|
|
61
61
|
}
|
|
@@ -171,6 +171,7 @@ export declare class Client extends ClientAbstract {
|
|
|
171
171
|
*/
|
|
172
172
|
constructor(storage?: Storage, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
|
|
173
173
|
private propagateConnectionState;
|
|
174
|
+
private lastPropagatedConnectionState;
|
|
174
175
|
protected stateChangeHandler: (connected: boolean) => void;
|
|
175
176
|
private storageInited;
|
|
176
177
|
/**
|
|
@@ -308,7 +309,7 @@ export declare class Client extends ClientAbstract {
|
|
|
308
309
|
private handleUpdate;
|
|
309
310
|
handler: Handler;
|
|
310
311
|
use(middleware: Handler): void;
|
|
311
|
-
on<U extends keyof Update, K extends keyof Update[U]>(filter: Update[U] extends string ? U : U | [U, ...K[]], handler: Handler<Pick<{
|
|
312
|
+
on<U extends keyof Update, K extends keyof Update[U]>(filter: Update[U] extends string ? U : Update[U] extends Array<any> ? U : U | [U, ...K[]], handler: Handler<Pick<{
|
|
312
313
|
[P in U]: With<Update[U], K>;
|
|
313
314
|
}, U>>): void;
|
|
314
315
|
}
|
|
@@ -318,6 +319,7 @@ export interface Update {
|
|
|
318
319
|
message: Message;
|
|
319
320
|
editedMessage: Message;
|
|
320
321
|
connectionState: ConnectionState;
|
|
322
|
+
deletedMessages: [Message, ...Message[]];
|
|
321
323
|
}
|
|
322
324
|
export interface Handler<U extends Partial<Update> = Partial<Update>> {
|
|
323
325
|
(update: U, next: () => Promise<void>): MaybePromise<void>;
|
package/esm/client/3_client.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { debug, gunzip, Mutex } from "../deps.js";
|
|
2
2
|
import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL, ZERO_CHANNEL_ID } from "../constants.js";
|
|
3
|
+
import { drop, mustPrompt, mustPromptOneOf } from "../utilities/1_misc.js";
|
|
3
4
|
import { bigIntFromBuffer, getRandomBigInt, getRandomId } from "../utilities/0_bigint.js";
|
|
5
|
+
import { getChannelChatId, hasChannelPts, hasPts, peerToChatId } from "./0_utilities.js";
|
|
4
6
|
import { UNREACHABLE } from "../utilities/0_control.js";
|
|
7
|
+
import { Queue } from "../utilities/0_queue.js";
|
|
5
8
|
import { sha1 } from "../utilities/0_hash.js";
|
|
9
|
+
import { TLError } from "../tl/0_tl_raw_reader.js";
|
|
6
10
|
import { as } from "../tl/1_tl_object.js";
|
|
7
11
|
import * as types from "../tl/2_types.js";
|
|
8
|
-
import * as functions from "../tl/3_functions.js";
|
|
9
12
|
import { TLReader } from "../tl/3_tl_reader.js";
|
|
13
|
+
import * as functions from "../tl/3_functions.js";
|
|
10
14
|
import { RPCResult } from "../tl/5_rpc_result.js";
|
|
11
15
|
import { Message as Message_ } from "../tl/6_message.js"; // MTProto API message
|
|
12
16
|
import { MessageContainer } from "../tl/7_message_container.js";
|
|
13
|
-
import { StorageMemory } from "../storage/1_storage_memory.js";
|
|
14
17
|
import { FileID, FileType, ThumbnailSource } from "../types/!0_file_id.js";
|
|
15
|
-
import { messageEntityToTlObject } from "../types/0_message_entity.js";
|
|
16
18
|
import { replyKeyboardRemoveToTlObject } from "../types/0_reply_keyboard_remove.js";
|
|
19
|
+
import { messageEntityToTlObject } from "../types/0_message_entity.js";
|
|
17
20
|
import { forceReplyToTlObject } from "../types/0_force_reply.js";
|
|
18
|
-
import {
|
|
21
|
+
import { constructUser } from "../types/1_user.js";
|
|
19
22
|
import { inlineKeyboardMarkupToTlObject } from "../types/2_inline_keyboard_markup.js";
|
|
23
|
+
import { replyKeyboardMarkupToTlObject } from "../types/2_reply_keyboard_markup.js";
|
|
20
24
|
import { constructMessage } from "../types/3_message.js"; // high-level wrapper for Telegram API's message
|
|
25
|
+
import { StorageMemory } from "../storage/1_storage_memory.js";
|
|
21
26
|
import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
|
|
22
|
-
import { parseHtml } from "./0_html.js";
|
|
23
27
|
import { checkPassword } from "./0_password.js";
|
|
24
|
-
import {
|
|
28
|
+
import { parseHtml } from "./0_html.js";
|
|
25
29
|
import { ClientPlain } from "./2_client_plain.js";
|
|
26
|
-
import {
|
|
27
|
-
import { getChannelChatId, hasChannelPts, hasPts, peerToChatId } from "./0_utilities.js";
|
|
28
|
-
import { constructUser } from "../types/1_user.js";
|
|
29
|
-
import { TLError } from "../tl/0_tl_raw_reader.js";
|
|
30
|
-
import { Queue } from "../utilities/0_queue.js";
|
|
30
|
+
import { ClientAbstract } from "./1_client_abstract.js";
|
|
31
31
|
const d = debug("Client");
|
|
32
32
|
const dGap = debug("Client/recoverUpdateGap");
|
|
33
33
|
const dGapC = debug("Client/recoverChannelUpdateGap");
|
|
@@ -161,12 +161,29 @@ export class Client extends ClientAbstract {
|
|
|
161
161
|
writable: true,
|
|
162
162
|
value: void 0
|
|
163
163
|
});
|
|
164
|
+
Object.defineProperty(this, "lastPropagatedConnectionState", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
configurable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: null
|
|
169
|
+
});
|
|
164
170
|
Object.defineProperty(this, "stateChangeHandler", {
|
|
165
171
|
enumerable: true,
|
|
166
172
|
configurable: true,
|
|
167
173
|
writable: true,
|
|
168
174
|
value: ((connected) => {
|
|
169
|
-
this.
|
|
175
|
+
this.connectMutex.acquire().then(async (release) => {
|
|
176
|
+
try {
|
|
177
|
+
const connectionState = connected ? "ready" : "not-connected";
|
|
178
|
+
if (this.connected == connected && this.lastPropagatedConnectionState != connectionState) {
|
|
179
|
+
await this.propagateConnectionState(connectionState);
|
|
180
|
+
this.lastPropagatedConnectionState = connectionState;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
release();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
170
187
|
}).bind(this)
|
|
171
188
|
});
|
|
172
189
|
Object.defineProperty(this, "storageInited", {
|
|
@@ -203,13 +220,13 @@ export class Client extends ClientAbstract {
|
|
|
203
220
|
enumerable: true,
|
|
204
221
|
configurable: true,
|
|
205
222
|
writable: true,
|
|
206
|
-
value: new Queue()
|
|
223
|
+
value: new Queue("handleUpdate")
|
|
207
224
|
});
|
|
208
225
|
Object.defineProperty(this, "processUpdatesQueue", {
|
|
209
226
|
enumerable: true,
|
|
210
227
|
configurable: true,
|
|
211
228
|
writable: true,
|
|
212
|
-
value: new Queue()
|
|
229
|
+
value: new Queue("processUpdates")
|
|
213
230
|
});
|
|
214
231
|
Object.defineProperty(this, "handler", {
|
|
215
232
|
enumerable: true,
|
|
@@ -561,7 +578,7 @@ export class Client extends ClientAbstract {
|
|
|
561
578
|
body = new TLReader(gunzip(body.packedData)).readObject();
|
|
562
579
|
}
|
|
563
580
|
dRecv("received %s", body.constructor.name);
|
|
564
|
-
if (body instanceof types.
|
|
581
|
+
if (body instanceof types._TypeUpdates || body instanceof types._TypeUpdate) {
|
|
565
582
|
this.processUpdatesQueue.add(() => this.processUpdates(body));
|
|
566
583
|
}
|
|
567
584
|
else if (message.body instanceof RPCResult) {
|
|
@@ -588,7 +605,7 @@ export class Client extends ClientAbstract {
|
|
|
588
605
|
this.promises.delete(messageId);
|
|
589
606
|
}
|
|
590
607
|
};
|
|
591
|
-
if (result instanceof types.
|
|
608
|
+
if (result instanceof types._TypeUpdates || result instanceof types._TypeUpdate) {
|
|
592
609
|
this.processUpdatesQueue.add(async () => {
|
|
593
610
|
await this.processUpdates(result);
|
|
594
611
|
resolvePromise();
|
|
@@ -692,7 +709,7 @@ export class Client extends ClientAbstract {
|
|
|
692
709
|
await this.storage.updateUsernames("channel", chat.id, [chat.username]);
|
|
693
710
|
}
|
|
694
711
|
if (chat.usernames) {
|
|
695
|
-
await this.storage.updateUsernames("channel", chat.id, chat.usernames.map((v) => v
|
|
712
|
+
await this.storage.updateUsernames("channel", chat.id, chat.usernames.map((v) => v.username));
|
|
696
713
|
}
|
|
697
714
|
}
|
|
698
715
|
else if (chat instanceof types.Chat) {
|
|
@@ -709,7 +726,7 @@ export class Client extends ClientAbstract {
|
|
|
709
726
|
await this.storage.updateUsernames("user", user.id, [user.username]);
|
|
710
727
|
}
|
|
711
728
|
if (user.usernames) {
|
|
712
|
-
await this.storage.updateUsernames("user", user.id, user.usernames.map((v) => v
|
|
729
|
+
await this.storage.updateUsernames("user", user.id, user.usernames.map((v) => v.username));
|
|
713
730
|
}
|
|
714
731
|
}
|
|
715
732
|
}
|
|
@@ -763,7 +780,7 @@ export class Client extends ClientAbstract {
|
|
|
763
780
|
await this.recoverUpdateGap("updatesTooLong");
|
|
764
781
|
return;
|
|
765
782
|
}
|
|
766
|
-
else if (updates_ instanceof types.
|
|
783
|
+
else if (updates_ instanceof types._TypeUpdate) {
|
|
767
784
|
updates = [updates_];
|
|
768
785
|
}
|
|
769
786
|
else {
|
|
@@ -842,7 +859,7 @@ export class Client extends ClientAbstract {
|
|
|
842
859
|
await this.recoverChannelUpdateGap(update.channelId, "updateChannelTooLong");
|
|
843
860
|
}
|
|
844
861
|
else if (update instanceof types.UpdateUserName) {
|
|
845
|
-
await this.storage.updateUsernames("user", update.userId, update.usernames.map((v) => v
|
|
862
|
+
await this.storage.updateUsernames("user", update.userId, update.usernames.map((v) => v.username));
|
|
846
863
|
}
|
|
847
864
|
else if (update instanceof types.UpdatePtsChanged) {
|
|
848
865
|
await this.fetchState("updatePtsChanged");
|
|
@@ -854,7 +871,7 @@ export class Client extends ClientAbstract {
|
|
|
854
871
|
}
|
|
855
872
|
}
|
|
856
873
|
/// If there were any Update, they will be passed to the update handling queue.
|
|
857
|
-
if (update instanceof types.
|
|
874
|
+
if (update instanceof types._TypeUpdate) {
|
|
858
875
|
updatesToHandle.push(update);
|
|
859
876
|
}
|
|
860
877
|
}
|
|
@@ -906,12 +923,12 @@ export class Client extends ClientAbstract {
|
|
|
906
923
|
await this.processUpdates(update, true);
|
|
907
924
|
}
|
|
908
925
|
if (difference instanceof types.UpdatesDifference) {
|
|
909
|
-
await this.storage.setState(difference.state
|
|
926
|
+
await this.storage.setState(difference.state);
|
|
910
927
|
dGap("recovered from update gap");
|
|
911
928
|
break;
|
|
912
929
|
}
|
|
913
930
|
else if (difference instanceof types.UpdatesDifferenceSlice) {
|
|
914
|
-
state = difference.intermediateState
|
|
931
|
+
state = difference.intermediateState;
|
|
915
932
|
}
|
|
916
933
|
else {
|
|
917
934
|
UNREACHABLE();
|
|
@@ -1364,7 +1381,7 @@ export class Client extends ClientAbstract {
|
|
|
1364
1381
|
}
|
|
1365
1382
|
else {
|
|
1366
1383
|
const stickerSet = await this.invoke(new functions.MessagesGetStickerSet({ stickerset: inputStickerSet, hash }));
|
|
1367
|
-
const name = stickerSet[as](types.MessagesStickerSet).set
|
|
1384
|
+
const name = stickerSet[as](types.MessagesStickerSet).set.shortName;
|
|
1368
1385
|
await this.storage.updateStickerSetName(inputStickerSet.id, inputStickerSet.accessHash, name);
|
|
1369
1386
|
return name;
|
|
1370
1387
|
}
|
|
@@ -1411,25 +1428,13 @@ export class Client extends ClientAbstract {
|
|
|
1411
1428
|
}
|
|
1412
1429
|
return constructUser(users[0][as](types.User));
|
|
1413
1430
|
}
|
|
1431
|
+
// TODO: log errors
|
|
1414
1432
|
async handleUpdate(update) {
|
|
1415
1433
|
if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateNewChannelMessage) {
|
|
1416
1434
|
if (update.message instanceof types.Message || update.message instanceof types.MessageService) {
|
|
1417
1435
|
await this.storage.setMessage(peerToChatId(update.message.peerId), update.message.id, update.message);
|
|
1418
1436
|
}
|
|
1419
1437
|
}
|
|
1420
|
-
else if (update instanceof types.UpdateDeleteChannelMessages) {
|
|
1421
|
-
for (const message of update.messages) {
|
|
1422
|
-
await this.storage.setMessage(getChannelChatId(update.channelId), message, null);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
else if (update instanceof types.UpdateDeleteMessages) {
|
|
1426
|
-
for (const message of update.messages) {
|
|
1427
|
-
const chatId = await this.storage.getMessageChat(message);
|
|
1428
|
-
if (chatId) {
|
|
1429
|
-
await this.storage.setMessage(chatId, message, null);
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
1438
|
if (update instanceof types.UpdateNewMessage ||
|
|
1434
1439
|
update instanceof types.UpdateNewChannelMessage ||
|
|
1435
1440
|
update instanceof types.UpdateEditMessage ||
|
|
@@ -1438,6 +1443,36 @@ export class Client extends ClientAbstract {
|
|
|
1438
1443
|
const message = await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this));
|
|
1439
1444
|
await this.handler({ [key]: message }, resolve);
|
|
1440
1445
|
}
|
|
1446
|
+
if (update instanceof types.UpdateDeleteMessages) {
|
|
1447
|
+
const deletedMessages = new Array();
|
|
1448
|
+
for (const messageId of update.messages) {
|
|
1449
|
+
const chatId = await this.storage.getMessageChat(messageId);
|
|
1450
|
+
if (chatId) {
|
|
1451
|
+
const message = await this.storage.getMessage(chatId, messageId);
|
|
1452
|
+
if (message != null) {
|
|
1453
|
+
deletedMessages.push(await constructMessage(message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1454
|
+
}
|
|
1455
|
+
await this.storage.setMessage(chatId, messageId, null);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
if (deletedMessages.length > 0) {
|
|
1459
|
+
await this.handler({ deletedMessages: deletedMessages }, resolve);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
else if (update instanceof types.UpdateDeleteChannelMessages) {
|
|
1463
|
+
const chatId = getChannelChatId(update.channelId);
|
|
1464
|
+
const deletedMessages = new Array();
|
|
1465
|
+
for (const messageId of update.messages) {
|
|
1466
|
+
const message = await this.storage.getMessage(chatId, messageId);
|
|
1467
|
+
if (message) {
|
|
1468
|
+
deletedMessages.push(await constructMessage(message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1469
|
+
}
|
|
1470
|
+
await this.storage.setMessage(chatId, messageId, null);
|
|
1471
|
+
}
|
|
1472
|
+
if (deletedMessages.length > 0) {
|
|
1473
|
+
await this.handler({ deletedMessages: deletedMessages }, resolve);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1441
1476
|
}
|
|
1442
1477
|
use(middleware) {
|
|
1443
1478
|
const handler = this.handler;
|
|
@@ -1451,7 +1486,9 @@ export class Client extends ClientAbstract {
|
|
|
1451
1486
|
});
|
|
1452
1487
|
};
|
|
1453
1488
|
}
|
|
1454
|
-
on(
|
|
1489
|
+
on(
|
|
1490
|
+
// deno-lint-ignore no-explicit-any
|
|
1491
|
+
filter, handler) {
|
|
1455
1492
|
const type = typeof filter === "string" ? filter : filter[0];
|
|
1456
1493
|
const keys = Array.isArray(filter) ? filter.slice(1) : [];
|
|
1457
1494
|
this.use((update, next) => {
|
package/esm/constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 161;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.0.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.0.990";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/esm/constants.js
CHANGED
|
@@ -54,7 +54,7 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
54
54
|
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
55
55
|
export const INITIAL_DC = "2-test";
|
|
56
56
|
export const LAYER = 161;
|
|
57
|
-
export const APP_VERSION = "MTKruto 0.0.
|
|
57
|
+
export const APP_VERSION = "MTKruto 0.0.990";
|
|
58
58
|
// @ts-ignore: lib
|
|
59
59
|
export const 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;
|
|
60
60
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|