@mtcute/core 0.20.4 → 0.21.1
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 +4 -0
- package/client.js +4 -0
- package/highlevel/base.cjs +3 -3
- package/highlevel/base.js +3 -3
- package/highlevel/client.d.cts +17 -10
- package/highlevel/client.d.ts +17 -10
- package/highlevel/methods/chats/get-peer.cjs +19 -0
- package/highlevel/methods/chats/get-peer.d.cts +4 -0
- package/highlevel/methods/chats/get-peer.d.ts +4 -0
- package/highlevel/methods/chats/get-peer.js +14 -0
- package/highlevel/methods/messages/send-paid-reaction.cjs +8 -2
- package/highlevel/methods/messages/send-paid-reaction.d.cts +8 -2
- package/highlevel/methods/messages/send-paid-reaction.d.ts +8 -2
- package/highlevel/methods/messages/send-paid-reaction.js +8 -2
- package/highlevel/methods/premium/send-star-gift.cjs +1 -1
- package/highlevel/methods/premium/send-star-gift.d.cts +2 -2
- package/highlevel/methods/premium/send-star-gift.d.ts +2 -2
- package/highlevel/methods/premium/send-star-gift.js +1 -1
- package/highlevel/methods/premium/transfer-star-gift.cjs +1 -1
- package/highlevel/methods/premium/transfer-star-gift.d.cts +2 -2
- package/highlevel/methods/premium/transfer-star-gift.d.ts +2 -2
- package/highlevel/methods/premium/transfer-star-gift.js +1 -1
- package/highlevel/methods/premium/upgrade-star-gift.cjs +1 -1
- package/highlevel/methods/premium/upgrade-star-gift.d.cts +2 -2
- package/highlevel/methods/premium/upgrade-star-gift.d.ts +2 -2
- package/highlevel/methods/premium/upgrade-star-gift.js +1 -1
- package/highlevel/methods.d.cts +1 -0
- package/highlevel/methods.d.ts +1 -0
- package/highlevel/types/misc/takeout-session.cjs +18 -21
- package/highlevel/types/misc/takeout-session.d.cts +16 -11
- package/highlevel/types/misc/takeout-session.d.ts +16 -11
- package/highlevel/types/misc/takeout-session.js +18 -21
- package/highlevel/types/premium/stars-gift-unique.cjs +4 -0
- package/highlevel/types/premium/stars-gift-unique.d.cts +2 -0
- package/highlevel/types/premium/stars-gift-unique.d.ts +2 -0
- package/highlevel/types/premium/stars-gift-unique.js +4 -0
- package/index.cjs +1 -0
- package/index.js +2 -1
- package/methods.cjs +2 -0
- package/methods.js +2 -0
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/package.json +2 -2
- package/utils/peer-utils.cjs +44 -0
- package/utils/peer-utils.d.cts +2 -0
- package/utils/peer-utils.d.ts +2 -0
- package/utils/peer-utils.js +44 -0
- package/utils.cjs +1 -0
- package/utils.js +2 -1
package/client.cjs
CHANGED
|
@@ -58,6 +58,7 @@ const getChat = require("./highlevel/methods/chats/get-chat.cjs");
|
|
|
58
58
|
const getFullChat = require("./highlevel/methods/chats/get-full-chat.cjs");
|
|
59
59
|
const getFullUser = require("./highlevel/methods/chats/get-full-user.cjs");
|
|
60
60
|
const getNearbyChats = require("./highlevel/methods/chats/get-nearby-chats.cjs");
|
|
61
|
+
const getPeer = require("./highlevel/methods/chats/get-peer.cjs");
|
|
61
62
|
const getSimilarChannels = require("./highlevel/methods/chats/get-similar-channels.cjs");
|
|
62
63
|
const getUser = require("./highlevel/methods/chats/get-user.cjs");
|
|
63
64
|
const iterChatEventLog = require("./highlevel/methods/chats/iter-chat-event-log.cjs");
|
|
@@ -589,6 +590,9 @@ TelegramClient.prototype.getFullUser = function(...args) {
|
|
|
589
590
|
TelegramClient.prototype.getNearbyChats = function(...args) {
|
|
590
591
|
return getNearbyChats.getNearbyChats(this._client, ...args);
|
|
591
592
|
};
|
|
593
|
+
TelegramClient.prototype.getPeer = function(...args) {
|
|
594
|
+
return getPeer.getPeer(this._client, ...args);
|
|
595
|
+
};
|
|
592
596
|
TelegramClient.prototype.getSimilarChannels = function(...args) {
|
|
593
597
|
return getSimilarChannels.getSimilarChannels(this._client, ...args);
|
|
594
598
|
};
|
package/client.js
CHANGED
|
@@ -51,6 +51,7 @@ import { getChat } from "./highlevel/methods/chats/get-chat.js";
|
|
|
51
51
|
import { getFullChat } from "./highlevel/methods/chats/get-full-chat.js";
|
|
52
52
|
import { getFullUser } from "./highlevel/methods/chats/get-full-user.js";
|
|
53
53
|
import { getNearbyChats } from "./highlevel/methods/chats/get-nearby-chats.js";
|
|
54
|
+
import { getPeer } from "./highlevel/methods/chats/get-peer.js";
|
|
54
55
|
import { getSimilarChannels } from "./highlevel/methods/chats/get-similar-channels.js";
|
|
55
56
|
import { getUser } from "./highlevel/methods/chats/get-user.js";
|
|
56
57
|
import { iterChatEventLog } from "./highlevel/methods/chats/iter-chat-event-log.js";
|
|
@@ -582,6 +583,9 @@ TelegramClient.prototype.getFullUser = function(...args) {
|
|
|
582
583
|
TelegramClient.prototype.getNearbyChats = function(...args) {
|
|
583
584
|
return getNearbyChats(this._client, ...args);
|
|
584
585
|
};
|
|
586
|
+
TelegramClient.prototype.getPeer = function(...args) {
|
|
587
|
+
return getPeer(this._client, ...args);
|
|
588
|
+
};
|
|
585
589
|
TelegramClient.prototype.getSimilarChannels = function(...args) {
|
|
586
590
|
return getSimilarChannels(this._client, ...args);
|
|
587
591
|
};
|
package/highlevel/base.cjs
CHANGED
|
@@ -134,9 +134,9 @@ class BaseTelegramClient {
|
|
|
134
134
|
this.log.prefix = "[USER n/a] ";
|
|
135
135
|
await this.storage.self.store(null);
|
|
136
136
|
const primaryDc = this.mt.network.getPrimaryDcId();
|
|
137
|
-
for (const
|
|
138
|
-
if (
|
|
139
|
-
await this.mt.storage.provider.authKeys.deleteByDc(
|
|
137
|
+
for (const dcId of [1, 2, 3, 4, 5]) {
|
|
138
|
+
if (dcId === primaryDc) continue;
|
|
139
|
+
await this.mt.storage.provider.authKeys.deleteByDc(dcId);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
async notifyChannelOpened(channelId, pts) {
|
package/highlevel/base.js
CHANGED
|
@@ -127,9 +127,9 @@ class BaseTelegramClient {
|
|
|
127
127
|
this.log.prefix = "[USER n/a] ";
|
|
128
128
|
await this.storage.self.store(null);
|
|
129
129
|
const primaryDc = this.mt.network.getPrimaryDcId();
|
|
130
|
-
for (const
|
|
131
|
-
if (
|
|
132
|
-
await this.mt.storage.provider.authKeys.deleteByDc(
|
|
130
|
+
for (const dcId of [1, 2, 3, 4, 5]) {
|
|
131
|
+
if (dcId === primaryDc) continue;
|
|
132
|
+
await this.mt.storage.provider.authKeys.deleteByDc(dcId);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
async notifyChannelOpened(channelId, pts) {
|
package/highlevel/client.d.cts
CHANGED
|
@@ -23,7 +23,7 @@ import { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
|
23
23
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
24
24
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
25
25
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
26
|
-
import { AllStories, ArrayPaginated, 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, PeerReaction, 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, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
|
|
26
|
+
import { AllStories, ArrayPaginated, 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, 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, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
|
|
27
27
|
import { ParsedUpdateHandlerParams } from './updates/parsed.js';
|
|
28
28
|
import { RawUpdateInfo } from './updates/types.js';
|
|
29
29
|
import { InputStringSessionData } from './utils/string-session.js';
|
|
@@ -1298,6 +1298,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1298
1298
|
* @param longitude Longitude of the location
|
|
1299
1299
|
*/
|
|
1300
1300
|
getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>;
|
|
1301
|
+
/** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
|
|
1302
|
+
getPeer(peer: InputPeerLike): Promise<Peer>;
|
|
1301
1303
|
/**
|
|
1302
1304
|
* Get channels that are similar to a given channel
|
|
1303
1305
|
*
|
|
@@ -3942,7 +3944,11 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3942
3944
|
getMyBoostSlots(): Promise<BoostSlot[]>;
|
|
3943
3945
|
/** Get one or more saved star gifts by their IDs */
|
|
3944
3946
|
getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
|
|
3945
|
-
/**
|
|
3947
|
+
/**
|
|
3948
|
+
* Get a list of saved star gifts of a user/channel
|
|
3949
|
+
*
|
|
3950
|
+
* Note that filters currently only work for channels
|
|
3951
|
+
*/
|
|
3946
3952
|
getSavedStarGifts(params: {
|
|
3947
3953
|
/** Peer to get saved gifts from */
|
|
3948
3954
|
owner: InputPeerLike;
|
|
@@ -3978,9 +3984,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3978
3984
|
/**
|
|
3979
3985
|
* Get a list of gifts sent to a user.
|
|
3980
3986
|
*
|
|
3981
|
-
* **Available**:
|
|
3987
|
+
* **Available**: ✅ both users and bots
|
|
3982
3988
|
*
|
|
3983
3989
|
* @param userId User whose gifts to fetch
|
|
3990
|
+
* @deprecated Use {@link getSavedStarGifts} instead
|
|
3984
3991
|
* @returns Gifts sent to the user
|
|
3985
3992
|
*/
|
|
3986
3993
|
getStarGifts(userId: InputPeerLike, params?: {
|
|
@@ -3994,7 +4001,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3994
4001
|
* @default 100
|
|
3995
4002
|
*/
|
|
3996
4003
|
limit?: number;
|
|
3997
|
-
}): Promise<ArrayPaginated<
|
|
4004
|
+
}): Promise<ArrayPaginated<SavedStarGift, string>>;
|
|
3998
4005
|
/**
|
|
3999
4006
|
* Get Telegram Stars transactions for a given peer.
|
|
4000
4007
|
*
|
|
@@ -4141,7 +4148,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4141
4148
|
*
|
|
4142
4149
|
* **Available**: 👤 users only
|
|
4143
4150
|
*
|
|
4144
|
-
* @returns Service message about the sent gift
|
|
4151
|
+
* @returns Service message about the sent gift, if one was generated.
|
|
4145
4152
|
*/
|
|
4146
4153
|
sendStarGift(params: {
|
|
4147
4154
|
/** ID of the peer to send the gift to */
|
|
@@ -4163,7 +4170,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4163
4170
|
* to the client's update handler.
|
|
4164
4171
|
*/
|
|
4165
4172
|
shouldDispatch?: true;
|
|
4166
|
-
}): Promise<Message>;
|
|
4173
|
+
}): Promise<Message | null>;
|
|
4167
4174
|
/**
|
|
4168
4175
|
* Set current user's business introduction.
|
|
4169
4176
|
*
|
|
@@ -4212,7 +4219,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4212
4219
|
*
|
|
4213
4220
|
* **Available**: 👤 users only
|
|
4214
4221
|
*
|
|
4215
|
-
* @returns Service message about the transferred gift
|
|
4222
|
+
* @returns Service message about the transferred gift, if one was generated.
|
|
4216
4223
|
*/
|
|
4217
4224
|
transferStarGift(params: {
|
|
4218
4225
|
/** Star gift to transfer */
|
|
@@ -4224,7 +4231,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4224
4231
|
* to the client's update handler.
|
|
4225
4232
|
*/
|
|
4226
4233
|
shouldDispatch?: true;
|
|
4227
|
-
}): Promise<Message>;
|
|
4234
|
+
}): Promise<Message | null>;
|
|
4228
4235
|
/**
|
|
4229
4236
|
* Upgrades a star gift to a unique gift.
|
|
4230
4237
|
*
|
|
@@ -4235,7 +4242,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4235
4242
|
*
|
|
4236
4243
|
* **Available**: 👤 users only
|
|
4237
4244
|
*
|
|
4238
|
-
* @returns Service message about the upgraded gift
|
|
4245
|
+
* @returns Service message about the upgraded gift, if one was generated.
|
|
4239
4246
|
*/
|
|
4240
4247
|
upgradeStarGift(params: {
|
|
4241
4248
|
gift: InputStarGift;
|
|
@@ -4249,7 +4256,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4249
4256
|
* to the client's update handler.
|
|
4250
4257
|
*/
|
|
4251
4258
|
shouldDispatch?: true;
|
|
4252
|
-
}): Promise<Message>;
|
|
4259
|
+
}): Promise<Message | null>;
|
|
4253
4260
|
/**
|
|
4254
4261
|
* Add a sticker to a sticker set.
|
|
4255
4262
|
*
|
package/highlevel/client.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
|
23
23
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
24
24
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
25
25
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
26
|
-
import { AllStories, ArrayPaginated, 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, PeerReaction, 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, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
|
|
26
|
+
import { AllStories, ArrayPaginated, 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, 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, UserStarGift, UserStatusUpdate, UserTypingUpdate, WebviewResult } from './types/index.js';
|
|
27
27
|
import { ParsedUpdateHandlerParams } from './updates/parsed.js';
|
|
28
28
|
import { RawUpdateInfo } from './updates/types.js';
|
|
29
29
|
import { InputStringSessionData } from './utils/string-session.js';
|
|
@@ -1298,6 +1298,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
1298
1298
|
* @param longitude Longitude of the location
|
|
1299
1299
|
*/
|
|
1300
1300
|
getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>;
|
|
1301
|
+
/** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
|
|
1302
|
+
getPeer(peer: InputPeerLike): Promise<Peer>;
|
|
1301
1303
|
/**
|
|
1302
1304
|
* Get channels that are similar to a given channel
|
|
1303
1305
|
*
|
|
@@ -3942,7 +3944,11 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3942
3944
|
getMyBoostSlots(): Promise<BoostSlot[]>;
|
|
3943
3945
|
/** Get one or more saved star gifts by their IDs */
|
|
3944
3946
|
getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
|
|
3945
|
-
/**
|
|
3947
|
+
/**
|
|
3948
|
+
* Get a list of saved star gifts of a user/channel
|
|
3949
|
+
*
|
|
3950
|
+
* Note that filters currently only work for channels
|
|
3951
|
+
*/
|
|
3946
3952
|
getSavedStarGifts(params: {
|
|
3947
3953
|
/** Peer to get saved gifts from */
|
|
3948
3954
|
owner: InputPeerLike;
|
|
@@ -3978,9 +3984,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3978
3984
|
/**
|
|
3979
3985
|
* Get a list of gifts sent to a user.
|
|
3980
3986
|
*
|
|
3981
|
-
* **Available**:
|
|
3987
|
+
* **Available**: ✅ both users and bots
|
|
3982
3988
|
*
|
|
3983
3989
|
* @param userId User whose gifts to fetch
|
|
3990
|
+
* @deprecated Use {@link getSavedStarGifts} instead
|
|
3984
3991
|
* @returns Gifts sent to the user
|
|
3985
3992
|
*/
|
|
3986
3993
|
getStarGifts(userId: InputPeerLike, params?: {
|
|
@@ -3994,7 +4001,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3994
4001
|
* @default 100
|
|
3995
4002
|
*/
|
|
3996
4003
|
limit?: number;
|
|
3997
|
-
}): Promise<ArrayPaginated<
|
|
4004
|
+
}): Promise<ArrayPaginated<SavedStarGift, string>>;
|
|
3998
4005
|
/**
|
|
3999
4006
|
* Get Telegram Stars transactions for a given peer.
|
|
4000
4007
|
*
|
|
@@ -4141,7 +4148,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4141
4148
|
*
|
|
4142
4149
|
* **Available**: 👤 users only
|
|
4143
4150
|
*
|
|
4144
|
-
* @returns Service message about the sent gift
|
|
4151
|
+
* @returns Service message about the sent gift, if one was generated.
|
|
4145
4152
|
*/
|
|
4146
4153
|
sendStarGift(params: {
|
|
4147
4154
|
/** ID of the peer to send the gift to */
|
|
@@ -4163,7 +4170,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4163
4170
|
* to the client's update handler.
|
|
4164
4171
|
*/
|
|
4165
4172
|
shouldDispatch?: true;
|
|
4166
|
-
}): Promise<Message>;
|
|
4173
|
+
}): Promise<Message | null>;
|
|
4167
4174
|
/**
|
|
4168
4175
|
* Set current user's business introduction.
|
|
4169
4176
|
*
|
|
@@ -4212,7 +4219,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4212
4219
|
*
|
|
4213
4220
|
* **Available**: 👤 users only
|
|
4214
4221
|
*
|
|
4215
|
-
* @returns Service message about the transferred gift
|
|
4222
|
+
* @returns Service message about the transferred gift, if one was generated.
|
|
4216
4223
|
*/
|
|
4217
4224
|
transferStarGift(params: {
|
|
4218
4225
|
/** Star gift to transfer */
|
|
@@ -4224,7 +4231,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4224
4231
|
* to the client's update handler.
|
|
4225
4232
|
*/
|
|
4226
4233
|
shouldDispatch?: true;
|
|
4227
|
-
}): Promise<Message>;
|
|
4234
|
+
}): Promise<Message | null>;
|
|
4228
4235
|
/**
|
|
4229
4236
|
* Upgrades a star gift to a unique gift.
|
|
4230
4237
|
*
|
|
@@ -4235,7 +4242,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4235
4242
|
*
|
|
4236
4243
|
* **Available**: 👤 users only
|
|
4237
4244
|
*
|
|
4238
|
-
* @returns Service message about the upgraded gift
|
|
4245
|
+
* @returns Service message about the upgraded gift, if one was generated.
|
|
4239
4246
|
*/
|
|
4240
4247
|
upgradeStarGift(params: {
|
|
4241
4248
|
gift: InputStarGift;
|
|
@@ -4249,7 +4256,7 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4249
4256
|
* to the client's update handler.
|
|
4250
4257
|
*/
|
|
4251
4258
|
shouldDispatch?: true;
|
|
4252
|
-
}): Promise<Message>;
|
|
4259
|
+
}): Promise<Message | null>;
|
|
4253
4260
|
/**
|
|
4254
4261
|
* Add a sticker to a sticker set.
|
|
4255
4262
|
*
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
|
|
4
|
+
console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
|
|
5
|
+
}
|
|
6
|
+
"use strict";
|
|
7
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
+
const peerUtils = require("../../utils/peer-utils.cjs");
|
|
9
|
+
const resolvePeer = require("../users/resolve-peer.cjs");
|
|
10
|
+
const getChat = require("./get-chat.cjs");
|
|
11
|
+
const getUser = require("./get-user.cjs");
|
|
12
|
+
async function getPeer(client, peer) {
|
|
13
|
+
const resolved = await resolvePeer.resolvePeer(client, peer);
|
|
14
|
+
if (peerUtils.isInputPeerUser(resolved)) {
|
|
15
|
+
return getUser.getUser(client, resolved);
|
|
16
|
+
}
|
|
17
|
+
return getChat.getChat(client, resolved);
|
|
18
|
+
}
|
|
19
|
+
exports.getPeer = getPeer;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Peer } from '../../types/index.js';
|
|
3
|
+
/** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
|
|
4
|
+
export declare function getPeer(client: ITelegramClient, peer: InputPeerLike): Promise<Peer>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
+
import { InputPeerLike, Peer } from '../../types/index.js';
|
|
3
|
+
/** Shorthand for {@link getChat} and {@link getUser} depending on the type of the peer */
|
|
4
|
+
export declare function getPeer(client: ITelegramClient, peer: InputPeerLike): Promise<Peer>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isInputPeerUser } from "../../utils/peer-utils.js";
|
|
2
|
+
import { resolvePeer } from "../users/resolve-peer.js";
|
|
3
|
+
import { getChat } from "./get-chat.js";
|
|
4
|
+
import { getUser } from "./get-user.js";
|
|
5
|
+
async function getPeer(client, peer) {
|
|
6
|
+
const resolved = await resolvePeer(client, peer);
|
|
7
|
+
if (isInputPeerUser(resolved)) {
|
|
8
|
+
return getUser(client, resolved);
|
|
9
|
+
}
|
|
10
|
+
return getChat(client, resolved);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
getPeer
|
|
14
|
+
};
|
|
@@ -15,9 +15,15 @@ const inputMessageId = require("../../types/messages/input-message-id.cjs");
|
|
|
15
15
|
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
16
16
|
const messageReactions = require("../../types/messages/message-reactions.cjs");
|
|
17
17
|
async function sendPaidReaction(client, params) {
|
|
18
|
-
const { anonymous, count = 1 } = params;
|
|
18
|
+
const { anonymous, asPeer, count = 1 } = params;
|
|
19
19
|
const { chatId, message } = inputMessageId.normalizeInputMessageId(params);
|
|
20
20
|
const peer = await resolvePeer.resolvePeer(client, chatId);
|
|
21
|
+
let privacy;
|
|
22
|
+
if (anonymous !== void 0) {
|
|
23
|
+
privacy = { _: anonymous ? "paidReactionPrivacyAnonymous" : "paidReactionPrivacyDefault" };
|
|
24
|
+
} else if (asPeer) {
|
|
25
|
+
privacy = { _: "paidReactionPrivacyPeer", peer: await resolvePeer.resolvePeer(client, asPeer) };
|
|
26
|
+
}
|
|
21
27
|
let res;
|
|
22
28
|
for (let i = 0; i < 3; i++) {
|
|
23
29
|
try {
|
|
@@ -26,7 +32,7 @@ async function sendPaidReaction(client, params) {
|
|
|
26
32
|
peer,
|
|
27
33
|
msgId: message,
|
|
28
34
|
count,
|
|
29
|
-
private:
|
|
35
|
+
private: privacy,
|
|
30
36
|
randomId: await client.getMtprotoMessageId()
|
|
31
37
|
});
|
|
32
38
|
break;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
2
|
+
import { InputMessageId, InputPeerLike, MessageReactions } from '../../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Send a paid reaction using Telegram Stars.
|
|
5
5
|
*
|
|
@@ -8,8 +8,14 @@ import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
|
8
8
|
* The message is normally available for users, but may not be available for bots in PMs.
|
|
9
9
|
*/
|
|
10
10
|
export declare function sendPaidReaction(client: ITelegramClient, params: InputMessageId & {
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Whether to send the reaction anonymously
|
|
13
|
+
*/
|
|
12
14
|
anonymous?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Peer as which to send the reaction, mutually exclusive with `anonymous`
|
|
17
|
+
*/
|
|
18
|
+
asPeer?: InputPeerLike;
|
|
13
19
|
/**
|
|
14
20
|
* Number of reactions to send
|
|
15
21
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ITelegramClient } from '../../client.types.js';
|
|
2
|
-
import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
2
|
+
import { InputMessageId, InputPeerLike, MessageReactions } from '../../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Send a paid reaction using Telegram Stars.
|
|
5
5
|
*
|
|
@@ -8,8 +8,14 @@ import { InputMessageId, MessageReactions } from '../../types/index.js';
|
|
|
8
8
|
* The message is normally available for users, but may not be available for bots in PMs.
|
|
9
9
|
*/
|
|
10
10
|
export declare function sendPaidReaction(client: ITelegramClient, params: InputMessageId & {
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Whether to send the reaction anonymously
|
|
13
|
+
*/
|
|
12
14
|
anonymous?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Peer as which to send the reaction, mutually exclusive with `anonymous`
|
|
17
|
+
*/
|
|
18
|
+
asPeer?: InputPeerLike;
|
|
13
19
|
/**
|
|
14
20
|
* Number of reactions to send
|
|
15
21
|
*
|
|
@@ -8,9 +8,15 @@ import { normalizeInputMessageId } from "../../types/messages/input-message-id.j
|
|
|
8
8
|
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
9
9
|
import { MessageReactions as MessageReactions$2 } from "../../types/messages/message-reactions.js";
|
|
10
10
|
async function sendPaidReaction(client, params) {
|
|
11
|
-
const { anonymous, count = 1 } = params;
|
|
11
|
+
const { anonymous, asPeer, count = 1 } = params;
|
|
12
12
|
const { chatId, message } = normalizeInputMessageId(params);
|
|
13
13
|
const peer = await resolvePeer(client, chatId);
|
|
14
|
+
let privacy;
|
|
15
|
+
if (anonymous !== void 0) {
|
|
16
|
+
privacy = { _: anonymous ? "paidReactionPrivacyAnonymous" : "paidReactionPrivacyDefault" };
|
|
17
|
+
} else if (asPeer) {
|
|
18
|
+
privacy = { _: "paidReactionPrivacyPeer", peer: await resolvePeer(client, asPeer) };
|
|
19
|
+
}
|
|
14
20
|
let res;
|
|
15
21
|
for (let i = 0; i < 3; i++) {
|
|
16
22
|
try {
|
|
@@ -19,7 +25,7 @@ async function sendPaidReaction(client, params) {
|
|
|
19
25
|
peer,
|
|
20
26
|
msgId: message,
|
|
21
27
|
count,
|
|
22
|
-
private:
|
|
28
|
+
private: privacy,
|
|
23
29
|
randomId: await client.getMtprotoMessageId()
|
|
24
30
|
});
|
|
25
31
|
break;
|
|
@@ -37,6 +37,6 @@ async function sendStarGift(client, params) {
|
|
|
37
37
|
formId: form.formId
|
|
38
38
|
});
|
|
39
39
|
typeAssertions.assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
|
|
40
|
-
return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch);
|
|
40
|
+
return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
|
|
41
41
|
}
|
|
42
42
|
exports.sendStarGift = sendStarGift;
|
|
@@ -12,7 +12,7 @@ import { InputText } from '../../types/misc/entities.js';
|
|
|
12
12
|
* > For GUI clients, you should refer to the method's source code and
|
|
13
13
|
* > present the payment form to the user.
|
|
14
14
|
*
|
|
15
|
-
* @returns Service message about the sent gift
|
|
15
|
+
* @returns Service message about the sent gift, if one was generated.
|
|
16
16
|
*/
|
|
17
17
|
export declare function sendStarGift(client: ITelegramClient, params: {
|
|
18
18
|
/** ID of the peer to send the gift to */
|
|
@@ -34,4 +34,4 @@ export declare function sendStarGift(client: ITelegramClient, params: {
|
|
|
34
34
|
* to the client's update handler.
|
|
35
35
|
*/
|
|
36
36
|
shouldDispatch?: true;
|
|
37
|
-
}): Promise<Message>;
|
|
37
|
+
}): Promise<Message | null>;
|
|
@@ -12,7 +12,7 @@ import { InputText } from '../../types/misc/entities.js';
|
|
|
12
12
|
* > For GUI clients, you should refer to the method's source code and
|
|
13
13
|
* > present the payment form to the user.
|
|
14
14
|
*
|
|
15
|
-
* @returns Service message about the sent gift
|
|
15
|
+
* @returns Service message about the sent gift, if one was generated.
|
|
16
16
|
*/
|
|
17
17
|
export declare function sendStarGift(client: ITelegramClient, params: {
|
|
18
18
|
/** ID of the peer to send the gift to */
|
|
@@ -34,4 +34,4 @@ export declare function sendStarGift(client: ITelegramClient, params: {
|
|
|
34
34
|
* to the client's update handler.
|
|
35
35
|
*/
|
|
36
36
|
shouldDispatch?: true;
|
|
37
|
-
}): Promise<Message>;
|
|
37
|
+
}): Promise<Message | null>;
|
|
@@ -30,7 +30,7 @@ async function sendStarGift(client, params) {
|
|
|
30
30
|
formId: form.formId
|
|
31
31
|
});
|
|
32
32
|
assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
|
|
33
|
-
return _findMessageInUpdate(client, res.updates, false, !shouldDispatch);
|
|
33
|
+
return _findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
36
|
sendStarGift
|
|
@@ -26,6 +26,6 @@ async function transferStarGift(client, params) {
|
|
|
26
26
|
formId: form.formId
|
|
27
27
|
});
|
|
28
28
|
typeAssertions.assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
|
|
29
|
-
return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch);
|
|
29
|
+
return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
|
|
30
30
|
}
|
|
31
31
|
exports.transferStarGift = transferStarGift;
|
|
@@ -9,7 +9,7 @@ import { Message } from '../../types/messages/message.js';
|
|
|
9
9
|
* > For GUI clients, you should refer to the method's source code and
|
|
10
10
|
* > present the payment form to the user.
|
|
11
11
|
*
|
|
12
|
-
* @returns Service message about the transferred gift
|
|
12
|
+
* @returns Service message about the transferred gift, if one was generated.
|
|
13
13
|
*/
|
|
14
14
|
export declare function transferStarGift(client: ITelegramClient, params: {
|
|
15
15
|
/** Star gift to transfer */
|
|
@@ -21,4 +21,4 @@ export declare function transferStarGift(client: ITelegramClient, params: {
|
|
|
21
21
|
* to the client's update handler.
|
|
22
22
|
*/
|
|
23
23
|
shouldDispatch?: true;
|
|
24
|
-
}): Promise<Message>;
|
|
24
|
+
}): Promise<Message | null>;
|
|
@@ -9,7 +9,7 @@ import { Message } from '../../types/messages/message.js';
|
|
|
9
9
|
* > For GUI clients, you should refer to the method's source code and
|
|
10
10
|
* > present the payment form to the user.
|
|
11
11
|
*
|
|
12
|
-
* @returns Service message about the transferred gift
|
|
12
|
+
* @returns Service message about the transferred gift, if one was generated.
|
|
13
13
|
*/
|
|
14
14
|
export declare function transferStarGift(client: ITelegramClient, params: {
|
|
15
15
|
/** Star gift to transfer */
|
|
@@ -21,4 +21,4 @@ export declare function transferStarGift(client: ITelegramClient, params: {
|
|
|
21
21
|
* to the client's update handler.
|
|
22
22
|
*/
|
|
23
23
|
shouldDispatch?: true;
|
|
24
|
-
}): Promise<Message>;
|
|
24
|
+
}): Promise<Message | null>;
|
|
@@ -19,7 +19,7 @@ async function transferStarGift(client, params) {
|
|
|
19
19
|
formId: form.formId
|
|
20
20
|
});
|
|
21
21
|
assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
|
|
22
|
-
return _findMessageInUpdate(client, res.updates, false, !shouldDispatch);
|
|
22
|
+
return _findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
|
|
23
23
|
}
|
|
24
24
|
export {
|
|
25
25
|
transferStarGift
|
|
@@ -25,6 +25,6 @@ async function upgradeStarGift(client, params) {
|
|
|
25
25
|
formId: form.formId
|
|
26
26
|
});
|
|
27
27
|
typeAssertions.assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
|
|
28
|
-
return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch);
|
|
28
|
+
return findInUpdate._findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
|
|
29
29
|
}
|
|
30
30
|
exports.upgradeStarGift = upgradeStarGift;
|
|
@@ -9,7 +9,7 @@ import { Message } from '../../types/messages/message.js';
|
|
|
9
9
|
* > For GUI clients, you should refer to the method's source code and
|
|
10
10
|
* > present the payment form to the user.
|
|
11
11
|
*
|
|
12
|
-
* @returns Service message about the upgraded gift
|
|
12
|
+
* @returns Service message about the upgraded gift, if one was generated.
|
|
13
13
|
*/
|
|
14
14
|
export declare function upgradeStarGift(client: ITelegramClient, params: {
|
|
15
15
|
gift: InputStarGift;
|
|
@@ -23,4 +23,4 @@ export declare function upgradeStarGift(client: ITelegramClient, params: {
|
|
|
23
23
|
* to the client's update handler.
|
|
24
24
|
*/
|
|
25
25
|
shouldDispatch?: true;
|
|
26
|
-
}): Promise<Message>;
|
|
26
|
+
}): Promise<Message | null>;
|
|
@@ -9,7 +9,7 @@ import { Message } from '../../types/messages/message.js';
|
|
|
9
9
|
* > For GUI clients, you should refer to the method's source code and
|
|
10
10
|
* > present the payment form to the user.
|
|
11
11
|
*
|
|
12
|
-
* @returns Service message about the upgraded gift
|
|
12
|
+
* @returns Service message about the upgraded gift, if one was generated.
|
|
13
13
|
*/
|
|
14
14
|
export declare function upgradeStarGift(client: ITelegramClient, params: {
|
|
15
15
|
gift: InputStarGift;
|
|
@@ -23,4 +23,4 @@ export declare function upgradeStarGift(client: ITelegramClient, params: {
|
|
|
23
23
|
* to the client's update handler.
|
|
24
24
|
*/
|
|
25
25
|
shouldDispatch?: true;
|
|
26
|
-
}): Promise<Message>;
|
|
26
|
+
}): Promise<Message | null>;
|
|
@@ -18,7 +18,7 @@ async function upgradeStarGift(client, params) {
|
|
|
18
18
|
formId: form.formId
|
|
19
19
|
});
|
|
20
20
|
assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
|
|
21
|
-
return _findMessageInUpdate(client, res.updates, false, !shouldDispatch);
|
|
21
|
+
return _findMessageInUpdate(client, res.updates, false, !shouldDispatch, true);
|
|
22
22
|
}
|
|
23
23
|
export {
|
|
24
24
|
upgradeStarGift
|
package/highlevel/methods.d.cts
CHANGED
|
@@ -54,6 +54,7 @@ export { getChat } from './methods/chats/get-chat.js';
|
|
|
54
54
|
export { getFullChat } from './methods/chats/get-full-chat.js';
|
|
55
55
|
export { getFullUser } from './methods/chats/get-full-user.js';
|
|
56
56
|
export { getNearbyChats } from './methods/chats/get-nearby-chats.js';
|
|
57
|
+
export { getPeer } from './methods/chats/get-peer.js';
|
|
57
58
|
export { getSimilarChannels } from './methods/chats/get-similar-channels.js';
|
|
58
59
|
export { getUser } from './methods/chats/get-user.js';
|
|
59
60
|
export { iterChatEventLog } from './methods/chats/iter-chat-event-log.js';
|
package/highlevel/methods.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ export { getChat } from './methods/chats/get-chat.js';
|
|
|
54
54
|
export { getFullChat } from './methods/chats/get-full-chat.js';
|
|
55
55
|
export { getFullUser } from './methods/chats/get-full-user.js';
|
|
56
56
|
export { getNearbyChats } from './methods/chats/get-nearby-chats.js';
|
|
57
|
+
export { getPeer } from './methods/chats/get-peer.js';
|
|
57
58
|
export { getSimilarChannels } from './methods/chats/get-similar-channels.js';
|
|
58
59
|
export { getUser } from './methods/chats/get-user.js';
|
|
59
60
|
export { iterChatEventLog } from './methods/chats/iter-chat-event-log.js';
|
|
@@ -26,14 +26,19 @@ class TakeoutSession {
|
|
|
26
26
|
* @param params Additional call parameters
|
|
27
27
|
*/
|
|
28
28
|
async call(message, params) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
let query = {
|
|
30
|
+
_: "invokeWithTakeout",
|
|
31
|
+
takeoutId: this.id,
|
|
32
|
+
query: message
|
|
33
|
+
};
|
|
34
|
+
if (params?.withMessageRange) {
|
|
35
|
+
query = {
|
|
36
|
+
_: "invokeWithMessagesRange",
|
|
37
|
+
range: params.withMessageRange,
|
|
38
|
+
query
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return this.client.call(query, params);
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* Create a proxy over {@link TelegramClient}
|
|
@@ -42,20 +47,12 @@ class TakeoutSession {
|
|
|
42
47
|
* You can optionally provide a function to check if some
|
|
43
48
|
* RPC method should be called via a takeout session or directly,
|
|
44
49
|
* otherwise all methods are called through the takeout session.
|
|
45
|
-
*
|
|
46
|
-
* > **Note**: This will return a `Proxy` object that
|
|
47
|
-
* > overrides `call` method. Using this method requires
|
|
48
|
-
* > that your target environment supports `Proxy` and `Reflect` APIs
|
|
49
|
-
*
|
|
50
|
-
* @param predicate
|
|
51
|
-
* Function that given the RPC call should determine whether
|
|
52
|
-
* that call should be called via takeout session or not.
|
|
53
|
-
* Returning `true` will use takeout session, `false` will not.
|
|
54
50
|
*/
|
|
55
|
-
createProxy(
|
|
56
|
-
const boundCall =
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
createProxy(params) {
|
|
52
|
+
const boundCall = params ? (obj, theirParams) => {
|
|
53
|
+
const mergedParams = theirParams ? { ...params, ...theirParams } : params;
|
|
54
|
+
if (!params.predicate || params.predicate?.(obj)) {
|
|
55
|
+
return this.call(obj, mergedParams);
|
|
59
56
|
}
|
|
60
57
|
return this.client.call(obj, params);
|
|
61
58
|
} : this.call.bind(this);
|
|
@@ -21,7 +21,10 @@ export declare class TakeoutSession {
|
|
|
21
21
|
* @param message RPC method to call
|
|
22
22
|
* @param params Additional call parameters
|
|
23
23
|
*/
|
|
24
|
-
call<T extends tl.RpcMethod>(message: MustEqual<T, tl.RpcMethod>, params?: RpcCallOptions
|
|
24
|
+
call<T extends tl.RpcMethod>(message: MustEqual<T, tl.RpcMethod>, params?: RpcCallOptions & {
|
|
25
|
+
/** If passed, the request will be wrapped in an `invokeWithMessagesRange` */
|
|
26
|
+
withMessageRange?: tl.TypeMessageRange;
|
|
27
|
+
}): Promise<tl.RpcCallReturn[T['_']]>;
|
|
25
28
|
/**
|
|
26
29
|
* Create a proxy over {@link TelegramClient}
|
|
27
30
|
* that will use this takeout session to call methods.
|
|
@@ -29,17 +32,19 @@ export declare class TakeoutSession {
|
|
|
29
32
|
* You can optionally provide a function to check if some
|
|
30
33
|
* RPC method should be called via a takeout session or directly,
|
|
31
34
|
* otherwise all methods are called through the takeout session.
|
|
32
|
-
*
|
|
33
|
-
* > **Note**: This will return a `Proxy` object that
|
|
34
|
-
* > overrides `call` method. Using this method requires
|
|
35
|
-
* > that your target environment supports `Proxy` and `Reflect` APIs
|
|
36
|
-
*
|
|
37
|
-
* @param predicate
|
|
38
|
-
* Function that given the RPC call should determine whether
|
|
39
|
-
* that call should be called via takeout session or not.
|
|
40
|
-
* Returning `true` will use takeout session, `false` will not.
|
|
41
35
|
*/
|
|
42
|
-
createProxy(
|
|
36
|
+
createProxy(params?: RpcCallOptions & {
|
|
37
|
+
/**
|
|
38
|
+
* Function that given the RPC call should determine whether
|
|
39
|
+
* that call should be called via takeout session (and use the rest of the params passed here) or not.
|
|
40
|
+
* Returning `true` will use takeout session, `false` will call the method directly.
|
|
41
|
+
*
|
|
42
|
+
* @default `undefined`, i.e. all calls are sent via takeout session
|
|
43
|
+
*/
|
|
44
|
+
predicate?: (obj: tl.TlObject) => boolean;
|
|
45
|
+
/** If passed, the request will be wrapped in an `invokeWithMessagesRange` */
|
|
46
|
+
withMessageRange?: tl.TypeMessageRange;
|
|
47
|
+
}): ITelegramClient;
|
|
43
48
|
/**
|
|
44
49
|
* Finish account takeout session
|
|
45
50
|
*
|
|
@@ -21,7 +21,10 @@ export declare class TakeoutSession {
|
|
|
21
21
|
* @param message RPC method to call
|
|
22
22
|
* @param params Additional call parameters
|
|
23
23
|
*/
|
|
24
|
-
call<T extends tl.RpcMethod>(message: MustEqual<T, tl.RpcMethod>, params?: RpcCallOptions
|
|
24
|
+
call<T extends tl.RpcMethod>(message: MustEqual<T, tl.RpcMethod>, params?: RpcCallOptions & {
|
|
25
|
+
/** If passed, the request will be wrapped in an `invokeWithMessagesRange` */
|
|
26
|
+
withMessageRange?: tl.TypeMessageRange;
|
|
27
|
+
}): Promise<tl.RpcCallReturn[T['_']]>;
|
|
25
28
|
/**
|
|
26
29
|
* Create a proxy over {@link TelegramClient}
|
|
27
30
|
* that will use this takeout session to call methods.
|
|
@@ -29,17 +32,19 @@ export declare class TakeoutSession {
|
|
|
29
32
|
* You can optionally provide a function to check if some
|
|
30
33
|
* RPC method should be called via a takeout session or directly,
|
|
31
34
|
* otherwise all methods are called through the takeout session.
|
|
32
|
-
*
|
|
33
|
-
* > **Note**: This will return a `Proxy` object that
|
|
34
|
-
* > overrides `call` method. Using this method requires
|
|
35
|
-
* > that your target environment supports `Proxy` and `Reflect` APIs
|
|
36
|
-
*
|
|
37
|
-
* @param predicate
|
|
38
|
-
* Function that given the RPC call should determine whether
|
|
39
|
-
* that call should be called via takeout session or not.
|
|
40
|
-
* Returning `true` will use takeout session, `false` will not.
|
|
41
35
|
*/
|
|
42
|
-
createProxy(
|
|
36
|
+
createProxy(params?: RpcCallOptions & {
|
|
37
|
+
/**
|
|
38
|
+
* Function that given the RPC call should determine whether
|
|
39
|
+
* that call should be called via takeout session (and use the rest of the params passed here) or not.
|
|
40
|
+
* Returning `true` will use takeout session, `false` will call the method directly.
|
|
41
|
+
*
|
|
42
|
+
* @default `undefined`, i.e. all calls are sent via takeout session
|
|
43
|
+
*/
|
|
44
|
+
predicate?: (obj: tl.TlObject) => boolean;
|
|
45
|
+
/** If passed, the request will be wrapped in an `invokeWithMessagesRange` */
|
|
46
|
+
withMessageRange?: tl.TypeMessageRange;
|
|
47
|
+
}): ITelegramClient;
|
|
43
48
|
/**
|
|
44
49
|
* Finish account takeout session
|
|
45
50
|
*
|
|
@@ -19,14 +19,19 @@ class TakeoutSession {
|
|
|
19
19
|
* @param params Additional call parameters
|
|
20
20
|
*/
|
|
21
21
|
async call(message, params) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
let query = {
|
|
23
|
+
_: "invokeWithTakeout",
|
|
24
|
+
takeoutId: this.id,
|
|
25
|
+
query: message
|
|
26
|
+
};
|
|
27
|
+
if (params?.withMessageRange) {
|
|
28
|
+
query = {
|
|
29
|
+
_: "invokeWithMessagesRange",
|
|
30
|
+
range: params.withMessageRange,
|
|
31
|
+
query
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return this.client.call(query, params);
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* Create a proxy over {@link TelegramClient}
|
|
@@ -35,20 +40,12 @@ class TakeoutSession {
|
|
|
35
40
|
* You can optionally provide a function to check if some
|
|
36
41
|
* RPC method should be called via a takeout session or directly,
|
|
37
42
|
* otherwise all methods are called through the takeout session.
|
|
38
|
-
*
|
|
39
|
-
* > **Note**: This will return a `Proxy` object that
|
|
40
|
-
* > overrides `call` method. Using this method requires
|
|
41
|
-
* > that your target environment supports `Proxy` and `Reflect` APIs
|
|
42
|
-
*
|
|
43
|
-
* @param predicate
|
|
44
|
-
* Function that given the RPC call should determine whether
|
|
45
|
-
* that call should be called via takeout session or not.
|
|
46
|
-
* Returning `true` will use takeout session, `false` will not.
|
|
47
43
|
*/
|
|
48
|
-
createProxy(
|
|
49
|
-
const boundCall =
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
createProxy(params) {
|
|
45
|
+
const boundCall = params ? (obj, theirParams) => {
|
|
46
|
+
const mergedParams = theirParams ? { ...params, ...theirParams } : params;
|
|
47
|
+
if (!params.predicate || params.predicate?.(obj)) {
|
|
48
|
+
return this.call(obj, mergedParams);
|
|
52
49
|
}
|
|
53
50
|
return this.client.call(obj, params);
|
|
54
51
|
} : this.call.bind(this);
|
|
@@ -152,6 +152,10 @@ class StarGiftUnique {
|
|
|
152
152
|
get ownerAddress() {
|
|
153
153
|
return this.raw.ownerAddress ?? null;
|
|
154
154
|
}
|
|
155
|
+
/** TON address of the gift NFT */
|
|
156
|
+
get giftAddress() {
|
|
157
|
+
return this.raw.giftAddress ?? null;
|
|
158
|
+
}
|
|
155
159
|
}
|
|
156
160
|
const StarGiftUnique$1 = /* @__PURE__ */ inspectable.makeInspectable(StarGiftUnique);
|
|
157
161
|
const StarGiftUnique$2 = /* @__PURE__ */ memoize.memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
|
|
@@ -73,4 +73,6 @@ export declare class StarGiftUnique {
|
|
|
73
73
|
get originalDetails(): StarGiftUniqueOriginalDetails | null;
|
|
74
74
|
/** TON address of the owner of the unique star gift */
|
|
75
75
|
get ownerAddress(): string | null;
|
|
76
|
+
/** TON address of the gift NFT */
|
|
77
|
+
get giftAddress(): string | null;
|
|
76
78
|
}
|
|
@@ -73,4 +73,6 @@ export declare class StarGiftUnique {
|
|
|
73
73
|
get originalDetails(): StarGiftUniqueOriginalDetails | null;
|
|
74
74
|
/** TON address of the owner of the unique star gift */
|
|
75
75
|
get ownerAddress(): string | null;
|
|
76
|
+
/** TON address of the gift NFT */
|
|
77
|
+
get giftAddress(): string | null;
|
|
76
78
|
}
|
|
@@ -145,6 +145,10 @@ class StarGiftUnique {
|
|
|
145
145
|
get ownerAddress() {
|
|
146
146
|
return this.raw.ownerAddress ?? null;
|
|
147
147
|
}
|
|
148
|
+
/** TON address of the gift NFT */
|
|
149
|
+
get giftAddress() {
|
|
150
|
+
return this.raw.giftAddress ?? null;
|
|
151
|
+
}
|
|
148
152
|
}
|
|
149
153
|
const StarGiftUnique$1 = /* @__PURE__ */ makeInspectable(StarGiftUnique);
|
|
150
154
|
const StarGiftUnique$2 = /* @__PURE__ */ memoizeGetters(StarGiftUnique$1, ["model", "pattern", "backdrop", "originalDetails"]);
|
package/index.cjs
CHANGED
|
@@ -152,6 +152,7 @@ const utils = require("./types/utils.cjs");
|
|
|
152
152
|
exports.Long = Long;
|
|
153
153
|
exports.getAllPeersFrom = peerUtils.getAllPeersFrom;
|
|
154
154
|
exports.getBarePeerId = peerUtils.getBarePeerId;
|
|
155
|
+
exports.getBasicPeerType = peerUtils.getBasicPeerType;
|
|
155
156
|
exports.getMarkedPeerId = peerUtils.getMarkedPeerId;
|
|
156
157
|
exports.parseMarkedPeerId = peerUtils.parseMarkedPeerId;
|
|
157
158
|
exports.toggleChannelIdMark = peerUtils.toggleChannelIdMark;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as default2 } from "long";
|
|
2
|
-
import { getAllPeersFrom, getBarePeerId, getMarkedPeerId, parseMarkedPeerId, toggleChannelIdMark } from "./utils/peer-utils.js";
|
|
2
|
+
import { getAllPeersFrom, getBarePeerId, getBasicPeerType, getMarkedPeerId, parseMarkedPeerId, toggleChannelIdMark } from "./utils/peer-utils.js";
|
|
3
3
|
import { mtp, tl } from "@mtcute/tl";
|
|
4
4
|
import { TelegramStorageManager } from "./highlevel/storage/storage.js";
|
|
5
5
|
import { SentCode } from "./highlevel/types/auth/sent-code.js";
|
|
@@ -308,6 +308,7 @@ export {
|
|
|
308
308
|
businessWorkHoursDaysToRaw,
|
|
309
309
|
getAllPeersFrom,
|
|
310
310
|
getBarePeerId,
|
|
311
|
+
getBasicPeerType,
|
|
311
312
|
getMarkedPeerId,
|
|
312
313
|
inputTextToTl,
|
|
313
314
|
isUploadedFile,
|
package/methods.cjs
CHANGED
|
@@ -56,6 +56,7 @@ const getChat = require("./highlevel/methods/chats/get-chat.cjs");
|
|
|
56
56
|
const getFullChat = require("./highlevel/methods/chats/get-full-chat.cjs");
|
|
57
57
|
const getFullUser = require("./highlevel/methods/chats/get-full-user.cjs");
|
|
58
58
|
const getNearbyChats = require("./highlevel/methods/chats/get-nearby-chats.cjs");
|
|
59
|
+
const getPeer = require("./highlevel/methods/chats/get-peer.cjs");
|
|
59
60
|
const getSimilarChannels = require("./highlevel/methods/chats/get-similar-channels.cjs");
|
|
60
61
|
const getUser = require("./highlevel/methods/chats/get-user.cjs");
|
|
61
62
|
const iterChatEventLog = require("./highlevel/methods/chats/iter-chat-event-log.cjs");
|
|
@@ -317,6 +318,7 @@ exports.getChat = getChat.getChat;
|
|
|
317
318
|
exports.getFullChat = getFullChat.getFullChat;
|
|
318
319
|
exports.getFullUser = getFullUser.getFullUser;
|
|
319
320
|
exports.getNearbyChats = getNearbyChats.getNearbyChats;
|
|
321
|
+
exports.getPeer = getPeer.getPeer;
|
|
320
322
|
exports.getSimilarChannels = getSimilarChannels.getSimilarChannels;
|
|
321
323
|
exports.getUser = getUser.getUser;
|
|
322
324
|
exports.iterChatEventLog = iterChatEventLog.iterChatEventLog;
|
package/methods.js
CHANGED
|
@@ -49,6 +49,7 @@ import { getChat } from "./highlevel/methods/chats/get-chat.js";
|
|
|
49
49
|
import { getFullChat } from "./highlevel/methods/chats/get-full-chat.js";
|
|
50
50
|
import { getFullUser } from "./highlevel/methods/chats/get-full-user.js";
|
|
51
51
|
import { getNearbyChats } from "./highlevel/methods/chats/get-nearby-chats.js";
|
|
52
|
+
import { getPeer } from "./highlevel/methods/chats/get-peer.js";
|
|
52
53
|
import { getSimilarChannels } from "./highlevel/methods/chats/get-similar-channels.js";
|
|
53
54
|
import { getUser } from "./highlevel/methods/chats/get-user.js";
|
|
54
55
|
import { iterChatEventLog } from "./highlevel/methods/chats/iter-chat-event-log.js";
|
|
@@ -379,6 +380,7 @@ export {
|
|
|
379
380
|
getMyUsername,
|
|
380
381
|
getNearbyChats,
|
|
381
382
|
getPasswordHint,
|
|
383
|
+
getPeer,
|
|
382
384
|
getPeerDialogs,
|
|
383
385
|
getPeerStories,
|
|
384
386
|
getPrimaryInviteLink,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.21.1",
|
|
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.9",
|
|
11
11
|
"@fuman/utils": "0.0.4",
|
|
12
12
|
"@mtcute/file-id": "^0.19.0",
|
|
13
|
-
"@mtcute/tl": "^
|
|
13
|
+
"@mtcute/tl": "^199.0.0",
|
|
14
14
|
"@mtcute/tl-runtime": "^0.19.0",
|
|
15
15
|
"@types/events": "3.0.0",
|
|
16
16
|
"long": "5.2.3"
|
package/utils/peer-utils.cjs
CHANGED
|
@@ -6,6 +6,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
8
|
const errors = require("../types/errors.cjs");
|
|
9
|
+
const utils = require("../types/utils.cjs");
|
|
9
10
|
const ZERO_CHANNEL_ID = -1e12;
|
|
10
11
|
const ZERO_SECRET_CHAT_ID = -2e12;
|
|
11
12
|
const MAX_SECRET_CHAT_ID = -1997852516353;
|
|
@@ -136,8 +137,51 @@ function* getAllPeersFrom(obj) {
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
}
|
|
140
|
+
function getBasicPeerType(id) {
|
|
141
|
+
if (typeof id === "number") {
|
|
142
|
+
if (id < 0) {
|
|
143
|
+
if (MIN_MARKED_CHAT_ID <= id) {
|
|
144
|
+
return "chat";
|
|
145
|
+
}
|
|
146
|
+
if (MIN_MARKED_CHANNEL_ID <= id && id !== ZERO_CHANNEL_ID) {
|
|
147
|
+
return "channel";
|
|
148
|
+
}
|
|
149
|
+
} else if (id > 0 && id <= MAX_USER_ID) {
|
|
150
|
+
return "user";
|
|
151
|
+
}
|
|
152
|
+
throw new Error(`Invalid marked peer id: ${id}`);
|
|
153
|
+
}
|
|
154
|
+
switch (id._) {
|
|
155
|
+
case "peerUser":
|
|
156
|
+
case "inputUser":
|
|
157
|
+
case "inputUserSelf":
|
|
158
|
+
case "inputPeerSelf":
|
|
159
|
+
case "inputUserFromMessage":
|
|
160
|
+
case "inputPeerUser":
|
|
161
|
+
case "inputPeerUserFromMessage":
|
|
162
|
+
case "inputUserEmpty":
|
|
163
|
+
case "mtcute.dummyInputPeerMinUser":
|
|
164
|
+
return "user";
|
|
165
|
+
case "peerChat":
|
|
166
|
+
case "inputPeerChat":
|
|
167
|
+
return "chat";
|
|
168
|
+
case "peerChannel":
|
|
169
|
+
case "inputChannel":
|
|
170
|
+
case "inputChannelEmpty":
|
|
171
|
+
case "mtcute.dummyInputPeerMinChannel":
|
|
172
|
+
case "inputChannelFromMessage":
|
|
173
|
+
case "inputPeerChannel":
|
|
174
|
+
case "inputPeerChannelFromMessage":
|
|
175
|
+
return "channel";
|
|
176
|
+
case "inputPeerEmpty":
|
|
177
|
+
throw new Error("Empty peer");
|
|
178
|
+
default:
|
|
179
|
+
utils.assertNever();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
139
182
|
exports.getAllPeersFrom = getAllPeersFrom;
|
|
140
183
|
exports.getBarePeerId = getBarePeerId;
|
|
184
|
+
exports.getBasicPeerType = getBasicPeerType;
|
|
141
185
|
exports.getMarkedPeerId = getMarkedPeerId;
|
|
142
186
|
exports.parseMarkedPeerId = parseMarkedPeerId;
|
|
143
187
|
exports.toggleChannelIdMark = toggleChannelIdMark;
|
package/utils/peer-utils.d.cts
CHANGED
|
@@ -27,3 +27,5 @@ export declare function parseMarkedPeerId(id: number): [BasicPeerType, number];
|
|
|
27
27
|
* Only checks `.user`, `.chat`, `.channel`, `.users` and `.chats` properties
|
|
28
28
|
*/
|
|
29
29
|
export declare function getAllPeersFrom(obj: tl.TlObject | tl.TlObject[]): Iterable<tl.TypeUser | tl.TypeChat>;
|
|
30
|
+
/** Get the {@link BasicPeerType} of a peer, either by its marked ID or by its TL object */
|
|
31
|
+
export declare function getBasicPeerType(id: number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel): BasicPeerType;
|
package/utils/peer-utils.d.ts
CHANGED
|
@@ -27,3 +27,5 @@ export declare function parseMarkedPeerId(id: number): [BasicPeerType, number];
|
|
|
27
27
|
* Only checks `.user`, `.chat`, `.channel`, `.users` and `.chats` properties
|
|
28
28
|
*/
|
|
29
29
|
export declare function getAllPeersFrom(obj: tl.TlObject | tl.TlObject[]): Iterable<tl.TypeUser | tl.TypeChat>;
|
|
30
|
+
/** Get the {@link BasicPeerType} of a peer, either by its marked ID or by its TL object */
|
|
31
|
+
export declare function getBasicPeerType(id: number | tl.TypePeer | tl.TypeInputPeer | tl.TypeInputUser | tl.TypeInputChannel): BasicPeerType;
|
package/utils/peer-utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MtUnsupportedError, MtArgumentError } from "../types/errors.js";
|
|
2
|
+
import { assertNever } from "../types/utils.js";
|
|
2
3
|
const ZERO_CHANNEL_ID = -1e12;
|
|
3
4
|
const ZERO_SECRET_CHAT_ID = -2e12;
|
|
4
5
|
const MAX_SECRET_CHAT_ID = -1997852516353;
|
|
@@ -129,9 +130,52 @@ function* getAllPeersFrom(obj) {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
}
|
|
133
|
+
function getBasicPeerType(id) {
|
|
134
|
+
if (typeof id === "number") {
|
|
135
|
+
if (id < 0) {
|
|
136
|
+
if (MIN_MARKED_CHAT_ID <= id) {
|
|
137
|
+
return "chat";
|
|
138
|
+
}
|
|
139
|
+
if (MIN_MARKED_CHANNEL_ID <= id && id !== ZERO_CHANNEL_ID) {
|
|
140
|
+
return "channel";
|
|
141
|
+
}
|
|
142
|
+
} else if (id > 0 && id <= MAX_USER_ID) {
|
|
143
|
+
return "user";
|
|
144
|
+
}
|
|
145
|
+
throw new Error(`Invalid marked peer id: ${id}`);
|
|
146
|
+
}
|
|
147
|
+
switch (id._) {
|
|
148
|
+
case "peerUser":
|
|
149
|
+
case "inputUser":
|
|
150
|
+
case "inputUserSelf":
|
|
151
|
+
case "inputPeerSelf":
|
|
152
|
+
case "inputUserFromMessage":
|
|
153
|
+
case "inputPeerUser":
|
|
154
|
+
case "inputPeerUserFromMessage":
|
|
155
|
+
case "inputUserEmpty":
|
|
156
|
+
case "mtcute.dummyInputPeerMinUser":
|
|
157
|
+
return "user";
|
|
158
|
+
case "peerChat":
|
|
159
|
+
case "inputPeerChat":
|
|
160
|
+
return "chat";
|
|
161
|
+
case "peerChannel":
|
|
162
|
+
case "inputChannel":
|
|
163
|
+
case "inputChannelEmpty":
|
|
164
|
+
case "mtcute.dummyInputPeerMinChannel":
|
|
165
|
+
case "inputChannelFromMessage":
|
|
166
|
+
case "inputPeerChannel":
|
|
167
|
+
case "inputPeerChannelFromMessage":
|
|
168
|
+
return "channel";
|
|
169
|
+
case "inputPeerEmpty":
|
|
170
|
+
throw new Error("Empty peer");
|
|
171
|
+
default:
|
|
172
|
+
assertNever();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
132
175
|
export {
|
|
133
176
|
getAllPeersFrom,
|
|
134
177
|
getBarePeerId,
|
|
178
|
+
getBasicPeerType,
|
|
135
179
|
getMarkedPeerId,
|
|
136
180
|
parseMarkedPeerId,
|
|
137
181
|
toggleChannelIdMark
|
package/utils.cjs
CHANGED
|
@@ -71,6 +71,7 @@ exports.getRandomInt = miscUtils$1.getRandomInt;
|
|
|
71
71
|
exports.sleepWithAbort = miscUtils$1.sleepWithAbort;
|
|
72
72
|
exports.getAllPeersFrom = peerUtils$1.getAllPeersFrom;
|
|
73
73
|
exports.getBarePeerId = peerUtils$1.getBarePeerId;
|
|
74
|
+
exports.getBasicPeerType = peerUtils$1.getBasicPeerType;
|
|
74
75
|
exports.getMarkedPeerId = peerUtils$1.getMarkedPeerId;
|
|
75
76
|
exports.parseMarkedPeerId = peerUtils$1.parseMarkedPeerId;
|
|
76
77
|
exports.toggleChannelIdMark = peerUtils$1.toggleChannelIdMark;
|
package/utils.js
CHANGED
|
@@ -10,7 +10,7 @@ import { SortedLinkedList } from "./utils/linked-list.js";
|
|
|
10
10
|
import { LogManager, Logger } from "./utils/logger.js";
|
|
11
11
|
import { LongMap, LongSet, compareLongs, longFromBuffer, longFromFastString, longToFastString, randomLong, removeFromLongArray } from "./utils/long-utils.js";
|
|
12
12
|
import { getRandomInt, sleepWithAbort } from "./utils/misc-utils.js";
|
|
13
|
-
import { getAllPeersFrom, getBarePeerId, getMarkedPeerId, parseMarkedPeerId, toggleChannelIdMark } from "./utils/peer-utils.js";
|
|
13
|
+
import { getAllPeersFrom, getBarePeerId, getBasicPeerType, getMarkedPeerId, parseMarkedPeerId, toggleChannelIdMark } from "./utils/peer-utils.js";
|
|
14
14
|
import { SortedArray } from "./utils/sorted-array.js";
|
|
15
15
|
import { jsonToTlJson, tlJsonToJson } from "./utils/tl-json.js";
|
|
16
16
|
import { assertTrue, assertTypeIs, assertTypeIsNot, hasValueAtKey, isPresent, isTlRpcError, mtpAssertTypeIs } from "./utils/type-assertions.js";
|
|
@@ -80,6 +80,7 @@ export {
|
|
|
80
80
|
generateKeyAndIvFromNonce,
|
|
81
81
|
getAllPeersFrom,
|
|
82
82
|
getBarePeerId,
|
|
83
|
+
getBasicPeerType,
|
|
83
84
|
getMarkedPeerId,
|
|
84
85
|
getRandomInt,
|
|
85
86
|
hasValueAtKey,
|