@mtcute/core 0.25.7 → 0.25.8
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/client.cjs +3 -0
- package/client.js +4 -1
- package/highlevel/client.d.cts +12 -2
- package/highlevel/client.d.ts +12 -2
- package/highlevel/methods/files/normalize-input-media.cjs +13 -4
- package/highlevel/methods/files/normalize-input-media.js +13 -4
- package/highlevel/methods/premium/buy-resale-gift.cjs +3 -2
- package/highlevel/methods/premium/buy-resale-gift.d.cts +2 -0
- package/highlevel/methods/premium/buy-resale-gift.d.ts +2 -0
- package/highlevel/methods/premium/buy-resale-gift.js +3 -2
- package/highlevel/methods/premium/get-resale-star-gifts.cjs +5 -1
- package/highlevel/methods/premium/get-resale-star-gifts.d.cts +7 -1
- package/highlevel/methods/premium/get-resale-star-gifts.d.ts +7 -1
- package/highlevel/methods/premium/get-resale-star-gifts.js +6 -2
- package/highlevel/methods.d.cts +1 -0
- package/highlevel/methods.d.ts +1 -0
- package/highlevel/types/peers/chat.cjs +5 -1
- package/highlevel/types/peers/chat.d.cts +5 -1
- package/highlevel/types/peers/chat.d.ts +5 -1
- package/highlevel/types/peers/chat.js +5 -1
- package/highlevel/types/peers/full-chat.cjs +4 -0
- package/highlevel/types/peers/full-chat.d.cts +2 -0
- package/highlevel/types/peers/full-chat.d.ts +2 -0
- package/highlevel/types/peers/full-chat.js +4 -0
- package/methods.cjs +1 -0
- package/methods.js +2 -1
- package/network/mtproto-session.cjs +1 -0
- package/network/mtproto-session.d.cts +1 -0
- package/network/mtproto-session.d.ts +1 -0
- package/network/mtproto-session.js +1 -0
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/network/session-connection.cjs +27 -10
- package/network/session-connection.d.cts +1 -0
- package/network/session-connection.d.ts +1 -0
- package/network/session-connection.js +27 -10
- package/package.json +1 -1
- package/utils/binary/serialization.d.cts +3 -3
- package/utils/binary/serialization.d.ts +3 -3
package/client.cjs
CHANGED
|
@@ -1089,6 +1089,9 @@ TelegramClient.prototype.getBusinessConnection = function(...args) {
|
|
|
1089
1089
|
TelegramClient.prototype.getMyBoostSlots = function(...args) {
|
|
1090
1090
|
return getMyBoostSlots.getMyBoostSlots(this._client, ...args);
|
|
1091
1091
|
};
|
|
1092
|
+
TelegramClient.prototype.getStarGiftResaleOptions = function(...args) {
|
|
1093
|
+
return getResaleStarGifts.getStarGiftResaleOptions(this._client, ...args);
|
|
1094
|
+
};
|
|
1092
1095
|
TelegramClient.prototype.getResaleOptions = function(...args) {
|
|
1093
1096
|
return getResaleStarGifts.getResaleOptions(this._client, ...args);
|
|
1094
1097
|
};
|
package/client.js
CHANGED
|
@@ -197,7 +197,7 @@ import { getBoosts } from "./highlevel/methods/premium/get-boosts.js";
|
|
|
197
197
|
import { getBusinessChatLinks } from "./highlevel/methods/premium/get-business-chat-links.js";
|
|
198
198
|
import { getBusinessConnection } from "./highlevel/methods/premium/get-business-connection.js";
|
|
199
199
|
import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.js";
|
|
200
|
-
import { getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
|
|
200
|
+
import { getStarGiftResaleOptions, getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
|
|
201
201
|
import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-star-gifts-by-id.js";
|
|
202
202
|
import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
|
|
203
203
|
import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
|
|
@@ -1082,6 +1082,9 @@ TelegramClient.prototype.getBusinessConnection = function(...args) {
|
|
|
1082
1082
|
TelegramClient.prototype.getMyBoostSlots = function(...args) {
|
|
1083
1083
|
return getMyBoostSlots(this._client, ...args);
|
|
1084
1084
|
};
|
|
1085
|
+
TelegramClient.prototype.getStarGiftResaleOptions = function(...args) {
|
|
1086
|
+
return getStarGiftResaleOptions(this._client, ...args);
|
|
1087
|
+
};
|
|
1085
1088
|
TelegramClient.prototype.getResaleOptions = function(...args) {
|
|
1086
1089
|
return getResaleOptions(this._client, ...args);
|
|
1087
1090
|
};
|
package/highlevel/client.d.cts
CHANGED
|
@@ -22,7 +22,7 @@ import { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
|
|
|
22
22
|
import { SendCopyParams } from './methods/messages/send-copy.js';
|
|
23
23
|
import { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
24
24
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
25
|
-
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
|
|
25
|
+
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta, getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
26
26
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
27
27
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
28
28
|
import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
|
|
@@ -3947,6 +3947,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3947
3947
|
* to the client's update handler.
|
|
3948
3948
|
*/
|
|
3949
3949
|
shouldDispatch?: true;
|
|
3950
|
+
/** Whether to use TON currency for payment */
|
|
3951
|
+
ton?: boolean;
|
|
3950
3952
|
}): Promise<Message | null>;
|
|
3951
3953
|
/**
|
|
3952
3954
|
* Check if the current user can apply boost to some channel
|
|
@@ -4048,7 +4050,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4048
4050
|
* **Available**: ✅ both users and bots
|
|
4049
4051
|
*
|
|
4050
4052
|
*/
|
|
4051
|
-
|
|
4053
|
+
getStarGiftResaleOptions(params: {
|
|
4052
4054
|
/** ID of the gift to get resale options for */
|
|
4053
4055
|
giftId: tl.Long;
|
|
4054
4056
|
/**
|
|
@@ -4069,6 +4071,14 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4069
4071
|
/** Limit for pagination */
|
|
4070
4072
|
limit?: number;
|
|
4071
4073
|
}): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
4074
|
+
/**
|
|
4075
|
+
* Get a list of star gifts up for resale
|
|
4076
|
+
*
|
|
4077
|
+
* **Available**: ✅ both users and bots
|
|
4078
|
+
*
|
|
4079
|
+
* @deprecated Deprecated alias, use `getStarGiftResaleOptions` instead
|
|
4080
|
+
*/
|
|
4081
|
+
getResaleOptions(params: Parameters<typeof getStarGiftResaleOptions>[1]): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
4072
4082
|
/** Get one or more saved star gifts by their IDs */
|
|
4073
4083
|
getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
|
|
4074
4084
|
/**
|
package/highlevel/client.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
|
|
|
22
22
|
import { SendCopyParams } from './methods/messages/send-copy.js';
|
|
23
23
|
import { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
24
24
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
25
|
-
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
|
|
25
|
+
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta, getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
26
26
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
27
27
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
28
28
|
import { AllStories, ArrayPaginated, ArrayPaginatedWithMeta, ArrayWithTotal, Boost, BoostSlot, BoostStats, BotChatJoinRequestUpdate, BotCommands, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessChatLink, BusinessConnection, BusinessMessage, BusinessWorkHoursDay, CallbackQuery, Chat, ChatEvent, ChatInviteLink, ChatInviteLinkMember, ChatJoinRequestUpdate, ChatlistPreview, ChatMember, ChatMemberUpdate, ChatPreview, ChosenInlineResult, CollectibleInfo, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, Dialog, FactCheck, FileDownloadLocation, FileDownloadParameters, ForumTopic, FullChat, FullUser, GameHighScore, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, InputChatEventFilters, InputDialogFolder, InputFileLike, InputInlineResult, InputMediaLike, InputMediaSticker, InputMessageId, InputPeerLike, InputPrivacyRule, InputReaction, InputStarGift, InputStickerSet, InputStickerSetItem, InputText, InputWebview, MaybeDynamic, Message, MessageEffect, MessageMedia, MessageReactions, ParametersSkip2, ParsedUpdate, Peer, PeerReaction, PeerSettings, PeerStories, Photo, Poll, PollUpdate, PollVoteUpdate, PreCheckoutQuery, RawDocument, ReplyMarkup, SavedStarGift, SentCode, StarGift, StarGiftUnique, StarsStatus, StarsTransaction, Sticker, StickerSet, StickerType, StoriesStealthMode, Story, StoryInteractions, StoryUpdate, StoryViewer, StoryViewersList, TakeoutSession, TextWithEntities, TypingStatus, UploadedFile, UploadFileLike, User, UserStatusUpdate, UserTypingUpdate, WebPageMedia, WebviewResult } from './types/index.js';
|
|
@@ -3947,6 +3947,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3947
3947
|
* to the client's update handler.
|
|
3948
3948
|
*/
|
|
3949
3949
|
shouldDispatch?: true;
|
|
3950
|
+
/** Whether to use TON currency for payment */
|
|
3951
|
+
ton?: boolean;
|
|
3950
3952
|
}): Promise<Message | null>;
|
|
3951
3953
|
/**
|
|
3952
3954
|
* Check if the current user can apply boost to some channel
|
|
@@ -4048,7 +4050,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4048
4050
|
* **Available**: ✅ both users and bots
|
|
4049
4051
|
*
|
|
4050
4052
|
*/
|
|
4051
|
-
|
|
4053
|
+
getStarGiftResaleOptions(params: {
|
|
4052
4054
|
/** ID of the gift to get resale options for */
|
|
4053
4055
|
giftId: tl.Long;
|
|
4054
4056
|
/**
|
|
@@ -4069,6 +4071,14 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4069
4071
|
/** Limit for pagination */
|
|
4070
4072
|
limit?: number;
|
|
4071
4073
|
}): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
4074
|
+
/**
|
|
4075
|
+
* Get a list of star gifts up for resale
|
|
4076
|
+
*
|
|
4077
|
+
* **Available**: ✅ both users and bots
|
|
4078
|
+
*
|
|
4079
|
+
* @deprecated Deprecated alias, use `getStarGiftResaleOptions` instead
|
|
4080
|
+
*/
|
|
4081
|
+
getResaleOptions(params: Parameters<typeof getStarGiftResaleOptions>[1]): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
4072
4082
|
/** Get one or more saved star gifts by their IDs */
|
|
4073
4083
|
getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
|
|
4074
4084
|
/**
|
|
@@ -278,11 +278,14 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
278
278
|
};
|
|
279
279
|
const input = media.file;
|
|
280
280
|
if (fileId.tdFileId.isFileIdLike(input)) {
|
|
281
|
+
const spoiler = (media.type === "video" || media.type === "photo") && media.spoiler;
|
|
281
282
|
if (typeof input === "string" && input.match(/^https?:\/\//)) {
|
|
282
283
|
return uploadMediaIfNeeded(
|
|
283
284
|
{
|
|
284
285
|
_: media.type === "photo" ? "inputMediaPhotoExternal" : "inputMediaDocumentExternal",
|
|
285
|
-
url: input
|
|
286
|
+
url: input,
|
|
287
|
+
ttlSeconds: media.ttlSeconds,
|
|
288
|
+
spoiler
|
|
286
289
|
},
|
|
287
290
|
media.type === "photo"
|
|
288
291
|
);
|
|
@@ -293,20 +296,26 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
293
296
|
if (parsed.location._ === "photo") {
|
|
294
297
|
return {
|
|
295
298
|
_: "inputMediaPhoto",
|
|
296
|
-
id: convertFileId.fileIdToInputPhoto(parsed)
|
|
299
|
+
id: convertFileId.fileIdToInputPhoto(parsed),
|
|
300
|
+
ttlSeconds: media.ttlSeconds,
|
|
301
|
+
spoiler
|
|
297
302
|
};
|
|
298
303
|
} else if (parsed.location._ === "web") {
|
|
299
304
|
return uploadMediaIfNeeded(
|
|
300
305
|
{
|
|
301
306
|
_: parsed.type === fileId.tdFileId.FileType.Photo ? "inputMediaPhotoExternal" : "inputMediaDocumentExternal",
|
|
302
|
-
url: parsed.location.url
|
|
307
|
+
url: parsed.location.url,
|
|
308
|
+
ttlSeconds: media.ttlSeconds,
|
|
309
|
+
spoiler
|
|
303
310
|
},
|
|
304
311
|
parsed.type === fileId.tdFileId.FileType.Photo
|
|
305
312
|
);
|
|
306
313
|
}
|
|
307
314
|
return {
|
|
308
315
|
_: "inputMediaDocument",
|
|
309
|
-
id: convertFileId.fileIdToInputDocument(parsed)
|
|
316
|
+
id: convertFileId.fileIdToInputDocument(parsed),
|
|
317
|
+
ttlSeconds: media.ttlSeconds,
|
|
318
|
+
spoiler
|
|
310
319
|
};
|
|
311
320
|
}
|
|
312
321
|
} else if (typeof input === "object" && tl.tl.isAnyInputMedia(input)) {
|
|
@@ -271,11 +271,14 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
271
271
|
};
|
|
272
272
|
const input = media.file;
|
|
273
273
|
if (tdFileId.isFileIdLike(input)) {
|
|
274
|
+
const spoiler = (media.type === "video" || media.type === "photo") && media.spoiler;
|
|
274
275
|
if (typeof input === "string" && input.match(/^https?:\/\//)) {
|
|
275
276
|
return uploadMediaIfNeeded(
|
|
276
277
|
{
|
|
277
278
|
_: media.type === "photo" ? "inputMediaPhotoExternal" : "inputMediaDocumentExternal",
|
|
278
|
-
url: input
|
|
279
|
+
url: input,
|
|
280
|
+
ttlSeconds: media.ttlSeconds,
|
|
281
|
+
spoiler
|
|
279
282
|
},
|
|
280
283
|
media.type === "photo"
|
|
281
284
|
);
|
|
@@ -286,20 +289,26 @@ async function _normalizeInputMedia(client, media, params = {}, uploadMedia = fa
|
|
|
286
289
|
if (parsed.location._ === "photo") {
|
|
287
290
|
return {
|
|
288
291
|
_: "inputMediaPhoto",
|
|
289
|
-
id: fileIdToInputPhoto(parsed)
|
|
292
|
+
id: fileIdToInputPhoto(parsed),
|
|
293
|
+
ttlSeconds: media.ttlSeconds,
|
|
294
|
+
spoiler
|
|
290
295
|
};
|
|
291
296
|
} else if (parsed.location._ === "web") {
|
|
292
297
|
return uploadMediaIfNeeded(
|
|
293
298
|
{
|
|
294
299
|
_: parsed.type === tdFileId.FileType.Photo ? "inputMediaPhotoExternal" : "inputMediaDocumentExternal",
|
|
295
|
-
url: parsed.location.url
|
|
300
|
+
url: parsed.location.url,
|
|
301
|
+
ttlSeconds: media.ttlSeconds,
|
|
302
|
+
spoiler
|
|
296
303
|
},
|
|
297
304
|
parsed.type === tdFileId.FileType.Photo
|
|
298
305
|
);
|
|
299
306
|
}
|
|
300
307
|
return {
|
|
301
308
|
_: "inputMediaDocument",
|
|
302
|
-
id: fileIdToInputDocument(parsed)
|
|
309
|
+
id: fileIdToInputDocument(parsed),
|
|
310
|
+
ttlSeconds: media.ttlSeconds,
|
|
311
|
+
spoiler
|
|
303
312
|
};
|
|
304
313
|
}
|
|
305
314
|
} else if (typeof input === "object" && tl.isAnyInputMedia(input)) {
|
|
@@ -9,11 +9,12 @@ const typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
|
9
9
|
const findInUpdate = require("../messages/find-in-update.cjs");
|
|
10
10
|
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
11
11
|
async function buyResaleGift(client, params) {
|
|
12
|
-
const { slug, recipient, shouldDispatch } = params;
|
|
12
|
+
const { slug, recipient, shouldDispatch, ton } = params;
|
|
13
13
|
const invoice = {
|
|
14
14
|
_: "inputInvoiceStarGiftResale",
|
|
15
15
|
slug,
|
|
16
|
-
toId: await resolvePeer.resolvePeer(client, recipient)
|
|
16
|
+
toId: await resolvePeer.resolvePeer(client, recipient),
|
|
17
|
+
ton
|
|
17
18
|
};
|
|
18
19
|
const form = await client.call({
|
|
19
20
|
_: "payments.getPaymentForm",
|
|
@@ -2,11 +2,12 @@ import { assertTypeIs } from "../../../utils/type-assertions.js";
|
|
|
2
2
|
import { _findMessageInUpdate } from "../messages/find-in-update.js";
|
|
3
3
|
import { resolvePeer } from "../users/resolve-peer.js";
|
|
4
4
|
async function buyResaleGift(client, params) {
|
|
5
|
-
const { slug, recipient, shouldDispatch } = params;
|
|
5
|
+
const { slug, recipient, shouldDispatch, ton } = params;
|
|
6
6
|
const invoice = {
|
|
7
7
|
_: "inputInvoiceStarGiftResale",
|
|
8
8
|
slug,
|
|
9
|
-
toId: await resolvePeer(client, recipient)
|
|
9
|
+
toId: await resolvePeer(client, recipient),
|
|
10
|
+
ton
|
|
10
11
|
};
|
|
11
12
|
const form = await client.call({
|
|
12
13
|
_: "payments.getPaymentForm",
|
|
@@ -63,7 +63,7 @@ function _normalizeResaleAttributes(attrs) {
|
|
|
63
63
|
}
|
|
64
64
|
return res;
|
|
65
65
|
}
|
|
66
|
-
async function
|
|
66
|
+
async function getStarGiftResaleOptions(client, params) {
|
|
67
67
|
const res = await client.call({
|
|
68
68
|
_: "payments.getResaleStarGifts",
|
|
69
69
|
sortByNum: params.sort === "num",
|
|
@@ -103,5 +103,9 @@ async function getResaleOptions(client, params) {
|
|
|
103
103
|
res.nextOffset
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
|
+
async function getResaleOptions(client, params) {
|
|
107
|
+
return getStarGiftResaleOptions(client, params);
|
|
108
|
+
}
|
|
106
109
|
exports._normalizeResaleAttributes = _normalizeResaleAttributes;
|
|
107
110
|
exports.getResaleOptions = getResaleOptions;
|
|
111
|
+
exports.getStarGiftResaleOptions = getStarGiftResaleOptions;
|
|
@@ -22,7 +22,7 @@ export interface ResaleStarGiftsMeta {
|
|
|
22
22
|
/**
|
|
23
23
|
* Get a list of star gifts up for resale
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function getStarGiftResaleOptions(client: ITelegramClient, params: {
|
|
26
26
|
/** ID of the gift to get resale options for */
|
|
27
27
|
giftId: tl.Long;
|
|
28
28
|
/**
|
|
@@ -43,3 +43,9 @@ export declare function getResaleOptions(client: ITelegramClient, params: {
|
|
|
43
43
|
/** Limit for pagination */
|
|
44
44
|
limit?: number;
|
|
45
45
|
}): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a list of star gifts up for resale
|
|
48
|
+
*
|
|
49
|
+
* @deprecated Deprecated alias, use `getStarGiftResaleOptions` instead
|
|
50
|
+
*/
|
|
51
|
+
export declare function getResaleOptions(client: ITelegramClient, params: Parameters<typeof getStarGiftResaleOptions>[1]): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
@@ -22,7 +22,7 @@ export interface ResaleStarGiftsMeta {
|
|
|
22
22
|
/**
|
|
23
23
|
* Get a list of star gifts up for resale
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function getStarGiftResaleOptions(client: ITelegramClient, params: {
|
|
26
26
|
/** ID of the gift to get resale options for */
|
|
27
27
|
giftId: tl.Long;
|
|
28
28
|
/**
|
|
@@ -43,3 +43,9 @@ export declare function getResaleOptions(client: ITelegramClient, params: {
|
|
|
43
43
|
/** Limit for pagination */
|
|
44
44
|
limit?: number;
|
|
45
45
|
}): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a list of star gifts up for resale
|
|
48
|
+
*
|
|
49
|
+
* @deprecated Deprecated alias, use `getStarGiftResaleOptions` instead
|
|
50
|
+
*/
|
|
51
|
+
export declare function getResaleOptions(client: ITelegramClient, params: Parameters<typeof getStarGiftResaleOptions>[1]): Promise<ArrayPaginatedWithMeta<StarGiftUnique, string, ResaleStarGiftsMeta>>;
|
|
@@ -56,7 +56,7 @@ function _normalizeResaleAttributes(attrs) {
|
|
|
56
56
|
}
|
|
57
57
|
return res;
|
|
58
58
|
}
|
|
59
|
-
async function
|
|
59
|
+
async function getStarGiftResaleOptions(client, params) {
|
|
60
60
|
const res = await client.call({
|
|
61
61
|
_: "payments.getResaleStarGifts",
|
|
62
62
|
sortByNum: params.sort === "num",
|
|
@@ -96,7 +96,11 @@ async function getResaleOptions(client, params) {
|
|
|
96
96
|
res.nextOffset
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
|
+
async function getResaleOptions(client, params) {
|
|
100
|
+
return getStarGiftResaleOptions(client, params);
|
|
101
|
+
}
|
|
99
102
|
export {
|
|
100
103
|
_normalizeResaleAttributes,
|
|
101
|
-
getResaleOptions
|
|
104
|
+
getResaleOptions,
|
|
105
|
+
getStarGiftResaleOptions
|
|
102
106
|
};
|
package/highlevel/methods.d.cts
CHANGED
|
@@ -231,6 +231,7 @@ export { getBoosts } from './methods/premium/get-boosts.js';
|
|
|
231
231
|
export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
|
|
232
232
|
export { getBusinessConnection } from './methods/premium/get-business-connection.js';
|
|
233
233
|
export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
|
|
234
|
+
export { getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
234
235
|
export { getResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
235
236
|
export type { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
|
|
236
237
|
export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
|
package/highlevel/methods.d.ts
CHANGED
|
@@ -231,6 +231,7 @@ export { getBoosts } from './methods/premium/get-boosts.js';
|
|
|
231
231
|
export { getBusinessChatLinks } from './methods/premium/get-business-chat-links.js';
|
|
232
232
|
export { getBusinessConnection } from './methods/premium/get-business-connection.js';
|
|
233
233
|
export { getMyBoostSlots } from './methods/premium/get-my-boost-slots.js';
|
|
234
|
+
export { getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
234
235
|
export { getResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
235
236
|
export type { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
|
|
236
237
|
export { getSavedStarGiftsById } from './methods/premium/get-saved-star-gifts-by-id.js';
|
|
@@ -398,7 +398,11 @@ class Chat {
|
|
|
398
398
|
if (this.raw._ !== "channelForbidden" || !this.raw.untilDate) return null;
|
|
399
399
|
return new Date(this.raw.untilDate * 1e3);
|
|
400
400
|
}
|
|
401
|
-
/**
|
|
401
|
+
/**
|
|
402
|
+
* Number of members in this chat (if available)
|
|
403
|
+
*
|
|
404
|
+
* If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
|
|
405
|
+
*/
|
|
402
406
|
get membersCount() {
|
|
403
407
|
return "participantsCount" in this.raw ? this.raw.participantsCount ?? null : null;
|
|
404
408
|
}
|
|
@@ -227,7 +227,11 @@ export declare class Chat {
|
|
|
227
227
|
* Returns `null` if the user is not banned, or if the ban is permanent
|
|
228
228
|
*/
|
|
229
229
|
get bannedUntilDate(): Date | null;
|
|
230
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* Number of members in this chat (if available)
|
|
232
|
+
*
|
|
233
|
+
* If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
|
|
234
|
+
*/
|
|
231
235
|
get membersCount(): number | null;
|
|
232
236
|
/**
|
|
233
237
|
* If this chat is a basic group that has been migrated to a supergroup,
|
|
@@ -227,7 +227,11 @@ export declare class Chat {
|
|
|
227
227
|
* Returns `null` if the user is not banned, or if the ban is permanent
|
|
228
228
|
*/
|
|
229
229
|
get bannedUntilDate(): Date | null;
|
|
230
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* Number of members in this chat (if available)
|
|
232
|
+
*
|
|
233
|
+
* If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
|
|
234
|
+
*/
|
|
231
235
|
get membersCount(): number | null;
|
|
232
236
|
/**
|
|
233
237
|
* If this chat is a basic group that has been migrated to a supergroup,
|
|
@@ -391,7 +391,11 @@ class Chat {
|
|
|
391
391
|
if (this.raw._ !== "channelForbidden" || !this.raw.untilDate) return null;
|
|
392
392
|
return new Date(this.raw.untilDate * 1e3);
|
|
393
393
|
}
|
|
394
|
-
/**
|
|
394
|
+
/**
|
|
395
|
+
* Number of members in this chat (if available)
|
|
396
|
+
*
|
|
397
|
+
* If not available, try fetching a full chat info with {@link TelegramClient.getFullChat}
|
|
398
|
+
*/
|
|
395
399
|
get membersCount() {
|
|
396
400
|
return "participantsCount" in this.raw ? this.raw.participantsCount ?? null : null;
|
|
397
401
|
}
|
|
@@ -178,6 +178,10 @@ class FullChat extends chat.Chat {
|
|
|
178
178
|
get canViewAdRevenue() {
|
|
179
179
|
return this.full._ === "channelFull" && this.full.canViewRevenue;
|
|
180
180
|
}
|
|
181
|
+
/** Number of members in the chat (0 if not available) */
|
|
182
|
+
get membersCount() {
|
|
183
|
+
return this.full._ === "channelFull" ? this.full.participantsCount ?? 0 : 0;
|
|
184
|
+
}
|
|
181
185
|
/** Number of admins in the chat (0 if not available) */
|
|
182
186
|
get adminsCount() {
|
|
183
187
|
return this.full._ === "channelFull" ? this.full.adminsCount ?? 0 : 0;
|
|
@@ -98,6 +98,8 @@ export declare class FullChat extends Chat {
|
|
|
98
98
|
get canViewStarsRevenue(): boolean;
|
|
99
99
|
/** Whether the current user can view ad revenue for this chat */
|
|
100
100
|
get canViewAdRevenue(): boolean;
|
|
101
|
+
/** Number of members in the chat (0 if not available) */
|
|
102
|
+
get membersCount(): number;
|
|
101
103
|
/** Number of admins in the chat (0 if not available) */
|
|
102
104
|
get adminsCount(): number;
|
|
103
105
|
/** Number of users kicked from the chat (if available) */
|
|
@@ -98,6 +98,8 @@ export declare class FullChat extends Chat {
|
|
|
98
98
|
get canViewStarsRevenue(): boolean;
|
|
99
99
|
/** Whether the current user can view ad revenue for this chat */
|
|
100
100
|
get canViewAdRevenue(): boolean;
|
|
101
|
+
/** Number of members in the chat (0 if not available) */
|
|
102
|
+
get membersCount(): number;
|
|
101
103
|
/** Number of admins in the chat (0 if not available) */
|
|
102
104
|
get adminsCount(): number;
|
|
103
105
|
/** Number of users kicked from the chat (if available) */
|
|
@@ -171,6 +171,10 @@ class FullChat extends Chat$2 {
|
|
|
171
171
|
get canViewAdRevenue() {
|
|
172
172
|
return this.full._ === "channelFull" && this.full.canViewRevenue;
|
|
173
173
|
}
|
|
174
|
+
/** Number of members in the chat (0 if not available) */
|
|
175
|
+
get membersCount() {
|
|
176
|
+
return this.full._ === "channelFull" ? this.full.participantsCount ?? 0 : 0;
|
|
177
|
+
}
|
|
174
178
|
/** Number of admins in the chat (0 if not available) */
|
|
175
179
|
get adminsCount() {
|
|
176
180
|
return this.full._ === "channelFull" ? this.full.adminsCount ?? 0 : 0;
|
package/methods.cjs
CHANGED
|
@@ -490,6 +490,7 @@ exports.getBusinessChatLinks = getBusinessChatLinks.getBusinessChatLinks;
|
|
|
490
490
|
exports.getBusinessConnection = getBusinessConnection.getBusinessConnection;
|
|
491
491
|
exports.getMyBoostSlots = getMyBoostSlots.getMyBoostSlots;
|
|
492
492
|
exports.getResaleOptions = getResaleStarGifts.getResaleOptions;
|
|
493
|
+
exports.getStarGiftResaleOptions = getResaleStarGifts.getStarGiftResaleOptions;
|
|
493
494
|
exports.getSavedStarGiftsById = getSavedStarGiftsById.getSavedStarGiftsById;
|
|
494
495
|
exports.getSavedStarGifts = getSavedStarGifts.getSavedStarGifts;
|
|
495
496
|
exports.getStarGiftOptions = getStarGiftOptions.getStarGiftOptions;
|
package/methods.js
CHANGED
|
@@ -194,7 +194,7 @@ import { getBoosts } from "./highlevel/methods/premium/get-boosts.js";
|
|
|
194
194
|
import { getBusinessChatLinks } from "./highlevel/methods/premium/get-business-chat-links.js";
|
|
195
195
|
import { getBusinessConnection } from "./highlevel/methods/premium/get-business-connection.js";
|
|
196
196
|
import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.js";
|
|
197
|
-
import { getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
|
|
197
|
+
import { getResaleOptions, getStarGiftResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
|
|
198
198
|
import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-star-gifts-by-id.js";
|
|
199
199
|
import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
|
|
200
200
|
import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
|
|
@@ -408,6 +408,7 @@ export {
|
|
|
408
408
|
getScheduledMessages,
|
|
409
409
|
getSimilarChannels,
|
|
410
410
|
getStarGiftOptions,
|
|
411
|
+
getStarGiftResaleOptions,
|
|
411
412
|
getStarGiftWithdrawalUrl,
|
|
412
413
|
getStarsTransactions,
|
|
413
414
|
getStickerSet,
|
|
@@ -43,6 +43,7 @@ class MtprotoSession {
|
|
|
43
43
|
queuedResendReq = [];
|
|
44
44
|
queuedCancelReq = [];
|
|
45
45
|
getStateSchedule = new sortedArray.SortedArray([], (a, b) => a.getState - b.getState);
|
|
46
|
+
pendingGetStateTimeouts = new longUtils.LongMap();
|
|
46
47
|
chains = /* @__PURE__ */ new Map();
|
|
47
48
|
chainsPendingFails = /* @__PURE__ */ new Map();
|
|
48
49
|
// requests info
|
|
@@ -83,6 +83,7 @@ export declare class MtprotoSession {
|
|
|
83
83
|
queuedResendReq: Long[];
|
|
84
84
|
queuedCancelReq: Long[];
|
|
85
85
|
getStateSchedule: SortedArray<PendingRpc>;
|
|
86
|
+
pendingGetStateTimeouts: LongMap<timers.Timer>;
|
|
86
87
|
chains: Map<string | number, Long>;
|
|
87
88
|
chainsPendingFails: Map<string | number, SortedArray<PendingRpc>>;
|
|
88
89
|
pendingMessages: LongMap<PendingMessage>;
|
|
@@ -83,6 +83,7 @@ export declare class MtprotoSession {
|
|
|
83
83
|
queuedResendReq: Long[];
|
|
84
84
|
queuedCancelReq: Long[];
|
|
85
85
|
getStateSchedule: SortedArray<PendingRpc>;
|
|
86
|
+
pendingGetStateTimeouts: LongMap<timers.Timer>;
|
|
86
87
|
chains: Map<string | number, Long>;
|
|
87
88
|
chainsPendingFails: Map<string | number, SortedArray<PendingRpc>>;
|
|
88
89
|
pendingMessages: LongMap<PendingMessage>;
|
|
@@ -36,6 +36,7 @@ class MtprotoSession {
|
|
|
36
36
|
queuedResendReq = [];
|
|
37
37
|
queuedCancelReq = [];
|
|
38
38
|
getStateSchedule = new SortedArray([], (a, b) => a.getState - b.getState);
|
|
39
|
+
pendingGetStateTimeouts = new LongMap();
|
|
39
40
|
chains = /* @__PURE__ */ new Map();
|
|
40
41
|
chainsPendingFails = /* @__PURE__ */ new Map();
|
|
41
42
|
// requests info
|
|
@@ -19,6 +19,7 @@ const abstract = require("./transports/abstract.cjs");
|
|
|
19
19
|
const errors = require("../types/errors.cjs");
|
|
20
20
|
const TEMP_AUTH_KEY_EXPIRY = 86400;
|
|
21
21
|
const GET_STATE_INTERVAL = 1500;
|
|
22
|
+
const GET_STATE_TIMEOUT = 2e3;
|
|
22
23
|
const GZIP_PACKED_ID = 812830625;
|
|
23
24
|
const MSG_CONTAINER_ID = 1945237724;
|
|
24
25
|
const RPC_RESULT_ID = 4082920705;
|
|
@@ -95,11 +96,8 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
95
96
|
prom.reject(new errors.MtcuteError("Connection closed"));
|
|
96
97
|
utils.timers.clearTimeout(timeout);
|
|
97
98
|
});
|
|
98
|
-
for (const msgId of this._session.
|
|
99
|
-
|
|
100
|
-
if (pending._ === "state") {
|
|
101
|
-
this._onMessageFailed(msgId, "connection loss", true);
|
|
102
|
-
}
|
|
99
|
+
for (const msgId of this._session.pendingGetStateTimeouts.keys()) {
|
|
100
|
+
this._onMessageFailed(msgId, "connection loss", true);
|
|
103
101
|
}
|
|
104
102
|
this.onDisconnect.emit();
|
|
105
103
|
this.reset();
|
|
@@ -113,6 +111,10 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
113
111
|
this._flushTimer.reset();
|
|
114
112
|
this._salts.isFetching = false;
|
|
115
113
|
this._session.resetLastPing(true);
|
|
114
|
+
for (const timeout of this._session.pendingGetStateTimeouts.values()) {
|
|
115
|
+
utils.timers.clearTimeout(timeout);
|
|
116
|
+
}
|
|
117
|
+
this._session.pendingGetStateTimeouts.clear();
|
|
116
118
|
if (forever) {
|
|
117
119
|
utils.timers.clearTimeout(this._pfsUpdateTimeout);
|
|
118
120
|
this.onDisconnect.clear();
|
|
@@ -734,16 +736,22 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
734
736
|
this._session.queuedResendReq.splice(0, 0, ...msgInfo.msgIds);
|
|
735
737
|
this._flushTimer.emitWhenIdle();
|
|
736
738
|
break;
|
|
737
|
-
case "state":
|
|
739
|
+
case "state": {
|
|
738
740
|
this.log.debug(
|
|
739
741
|
"state request %l (size = %d) failed because of %s",
|
|
740
742
|
msgId,
|
|
741
743
|
msgInfo.msgIds.length,
|
|
742
744
|
reason
|
|
743
745
|
);
|
|
746
|
+
const timer = this._session.pendingGetStateTimeouts.get(msgId);
|
|
747
|
+
if (timer) {
|
|
748
|
+
utils.timers.clearTimeout(timer);
|
|
749
|
+
this._session.pendingGetStateTimeouts.delete(msgId);
|
|
750
|
+
}
|
|
744
751
|
this._session.queuedStateReq.splice(0, 0, ...msgInfo.msgIds);
|
|
745
752
|
this._flushTimer.emitWhenIdle();
|
|
746
753
|
break;
|
|
754
|
+
}
|
|
747
755
|
case "bind":
|
|
748
756
|
this.log.debug("temp key binding request %l failed because of %s, retrying", msgId, reason);
|
|
749
757
|
msgInfo.promise.reject(new Error(reason));
|
|
@@ -900,6 +908,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
900
908
|
return;
|
|
901
909
|
}
|
|
902
910
|
this._session.pendingMessages.delete(msg.reqMsgId);
|
|
911
|
+
this._session.pendingGetStateTimeouts.delete(msg.reqMsgId);
|
|
903
912
|
this._onMessagesInfo(info.msgIds, msg.info);
|
|
904
913
|
}
|
|
905
914
|
_onFutureSalts(msg) {
|
|
@@ -1094,6 +1103,14 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
1094
1103
|
flushWhenIdle() {
|
|
1095
1104
|
this._flushTimer.emitWhenIdle();
|
|
1096
1105
|
}
|
|
1106
|
+
_handleGetStateTimeout = (msgId) => {
|
|
1107
|
+
const pending = this._session.pendingGetStateTimeouts.get(msgId);
|
|
1108
|
+
if (!pending) {
|
|
1109
|
+
this.log.warn("get_state timed out for unknown msg_id %l", msgId);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
this._onMessageFailed(msgId, "timeout");
|
|
1113
|
+
};
|
|
1097
1114
|
_flush() {
|
|
1098
1115
|
if (this._disconnectedManually || !this._session._authKey.ready || this._isPfsBindingPending || this._session.current429Timeout) {
|
|
1099
1116
|
this.log.debug(
|
|
@@ -1295,6 +1312,8 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
1295
1312
|
};
|
|
1296
1313
|
this._session.pendingMessages.set(getStateMsgId, getStatePending);
|
|
1297
1314
|
otherPendings.push(getStatePending);
|
|
1315
|
+
const timeout = utils.timers.setTimeout(this._handleGetStateTimeout, GET_STATE_TIMEOUT, getStateMsgId);
|
|
1316
|
+
this._session.pendingGetStateTimeouts.set(getStateMsgId, timeout);
|
|
1298
1317
|
}
|
|
1299
1318
|
if (resendRequest) {
|
|
1300
1319
|
resendMsgId = this._registerOutgoingMsgId(this._session.writeMessage(writer, resendRequest));
|
|
@@ -1373,10 +1392,8 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
1373
1392
|
if (msg.getState) {
|
|
1374
1393
|
this._session.getStateSchedule.remove(msg);
|
|
1375
1394
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
this._session.getStateSchedule.insert(msg);
|
|
1379
|
-
}
|
|
1395
|
+
msg.getState = getStateTime;
|
|
1396
|
+
this._session.getStateSchedule.insert(msg);
|
|
1380
1397
|
if (rootMsgId === null) rootMsgId = msg.msgId;
|
|
1381
1398
|
writer.long(this._registerOutgoingMsgId(msg.msgId));
|
|
1382
1399
|
writer.uint(msg.seqNo);
|
|
@@ -12,6 +12,7 @@ import { TransportError } from "./transports/abstract.js";
|
|
|
12
12
|
import { MtcuteError, MtTimeoutError, MtArgumentError } from "../types/errors.js";
|
|
13
13
|
const TEMP_AUTH_KEY_EXPIRY = 86400;
|
|
14
14
|
const GET_STATE_INTERVAL = 1500;
|
|
15
|
+
const GET_STATE_TIMEOUT = 2e3;
|
|
15
16
|
const GZIP_PACKED_ID = 812830625;
|
|
16
17
|
const MSG_CONTAINER_ID = 1945237724;
|
|
17
18
|
const RPC_RESULT_ID = 4082920705;
|
|
@@ -88,11 +89,8 @@ class SessionConnection extends PersistentConnection {
|
|
|
88
89
|
prom.reject(new MtcuteError("Connection closed"));
|
|
89
90
|
timers.clearTimeout(timeout);
|
|
90
91
|
});
|
|
91
|
-
for (const msgId of this._session.
|
|
92
|
-
|
|
93
|
-
if (pending._ === "state") {
|
|
94
|
-
this._onMessageFailed(msgId, "connection loss", true);
|
|
95
|
-
}
|
|
92
|
+
for (const msgId of this._session.pendingGetStateTimeouts.keys()) {
|
|
93
|
+
this._onMessageFailed(msgId, "connection loss", true);
|
|
96
94
|
}
|
|
97
95
|
this.onDisconnect.emit();
|
|
98
96
|
this.reset();
|
|
@@ -106,6 +104,10 @@ class SessionConnection extends PersistentConnection {
|
|
|
106
104
|
this._flushTimer.reset();
|
|
107
105
|
this._salts.isFetching = false;
|
|
108
106
|
this._session.resetLastPing(true);
|
|
107
|
+
for (const timeout of this._session.pendingGetStateTimeouts.values()) {
|
|
108
|
+
timers.clearTimeout(timeout);
|
|
109
|
+
}
|
|
110
|
+
this._session.pendingGetStateTimeouts.clear();
|
|
109
111
|
if (forever) {
|
|
110
112
|
timers.clearTimeout(this._pfsUpdateTimeout);
|
|
111
113
|
this.onDisconnect.clear();
|
|
@@ -727,16 +729,22 @@ class SessionConnection extends PersistentConnection {
|
|
|
727
729
|
this._session.queuedResendReq.splice(0, 0, ...msgInfo.msgIds);
|
|
728
730
|
this._flushTimer.emitWhenIdle();
|
|
729
731
|
break;
|
|
730
|
-
case "state":
|
|
732
|
+
case "state": {
|
|
731
733
|
this.log.debug(
|
|
732
734
|
"state request %l (size = %d) failed because of %s",
|
|
733
735
|
msgId,
|
|
734
736
|
msgInfo.msgIds.length,
|
|
735
737
|
reason
|
|
736
738
|
);
|
|
739
|
+
const timer = this._session.pendingGetStateTimeouts.get(msgId);
|
|
740
|
+
if (timer) {
|
|
741
|
+
timers.clearTimeout(timer);
|
|
742
|
+
this._session.pendingGetStateTimeouts.delete(msgId);
|
|
743
|
+
}
|
|
737
744
|
this._session.queuedStateReq.splice(0, 0, ...msgInfo.msgIds);
|
|
738
745
|
this._flushTimer.emitWhenIdle();
|
|
739
746
|
break;
|
|
747
|
+
}
|
|
740
748
|
case "bind":
|
|
741
749
|
this.log.debug("temp key binding request %l failed because of %s, retrying", msgId, reason);
|
|
742
750
|
msgInfo.promise.reject(new Error(reason));
|
|
@@ -893,6 +901,7 @@ class SessionConnection extends PersistentConnection {
|
|
|
893
901
|
return;
|
|
894
902
|
}
|
|
895
903
|
this._session.pendingMessages.delete(msg.reqMsgId);
|
|
904
|
+
this._session.pendingGetStateTimeouts.delete(msg.reqMsgId);
|
|
896
905
|
this._onMessagesInfo(info.msgIds, msg.info);
|
|
897
906
|
}
|
|
898
907
|
_onFutureSalts(msg) {
|
|
@@ -1087,6 +1096,14 @@ class SessionConnection extends PersistentConnection {
|
|
|
1087
1096
|
flushWhenIdle() {
|
|
1088
1097
|
this._flushTimer.emitWhenIdle();
|
|
1089
1098
|
}
|
|
1099
|
+
_handleGetStateTimeout = (msgId) => {
|
|
1100
|
+
const pending = this._session.pendingGetStateTimeouts.get(msgId);
|
|
1101
|
+
if (!pending) {
|
|
1102
|
+
this.log.warn("get_state timed out for unknown msg_id %l", msgId);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
this._onMessageFailed(msgId, "timeout");
|
|
1106
|
+
};
|
|
1090
1107
|
_flush() {
|
|
1091
1108
|
if (this._disconnectedManually || !this._session._authKey.ready || this._isPfsBindingPending || this._session.current429Timeout) {
|
|
1092
1109
|
this.log.debug(
|
|
@@ -1288,6 +1305,8 @@ class SessionConnection extends PersistentConnection {
|
|
|
1288
1305
|
};
|
|
1289
1306
|
this._session.pendingMessages.set(getStateMsgId, getStatePending);
|
|
1290
1307
|
otherPendings.push(getStatePending);
|
|
1308
|
+
const timeout = timers.setTimeout(this._handleGetStateTimeout, GET_STATE_TIMEOUT, getStateMsgId);
|
|
1309
|
+
this._session.pendingGetStateTimeouts.set(getStateMsgId, timeout);
|
|
1291
1310
|
}
|
|
1292
1311
|
if (resendRequest) {
|
|
1293
1312
|
resendMsgId = this._registerOutgoingMsgId(this._session.writeMessage(writer, resendRequest));
|
|
@@ -1366,10 +1385,8 @@ class SessionConnection extends PersistentConnection {
|
|
|
1366
1385
|
if (msg.getState) {
|
|
1367
1386
|
this._session.getStateSchedule.remove(msg);
|
|
1368
1387
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
this._session.getStateSchedule.insert(msg);
|
|
1372
|
-
}
|
|
1388
|
+
msg.getState = getStateTime;
|
|
1389
|
+
this._session.getStateSchedule.insert(msg);
|
|
1373
1390
|
if (rootMsgId === null) rootMsgId = msg.msgId;
|
|
1374
1391
|
writer.long(this._registerOutgoingMsgId(msg.msgId));
|
|
1375
1392
|
writer.uint(msg.seqNo);
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { tl } from '@mtcute/tl';
|
|
1
|
+
import { mtp, tl } from '@mtcute/tl';
|
|
2
2
|
import { PeersIndex } from '../../highlevel/index.js';
|
|
3
3
|
/** Serialize a raw TL object to binary */
|
|
4
|
-
export declare function serializeObject(obj: tl.TlObject): Uint8Array;
|
|
4
|
+
export declare function serializeObject(obj: tl.TlObject | mtp.TlObject): Uint8Array;
|
|
5
5
|
/** Deserialize a binary TL object */
|
|
6
|
-
export declare function deserializeObject(data: Uint8Array): tl.TlObject;
|
|
6
|
+
export declare function deserializeObject(data: Uint8Array): tl.TlObject | mtp.TlObject;
|
|
7
7
|
/** Helper function to serialize a {@link PeersIndex} */
|
|
8
8
|
export declare function serializePeersIndex({ users, chats }: PeersIndex): Uint8Array;
|
|
9
9
|
/** Helper function to deserialize a {@link PeersIndex} */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { tl } from '@mtcute/tl';
|
|
1
|
+
import { mtp, tl } from '@mtcute/tl';
|
|
2
2
|
import { PeersIndex } from '../../highlevel/index.js';
|
|
3
3
|
/** Serialize a raw TL object to binary */
|
|
4
|
-
export declare function serializeObject(obj: tl.TlObject): Uint8Array;
|
|
4
|
+
export declare function serializeObject(obj: tl.TlObject | mtp.TlObject): Uint8Array;
|
|
5
5
|
/** Deserialize a binary TL object */
|
|
6
|
-
export declare function deserializeObject(data: Uint8Array): tl.TlObject;
|
|
6
|
+
export declare function deserializeObject(data: Uint8Array): tl.TlObject | mtp.TlObject;
|
|
7
7
|
/** Helper function to serialize a {@link PeersIndex} */
|
|
8
8
|
export declare function serializePeersIndex({ users, chats }: PeersIndex): Uint8Array;
|
|
9
9
|
/** Helper function to deserialize a {@link PeersIndex} */
|