@mtcute/core 0.25.6 → 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 +7 -0
- package/client.js +8 -1
- package/highlevel/client.d.cts +61 -4
- package/highlevel/client.d.ts +61 -4
- package/highlevel/methods/files/normalize-input-media.cjs +13 -4
- package/highlevel/methods/files/normalize-input-media.js +13 -4
- package/highlevel/methods/messages/search-posts-global.cjs +48 -0
- package/highlevel/methods/messages/search-posts-global.d.cts +27 -0
- package/highlevel/methods/messages/search-posts-global.d.ts +27 -0
- package/highlevel/methods/messages/search-posts-global.js +43 -0
- 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/premium/set-gift-resale-price.cjs +11 -1
- package/highlevel/methods/premium/set-gift-resale-price.d.cts +5 -2
- package/highlevel/methods/premium/set-gift-resale-price.d.ts +5 -2
- package/highlevel/methods/premium/set-gift-resale-price.js +11 -1
- package/highlevel/methods/stories/send-story.cjs +3 -2
- package/highlevel/methods/stories/send-story.d.cts +4 -0
- package/highlevel/methods/stories/send-story.d.ts +4 -0
- package/highlevel/methods/stories/send-story.js +3 -2
- package/highlevel/methods.d.cts +3 -0
- package/highlevel/methods.d.ts +3 -0
- package/highlevel/types/messages/message-action.cjs +2 -1
- package/highlevel/types/messages/message-action.d.cts +2 -0
- package/highlevel/types/messages/message-action.d.ts +2 -0
- package/highlevel/types/messages/message-action.js +2 -1
- 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/highlevel/types/peers/full-user.cjs +14 -1
- package/highlevel/types/peers/full-user.d.cts +9 -0
- package/highlevel/types/peers/full-user.d.ts +9 -0
- package/highlevel/types/peers/full-user.js +14 -1
- package/highlevel/types/premium/stars-gift-unique.cjs +8 -1
- 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 +8 -1
- package/highlevel/types/stories/story.cjs +6 -0
- package/highlevel/types/stories/story.d.cts +4 -0
- package/highlevel/types/stories/story.d.ts +4 -0
- package/highlevel/types/stories/story.js +6 -0
- package/methods.cjs +3 -0
- package/methods.js +4 -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 +2 -2
- package/utils/binary/compat.cjs +30 -0
- package/utils/binary/compat.js +30 -0
- package/utils/binary/serialization.d.cts +3 -3
- package/utils/binary/serialization.d.ts +3 -3
package/client.cjs
CHANGED
|
@@ -163,6 +163,7 @@ const readReactions = require("./highlevel/methods/messages/read-reactions.cjs")
|
|
|
163
163
|
const searchGlobal = require("./highlevel/methods/messages/search-global.cjs");
|
|
164
164
|
const searchHashtag = require("./highlevel/methods/messages/search-hashtag.cjs");
|
|
165
165
|
const searchMessages = require("./highlevel/methods/messages/search-messages.cjs");
|
|
166
|
+
const searchPostsGlobal = require("./highlevel/methods/messages/search-posts-global.cjs");
|
|
166
167
|
const sendAnswer = require("./highlevel/methods/messages/send-answer.cjs");
|
|
167
168
|
const sendComment = require("./highlevel/methods/messages/send-comment.cjs");
|
|
168
169
|
const sendCopyGroup = require("./highlevel/methods/messages/send-copy-group.cjs");
|
|
@@ -935,6 +936,9 @@ TelegramClient.prototype.iterSearchHashtag = function(...args) {
|
|
|
935
936
|
TelegramClient.prototype.searchMessages = function(...args) {
|
|
936
937
|
return searchMessages.searchMessages(this._client, ...args);
|
|
937
938
|
};
|
|
939
|
+
TelegramClient.prototype.searchPostsGlobal = function(...args) {
|
|
940
|
+
return searchPostsGlobal.searchPostsGlobal(this._client, ...args);
|
|
941
|
+
};
|
|
938
942
|
TelegramClient.prototype.answerText = function(...args) {
|
|
939
943
|
return sendAnswer.answerText(this._client, ...args);
|
|
940
944
|
};
|
|
@@ -1085,6 +1089,9 @@ TelegramClient.prototype.getBusinessConnection = function(...args) {
|
|
|
1085
1089
|
TelegramClient.prototype.getMyBoostSlots = function(...args) {
|
|
1086
1090
|
return getMyBoostSlots.getMyBoostSlots(this._client, ...args);
|
|
1087
1091
|
};
|
|
1092
|
+
TelegramClient.prototype.getStarGiftResaleOptions = function(...args) {
|
|
1093
|
+
return getResaleStarGifts.getStarGiftResaleOptions(this._client, ...args);
|
|
1094
|
+
};
|
|
1088
1095
|
TelegramClient.prototype.getResaleOptions = function(...args) {
|
|
1089
1096
|
return getResaleStarGifts.getResaleOptions(this._client, ...args);
|
|
1090
1097
|
};
|
package/client.js
CHANGED
|
@@ -156,6 +156,7 @@ import { readReactions } from "./highlevel/methods/messages/read-reactions.js";
|
|
|
156
156
|
import { searchGlobal } from "./highlevel/methods/messages/search-global.js";
|
|
157
157
|
import { searchHashtag, iterSearchHashtag } from "./highlevel/methods/messages/search-hashtag.js";
|
|
158
158
|
import { searchMessages } from "./highlevel/methods/messages/search-messages.js";
|
|
159
|
+
import { searchPostsGlobal } from "./highlevel/methods/messages/search-posts-global.js";
|
|
159
160
|
import { answerText, answerMedia, answerMediaGroup } from "./highlevel/methods/messages/send-answer.js";
|
|
160
161
|
import { commentText, commentMedia, commentMediaGroup } from "./highlevel/methods/messages/send-comment.js";
|
|
161
162
|
import { sendCopyGroup } from "./highlevel/methods/messages/send-copy-group.js";
|
|
@@ -196,7 +197,7 @@ import { getBoosts } from "./highlevel/methods/premium/get-boosts.js";
|
|
|
196
197
|
import { getBusinessChatLinks } from "./highlevel/methods/premium/get-business-chat-links.js";
|
|
197
198
|
import { getBusinessConnection } from "./highlevel/methods/premium/get-business-connection.js";
|
|
198
199
|
import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.js";
|
|
199
|
-
import { getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
|
|
200
|
+
import { getStarGiftResaleOptions, getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
|
|
200
201
|
import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-star-gifts-by-id.js";
|
|
201
202
|
import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
|
|
202
203
|
import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
|
|
@@ -928,6 +929,9 @@ TelegramClient.prototype.iterSearchHashtag = function(...args) {
|
|
|
928
929
|
TelegramClient.prototype.searchMessages = function(...args) {
|
|
929
930
|
return searchMessages(this._client, ...args);
|
|
930
931
|
};
|
|
932
|
+
TelegramClient.prototype.searchPostsGlobal = function(...args) {
|
|
933
|
+
return searchPostsGlobal(this._client, ...args);
|
|
934
|
+
};
|
|
931
935
|
TelegramClient.prototype.answerText = function(...args) {
|
|
932
936
|
return answerText(this._client, ...args);
|
|
933
937
|
};
|
|
@@ -1078,6 +1082,9 @@ TelegramClient.prototype.getBusinessConnection = function(...args) {
|
|
|
1078
1082
|
TelegramClient.prototype.getMyBoostSlots = function(...args) {
|
|
1079
1083
|
return getMyBoostSlots(this._client, ...args);
|
|
1080
1084
|
};
|
|
1085
|
+
TelegramClient.prototype.getStarGiftResaleOptions = function(...args) {
|
|
1086
|
+
return getStarGiftResaleOptions(this._client, ...args);
|
|
1087
|
+
};
|
|
1081
1088
|
TelegramClient.prototype.getResaleOptions = function(...args) {
|
|
1082
1089
|
return getResaleOptions(this._client, ...args);
|
|
1083
1090
|
};
|
package/highlevel/client.d.cts
CHANGED
|
@@ -16,12 +16,13 @@ import { GetReactionUsersOffset, getReactionUsers } from './methods/messages/get
|
|
|
16
16
|
import { SearchGlobalOffset, searchGlobal } from './methods/messages/search-global.js';
|
|
17
17
|
import { SearchHashtagOffset, searchHashtag } from './methods/messages/search-hashtag.js';
|
|
18
18
|
import { SearchMessagesOffset, searchMessages } from './methods/messages/search-messages.js';
|
|
19
|
+
import { SearchPostsGlobalOffset } from './methods/messages/search-posts-global.js';
|
|
19
20
|
import { CommonSendParams } from './methods/messages/send-common.js';
|
|
20
21
|
import { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
|
|
21
22
|
import { SendCopyParams } from './methods/messages/send-copy.js';
|
|
22
23
|
import { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
23
24
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
24
|
-
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
|
|
25
|
+
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta, getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
25
26
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
26
27
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
27
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';
|
|
@@ -2647,6 +2648,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
2647
2648
|
/**
|
|
2648
2649
|
* Append item(s) to a todo list
|
|
2649
2650
|
*
|
|
2651
|
+
* **Available**: ✅ both users and bots
|
|
2652
|
+
*
|
|
2650
2653
|
* @returns Service message about the appended todo item(s), if any.
|
|
2651
2654
|
*/
|
|
2652
2655
|
appendTodoList(params: InputMessageId & {
|
|
@@ -3401,6 +3404,26 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3401
3404
|
*/
|
|
3402
3405
|
fromUser?: InputPeerLike;
|
|
3403
3406
|
}): Promise<ArrayPaginated<Message, SearchMessagesOffset>>;
|
|
3407
|
+
/**
|
|
3408
|
+
* Search for posts globally across all public channels in Telegram
|
|
3409
|
+
*
|
|
3410
|
+
* **Available**: 👤 users only
|
|
3411
|
+
*
|
|
3412
|
+
* @param query Keyword to search for
|
|
3413
|
+
* @param params Additional parameters
|
|
3414
|
+
*/
|
|
3415
|
+
searchPostsGlobal(query: string, params?: {
|
|
3416
|
+
/** Offset for the search */
|
|
3417
|
+
offset?: SearchPostsGlobalOffset;
|
|
3418
|
+
/** Limit the number of results */
|
|
3419
|
+
limit?: number;
|
|
3420
|
+
/**
|
|
3421
|
+
* The amount of stars you are willing to pay for the search
|
|
3422
|
+
*/
|
|
3423
|
+
payStars?: tl.Long;
|
|
3424
|
+
}): Promise<ArrayPaginatedWithMeta<Message, SearchPostsGlobalOffset, {
|
|
3425
|
+
limits?: tl.TypeSearchPostsFlood;
|
|
3426
|
+
}>>;
|
|
3404
3427
|
/** Send a text to the same chat (and topic, if applicable) as a given message */
|
|
3405
3428
|
answerText(message: Message, ...params: ParametersSkip2<typeof sendText>): ReturnType<typeof sendText>;
|
|
3406
3429
|
/** Send a media to the same chat (and topic, if applicable) as a given message */
|
|
@@ -3742,6 +3765,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3742
3765
|
/**
|
|
3743
3766
|
* Toggle the completion status of a todo list item(s)
|
|
3744
3767
|
*
|
|
3768
|
+
* **Available**: ✅ both users and bots
|
|
3769
|
+
*
|
|
3745
3770
|
* @returns Service message about the toggled items, if any.
|
|
3746
3771
|
*/
|
|
3747
3772
|
toggleTodoCompleted(params: InputMessageId & {
|
|
@@ -3922,6 +3947,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3922
3947
|
* to the client's update handler.
|
|
3923
3948
|
*/
|
|
3924
3949
|
shouldDispatch?: true;
|
|
3950
|
+
/** Whether to use TON currency for payment */
|
|
3951
|
+
ton?: boolean;
|
|
3925
3952
|
}): Promise<Message | null>;
|
|
3926
3953
|
/**
|
|
3927
3954
|
* Check if the current user can apply boost to some channel
|
|
@@ -4020,8 +4047,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4020
4047
|
getMyBoostSlots(): Promise<BoostSlot[]>;
|
|
4021
4048
|
/**
|
|
4022
4049
|
* Get a list of star gifts up for resale
|
|
4050
|
+
* **Available**: ✅ both users and bots
|
|
4051
|
+
*
|
|
4023
4052
|
*/
|
|
4024
|
-
|
|
4053
|
+
getStarGiftResaleOptions(params: {
|
|
4025
4054
|
/** ID of the gift to get resale options for */
|
|
4026
4055
|
giftId: tl.Long;
|
|
4027
4056
|
/**
|
|
@@ -4042,12 +4071,22 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4042
4071
|
/** Limit for pagination */
|
|
4043
4072
|
limit?: number;
|
|
4044
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>>;
|
|
4045
4082
|
/** Get one or more saved star gifts by their IDs */
|
|
4046
4083
|
getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
|
|
4047
4084
|
/**
|
|
4048
4085
|
* Get a list of saved star gifts of a user/channel
|
|
4049
4086
|
*
|
|
4050
4087
|
* Note that filters currently only work for channels
|
|
4088
|
+
* **Available**: ✅ both users and bots
|
|
4089
|
+
*
|
|
4051
4090
|
*/
|
|
4052
4091
|
getSavedStarGifts(params: {
|
|
4053
4092
|
/** Peer to get saved gifts from */
|
|
@@ -4062,6 +4101,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4062
4101
|
excludeLimited?: boolean;
|
|
4063
4102
|
/** Whether to exclude unique gifts */
|
|
4064
4103
|
excludeUnique?: boolean;
|
|
4104
|
+
/** ID of the collection to get gifts from */
|
|
4105
|
+
collectionId?: number;
|
|
4065
4106
|
/** Whether to sort by value */
|
|
4066
4107
|
sortByValue?: boolean;
|
|
4067
4108
|
/** Offset for pagination */
|
|
@@ -4116,6 +4157,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4116
4157
|
}): Promise<StarsStatus>;
|
|
4117
4158
|
/**
|
|
4118
4159
|
* Get information about a unique star gift by its slug
|
|
4160
|
+
* **Available**: ✅ both users and bots
|
|
4161
|
+
*
|
|
4119
4162
|
*/
|
|
4120
4163
|
getUniqueStarGift(slug: string): Promise<StarGiftUnique>;
|
|
4121
4164
|
/**
|
|
@@ -4143,6 +4186,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4143
4186
|
/**
|
|
4144
4187
|
* Iterate over saved star gifts of a user,
|
|
4145
4188
|
* wrapper over {@link getSavedStarGifts}
|
|
4189
|
+
* **Available**: ✅ both users and bots
|
|
4190
|
+
*
|
|
4146
4191
|
*/
|
|
4147
4192
|
iterSavedStarGifts(params: {
|
|
4148
4193
|
/** Peer to get saved gifts from */
|
|
@@ -4194,6 +4239,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4194
4239
|
}): AsyncIterableIterator<StarsTransaction>;
|
|
4195
4240
|
/**
|
|
4196
4241
|
* Toggles whether one or more star gift is pinned to the top of the list
|
|
4242
|
+
* **Available**: ✅ both users and bots
|
|
4243
|
+
*
|
|
4197
4244
|
*/
|
|
4198
4245
|
togglePinnedStarGifts(params: {
|
|
4199
4246
|
/** One or more gifts to pin */
|
|
@@ -4276,8 +4323,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4276
4323
|
setResaleStarGiftPrice(params: {
|
|
4277
4324
|
/** Star gift to update the price of */
|
|
4278
4325
|
gift: InputStarGift;
|
|
4279
|
-
/**
|
|
4280
|
-
|
|
4326
|
+
/**
|
|
4327
|
+
* New price of the gift (in stars), or `null` to unlist
|
|
4328
|
+
*/
|
|
4329
|
+
price: tl.Long | number | tl.TypeStarsAmount | null;
|
|
4281
4330
|
}): Promise<void>;
|
|
4282
4331
|
/**
|
|
4283
4332
|
* Transfer a unique star gift.
|
|
@@ -4287,6 +4336,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4287
4336
|
* > For GUI clients, you should refer to the method's source code and
|
|
4288
4337
|
* > present the payment form to the user.
|
|
4289
4338
|
*
|
|
4339
|
+
* **Available**: 👤 users only
|
|
4340
|
+
*
|
|
4290
4341
|
* @returns Service message about the transferred gift, if one was generated.
|
|
4291
4342
|
*/
|
|
4292
4343
|
transferStarGift(params: {
|
|
@@ -4308,6 +4359,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4308
4359
|
* > For GUI clients, you should refer to the method's source code and
|
|
4309
4360
|
* > present the payment form to the user.
|
|
4310
4361
|
*
|
|
4362
|
+
* **Available**: 👤 users only
|
|
4363
|
+
*
|
|
4311
4364
|
* @returns Service message about the upgraded gift, if one was generated.
|
|
4312
4365
|
*/
|
|
4313
4366
|
upgradeStarGift(params: {
|
|
@@ -4873,6 +4926,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4873
4926
|
* @default 86400
|
|
4874
4927
|
*/
|
|
4875
4928
|
period?: number;
|
|
4929
|
+
/**
|
|
4930
|
+
* IDs of albums to add the story to
|
|
4931
|
+
*/
|
|
4932
|
+
addToAlbums?: number[];
|
|
4876
4933
|
}): Promise<Story>;
|
|
4877
4934
|
/**
|
|
4878
4935
|
* Toggle whether peer's stories are archived (hidden) or not.
|
package/highlevel/client.d.ts
CHANGED
|
@@ -16,12 +16,13 @@ import { GetReactionUsersOffset, getReactionUsers } from './methods/messages/get
|
|
|
16
16
|
import { SearchGlobalOffset, searchGlobal } from './methods/messages/search-global.js';
|
|
17
17
|
import { SearchHashtagOffset, searchHashtag } from './methods/messages/search-hashtag.js';
|
|
18
18
|
import { SearchMessagesOffset, searchMessages } from './methods/messages/search-messages.js';
|
|
19
|
+
import { SearchPostsGlobalOffset } from './methods/messages/search-posts-global.js';
|
|
19
20
|
import { CommonSendParams } from './methods/messages/send-common.js';
|
|
20
21
|
import { SendCopyGroupParams } from './methods/messages/send-copy-group.js';
|
|
21
22
|
import { SendCopyParams } from './methods/messages/send-copy.js';
|
|
22
23
|
import { QuoteParamsFrom } from './methods/messages/send-quote.js';
|
|
23
24
|
import { CanApplyBoostResult } from './methods/premium/can-apply-boost.js';
|
|
24
|
-
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta } from './methods/premium/get-resale-star-gifts.js';
|
|
25
|
+
import { InputStarGiftAttributeIds, ResaleStarGiftsMeta, getStarGiftResaleOptions } from './methods/premium/get-resale-star-gifts.js';
|
|
25
26
|
import { CanSendStoryResult } from './methods/stories/can-send-story.js';
|
|
26
27
|
import { ITelegramStorageProvider } from './storage/provider.js';
|
|
27
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';
|
|
@@ -2647,6 +2648,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
2647
2648
|
/**
|
|
2648
2649
|
* Append item(s) to a todo list
|
|
2649
2650
|
*
|
|
2651
|
+
* **Available**: ✅ both users and bots
|
|
2652
|
+
*
|
|
2650
2653
|
* @returns Service message about the appended todo item(s), if any.
|
|
2651
2654
|
*/
|
|
2652
2655
|
appendTodoList(params: InputMessageId & {
|
|
@@ -3401,6 +3404,26 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3401
3404
|
*/
|
|
3402
3405
|
fromUser?: InputPeerLike;
|
|
3403
3406
|
}): Promise<ArrayPaginated<Message, SearchMessagesOffset>>;
|
|
3407
|
+
/**
|
|
3408
|
+
* Search for posts globally across all public channels in Telegram
|
|
3409
|
+
*
|
|
3410
|
+
* **Available**: 👤 users only
|
|
3411
|
+
*
|
|
3412
|
+
* @param query Keyword to search for
|
|
3413
|
+
* @param params Additional parameters
|
|
3414
|
+
*/
|
|
3415
|
+
searchPostsGlobal(query: string, params?: {
|
|
3416
|
+
/** Offset for the search */
|
|
3417
|
+
offset?: SearchPostsGlobalOffset;
|
|
3418
|
+
/** Limit the number of results */
|
|
3419
|
+
limit?: number;
|
|
3420
|
+
/**
|
|
3421
|
+
* The amount of stars you are willing to pay for the search
|
|
3422
|
+
*/
|
|
3423
|
+
payStars?: tl.Long;
|
|
3424
|
+
}): Promise<ArrayPaginatedWithMeta<Message, SearchPostsGlobalOffset, {
|
|
3425
|
+
limits?: tl.TypeSearchPostsFlood;
|
|
3426
|
+
}>>;
|
|
3404
3427
|
/** Send a text to the same chat (and topic, if applicable) as a given message */
|
|
3405
3428
|
answerText(message: Message, ...params: ParametersSkip2<typeof sendText>): ReturnType<typeof sendText>;
|
|
3406
3429
|
/** Send a media to the same chat (and topic, if applicable) as a given message */
|
|
@@ -3742,6 +3765,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3742
3765
|
/**
|
|
3743
3766
|
* Toggle the completion status of a todo list item(s)
|
|
3744
3767
|
*
|
|
3768
|
+
* **Available**: ✅ both users and bots
|
|
3769
|
+
*
|
|
3745
3770
|
* @returns Service message about the toggled items, if any.
|
|
3746
3771
|
*/
|
|
3747
3772
|
toggleTodoCompleted(params: InputMessageId & {
|
|
@@ -3922,6 +3947,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
3922
3947
|
* to the client's update handler.
|
|
3923
3948
|
*/
|
|
3924
3949
|
shouldDispatch?: true;
|
|
3950
|
+
/** Whether to use TON currency for payment */
|
|
3951
|
+
ton?: boolean;
|
|
3925
3952
|
}): Promise<Message | null>;
|
|
3926
3953
|
/**
|
|
3927
3954
|
* Check if the current user can apply boost to some channel
|
|
@@ -4020,8 +4047,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4020
4047
|
getMyBoostSlots(): Promise<BoostSlot[]>;
|
|
4021
4048
|
/**
|
|
4022
4049
|
* Get a list of star gifts up for resale
|
|
4050
|
+
* **Available**: ✅ both users and bots
|
|
4051
|
+
*
|
|
4023
4052
|
*/
|
|
4024
|
-
|
|
4053
|
+
getStarGiftResaleOptions(params: {
|
|
4025
4054
|
/** ID of the gift to get resale options for */
|
|
4026
4055
|
giftId: tl.Long;
|
|
4027
4056
|
/**
|
|
@@ -4042,12 +4071,22 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4042
4071
|
/** Limit for pagination */
|
|
4043
4072
|
limit?: number;
|
|
4044
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>>;
|
|
4045
4082
|
/** Get one or more saved star gifts by their IDs */
|
|
4046
4083
|
getSavedStarGiftsById(gifts: MaybeArray<InputStarGift>): Promise<SavedStarGift[]>;
|
|
4047
4084
|
/**
|
|
4048
4085
|
* Get a list of saved star gifts of a user/channel
|
|
4049
4086
|
*
|
|
4050
4087
|
* Note that filters currently only work for channels
|
|
4088
|
+
* **Available**: ✅ both users and bots
|
|
4089
|
+
*
|
|
4051
4090
|
*/
|
|
4052
4091
|
getSavedStarGifts(params: {
|
|
4053
4092
|
/** Peer to get saved gifts from */
|
|
@@ -4062,6 +4101,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4062
4101
|
excludeLimited?: boolean;
|
|
4063
4102
|
/** Whether to exclude unique gifts */
|
|
4064
4103
|
excludeUnique?: boolean;
|
|
4104
|
+
/** ID of the collection to get gifts from */
|
|
4105
|
+
collectionId?: number;
|
|
4065
4106
|
/** Whether to sort by value */
|
|
4066
4107
|
sortByValue?: boolean;
|
|
4067
4108
|
/** Offset for pagination */
|
|
@@ -4116,6 +4157,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4116
4157
|
}): Promise<StarsStatus>;
|
|
4117
4158
|
/**
|
|
4118
4159
|
* Get information about a unique star gift by its slug
|
|
4160
|
+
* **Available**: ✅ both users and bots
|
|
4161
|
+
*
|
|
4119
4162
|
*/
|
|
4120
4163
|
getUniqueStarGift(slug: string): Promise<StarGiftUnique>;
|
|
4121
4164
|
/**
|
|
@@ -4143,6 +4186,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4143
4186
|
/**
|
|
4144
4187
|
* Iterate over saved star gifts of a user,
|
|
4145
4188
|
* wrapper over {@link getSavedStarGifts}
|
|
4189
|
+
* **Available**: ✅ both users and bots
|
|
4190
|
+
*
|
|
4146
4191
|
*/
|
|
4147
4192
|
iterSavedStarGifts(params: {
|
|
4148
4193
|
/** Peer to get saved gifts from */
|
|
@@ -4194,6 +4239,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4194
4239
|
}): AsyncIterableIterator<StarsTransaction>;
|
|
4195
4240
|
/**
|
|
4196
4241
|
* Toggles whether one or more star gift is pinned to the top of the list
|
|
4242
|
+
* **Available**: ✅ both users and bots
|
|
4243
|
+
*
|
|
4197
4244
|
*/
|
|
4198
4245
|
togglePinnedStarGifts(params: {
|
|
4199
4246
|
/** One or more gifts to pin */
|
|
@@ -4276,8 +4323,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4276
4323
|
setResaleStarGiftPrice(params: {
|
|
4277
4324
|
/** Star gift to update the price of */
|
|
4278
4325
|
gift: InputStarGift;
|
|
4279
|
-
/**
|
|
4280
|
-
|
|
4326
|
+
/**
|
|
4327
|
+
* New price of the gift (in stars), or `null` to unlist
|
|
4328
|
+
*/
|
|
4329
|
+
price: tl.Long | number | tl.TypeStarsAmount | null;
|
|
4281
4330
|
}): Promise<void>;
|
|
4282
4331
|
/**
|
|
4283
4332
|
* Transfer a unique star gift.
|
|
@@ -4287,6 +4336,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4287
4336
|
* > For GUI clients, you should refer to the method's source code and
|
|
4288
4337
|
* > present the payment form to the user.
|
|
4289
4338
|
*
|
|
4339
|
+
* **Available**: 👤 users only
|
|
4340
|
+
*
|
|
4290
4341
|
* @returns Service message about the transferred gift, if one was generated.
|
|
4291
4342
|
*/
|
|
4292
4343
|
transferStarGift(params: {
|
|
@@ -4308,6 +4359,8 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4308
4359
|
* > For GUI clients, you should refer to the method's source code and
|
|
4309
4360
|
* > present the payment form to the user.
|
|
4310
4361
|
*
|
|
4362
|
+
* **Available**: 👤 users only
|
|
4363
|
+
*
|
|
4311
4364
|
* @returns Service message about the upgraded gift, if one was generated.
|
|
4312
4365
|
*/
|
|
4313
4366
|
upgradeStarGift(params: {
|
|
@@ -4873,6 +4926,10 @@ export interface TelegramClient extends ITelegramClient {
|
|
|
4873
4926
|
* @default 86400
|
|
4874
4927
|
*/
|
|
4875
4928
|
period?: number;
|
|
4929
|
+
/**
|
|
4930
|
+
* IDs of albums to add the story to
|
|
4931
|
+
*/
|
|
4932
|
+
addToAlbums?: number[];
|
|
4876
4933
|
}): Promise<Story>;
|
|
4877
4934
|
/**
|
|
4878
4935
|
* Toggle whether peer's stories are archived (hidden) or not.
|
|
@@ -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)) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
2
|
+
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
|
|
3
|
+
console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. 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 typeAssertions = require("../../../utils/type-assertions.cjs");
|
|
9
|
+
const miscUtils = require("../../utils/misc-utils.cjs");
|
|
10
|
+
const peersIndex = require("../../types/peers/peers-index.cjs");
|
|
11
|
+
const message = require("../../types/messages/message.cjs");
|
|
12
|
+
const defaultOffset = {
|
|
13
|
+
rate: 0,
|
|
14
|
+
peer: { _: "inputPeerEmpty" },
|
|
15
|
+
id: 0
|
|
16
|
+
};
|
|
17
|
+
async function searchPostsGlobal(client, query, params) {
|
|
18
|
+
const {
|
|
19
|
+
offset: { rate: offsetRate, peer: offsetPeer, id: offsetId } = defaultOffset,
|
|
20
|
+
limit = 100,
|
|
21
|
+
payStars
|
|
22
|
+
} = params ?? {};
|
|
23
|
+
const res = await client.call({
|
|
24
|
+
_: "channels.searchPosts",
|
|
25
|
+
query,
|
|
26
|
+
allowPaidStars: payStars,
|
|
27
|
+
offsetId,
|
|
28
|
+
offsetRate,
|
|
29
|
+
offsetPeer,
|
|
30
|
+
limit
|
|
31
|
+
});
|
|
32
|
+
typeAssertions.assertTypeIsNot("searchHashtag", res, "messages.messagesNotModified");
|
|
33
|
+
const peers = peersIndex.PeersIndex.from(res);
|
|
34
|
+
const msgs = res.messages.filter((msg) => msg._ !== "messageEmpty").map((msg) => new message.Message(msg, peers));
|
|
35
|
+
const last = msgs[msgs.length - 1];
|
|
36
|
+
const next = last ? {
|
|
37
|
+
rate: res.nextRate ?? last.raw.date,
|
|
38
|
+
peer: last.chat.inputPeer,
|
|
39
|
+
id: last.id
|
|
40
|
+
} : void 0;
|
|
41
|
+
return miscUtils.makeArrayPaginatedWithMeta(
|
|
42
|
+
msgs,
|
|
43
|
+
res.count ?? msgs.length,
|
|
44
|
+
{ limits: res.searchFlood },
|
|
45
|
+
next
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
exports.searchPostsGlobal = searchPostsGlobal;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { tl } from '@mtcute/tl';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { ArrayPaginatedWithMeta } from '../../types/utils.js';
|
|
4
|
+
import { Message } from '../../types/index.js';
|
|
5
|
+
export interface SearchPostsGlobalOffset {
|
|
6
|
+
rate: number;
|
|
7
|
+
peer: tl.TypeInputPeer;
|
|
8
|
+
id: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Search for posts globally across all public channels in Telegram
|
|
12
|
+
*
|
|
13
|
+
* @param query Keyword to search for
|
|
14
|
+
* @param params Additional parameters
|
|
15
|
+
*/
|
|
16
|
+
export declare function searchPostsGlobal(client: ITelegramClient, query: string, params?: {
|
|
17
|
+
/** Offset for the search */
|
|
18
|
+
offset?: SearchPostsGlobalOffset;
|
|
19
|
+
/** Limit the number of results */
|
|
20
|
+
limit?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The amount of stars you are willing to pay for the search
|
|
23
|
+
*/
|
|
24
|
+
payStars?: tl.Long;
|
|
25
|
+
}): Promise<ArrayPaginatedWithMeta<Message, SearchPostsGlobalOffset, {
|
|
26
|
+
limits?: tl.TypeSearchPostsFlood;
|
|
27
|
+
}>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { tl } from '@mtcute/tl';
|
|
2
|
+
import { ITelegramClient } from '../../client.types.js';
|
|
3
|
+
import { ArrayPaginatedWithMeta } from '../../types/utils.js';
|
|
4
|
+
import { Message } from '../../types/index.js';
|
|
5
|
+
export interface SearchPostsGlobalOffset {
|
|
6
|
+
rate: number;
|
|
7
|
+
peer: tl.TypeInputPeer;
|
|
8
|
+
id: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Search for posts globally across all public channels in Telegram
|
|
12
|
+
*
|
|
13
|
+
* @param query Keyword to search for
|
|
14
|
+
* @param params Additional parameters
|
|
15
|
+
*/
|
|
16
|
+
export declare function searchPostsGlobal(client: ITelegramClient, query: string, params?: {
|
|
17
|
+
/** Offset for the search */
|
|
18
|
+
offset?: SearchPostsGlobalOffset;
|
|
19
|
+
/** Limit the number of results */
|
|
20
|
+
limit?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The amount of stars you are willing to pay for the search
|
|
23
|
+
*/
|
|
24
|
+
payStars?: tl.Long;
|
|
25
|
+
}): Promise<ArrayPaginatedWithMeta<Message, SearchPostsGlobalOffset, {
|
|
26
|
+
limits?: tl.TypeSearchPostsFlood;
|
|
27
|
+
}>>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { assertTypeIsNot } from "../../../utils/type-assertions.js";
|
|
2
|
+
import { makeArrayPaginatedWithMeta } from "../../utils/misc-utils.js";
|
|
3
|
+
import { PeersIndex } from "../../types/peers/peers-index.js";
|
|
4
|
+
import { Message as Message$2 } from "../../types/messages/message.js";
|
|
5
|
+
const defaultOffset = {
|
|
6
|
+
rate: 0,
|
|
7
|
+
peer: { _: "inputPeerEmpty" },
|
|
8
|
+
id: 0
|
|
9
|
+
};
|
|
10
|
+
async function searchPostsGlobal(client, query, params) {
|
|
11
|
+
const {
|
|
12
|
+
offset: { rate: offsetRate, peer: offsetPeer, id: offsetId } = defaultOffset,
|
|
13
|
+
limit = 100,
|
|
14
|
+
payStars
|
|
15
|
+
} = params ?? {};
|
|
16
|
+
const res = await client.call({
|
|
17
|
+
_: "channels.searchPosts",
|
|
18
|
+
query,
|
|
19
|
+
allowPaidStars: payStars,
|
|
20
|
+
offsetId,
|
|
21
|
+
offsetRate,
|
|
22
|
+
offsetPeer,
|
|
23
|
+
limit
|
|
24
|
+
});
|
|
25
|
+
assertTypeIsNot("searchHashtag", res, "messages.messagesNotModified");
|
|
26
|
+
const peers = PeersIndex.from(res);
|
|
27
|
+
const msgs = res.messages.filter((msg) => msg._ !== "messageEmpty").map((msg) => new Message$2(msg, peers));
|
|
28
|
+
const last = msgs[msgs.length - 1];
|
|
29
|
+
const next = last ? {
|
|
30
|
+
rate: res.nextRate ?? last.raw.date,
|
|
31
|
+
peer: last.chat.inputPeer,
|
|
32
|
+
id: last.id
|
|
33
|
+
} : void 0;
|
|
34
|
+
return makeArrayPaginatedWithMeta(
|
|
35
|
+
msgs,
|
|
36
|
+
res.count ?? msgs.length,
|
|
37
|
+
{ limits: res.searchFlood },
|
|
38
|
+
next
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
searchPostsGlobal
|
|
43
|
+
};
|