@mtkruto/node 0.1.114 → 0.1.115
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/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/3_types.d.ts +4 -0
- package/esm/client/5_client.d.ts +1 -1
- package/esm/client/5_client.js +33 -38
- package/package.json +1 -1
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/3_types.d.ts +4 -0
- package/script/client/5_client.d.ts +1 -1
- package/script/client/5_client.js +33 -38
package/esm/4_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 = 166;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.115";
|
|
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/4_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";
|
|
56
56
|
export const LAYER = 166;
|
|
57
|
-
export const APP_VERSION = "MTKruto 0.1.
|
|
57
|
+
export const APP_VERSION = "MTKruto 0.1.115";
|
|
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];
|
package/esm/client/3_types.d.ts
CHANGED
|
@@ -41,6 +41,10 @@ export interface ClientParams extends ClientPlainParams {
|
|
|
41
41
|
* Whether to use default handlers. Defaults to `true`.
|
|
42
42
|
*/
|
|
43
43
|
defaultHandlers?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to ignore outgoing messages. Defaults to `true` for bots, and `false` for users.
|
|
46
|
+
*/
|
|
47
|
+
ignoreOutgoing?: boolean;
|
|
44
48
|
}
|
|
45
49
|
export interface AnswerCallbackQueryParams {
|
|
46
50
|
/** A text to be shown to the user. */
|
package/esm/client/5_client.d.ts
CHANGED
|
@@ -135,7 +135,7 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
135
135
|
* Alias for `invoke` with its second parameter being `true`.
|
|
136
136
|
*/
|
|
137
137
|
send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
|
|
138
|
-
checkGap(pts: number, ptsCount: number
|
|
138
|
+
checkGap(pts: number, ptsCount: number): Promise<void>;
|
|
139
139
|
getUserAccessHash(userId: bigint): Promise<bigint>;
|
|
140
140
|
getInputPeer(id: ChatID): Promise<types.InputPeerChat | types.InputPeerUser | types.InputPeerChannel>;
|
|
141
141
|
private [getEntity];
|
package/esm/client/5_client.js
CHANGED
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
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");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkChannelGap, _Client_processUpdates, _Client_setUpdateStateDate, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo;
|
|
12
|
+
var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkChannelGap, _Client_processUpdates, _Client_setUpdateStateDate, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo;
|
|
13
13
|
import { debug, gunzip, Mutex } from "../0_deps.js";
|
|
14
14
|
import { bigIntFromBuffer, drop, getRandomBigInt, getRandomId, mod, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
15
15
|
import { as, functions, getChannelChatId, Message_, MessageContainer, peerToChatId, RPCResult, TLError, TLReader, types } from "../2_tl.js";
|
|
@@ -119,6 +119,7 @@ export class Client extends ClientAbstract {
|
|
|
119
119
|
});
|
|
120
120
|
_Client_publicKeys.set(this, void 0);
|
|
121
121
|
_Client_autoStart.set(this, void 0);
|
|
122
|
+
_Client_ignoreOutgoing.set(this, void 0);
|
|
122
123
|
_Client_constructContext.set(this, (update) => {
|
|
123
124
|
const msg = update.message ?? update.editedMessage ?? update.callbackQuery?.message;
|
|
124
125
|
const mustGetMsg = () => {
|
|
@@ -292,6 +293,7 @@ export class Client extends ClientAbstract {
|
|
|
292
293
|
this.systemVersion = params?.systemVersion ?? SYSTEM_VERSION;
|
|
293
294
|
__classPrivateFieldSet(this, _Client_publicKeys, params?.publicKeys, "f");
|
|
294
295
|
__classPrivateFieldSet(this, _Client_autoStart, params?.autoStart ?? true, "f");
|
|
296
|
+
__classPrivateFieldSet(this, _Client_ignoreOutgoing, params?.ignoreOutgoing ?? null, "f");
|
|
295
297
|
if (params?.defaultHandlers ?? true) {
|
|
296
298
|
this.on("connectionState", ({ connectionState }, next) => {
|
|
297
299
|
drop((async () => {
|
|
@@ -401,7 +403,7 @@ export class Client extends ClientAbstract {
|
|
|
401
403
|
release();
|
|
402
404
|
}
|
|
403
405
|
}
|
|
404
|
-
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
406
|
+
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
405
407
|
__classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
|
|
406
408
|
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { connectionState }), resolve);
|
|
407
409
|
});
|
|
@@ -639,24 +641,19 @@ export class Client extends ClientAbstract {
|
|
|
639
641
|
send(function_) {
|
|
640
642
|
return this.invoke(function_, true);
|
|
641
643
|
}
|
|
642
|
-
async checkGap(pts, ptsCount
|
|
644
|
+
async checkGap(pts, ptsCount) {
|
|
643
645
|
const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
644
646
|
if (localState.pts + ptsCount < pts) {
|
|
645
|
-
|
|
646
|
-
UNREACHABLE();
|
|
647
|
-
}
|
|
648
|
-
else {
|
|
649
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
|
|
650
|
-
}
|
|
647
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
|
|
651
648
|
}
|
|
652
649
|
}
|
|
653
650
|
async getUserAccessHash(userId) {
|
|
654
651
|
const users = await this.invoke(new functions.UsersGetUsers({ id: [new types.InputUser({ userId, accessHash: 0n })] }));
|
|
655
|
-
return users[0][as](types.User).accessHash ?? 0n;
|
|
652
|
+
return users[0]?.[as](types.User).accessHash ?? 0n;
|
|
656
653
|
}
|
|
657
654
|
async getInputPeer(id) {
|
|
658
655
|
const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
|
|
659
|
-
if (inputPeer instanceof types.InputPeerUser || inputPeer instanceof types.InputPeerChannel && inputPeer.accessHash == 0n && await this.storage.getAccountType() == "bot") {
|
|
656
|
+
if ((inputPeer instanceof types.InputPeerUser || inputPeer instanceof types.InputPeerChannel && inputPeer.accessHash == 0n) && await this.storage.getAccountType() == "bot") {
|
|
660
657
|
if ("channelId" in inputPeer) {
|
|
661
658
|
inputPeer.accessHash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channelId);
|
|
662
659
|
}
|
|
@@ -723,7 +720,7 @@ export class Client extends ClientAbstract {
|
|
|
723
720
|
}
|
|
724
721
|
dRecv("received %s", body.constructor.name);
|
|
725
722
|
if (body instanceof types._TypeUpdates || body instanceof types._TypeUpdate) {
|
|
726
|
-
__classPrivateFieldGet(this, _Client_processUpdatesQueue, "f").add(() => __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, body));
|
|
723
|
+
__classPrivateFieldGet(this, _Client_processUpdatesQueue, "f").add(() => __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, body, true));
|
|
727
724
|
}
|
|
728
725
|
else if (body instanceof types.NewSessionCreated) {
|
|
729
726
|
__classPrivateFieldGet(this, _Client_state, "f").salt = body.serverSalt;
|
|
@@ -755,7 +752,7 @@ export class Client extends ClientAbstract {
|
|
|
755
752
|
};
|
|
756
753
|
if (result instanceof types._TypeUpdates || result instanceof types._TypeUpdate) {
|
|
757
754
|
__classPrivateFieldGet(this, _Client_processUpdatesQueue, "f").add(async () => {
|
|
758
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, result);
|
|
755
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, result, true);
|
|
759
756
|
resolvePromise();
|
|
760
757
|
});
|
|
761
758
|
}
|
|
@@ -911,20 +908,15 @@ export class Client extends ClientAbstract {
|
|
|
911
908
|
}
|
|
912
909
|
}
|
|
913
910
|
}
|
|
914
|
-
}, _Client_checkChannelGap = async function _Client_checkChannelGap(channelId, pts, ptsCount
|
|
911
|
+
}, _Client_checkChannelGap = async function _Client_checkChannelGap(channelId, pts, ptsCount) {
|
|
915
912
|
let localPts = await this.storage.getChannelPts(channelId);
|
|
916
913
|
if (!localPts) {
|
|
917
914
|
localPts = pts - ptsCount;
|
|
918
915
|
}
|
|
919
916
|
if (localPts + ptsCount < pts) {
|
|
920
|
-
|
|
921
|
-
UNREACHABLE();
|
|
922
|
-
}
|
|
923
|
-
else {
|
|
924
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
|
|
925
|
-
}
|
|
917
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
|
|
926
918
|
}
|
|
927
|
-
}, _Client_processUpdates = async function _Client_processUpdates(updates_,
|
|
919
|
+
}, _Client_processUpdates = async function _Client_processUpdates(updates_, checkGap) {
|
|
928
920
|
/// First, individual updates (Update[1]) and updateShort* are extracted from Updates.[2]
|
|
929
921
|
///
|
|
930
922
|
/// If an updatesTooLong[3] was received, an update gap recovery is initiated and no further action will be taken.
|
|
@@ -966,7 +958,9 @@ export class Client extends ClientAbstract {
|
|
|
966
958
|
if (update.pts == 0) {
|
|
967
959
|
continue;
|
|
968
960
|
}
|
|
969
|
-
|
|
961
|
+
if (checkGap) {
|
|
962
|
+
await this.checkGap(update.pts, update.ptsCount);
|
|
963
|
+
}
|
|
970
964
|
localState ??= await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
971
965
|
originalPts ??= localState.pts;
|
|
972
966
|
if (localState.pts + update.ptsCount > update.pts) {
|
|
@@ -982,7 +976,9 @@ export class Client extends ClientAbstract {
|
|
|
982
976
|
}
|
|
983
977
|
const ptsCount = update.ptsCount;
|
|
984
978
|
const channelId = update instanceof types.UpdateNewChannelMessage || update instanceof types.UpdateEditChannelMessage ? update.message.peerId[as](types.PeerChannel).channelId : update.channelId;
|
|
985
|
-
|
|
979
|
+
if (checkGap) {
|
|
980
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkChannelGap).call(this, channelId, update.pts, ptsCount);
|
|
981
|
+
}
|
|
986
982
|
let currentPts = channelPtsMap.get(channelId);
|
|
987
983
|
if (currentPts === undefined) {
|
|
988
984
|
currentPts = await this.storage.getChannelPts(channelId);
|
|
@@ -996,14 +992,6 @@ export class Client extends ClientAbstract {
|
|
|
996
992
|
}
|
|
997
993
|
}
|
|
998
994
|
}
|
|
999
|
-
if (!assertNoGap) {
|
|
1000
|
-
if (localState != null && originalPts != null && localState.pts != originalPts) {
|
|
1001
|
-
await this.storage.setState(localState);
|
|
1002
|
-
}
|
|
1003
|
-
for (const [channelId, pts] of channelPtsMap.entries()) {
|
|
1004
|
-
await this.storage.setChannelPts(channelId, pts);
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
995
|
/// We process the updates when we are sure there is no gap.
|
|
1008
996
|
if (updates_ instanceof types.Updates || updates_ instanceof types.UpdatesCombined) {
|
|
1009
997
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, updates_.chats);
|
|
@@ -1082,10 +1070,10 @@ export class Client extends ClientAbstract {
|
|
|
1082
1070
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1083
1071
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
1084
1072
|
for (const message of difference.newMessages) {
|
|
1085
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new types.UpdateNewMessage({ message, pts: 0, ptsCount: 0 }),
|
|
1073
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new types.UpdateNewMessage({ message, pts: 0, ptsCount: 0 }), false);
|
|
1086
1074
|
}
|
|
1087
1075
|
for (const update of difference.otherUpdates) {
|
|
1088
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update,
|
|
1076
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update, false);
|
|
1089
1077
|
}
|
|
1090
1078
|
if (difference instanceof types.UpdatesDifference) {
|
|
1091
1079
|
await this.storage.setState(difference.state);
|
|
@@ -1133,10 +1121,10 @@ export class Client extends ClientAbstract {
|
|
|
1133
1121
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1134
1122
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
1135
1123
|
for (const message of difference.newMessages) {
|
|
1136
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }),
|
|
1124
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), false);
|
|
1137
1125
|
}
|
|
1138
1126
|
for (const update of difference.otherUpdates) {
|
|
1139
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update,
|
|
1127
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update, false);
|
|
1140
1128
|
}
|
|
1141
1129
|
await this.storage.setChannelPts(channelId, difference.pts);
|
|
1142
1130
|
dGapC("recovered from update gap [%o, %s]", channelId, source);
|
|
@@ -1148,7 +1136,7 @@ export class Client extends ClientAbstract {
|
|
|
1148
1136
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1149
1137
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
1150
1138
|
for (const message of difference.messages) {
|
|
1151
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }),
|
|
1139
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), false);
|
|
1152
1140
|
}
|
|
1153
1141
|
const pts_ = difference.dialog[as](types.Dialog).pts;
|
|
1154
1142
|
if (pts_ != undefined) {
|
|
@@ -2102,8 +2090,15 @@ async function _Client_handleUpdate(update) {
|
|
|
2102
2090
|
update instanceof types.UpdateEditChannelMessage) {
|
|
2103
2091
|
const key = update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage ? "message" : "editedMessage";
|
|
2104
2092
|
if (!(update.message instanceof types.MessageEmpty)) {
|
|
2105
|
-
const
|
|
2106
|
-
|
|
2093
|
+
const isOutgoing = update.message.out;
|
|
2094
|
+
let shouldIgnore = isOutgoing ? (await this.storage.getAccountType()) == "user" ? false : true : false;
|
|
2095
|
+
if (__classPrivateFieldGet(this, _Client_ignoreOutgoing, "f") != null && isOutgoing) {
|
|
2096
|
+
shouldIgnore = __classPrivateFieldGet(this, _Client_ignoreOutgoing, "f");
|
|
2097
|
+
}
|
|
2098
|
+
if (!shouldIgnore) {
|
|
2099
|
+
const message = await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this));
|
|
2100
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { [key]: message }), resolve);
|
|
2101
|
+
}
|
|
2107
2102
|
}
|
|
2108
2103
|
}
|
|
2109
2104
|
if (update instanceof types.UpdateDeleteMessages) {
|
package/package.json
CHANGED
package/script/4_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 = 166;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.115";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
80
80
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
81
81
|
exports.INITIAL_DC = "2";
|
|
82
82
|
exports.LAYER = 166;
|
|
83
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
83
|
+
exports.APP_VERSION = "MTKruto 0.1.115";
|
|
84
84
|
// @ts-ignore: lib
|
|
85
85
|
exports.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;
|
|
86
86
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -41,6 +41,10 @@ export interface ClientParams extends ClientPlainParams {
|
|
|
41
41
|
* Whether to use default handlers. Defaults to `true`.
|
|
42
42
|
*/
|
|
43
43
|
defaultHandlers?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to ignore outgoing messages. Defaults to `true` for bots, and `false` for users.
|
|
46
|
+
*/
|
|
47
|
+
ignoreOutgoing?: boolean;
|
|
44
48
|
}
|
|
45
49
|
export interface AnswerCallbackQueryParams {
|
|
46
50
|
/** A text to be shown to the user. */
|
|
@@ -135,7 +135,7 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
|
|
|
135
135
|
* Alias for `invoke` with its second parameter being `true`.
|
|
136
136
|
*/
|
|
137
137
|
send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
|
|
138
|
-
checkGap(pts: number, ptsCount: number
|
|
138
|
+
checkGap(pts: number, ptsCount: number): Promise<void>;
|
|
139
139
|
getUserAccessHash(userId: bigint): Promise<bigint>;
|
|
140
140
|
getInputPeer(id: ChatID): Promise<types.InputPeerChat | types.InputPeerUser | types.InputPeerChannel>;
|
|
141
141
|
private [getEntity];
|
|
@@ -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 _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkChannelGap, _Client_processUpdates, _Client_setUpdateStateDate, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo;
|
|
13
|
+
var _Client_instances, _a, _Client_auth, _Client_sessionId, _Client_state, _Client_promises, _Client_toAcknowledge, _Client_updateState, _Client_publicKeys, _Client_autoStart, _Client_ignoreOutgoing, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_storageInited, _Client_setAuth, _Client_authKeyWasCreated, _Client_connectMutex, _Client_assertUser, _Client_assertBot, _Client_fetchState, _Client_connectionInited, _Client_initConnection, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_selfId, _Client_getSelfId, _Client_receiveLoop, _Client_pingInterval, _Client_pingLoop, _Client_pingLoopStarted, _Client_autoStarted, _Client_lastMsgId, _Client_invoke, _Client_handleInvokeError, _Client_processChats, _Client_processUsers, _Client_handleUpdateQueue, _Client_processUpdatesQueue, _Client_checkChannelGap, _Client_processUpdates, _Client_setUpdateStateDate, _Client_getLocalState, _Client_recoverUpdateGap, _Client_recoverChannelUpdateGap, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_updatesToMessages, _Client_resolveSendAs, _Client_parseText, _Client_getMessagesInner, _Client_downloadInner, _Client_handleUpdate, _Client_usernameResolver, _Client_constructReplyMarkup, _Client_assertMsgHas, _Client_handle, _Client_setMyInfo, _Client_getMyInfo;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Client = exports.ConnectionError = exports.restartAuth = exports.skipInvoke = exports.handleMigrationError = void 0;
|
|
16
16
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -124,6 +124,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
124
124
|
});
|
|
125
125
|
_Client_publicKeys.set(this, void 0);
|
|
126
126
|
_Client_autoStart.set(this, void 0);
|
|
127
|
+
_Client_ignoreOutgoing.set(this, void 0);
|
|
127
128
|
_Client_constructContext.set(this, (update) => {
|
|
128
129
|
const msg = update.message ?? update.editedMessage ?? update.callbackQuery?.message;
|
|
129
130
|
const mustGetMsg = () => {
|
|
@@ -297,6 +298,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
297
298
|
this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
|
|
298
299
|
__classPrivateFieldSet(this, _Client_publicKeys, params?.publicKeys, "f");
|
|
299
300
|
__classPrivateFieldSet(this, _Client_autoStart, params?.autoStart ?? true, "f");
|
|
301
|
+
__classPrivateFieldSet(this, _Client_ignoreOutgoing, params?.ignoreOutgoing ?? null, "f");
|
|
300
302
|
if (params?.defaultHandlers ?? true) {
|
|
301
303
|
this.on("connectionState", ({ connectionState }, next) => {
|
|
302
304
|
(0, _1_utilities_js_1.drop)((async () => {
|
|
@@ -406,7 +408,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
406
408
|
release();
|
|
407
409
|
}
|
|
408
410
|
}
|
|
409
|
-
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
411
|
+
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
410
412
|
__classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
|
|
411
413
|
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { connectionState }), _0_utilities_js_1.resolve);
|
|
412
414
|
});
|
|
@@ -644,24 +646,19 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
644
646
|
send(function_) {
|
|
645
647
|
return this.invoke(function_, true);
|
|
646
648
|
}
|
|
647
|
-
async checkGap(pts, ptsCount
|
|
649
|
+
async checkGap(pts, ptsCount) {
|
|
648
650
|
const localState = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
649
651
|
if (localState.pts + ptsCount < pts) {
|
|
650
|
-
|
|
651
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
|
|
655
|
-
}
|
|
652
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverUpdateGap).call(this, "processUpdates");
|
|
656
653
|
}
|
|
657
654
|
}
|
|
658
655
|
async getUserAccessHash(userId) {
|
|
659
656
|
const users = await this.invoke(new _2_tl_js_1.functions.UsersGetUsers({ id: [new _2_tl_js_1.types.InputUser({ userId, accessHash: 0n })] }));
|
|
660
|
-
return users[0][_2_tl_js_1.as](_2_tl_js_1.types.User).accessHash ?? 0n;
|
|
657
|
+
return users[0]?.[_2_tl_js_1.as](_2_tl_js_1.types.User).accessHash ?? 0n;
|
|
661
658
|
}
|
|
662
659
|
async getInputPeer(id) {
|
|
663
660
|
const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
|
|
664
|
-
if (inputPeer instanceof _2_tl_js_1.types.InputPeerUser || inputPeer instanceof _2_tl_js_1.types.InputPeerChannel && inputPeer.accessHash == 0n && await this.storage.getAccountType() == "bot") {
|
|
661
|
+
if ((inputPeer instanceof _2_tl_js_1.types.InputPeerUser || inputPeer instanceof _2_tl_js_1.types.InputPeerChannel && inputPeer.accessHash == 0n) && await this.storage.getAccountType() == "bot") {
|
|
665
662
|
if ("channelId" in inputPeer) {
|
|
666
663
|
inputPeer.accessHash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channelId);
|
|
667
664
|
}
|
|
@@ -728,7 +725,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
728
725
|
}
|
|
729
726
|
dRecv("received %s", body.constructor.name);
|
|
730
727
|
if (body instanceof _2_tl_js_1.types._TypeUpdates || body instanceof _2_tl_js_1.types._TypeUpdate) {
|
|
731
|
-
__classPrivateFieldGet(this, _Client_processUpdatesQueue, "f").add(() => __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, body));
|
|
728
|
+
__classPrivateFieldGet(this, _Client_processUpdatesQueue, "f").add(() => __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, body, true));
|
|
732
729
|
}
|
|
733
730
|
else if (body instanceof _2_tl_js_1.types.NewSessionCreated) {
|
|
734
731
|
__classPrivateFieldGet(this, _Client_state, "f").salt = body.serverSalt;
|
|
@@ -760,7 +757,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
760
757
|
};
|
|
761
758
|
if (result instanceof _2_tl_js_1.types._TypeUpdates || result instanceof _2_tl_js_1.types._TypeUpdate) {
|
|
762
759
|
__classPrivateFieldGet(this, _Client_processUpdatesQueue, "f").add(async () => {
|
|
763
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, result);
|
|
760
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, result, true);
|
|
764
761
|
resolvePromise();
|
|
765
762
|
});
|
|
766
763
|
}
|
|
@@ -916,20 +913,15 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
916
913
|
}
|
|
917
914
|
}
|
|
918
915
|
}
|
|
919
|
-
}, _Client_checkChannelGap = async function _Client_checkChannelGap(channelId, pts, ptsCount
|
|
916
|
+
}, _Client_checkChannelGap = async function _Client_checkChannelGap(channelId, pts, ptsCount) {
|
|
920
917
|
let localPts = await this.storage.getChannelPts(channelId);
|
|
921
918
|
if (!localPts) {
|
|
922
919
|
localPts = pts - ptsCount;
|
|
923
920
|
}
|
|
924
921
|
if (localPts + ptsCount < pts) {
|
|
925
|
-
|
|
926
|
-
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
927
|
-
}
|
|
928
|
-
else {
|
|
929
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
|
|
930
|
-
}
|
|
922
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_recoverChannelUpdateGap).call(this, channelId, "processUpdates");
|
|
931
923
|
}
|
|
932
|
-
}, _Client_processUpdates = async function _Client_processUpdates(updates_,
|
|
924
|
+
}, _Client_processUpdates = async function _Client_processUpdates(updates_, checkGap) {
|
|
933
925
|
/// First, individual updates (Update[1]) and updateShort* are extracted from Updates.[2]
|
|
934
926
|
///
|
|
935
927
|
/// If an updatesTooLong[3] was received, an update gap recovery is initiated and no further action will be taken.
|
|
@@ -971,7 +963,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
971
963
|
if (update.pts == 0) {
|
|
972
964
|
continue;
|
|
973
965
|
}
|
|
974
|
-
|
|
966
|
+
if (checkGap) {
|
|
967
|
+
await this.checkGap(update.pts, update.ptsCount);
|
|
968
|
+
}
|
|
975
969
|
localState ??= await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getLocalState).call(this);
|
|
976
970
|
originalPts ??= localState.pts;
|
|
977
971
|
if (localState.pts + update.ptsCount > update.pts) {
|
|
@@ -987,7 +981,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
987
981
|
}
|
|
988
982
|
const ptsCount = update.ptsCount;
|
|
989
983
|
const channelId = update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateEditChannelMessage ? update.message.peerId[_2_tl_js_1.as](_2_tl_js_1.types.PeerChannel).channelId : update.channelId;
|
|
990
|
-
|
|
984
|
+
if (checkGap) {
|
|
985
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_checkChannelGap).call(this, channelId, update.pts, ptsCount);
|
|
986
|
+
}
|
|
991
987
|
let currentPts = channelPtsMap.get(channelId);
|
|
992
988
|
if (currentPts === undefined) {
|
|
993
989
|
currentPts = await this.storage.getChannelPts(channelId);
|
|
@@ -1001,14 +997,6 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1001
997
|
}
|
|
1002
998
|
}
|
|
1003
999
|
}
|
|
1004
|
-
if (!assertNoGap) {
|
|
1005
|
-
if (localState != null && originalPts != null && localState.pts != originalPts) {
|
|
1006
|
-
await this.storage.setState(localState);
|
|
1007
|
-
}
|
|
1008
|
-
for (const [channelId, pts] of channelPtsMap.entries()) {
|
|
1009
|
-
await this.storage.setChannelPts(channelId, pts);
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
1000
|
/// We process the updates when we are sure there is no gap.
|
|
1013
1001
|
if (updates_ instanceof _2_tl_js_1.types.Updates || updates_ instanceof _2_tl_js_1.types.UpdatesCombined) {
|
|
1014
1002
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, updates_.chats);
|
|
@@ -1087,10 +1075,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1087
1075
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1088
1076
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
1089
1077
|
for (const message of difference.newMessages) {
|
|
1090
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new _2_tl_js_1.types.UpdateNewMessage({ message, pts: 0, ptsCount: 0 }),
|
|
1078
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new _2_tl_js_1.types.UpdateNewMessage({ message, pts: 0, ptsCount: 0 }), false);
|
|
1091
1079
|
}
|
|
1092
1080
|
for (const update of difference.otherUpdates) {
|
|
1093
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update,
|
|
1081
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update, false);
|
|
1094
1082
|
}
|
|
1095
1083
|
if (difference instanceof _2_tl_js_1.types.UpdatesDifference) {
|
|
1096
1084
|
await this.storage.setState(difference.state);
|
|
@@ -1138,10 +1126,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1138
1126
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1139
1127
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
1140
1128
|
for (const message of difference.newMessages) {
|
|
1141
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new _2_tl_js_1.types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }),
|
|
1129
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new _2_tl_js_1.types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), false);
|
|
1142
1130
|
}
|
|
1143
1131
|
for (const update of difference.otherUpdates) {
|
|
1144
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update,
|
|
1132
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, update, false);
|
|
1145
1133
|
}
|
|
1146
1134
|
await this.storage.setChannelPts(channelId, difference.pts);
|
|
1147
1135
|
dGapC("recovered from update gap [%o, %s]", channelId, source);
|
|
@@ -1153,7 +1141,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1153
1141
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processChats).call(this, difference.chats);
|
|
1154
1142
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUsers).call(this, difference.users);
|
|
1155
1143
|
for (const message of difference.messages) {
|
|
1156
|
-
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new _2_tl_js_1.types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }),
|
|
1144
|
+
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_processUpdates).call(this, new _2_tl_js_1.types.UpdateNewChannelMessage({ message, pts: 0, ptsCount: 0 }), false);
|
|
1157
1145
|
}
|
|
1158
1146
|
const pts_ = difference.dialog[_2_tl_js_1.as](_2_tl_js_1.types.Dialog).pts;
|
|
1159
1147
|
if (pts_ != undefined) {
|
|
@@ -2108,8 +2096,15 @@ async function _Client_handleUpdate(update) {
|
|
|
2108
2096
|
update instanceof _2_tl_js_1.types.UpdateEditChannelMessage) {
|
|
2109
2097
|
const key = update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage ? "message" : "editedMessage";
|
|
2110
2098
|
if (!(update.message instanceof _2_tl_js_1.types.MessageEmpty)) {
|
|
2111
|
-
const
|
|
2112
|
-
|
|
2099
|
+
const isOutgoing = update.message.out;
|
|
2100
|
+
let shouldIgnore = isOutgoing ? (await this.storage.getAccountType()) == "user" ? false : true : false;
|
|
2101
|
+
if (__classPrivateFieldGet(this, _Client_ignoreOutgoing, "f") != null && isOutgoing) {
|
|
2102
|
+
shouldIgnore = __classPrivateFieldGet(this, _Client_ignoreOutgoing, "f");
|
|
2103
|
+
}
|
|
2104
|
+
if (!shouldIgnore) {
|
|
2105
|
+
const message = await (0, _3_types_js_1.constructMessage)(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this));
|
|
2106
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, { [key]: message }), _0_utilities_js_1.resolve);
|
|
2107
|
+
}
|
|
2113
2108
|
}
|
|
2114
2109
|
}
|
|
2115
2110
|
if (update instanceof _2_tl_js_1.types.UpdateDeleteMessages) {
|