@mtcute/core 0.25.2 → 0.25.4
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/highlevel/methods/messages/send-common.cjs +2 -1
- package/highlevel/methods/messages/send-common.d.cts +4 -0
- package/highlevel/methods/messages/send-common.d.ts +4 -0
- package/highlevel/methods/messages/send-common.js +2 -1
- package/highlevel/methods/premium/get-star-gift-options.cjs +3 -1
- package/highlevel/methods/premium/get-star-gift-options.js +3 -1
- package/highlevel/methods/users/resolve-peer.cjs +28 -20
- package/highlevel/methods/users/resolve-peer.js +28 -20
- package/highlevel/types/messages/message-action.cjs +1 -1
- package/highlevel/types/messages/message-action.js +1 -1
- package/highlevel/types/messages/replied-message.cjs +4 -0
- package/highlevel/types/messages/replied-message.d.cts +2 -0
- package/highlevel/types/messages/replied-message.d.ts +2 -0
- package/highlevel/types/messages/replied-message.js +4 -0
- package/highlevel/types/premium/saved-star-gift.cjs +1 -1
- package/highlevel/types/premium/saved-star-gift.js +1 -1
- package/highlevel/types/premium/stars-gift-unique.cjs +7 -0
- package/highlevel/types/premium/stars-gift-unique.d.cts +4 -0
- package/highlevel/types/premium/stars-gift-unique.d.ts +4 -0
- package/highlevel/types/premium/stars-gift-unique.js +7 -0
- package/highlevel/types/premium/stars-gift.cjs +10 -1
- package/highlevel/types/premium/stars-gift.d.cts +8 -2
- package/highlevel/types/premium/stars-gift.d.ts +8 -2
- package/highlevel/types/premium/stars-gift.js +10 -1
- package/highlevel/types/premium/stars-transaction.cjs +1 -1
- package/highlevel/types/premium/stars-transaction.js +1 -1
- package/highlevel/updates/manager.cjs +2 -2
- package/highlevel/updates/manager.js +2 -2
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/network/session-connection.cjs +2 -2
- package/network/session-connection.js +2 -2
- package/package.json +2 -2
- package/utils/binary/compat.cjs +22 -2
- package/utils/binary/compat.js +22 -2
|
@@ -56,7 +56,8 @@ async function _processCommonSendParameters(client, chatId, params) {
|
|
|
56
56
|
quoteText: params.quote?.text,
|
|
57
57
|
quoteEntities: params.quote?.entities,
|
|
58
58
|
quoteOffset: params.quoteOffset,
|
|
59
|
-
monoforumPeerId: params.toMonoforumPeer ? await resolvePeer.resolvePeer(client, params.toMonoforumPeer) : void 0
|
|
59
|
+
monoforumPeerId: params.toMonoforumPeer ? await resolvePeer.resolvePeer(client, params.toMonoforumPeer) : void 0,
|
|
60
|
+
todoItemId: params.replyToTodoItem
|
|
60
61
|
};
|
|
61
62
|
} else if (params.toMonoforumPeer) {
|
|
62
63
|
tlReplyTo = {
|
|
@@ -12,6 +12,10 @@ export interface CommonSendParams {
|
|
|
12
12
|
* Can also be a message from another chat, in which case a quote will be sent.
|
|
13
13
|
*/
|
|
14
14
|
replyTo?: number | Message;
|
|
15
|
+
/**
|
|
16
|
+
* If this is a reply to a specific todo item, ID of that item
|
|
17
|
+
*/
|
|
18
|
+
replyToTodoItem?: number;
|
|
15
19
|
/**
|
|
16
20
|
* When the chat is a monoforum you are an admin of, you **must** pass an
|
|
17
21
|
* ID of a peer you are sending the message to.
|
|
@@ -12,6 +12,10 @@ export interface CommonSendParams {
|
|
|
12
12
|
* Can also be a message from another chat, in which case a quote will be sent.
|
|
13
13
|
*/
|
|
14
14
|
replyTo?: number | Message;
|
|
15
|
+
/**
|
|
16
|
+
* If this is a reply to a specific todo item, ID of that item
|
|
17
|
+
*/
|
|
18
|
+
replyToTodoItem?: number;
|
|
15
19
|
/**
|
|
16
20
|
* When the chat is a monoforum you are an admin of, you **must** pass an
|
|
17
21
|
* ID of a peer you are sending the message to.
|
|
@@ -49,7 +49,8 @@ async function _processCommonSendParameters(client, chatId, params) {
|
|
|
49
49
|
quoteText: params.quote?.text,
|
|
50
50
|
quoteEntities: params.quote?.entities,
|
|
51
51
|
quoteOffset: params.quoteOffset,
|
|
52
|
-
monoforumPeerId: params.toMonoforumPeer ? await resolvePeer(client, params.toMonoforumPeer) : void 0
|
|
52
|
+
monoforumPeerId: params.toMonoforumPeer ? await resolvePeer(client, params.toMonoforumPeer) : void 0,
|
|
53
|
+
todoItemId: params.replyToTodoItem
|
|
53
54
|
};
|
|
54
55
|
} else if (params.toMonoforumPeer) {
|
|
55
56
|
tlReplyTo = {
|
|
@@ -7,16 +7,18 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
8
|
const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
9
9
|
const starsGift = require("../../types/premium/stars-gift.cjs");
|
|
10
|
+
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
10
11
|
async function getStarGiftOptions(client) {
|
|
11
12
|
const res = await client.call({
|
|
12
13
|
_: "payments.getStarGifts",
|
|
13
14
|
hash: 0
|
|
14
15
|
});
|
|
15
16
|
typeAssertions.assertTypeIsNot("payments.getStarGifts", res, "payments.starGiftsNotModified");
|
|
17
|
+
const peers = peersIndex.PeersIndex.from(res);
|
|
16
18
|
const ret = [];
|
|
17
19
|
for (const gift of res.gifts) {
|
|
18
20
|
if (gift._ === "starGift") {
|
|
19
|
-
ret.push(new starsGift.StarGift(gift));
|
|
21
|
+
ret.push(new starsGift.StarGift(gift, peers));
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
return ret;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { assertTypeIsNot } from "../../../utils/type-assertions.js";
|
|
2
2
|
import { StarGift as StarGift$2 } from "../../types/premium/stars-gift.js";
|
|
3
|
+
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
3
4
|
async function getStarGiftOptions(client) {
|
|
4
5
|
const res = await client.call({
|
|
5
6
|
_: "payments.getStarGifts",
|
|
6
7
|
hash: 0
|
|
7
8
|
});
|
|
8
9
|
assertTypeIsNot("payments.getStarGifts", res, "payments.starGiftsNotModified");
|
|
10
|
+
const peers = PeersIndex.from(res);
|
|
9
11
|
const ret = [];
|
|
10
12
|
for (const gift of res.gifts) {
|
|
11
13
|
if (gift._ === "starGift") {
|
|
12
|
-
ret.push(new StarGift$2(gift));
|
|
14
|
+
ret.push(new StarGift$2(gift, peers));
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
return ret;
|
|
@@ -133,32 +133,40 @@ async function resolvePeer(client, peerId, force = false) {
|
|
|
133
133
|
}
|
|
134
134
|
switch (peerType) {
|
|
135
135
|
case "user": {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
accessHash: Long.ZERO
|
|
140
|
-
});
|
|
141
|
-
if (res != null && res._ === "user" && res.accessHash != null) {
|
|
142
|
-
return {
|
|
143
|
-
_: "inputPeerUser",
|
|
136
|
+
try {
|
|
137
|
+
const res = await batchedQueries._getUsersBatched(client, {
|
|
138
|
+
_: "inputUser",
|
|
144
139
|
userId: bareId,
|
|
145
|
-
accessHash:
|
|
146
|
-
};
|
|
140
|
+
accessHash: Long.ZERO
|
|
141
|
+
});
|
|
142
|
+
if (res != null && res._ === "user" && res.accessHash != null) {
|
|
143
|
+
return {
|
|
144
|
+
_: "inputPeerUser",
|
|
145
|
+
userId: bareId,
|
|
146
|
+
accessHash: res.accessHash
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
} catch (e) {
|
|
150
|
+
if (!tl.tl.RpcError.is(e, "USER_INVALID")) throw e;
|
|
147
151
|
}
|
|
148
152
|
break;
|
|
149
153
|
}
|
|
150
154
|
case "channel": {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
accessHash: Long.ZERO
|
|
155
|
-
});
|
|
156
|
-
if (res != null && res._ === "channel" && res.accessHash != null) {
|
|
157
|
-
return {
|
|
158
|
-
_: "inputPeerChannel",
|
|
155
|
+
try {
|
|
156
|
+
const res = await batchedQueries._getChannelsBatched(client, {
|
|
157
|
+
_: "inputChannel",
|
|
159
158
|
channelId: bareId,
|
|
160
|
-
accessHash:
|
|
161
|
-
};
|
|
159
|
+
accessHash: Long.ZERO
|
|
160
|
+
});
|
|
161
|
+
if (res != null && res._ === "channel" && res.accessHash != null) {
|
|
162
|
+
return {
|
|
163
|
+
_: "inputPeerChannel",
|
|
164
|
+
channelId: bareId,
|
|
165
|
+
accessHash: res.accessHash
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
} catch (e) {
|
|
169
|
+
if (!tl.tl.RpcError.is(e, "CHANNEL_INVALID")) throw e;
|
|
162
170
|
}
|
|
163
171
|
break;
|
|
164
172
|
}
|
|
@@ -126,32 +126,40 @@ async function resolvePeer(client, peerId, force = false) {
|
|
|
126
126
|
}
|
|
127
127
|
switch (peerType) {
|
|
128
128
|
case "user": {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
accessHash: Long.ZERO
|
|
133
|
-
});
|
|
134
|
-
if (res != null && res._ === "user" && res.accessHash != null) {
|
|
135
|
-
return {
|
|
136
|
-
_: "inputPeerUser",
|
|
129
|
+
try {
|
|
130
|
+
const res = await _getUsersBatched(client, {
|
|
131
|
+
_: "inputUser",
|
|
137
132
|
userId: bareId,
|
|
138
|
-
accessHash:
|
|
139
|
-
};
|
|
133
|
+
accessHash: Long.ZERO
|
|
134
|
+
});
|
|
135
|
+
if (res != null && res._ === "user" && res.accessHash != null) {
|
|
136
|
+
return {
|
|
137
|
+
_: "inputPeerUser",
|
|
138
|
+
userId: bareId,
|
|
139
|
+
accessHash: res.accessHash
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
} catch (e) {
|
|
143
|
+
if (!tl.RpcError.is(e, "USER_INVALID")) throw e;
|
|
140
144
|
}
|
|
141
145
|
break;
|
|
142
146
|
}
|
|
143
147
|
case "channel": {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
accessHash: Long.ZERO
|
|
148
|
-
});
|
|
149
|
-
if (res != null && res._ === "channel" && res.accessHash != null) {
|
|
150
|
-
return {
|
|
151
|
-
_: "inputPeerChannel",
|
|
148
|
+
try {
|
|
149
|
+
const res = await _getChannelsBatched(client, {
|
|
150
|
+
_: "inputChannel",
|
|
152
151
|
channelId: bareId,
|
|
153
|
-
accessHash:
|
|
154
|
-
};
|
|
152
|
+
accessHash: Long.ZERO
|
|
153
|
+
});
|
|
154
|
+
if (res != null && res._ === "channel" && res.accessHash != null) {
|
|
155
|
+
return {
|
|
156
|
+
_: "inputPeerChannel",
|
|
157
|
+
channelId: bareId,
|
|
158
|
+
accessHash: res.accessHash
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
} catch (e) {
|
|
162
|
+
if (!tl.RpcError.is(e, "CHANNEL_INVALID")) throw e;
|
|
155
163
|
}
|
|
156
164
|
break;
|
|
157
165
|
}
|
|
@@ -295,7 +295,7 @@ function _messageActionFromTl(act) {
|
|
|
295
295
|
converted: act.converted,
|
|
296
296
|
convertStars: act.convertStars ?? Long.ZERO,
|
|
297
297
|
refunded: act.refunded,
|
|
298
|
-
gift: new starsGift.StarGift(act.gift),
|
|
298
|
+
gift: new starsGift.StarGift(act.gift, this._peers),
|
|
299
299
|
message: act.message ?? null,
|
|
300
300
|
canUpgrade: act.canUpgrade,
|
|
301
301
|
upgraded: act.upgraded,
|
|
@@ -288,7 +288,7 @@ function _messageActionFromTl(act) {
|
|
|
288
288
|
converted: act.converted,
|
|
289
289
|
convertStars: act.convertStars ?? Long.ZERO,
|
|
290
290
|
refunded: act.refunded,
|
|
291
|
-
gift: new StarGift$2(act.gift),
|
|
291
|
+
gift: new StarGift$2(act.gift, this._peers),
|
|
292
292
|
message: act.message ?? null,
|
|
293
293
|
canUpgrade: act.canUpgrade,
|
|
294
294
|
upgraded: act.upgraded,
|
|
@@ -66,6 +66,10 @@ class RepliedMessageInfo {
|
|
|
66
66
|
}
|
|
67
67
|
return this.raw.replyToTopId ?? null;
|
|
68
68
|
}
|
|
69
|
+
/** If this is a reply to a specific todo item, ID of that item */
|
|
70
|
+
get todoItemId() {
|
|
71
|
+
return this.raw.todoItemId ?? null;
|
|
72
|
+
}
|
|
69
73
|
/**
|
|
70
74
|
* If replied-to message is available, chat where the message was sent.
|
|
71
75
|
*
|
|
@@ -56,6 +56,8 @@ export declare class RepliedMessageInfo {
|
|
|
56
56
|
get id(): number | null;
|
|
57
57
|
/** ID of the replies thread where this message belongs to */
|
|
58
58
|
get threadId(): number | null;
|
|
59
|
+
/** If this is a reply to a specific todo item, ID of that item */
|
|
60
|
+
get todoItemId(): number | null;
|
|
59
61
|
/**
|
|
60
62
|
* If replied-to message is available, chat where the message was sent.
|
|
61
63
|
*
|
|
@@ -56,6 +56,8 @@ export declare class RepliedMessageInfo {
|
|
|
56
56
|
get id(): number | null;
|
|
57
57
|
/** ID of the replies thread where this message belongs to */
|
|
58
58
|
get threadId(): number | null;
|
|
59
|
+
/** If this is a reply to a specific todo item, ID of that item */
|
|
60
|
+
get todoItemId(): number | null;
|
|
59
61
|
/**
|
|
60
62
|
* If replied-to message is available, chat where the message was sent.
|
|
61
63
|
*
|
|
@@ -59,6 +59,10 @@ class RepliedMessageInfo {
|
|
|
59
59
|
}
|
|
60
60
|
return this.raw.replyToTopId ?? null;
|
|
61
61
|
}
|
|
62
|
+
/** If this is a reply to a specific todo item, ID of that item */
|
|
63
|
+
get todoItemId() {
|
|
64
|
+
return this.raw.todoItemId ?? null;
|
|
65
|
+
}
|
|
62
66
|
/**
|
|
63
67
|
* If replied-to message is available, chat where the message was sent.
|
|
64
68
|
*
|
|
@@ -46,7 +46,7 @@ class SavedStarGift {
|
|
|
46
46
|
/** The gift itself */
|
|
47
47
|
get gift() {
|
|
48
48
|
if (this.raw.gift._ === "starGift") {
|
|
49
|
-
return new starsGift.StarGift(this.raw.gift);
|
|
49
|
+
return new starsGift.StarGift(this.raw.gift, this._peers);
|
|
50
50
|
}
|
|
51
51
|
return new starsGiftUnique.StarGiftUnique(this.raw.gift, this._peers);
|
|
52
52
|
}
|
|
@@ -39,7 +39,7 @@ class SavedStarGift {
|
|
|
39
39
|
/** The gift itself */
|
|
40
40
|
get gift() {
|
|
41
41
|
if (this.raw.gift._ === "starGift") {
|
|
42
|
-
return new StarGift$2(this.raw.gift);
|
|
42
|
+
return new StarGift$2(this.raw.gift, this._peers);
|
|
43
43
|
}
|
|
44
44
|
return new StarGiftUnique$2(this.raw.gift, this._peers);
|
|
45
45
|
}
|
|
@@ -197,6 +197,13 @@ class StarGiftUnique {
|
|
|
197
197
|
get giftAddress() {
|
|
198
198
|
return this.raw.giftAddress ?? null;
|
|
199
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* User/channel who released this collection
|
|
202
|
+
*/
|
|
203
|
+
get releasedBy() {
|
|
204
|
+
if (!this.raw.releasedBy) return null;
|
|
205
|
+
return peer.parsePeer(this.raw.releasedBy, this._peers);
|
|
206
|
+
}
|
|
200
207
|
}
|
|
201
208
|
const StarGiftUnique$1 = /* @__PURE__ */ inspectable.makeInspectable(StarGiftUnique);
|
|
202
209
|
const StarGiftUnique$2 = /* @__PURE__ */ memoize.memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
|
|
@@ -190,6 +190,13 @@ class StarGiftUnique {
|
|
|
190
190
|
get giftAddress() {
|
|
191
191
|
return this.raw.giftAddress ?? null;
|
|
192
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* User/channel who released this collection
|
|
195
|
+
*/
|
|
196
|
+
get releasedBy() {
|
|
197
|
+
if (!this.raw.releasedBy) return null;
|
|
198
|
+
return parsePeer(this.raw.releasedBy, this._peers);
|
|
199
|
+
}
|
|
193
200
|
}
|
|
194
201
|
const StarGiftUnique$1 = /* @__PURE__ */ makeInspectable(StarGiftUnique);
|
|
195
202
|
const StarGiftUnique$2 = /* @__PURE__ */ memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
|
|
@@ -11,9 +11,11 @@ const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
|
11
11
|
const inspectable = require("../../utils/inspectable.cjs");
|
|
12
12
|
const memoize = require("../../utils/memoize.cjs");
|
|
13
13
|
const documentUtils = require("../media/document-utils.cjs");
|
|
14
|
+
const peer = require("../peers/peer.cjs");
|
|
14
15
|
class StarGift {
|
|
15
|
-
constructor(raw) {
|
|
16
|
+
constructor(raw, _peers) {
|
|
16
17
|
this.raw = raw;
|
|
18
|
+
this._peers = _peers;
|
|
17
19
|
}
|
|
18
20
|
/** ID of the gift */
|
|
19
21
|
get id() {
|
|
@@ -86,6 +88,13 @@ class StarGift {
|
|
|
86
88
|
get title() {
|
|
87
89
|
return this.raw.title ?? null;
|
|
88
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* User/channel who released this collection
|
|
93
|
+
*/
|
|
94
|
+
get releasedBy() {
|
|
95
|
+
if (!this.raw.releasedBy) return null;
|
|
96
|
+
return peer.parsePeer(this.raw.releasedBy, this._peers);
|
|
97
|
+
}
|
|
89
98
|
}
|
|
90
99
|
const StarGift$1 = /* @__PURE__ */ inspectable.makeInspectable(StarGift);
|
|
91
100
|
const StarGift$2 = /* @__PURE__ */ memoize.memoizeGetters(StarGift$1, ["sticker"]);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { tl } from '@mtcute/tl';
|
|
2
2
|
import { Sticker } from '../media/sticker.js';
|
|
3
3
|
import { Message } from '../messages/message.js';
|
|
4
|
-
import {
|
|
4
|
+
import { PeersIndex } from '../peers/peers-index.js';
|
|
5
5
|
import { default as Long } from 'long';
|
|
6
|
+
import { InputPeerLike, Peer } from '../peers/peer.js';
|
|
6
7
|
export type InputStarGift = {
|
|
7
8
|
/** ID of the message containing the gift */
|
|
8
9
|
message: number | Message;
|
|
@@ -17,7 +18,8 @@ export type InputStarGift = {
|
|
|
17
18
|
*/
|
|
18
19
|
export declare class StarGift {
|
|
19
20
|
readonly raw: tl.RawStarGift;
|
|
20
|
-
|
|
21
|
+
readonly _peers: PeersIndex;
|
|
22
|
+
constructor(raw: tl.RawStarGift, _peers: PeersIndex);
|
|
21
23
|
/** ID of the gift */
|
|
22
24
|
get id(): tl.Long;
|
|
23
25
|
/** Whether this gift sold out and cannot be bought anymore */
|
|
@@ -59,4 +61,8 @@ export declare class StarGift {
|
|
|
59
61
|
get resaleFloorPrice(): tl.Long | null;
|
|
60
62
|
/** Title of the gift */
|
|
61
63
|
get title(): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* User/channel who released this collection
|
|
66
|
+
*/
|
|
67
|
+
get releasedBy(): Peer | null;
|
|
62
68
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { tl } from '@mtcute/tl';
|
|
2
2
|
import { Sticker } from '../media/sticker.js';
|
|
3
3
|
import { Message } from '../messages/message.js';
|
|
4
|
-
import {
|
|
4
|
+
import { PeersIndex } from '../peers/peers-index.js';
|
|
5
5
|
import { default as Long } from 'long';
|
|
6
|
+
import { InputPeerLike, Peer } from '../peers/peer.js';
|
|
6
7
|
export type InputStarGift = {
|
|
7
8
|
/** ID of the message containing the gift */
|
|
8
9
|
message: number | Message;
|
|
@@ -17,7 +18,8 @@ export type InputStarGift = {
|
|
|
17
18
|
*/
|
|
18
19
|
export declare class StarGift {
|
|
19
20
|
readonly raw: tl.RawStarGift;
|
|
20
|
-
|
|
21
|
+
readonly _peers: PeersIndex;
|
|
22
|
+
constructor(raw: tl.RawStarGift, _peers: PeersIndex);
|
|
21
23
|
/** ID of the gift */
|
|
22
24
|
get id(): tl.Long;
|
|
23
25
|
/** Whether this gift sold out and cannot be bought anymore */
|
|
@@ -59,4 +61,8 @@ export declare class StarGift {
|
|
|
59
61
|
get resaleFloorPrice(): tl.Long | null;
|
|
60
62
|
/** Title of the gift */
|
|
61
63
|
get title(): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* User/channel who released this collection
|
|
66
|
+
*/
|
|
67
|
+
get releasedBy(): Peer | null;
|
|
62
68
|
}
|
|
@@ -4,9 +4,11 @@ import { assertTypeIs } from "../../../utils/type-assertions.js";
|
|
|
4
4
|
import { makeInspectable } from "../../utils/inspectable.js";
|
|
5
5
|
import { memoizeGetters } from "../../utils/memoize.js";
|
|
6
6
|
import { parseDocument } from "../media/document-utils.js";
|
|
7
|
+
import { parsePeer } from "../peers/peer.js";
|
|
7
8
|
class StarGift {
|
|
8
|
-
constructor(raw) {
|
|
9
|
+
constructor(raw, _peers) {
|
|
9
10
|
this.raw = raw;
|
|
11
|
+
this._peers = _peers;
|
|
10
12
|
}
|
|
11
13
|
/** ID of the gift */
|
|
12
14
|
get id() {
|
|
@@ -79,6 +81,13 @@ class StarGift {
|
|
|
79
81
|
get title() {
|
|
80
82
|
return this.raw.title ?? null;
|
|
81
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* User/channel who released this collection
|
|
86
|
+
*/
|
|
87
|
+
get releasedBy() {
|
|
88
|
+
if (!this.raw.releasedBy) return null;
|
|
89
|
+
return parsePeer(this.raw.releasedBy, this._peers);
|
|
90
|
+
}
|
|
82
91
|
}
|
|
83
92
|
const StarGift$1 = /* @__PURE__ */ makeInspectable(StarGift);
|
|
84
93
|
const StarGift$2 = /* @__PURE__ */ memoizeGetters(StarGift$1, ["sticker"]);
|
|
@@ -118,7 +118,7 @@ class StarsTransaction {
|
|
|
118
118
|
return {
|
|
119
119
|
type: "star_gift",
|
|
120
120
|
peer: peer$1,
|
|
121
|
-
gift: new starsGift.StarGift(this.raw.stargift)
|
|
121
|
+
gift: new starsGift.StarGift(this.raw.stargift, this.peers)
|
|
122
122
|
};
|
|
123
123
|
} else if (this.raw.stargiftUpgrade) {
|
|
124
124
|
return {
|
|
@@ -219,9 +219,9 @@ class UpdatesManager {
|
|
|
219
219
|
}
|
|
220
220
|
if (this.pendingUpdateContainers.length % WARN_EVERY === 0) {
|
|
221
221
|
if (this.updatesLoopActive) {
|
|
222
|
-
this.log.warn("%d pending update containers, but the updates loop is not active. did you forget to start it?", this.pendingUpdateContainers.length);
|
|
223
|
-
} else {
|
|
224
222
|
this.log.warn("%d pending update containers, can't keep up!", this.pendingUpdateContainers.length);
|
|
223
|
+
} else {
|
|
224
|
+
this.log.warn("%d pending update containers, but the updates loop is not active. did you forget to start it?", this.pendingUpdateContainers.length);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
this.updatesLoopCv.notify();
|
|
@@ -212,9 +212,9 @@ class UpdatesManager {
|
|
|
212
212
|
}
|
|
213
213
|
if (this.pendingUpdateContainers.length % WARN_EVERY === 0) {
|
|
214
214
|
if (this.updatesLoopActive) {
|
|
215
|
-
this.log.warn("%d pending update containers, but the updates loop is not active. did you forget to start it?", this.pendingUpdateContainers.length);
|
|
216
|
-
} else {
|
|
217
215
|
this.log.warn("%d pending update containers, can't keep up!", this.pendingUpdateContainers.length);
|
|
216
|
+
} else {
|
|
217
|
+
this.log.warn("%d pending update containers, but the updates loop is not active. did you forget to start it?", this.pendingUpdateContainers.length);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
this.updatesLoopCv.notify();
|
|
@@ -536,8 +536,9 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
536
536
|
this.log.error("received rpc_result for %s request %l", msg._, reqMsgId);
|
|
537
537
|
return;
|
|
538
538
|
}
|
|
539
|
-
longUtils.removeFromLongArray(this._session.queuedStateReq, reqMsgId);
|
|
540
539
|
const rpc = msg.rpc;
|
|
540
|
+
longUtils.removeFromLongArray(this._session.queuedStateReq, reqMsgId);
|
|
541
|
+
this._session.getStateSchedule.remove(rpc);
|
|
541
542
|
rpc.resetAbortSignal?.();
|
|
542
543
|
const resultConstructorId = message.peekUint();
|
|
543
544
|
let result;
|
|
@@ -660,7 +661,6 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
660
661
|
this._onMessageAcked(rpc.containerId);
|
|
661
662
|
}
|
|
662
663
|
longUtils.removeFromLongArray(this._session.queuedResendReq, msgId);
|
|
663
|
-
this._session.getStateSchedule.remove(rpc);
|
|
664
664
|
break;
|
|
665
665
|
}
|
|
666
666
|
case "bind":
|
|
@@ -529,8 +529,9 @@ class SessionConnection extends PersistentConnection {
|
|
|
529
529
|
this.log.error("received rpc_result for %s request %l", msg._, reqMsgId);
|
|
530
530
|
return;
|
|
531
531
|
}
|
|
532
|
-
removeFromLongArray(this._session.queuedStateReq, reqMsgId);
|
|
533
532
|
const rpc = msg.rpc;
|
|
533
|
+
removeFromLongArray(this._session.queuedStateReq, reqMsgId);
|
|
534
|
+
this._session.getStateSchedule.remove(rpc);
|
|
534
535
|
rpc.resetAbortSignal?.();
|
|
535
536
|
const resultConstructorId = message.peekUint();
|
|
536
537
|
let result;
|
|
@@ -653,7 +654,6 @@ class SessionConnection extends PersistentConnection {
|
|
|
653
654
|
this._onMessageAcked(rpc.containerId);
|
|
654
655
|
}
|
|
655
656
|
removeFromLongArray(this._session.queuedResendReq, msgId);
|
|
656
|
-
this._session.getStateSchedule.remove(rpc);
|
|
657
657
|
break;
|
|
658
658
|
}
|
|
659
659
|
case "bind":
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.25.
|
|
4
|
+
"version": "0.25.4",
|
|
5
5
|
"description": "Type-safe library for MTProto (Telegram API)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@fuman/net": "0.0.15",
|
|
11
11
|
"@fuman/utils": "0.0.15",
|
|
12
12
|
"@mtcute/file-id": "^0.24.3",
|
|
13
|
-
"@mtcute/tl": "^
|
|
13
|
+
"@mtcute/tl": "^208.0.0",
|
|
14
14
|
"@mtcute/tl-runtime": "^0.24.3",
|
|
15
15
|
"@types/events": "3.0.0",
|
|
16
16
|
"long": "5.2.3"
|
package/utils/binary/compat.cjs
CHANGED
|
@@ -31,8 +31,10 @@ function mapCompatStarGift(obj) {
|
|
|
31
31
|
};
|
|
32
32
|
case "starGiftUnique_layer198":
|
|
33
33
|
case "starGiftUnique_layer202":
|
|
34
|
+
case "starGiftUnique_layer206":
|
|
34
35
|
return replaceType(obj, "starGiftUnique");
|
|
35
36
|
case "starGift_layer202":
|
|
37
|
+
case "starGift_layer206":
|
|
36
38
|
return replaceType(obj, "starGift");
|
|
37
39
|
default:
|
|
38
40
|
return obj;
|
|
@@ -79,6 +81,18 @@ function mapCompatMessageAction(obj) {
|
|
|
79
81
|
return obj;
|
|
80
82
|
}
|
|
81
83
|
}
|
|
84
|
+
function mapMessageReplyHeader(obj) {
|
|
85
|
+
switch (obj._) {
|
|
86
|
+
case "messageReplyHeader_layer206":
|
|
87
|
+
return {
|
|
88
|
+
...obj,
|
|
89
|
+
_: "messageReplyHeader",
|
|
90
|
+
replyMedia: obj.replyMedia ? mapCompatMessageMedia(obj.replyMedia) : void 0
|
|
91
|
+
};
|
|
92
|
+
default:
|
|
93
|
+
return obj;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
82
96
|
function mapCompatMessage(obj) {
|
|
83
97
|
switch (obj._) {
|
|
84
98
|
case "message_layer199":
|
|
@@ -86,13 +100,15 @@ function mapCompatMessage(obj) {
|
|
|
86
100
|
return {
|
|
87
101
|
...obj,
|
|
88
102
|
_: "message",
|
|
89
|
-
media: obj.media ? mapCompatMessageMedia(obj.media) : void 0
|
|
103
|
+
media: obj.media ? mapCompatMessageMedia(obj.media) : void 0,
|
|
104
|
+
replyTo: obj.replyTo ? mapMessageReplyHeader(obj.replyTo) : void 0
|
|
90
105
|
};
|
|
91
106
|
case "messageService_layer204":
|
|
92
107
|
return {
|
|
93
108
|
...obj,
|
|
94
109
|
_: "messageService",
|
|
95
|
-
action: mapCompatMessageAction(obj.action)
|
|
110
|
+
action: mapCompatMessageAction(obj.action),
|
|
111
|
+
replyTo: obj.replyTo ? mapMessageReplyHeader(obj.replyTo) : void 0
|
|
96
112
|
};
|
|
97
113
|
default:
|
|
98
114
|
return obj;
|
|
@@ -103,7 +119,9 @@ function mapCompatObject(obj) {
|
|
|
103
119
|
case "starGiftUnique_layer197":
|
|
104
120
|
case "starGiftUnique_layer198":
|
|
105
121
|
case "starGiftUnique_layer202":
|
|
122
|
+
case "starGiftUnique_layer206":
|
|
106
123
|
case "starGift_layer202":
|
|
124
|
+
case "starGift_layer206":
|
|
107
125
|
return mapCompatStarGift(obj);
|
|
108
126
|
case "emojiStatus_layer197":
|
|
109
127
|
return mapCompatEmojiStatus(obj);
|
|
@@ -140,6 +158,8 @@ function mapCompatObject(obj) {
|
|
|
140
158
|
case "message_layer204":
|
|
141
159
|
case "messageService_layer204":
|
|
142
160
|
return mapCompatMessage(obj);
|
|
161
|
+
case "messageReplyHeader_layer206":
|
|
162
|
+
return mapMessageReplyHeader(obj);
|
|
143
163
|
default:
|
|
144
164
|
return obj;
|
|
145
165
|
}
|
package/utils/binary/compat.js
CHANGED
|
@@ -24,8 +24,10 @@ function mapCompatStarGift(obj) {
|
|
|
24
24
|
};
|
|
25
25
|
case "starGiftUnique_layer198":
|
|
26
26
|
case "starGiftUnique_layer202":
|
|
27
|
+
case "starGiftUnique_layer206":
|
|
27
28
|
return replaceType(obj, "starGiftUnique");
|
|
28
29
|
case "starGift_layer202":
|
|
30
|
+
case "starGift_layer206":
|
|
29
31
|
return replaceType(obj, "starGift");
|
|
30
32
|
default:
|
|
31
33
|
return obj;
|
|
@@ -72,6 +74,18 @@ function mapCompatMessageAction(obj) {
|
|
|
72
74
|
return obj;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
77
|
+
function mapMessageReplyHeader(obj) {
|
|
78
|
+
switch (obj._) {
|
|
79
|
+
case "messageReplyHeader_layer206":
|
|
80
|
+
return {
|
|
81
|
+
...obj,
|
|
82
|
+
_: "messageReplyHeader",
|
|
83
|
+
replyMedia: obj.replyMedia ? mapCompatMessageMedia(obj.replyMedia) : void 0
|
|
84
|
+
};
|
|
85
|
+
default:
|
|
86
|
+
return obj;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
75
89
|
function mapCompatMessage(obj) {
|
|
76
90
|
switch (obj._) {
|
|
77
91
|
case "message_layer199":
|
|
@@ -79,13 +93,15 @@ function mapCompatMessage(obj) {
|
|
|
79
93
|
return {
|
|
80
94
|
...obj,
|
|
81
95
|
_: "message",
|
|
82
|
-
media: obj.media ? mapCompatMessageMedia(obj.media) : void 0
|
|
96
|
+
media: obj.media ? mapCompatMessageMedia(obj.media) : void 0,
|
|
97
|
+
replyTo: obj.replyTo ? mapMessageReplyHeader(obj.replyTo) : void 0
|
|
83
98
|
};
|
|
84
99
|
case "messageService_layer204":
|
|
85
100
|
return {
|
|
86
101
|
...obj,
|
|
87
102
|
_: "messageService",
|
|
88
|
-
action: mapCompatMessageAction(obj.action)
|
|
103
|
+
action: mapCompatMessageAction(obj.action),
|
|
104
|
+
replyTo: obj.replyTo ? mapMessageReplyHeader(obj.replyTo) : void 0
|
|
89
105
|
};
|
|
90
106
|
default:
|
|
91
107
|
return obj;
|
|
@@ -96,7 +112,9 @@ function mapCompatObject(obj) {
|
|
|
96
112
|
case "starGiftUnique_layer197":
|
|
97
113
|
case "starGiftUnique_layer198":
|
|
98
114
|
case "starGiftUnique_layer202":
|
|
115
|
+
case "starGiftUnique_layer206":
|
|
99
116
|
case "starGift_layer202":
|
|
117
|
+
case "starGift_layer206":
|
|
100
118
|
return mapCompatStarGift(obj);
|
|
101
119
|
case "emojiStatus_layer197":
|
|
102
120
|
return mapCompatEmojiStatus(obj);
|
|
@@ -133,6 +151,8 @@ function mapCompatObject(obj) {
|
|
|
133
151
|
case "message_layer204":
|
|
134
152
|
case "messageService_layer204":
|
|
135
153
|
return mapCompatMessage(obj);
|
|
154
|
+
case "messageReplyHeader_layer206":
|
|
155
|
+
return mapMessageReplyHeader(obj);
|
|
136
156
|
default:
|
|
137
157
|
return obj;
|
|
138
158
|
}
|