@mtcute/core 0.25.5 → 0.25.7

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.
Files changed (57) hide show
  1. package/client.cjs +4 -0
  2. package/client.js +4 -0
  3. package/highlevel/client.d.cts +49 -2
  4. package/highlevel/client.d.ts +49 -2
  5. package/highlevel/methods/messages/search-posts-global.cjs +48 -0
  6. package/highlevel/methods/messages/search-posts-global.d.cts +27 -0
  7. package/highlevel/methods/messages/search-posts-global.d.ts +27 -0
  8. package/highlevel/methods/messages/search-posts-global.js +43 -0
  9. package/highlevel/methods/premium/get-saved-star-gifts.cjs +1 -0
  10. package/highlevel/methods/premium/get-saved-star-gifts.d.cts +2 -0
  11. package/highlevel/methods/premium/get-saved-star-gifts.d.ts +2 -0
  12. package/highlevel/methods/premium/get-saved-star-gifts.js +1 -0
  13. package/highlevel/methods/premium/set-gift-resale-price.cjs +11 -1
  14. package/highlevel/methods/premium/set-gift-resale-price.d.cts +5 -2
  15. package/highlevel/methods/premium/set-gift-resale-price.d.ts +5 -2
  16. package/highlevel/methods/premium/set-gift-resale-price.js +11 -1
  17. package/highlevel/methods/stories/send-story.cjs +3 -2
  18. package/highlevel/methods/stories/send-story.d.cts +4 -0
  19. package/highlevel/methods/stories/send-story.d.ts +4 -0
  20. package/highlevel/methods/stories/send-story.js +3 -2
  21. package/highlevel/methods.d.cts +2 -0
  22. package/highlevel/methods.d.ts +2 -0
  23. package/highlevel/types/messages/message-action.cjs +2 -1
  24. package/highlevel/types/messages/message-action.d.cts +2 -0
  25. package/highlevel/types/messages/message-action.d.ts +2 -0
  26. package/highlevel/types/messages/message-action.js +2 -1
  27. package/highlevel/types/peers/full-user.cjs +20 -1
  28. package/highlevel/types/peers/full-user.d.cts +13 -0
  29. package/highlevel/types/peers/full-user.d.ts +13 -0
  30. package/highlevel/types/peers/full-user.js +20 -1
  31. package/highlevel/types/premium/saved-star-gift.cjs +4 -0
  32. package/highlevel/types/premium/saved-star-gift.d.cts +2 -0
  33. package/highlevel/types/premium/saved-star-gift.d.ts +2 -0
  34. package/highlevel/types/premium/saved-star-gift.js +4 -0
  35. package/highlevel/types/premium/stars-gift-unique.cjs +12 -1
  36. package/highlevel/types/premium/stars-gift-unique.d.cts +4 -0
  37. package/highlevel/types/premium/stars-gift-unique.d.ts +4 -0
  38. package/highlevel/types/premium/stars-gift-unique.js +12 -1
  39. package/highlevel/types/premium/stars-gift.cjs +16 -0
  40. package/highlevel/types/premium/stars-gift.d.cts +10 -0
  41. package/highlevel/types/premium/stars-gift.d.ts +10 -0
  42. package/highlevel/types/premium/stars-gift.js +16 -0
  43. package/highlevel/types/stories/story.cjs +6 -0
  44. package/highlevel/types/stories/story.d.cts +4 -0
  45. package/highlevel/types/stories/story.d.ts +4 -0
  46. package/highlevel/types/stories/story.js +6 -0
  47. package/methods.cjs +2 -0
  48. package/methods.js +2 -0
  49. package/network/network-manager.cjs +1 -1
  50. package/network/network-manager.js +1 -1
  51. package/network/session-connection.cjs +5 -1
  52. package/network/session-connection.d.cts +1 -0
  53. package/network/session-connection.d.ts +1 -0
  54. package/network/session-connection.js +5 -1
  55. package/package.json +2 -2
  56. package/utils/binary/compat.cjs +33 -0
  57. package/utils/binary/compat.js +33 -0
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
  };
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";
@@ -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
  };
@@ -16,6 +16,7 @@ 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';
@@ -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 & {
@@ -4020,6 +4045,8 @@ export interface TelegramClient extends ITelegramClient {
4020
4045
  getMyBoostSlots(): Promise<BoostSlot[]>;
4021
4046
  /**
4022
4047
  * Get a list of star gifts up for resale
4048
+ * **Available**: ✅ both users and bots
4049
+ *
4023
4050
  */
4024
4051
  getResaleOptions(params: {
4025
4052
  /** ID of the gift to get resale options for */
@@ -4048,6 +4075,8 @@ export interface TelegramClient extends ITelegramClient {
4048
4075
  * Get a list of saved star gifts of a user/channel
4049
4076
  *
4050
4077
  * Note that filters currently only work for channels
4078
+ * **Available**: ✅ both users and bots
4079
+ *
4051
4080
  */
4052
4081
  getSavedStarGifts(params: {
4053
4082
  /** Peer to get saved gifts from */
@@ -4062,6 +4091,8 @@ export interface TelegramClient extends ITelegramClient {
4062
4091
  excludeLimited?: boolean;
4063
4092
  /** Whether to exclude unique gifts */
4064
4093
  excludeUnique?: boolean;
4094
+ /** ID of the collection to get gifts from */
4095
+ collectionId?: number;
4065
4096
  /** Whether to sort by value */
4066
4097
  sortByValue?: boolean;
4067
4098
  /** Offset for pagination */
@@ -4116,6 +4147,8 @@ export interface TelegramClient extends ITelegramClient {
4116
4147
  }): Promise<StarsStatus>;
4117
4148
  /**
4118
4149
  * Get information about a unique star gift by its slug
4150
+ * **Available**: ✅ both users and bots
4151
+ *
4119
4152
  */
4120
4153
  getUniqueStarGift(slug: string): Promise<StarGiftUnique>;
4121
4154
  /**
@@ -4143,6 +4176,8 @@ export interface TelegramClient extends ITelegramClient {
4143
4176
  /**
4144
4177
  * Iterate over saved star gifts of a user,
4145
4178
  * wrapper over {@link getSavedStarGifts}
4179
+ * **Available**: ✅ both users and bots
4180
+ *
4146
4181
  */
4147
4182
  iterSavedStarGifts(params: {
4148
4183
  /** Peer to get saved gifts from */
@@ -4194,6 +4229,8 @@ export interface TelegramClient extends ITelegramClient {
4194
4229
  }): AsyncIterableIterator<StarsTransaction>;
4195
4230
  /**
4196
4231
  * Toggles whether one or more star gift is pinned to the top of the list
4232
+ * **Available**: ✅ both users and bots
4233
+ *
4197
4234
  */
4198
4235
  togglePinnedStarGifts(params: {
4199
4236
  /** One or more gifts to pin */
@@ -4276,8 +4313,10 @@ export interface TelegramClient extends ITelegramClient {
4276
4313
  setResaleStarGiftPrice(params: {
4277
4314
  /** Star gift to update the price of */
4278
4315
  gift: InputStarGift;
4279
- /** New price of the gift (in stars), or `null` to unlist */
4280
- price: number | null;
4316
+ /**
4317
+ * New price of the gift (in stars), or `null` to unlist
4318
+ */
4319
+ price: tl.Long | number | tl.TypeStarsAmount | null;
4281
4320
  }): Promise<void>;
4282
4321
  /**
4283
4322
  * Transfer a unique star gift.
@@ -4287,6 +4326,8 @@ export interface TelegramClient extends ITelegramClient {
4287
4326
  * > For GUI clients, you should refer to the method's source code and
4288
4327
  * > present the payment form to the user.
4289
4328
  *
4329
+ * **Available**: 👤 users only
4330
+ *
4290
4331
  * @returns Service message about the transferred gift, if one was generated.
4291
4332
  */
4292
4333
  transferStarGift(params: {
@@ -4308,6 +4349,8 @@ export interface TelegramClient extends ITelegramClient {
4308
4349
  * > For GUI clients, you should refer to the method's source code and
4309
4350
  * > present the payment form to the user.
4310
4351
  *
4352
+ * **Available**: 👤 users only
4353
+ *
4311
4354
  * @returns Service message about the upgraded gift, if one was generated.
4312
4355
  */
4313
4356
  upgradeStarGift(params: {
@@ -4873,6 +4916,10 @@ export interface TelegramClient extends ITelegramClient {
4873
4916
  * @default 86400
4874
4917
  */
4875
4918
  period?: number;
4919
+ /**
4920
+ * IDs of albums to add the story to
4921
+ */
4922
+ addToAlbums?: number[];
4876
4923
  }): Promise<Story>;
4877
4924
  /**
4878
4925
  * Toggle whether peer's stories are archived (hidden) or not.
@@ -16,6 +16,7 @@ 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';
@@ -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 & {
@@ -4020,6 +4045,8 @@ export interface TelegramClient extends ITelegramClient {
4020
4045
  getMyBoostSlots(): Promise<BoostSlot[]>;
4021
4046
  /**
4022
4047
  * Get a list of star gifts up for resale
4048
+ * **Available**: ✅ both users and bots
4049
+ *
4023
4050
  */
4024
4051
  getResaleOptions(params: {
4025
4052
  /** ID of the gift to get resale options for */
@@ -4048,6 +4075,8 @@ export interface TelegramClient extends ITelegramClient {
4048
4075
  * Get a list of saved star gifts of a user/channel
4049
4076
  *
4050
4077
  * Note that filters currently only work for channels
4078
+ * **Available**: ✅ both users and bots
4079
+ *
4051
4080
  */
4052
4081
  getSavedStarGifts(params: {
4053
4082
  /** Peer to get saved gifts from */
@@ -4062,6 +4091,8 @@ export interface TelegramClient extends ITelegramClient {
4062
4091
  excludeLimited?: boolean;
4063
4092
  /** Whether to exclude unique gifts */
4064
4093
  excludeUnique?: boolean;
4094
+ /** ID of the collection to get gifts from */
4095
+ collectionId?: number;
4065
4096
  /** Whether to sort by value */
4066
4097
  sortByValue?: boolean;
4067
4098
  /** Offset for pagination */
@@ -4116,6 +4147,8 @@ export interface TelegramClient extends ITelegramClient {
4116
4147
  }): Promise<StarsStatus>;
4117
4148
  /**
4118
4149
  * Get information about a unique star gift by its slug
4150
+ * **Available**: ✅ both users and bots
4151
+ *
4119
4152
  */
4120
4153
  getUniqueStarGift(slug: string): Promise<StarGiftUnique>;
4121
4154
  /**
@@ -4143,6 +4176,8 @@ export interface TelegramClient extends ITelegramClient {
4143
4176
  /**
4144
4177
  * Iterate over saved star gifts of a user,
4145
4178
  * wrapper over {@link getSavedStarGifts}
4179
+ * **Available**: ✅ both users and bots
4180
+ *
4146
4181
  */
4147
4182
  iterSavedStarGifts(params: {
4148
4183
  /** Peer to get saved gifts from */
@@ -4194,6 +4229,8 @@ export interface TelegramClient extends ITelegramClient {
4194
4229
  }): AsyncIterableIterator<StarsTransaction>;
4195
4230
  /**
4196
4231
  * Toggles whether one or more star gift is pinned to the top of the list
4232
+ * **Available**: ✅ both users and bots
4233
+ *
4197
4234
  */
4198
4235
  togglePinnedStarGifts(params: {
4199
4236
  /** One or more gifts to pin */
@@ -4276,8 +4313,10 @@ export interface TelegramClient extends ITelegramClient {
4276
4313
  setResaleStarGiftPrice(params: {
4277
4314
  /** Star gift to update the price of */
4278
4315
  gift: InputStarGift;
4279
- /** New price of the gift (in stars), or `null` to unlist */
4280
- price: number | null;
4316
+ /**
4317
+ * New price of the gift (in stars), or `null` to unlist
4318
+ */
4319
+ price: tl.Long | number | tl.TypeStarsAmount | null;
4281
4320
  }): Promise<void>;
4282
4321
  /**
4283
4322
  * Transfer a unique star gift.
@@ -4287,6 +4326,8 @@ export interface TelegramClient extends ITelegramClient {
4287
4326
  * > For GUI clients, you should refer to the method's source code and
4288
4327
  * > present the payment form to the user.
4289
4328
  *
4329
+ * **Available**: 👤 users only
4330
+ *
4290
4331
  * @returns Service message about the transferred gift, if one was generated.
4291
4332
  */
4292
4333
  transferStarGift(params: {
@@ -4308,6 +4349,8 @@ export interface TelegramClient extends ITelegramClient {
4308
4349
  * > For GUI clients, you should refer to the method's source code and
4309
4350
  * > present the payment form to the user.
4310
4351
  *
4352
+ * **Available**: 👤 users only
4353
+ *
4311
4354
  * @returns Service message about the upgraded gift, if one was generated.
4312
4355
  */
4313
4356
  upgradeStarGift(params: {
@@ -4873,6 +4916,10 @@ export interface TelegramClient extends ITelegramClient {
4873
4916
  * @default 86400
4874
4917
  */
4875
4918
  period?: number;
4919
+ /**
4920
+ * IDs of albums to add the story to
4921
+ */
4922
+ addToAlbums?: number[];
4876
4923
  }): Promise<Story>;
4877
4924
  /**
4878
4925
  * Toggle whether peer's stories are archived (hidden) or not.
@@ -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
+ };
@@ -19,6 +19,7 @@ async function getSavedStarGifts(client, params) {
19
19
  excludeLimited: params.excludeLimited,
20
20
  excludeUnique: params.excludeUnique,
21
21
  sortByValue: params.sortByValue,
22
+ collectionId: params.collectionId,
22
23
  offset: params.offset ?? "",
23
24
  limit: params.limit ?? 100
24
25
  });
@@ -19,6 +19,8 @@ export declare function getSavedStarGifts(client: ITelegramClient, params: {
19
19
  excludeLimited?: boolean;
20
20
  /** Whether to exclude unique gifts */
21
21
  excludeUnique?: boolean;
22
+ /** ID of the collection to get gifts from */
23
+ collectionId?: number;
22
24
  /** Whether to sort by value */
23
25
  sortByValue?: boolean;
24
26
  /** Offset for pagination */
@@ -19,6 +19,8 @@ export declare function getSavedStarGifts(client: ITelegramClient, params: {
19
19
  excludeLimited?: boolean;
20
20
  /** Whether to exclude unique gifts */
21
21
  excludeUnique?: boolean;
22
+ /** ID of the collection to get gifts from */
23
+ collectionId?: number;
22
24
  /** Whether to sort by value */
23
25
  sortByValue?: boolean;
24
26
  /** Offset for pagination */
@@ -12,6 +12,7 @@ async function getSavedStarGifts(client, params) {
12
12
  excludeLimited: params.excludeLimited,
13
13
  excludeUnique: params.excludeUnique,
14
14
  sortByValue: params.sortByValue,
15
+ collectionId: params.collectionId,
15
16
  offset: params.offset ?? "",
16
17
  limit: params.limit ?? 100
17
18
  });
@@ -9,10 +9,20 @@ const Long = require("long");
9
9
  const _normalizeInputStarGift = require("./_normalize-input-star-gift.cjs");
10
10
  async function setResaleStarGiftPrice(client, params) {
11
11
  const { gift, price } = params;
12
+ let starsAmount;
13
+ if (price === null) {
14
+ starsAmount = { _: "starsAmount", amount: Long.ZERO, nanos: 0 };
15
+ } else if (typeof price === "number") {
16
+ starsAmount = { _: "starsAmount", amount: Long.fromNumber(price), nanos: 0 };
17
+ } else if (Long.isLong(price)) {
18
+ starsAmount = { _: "starsAmount", amount: price, nanos: 0 };
19
+ } else {
20
+ starsAmount = price;
21
+ }
12
22
  const r = await client.call({
13
23
  _: "payments.updateStarGiftPrice",
14
24
  stargift: await _normalizeInputStarGift._normalizeInputStarGift(client, gift),
15
- resellStars: price === null ? Long.ZERO : Long.fromNumber(price)
25
+ resellAmount: starsAmount
16
26
  });
17
27
  client.handleClientUpdate(r);
18
28
  }
@@ -1,9 +1,12 @@
1
+ import { tl } from '@mtcute/tl';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { InputStarGift } from '../../types/index.js';
3
4
  /** Set resale price for an owned star gift */
4
5
  export declare function setResaleStarGiftPrice(client: ITelegramClient, params: {
5
6
  /** Star gift to update the price of */
6
7
  gift: InputStarGift;
7
- /** New price of the gift (in stars), or `null` to unlist */
8
- price: number | null;
8
+ /**
9
+ * New price of the gift (in stars), or `null` to unlist
10
+ */
11
+ price: tl.Long | number | tl.TypeStarsAmount | null;
9
12
  }): Promise<void>;
@@ -1,9 +1,12 @@
1
+ import { tl } from '@mtcute/tl';
1
2
  import { ITelegramClient } from '../../client.types.js';
2
3
  import { InputStarGift } from '../../types/index.js';
3
4
  /** Set resale price for an owned star gift */
4
5
  export declare function setResaleStarGiftPrice(client: ITelegramClient, params: {
5
6
  /** Star gift to update the price of */
6
7
  gift: InputStarGift;
7
- /** New price of the gift (in stars), or `null` to unlist */
8
- price: number | null;
8
+ /**
9
+ * New price of the gift (in stars), or `null` to unlist
10
+ */
11
+ price: tl.Long | number | tl.TypeStarsAmount | null;
9
12
  }): Promise<void>;
@@ -2,10 +2,20 @@ import Long from "long";
2
2
  import { _normalizeInputStarGift } from "./_normalize-input-star-gift.js";
3
3
  async function setResaleStarGiftPrice(client, params) {
4
4
  const { gift, price } = params;
5
+ let starsAmount;
6
+ if (price === null) {
7
+ starsAmount = { _: "starsAmount", amount: Long.ZERO, nanos: 0 };
8
+ } else if (typeof price === "number") {
9
+ starsAmount = { _: "starsAmount", amount: Long.fromNumber(price), nanos: 0 };
10
+ } else if (Long.isLong(price)) {
11
+ starsAmount = { _: "starsAmount", amount: price, nanos: 0 };
12
+ } else {
13
+ starsAmount = price;
14
+ }
5
15
  const r = await client.call({
6
16
  _: "payments.updateStarGiftPrice",
7
17
  stargift: await _normalizeInputStarGift(client, gift),
8
- resellStars: price === null ? Long.ZERO : Long.fromNumber(price)
18
+ resellAmount: starsAmount
9
19
  });
10
20
  client.handleClientUpdate(r);
11
21
  }
@@ -12,7 +12,7 @@ const normalizeText = require("../misc/normalize-text.cjs");
12
12
  const resolvePeer = require("../users/resolve-peer.cjs");
13
13
  const findInUpdate = require("./find-in-update.cjs");
14
14
  async function sendStory(client, params) {
15
- const { peer = "me", pinned, forbidForwards, interactiveElements, period } = params;
15
+ const { peer = "me", pinned, forbidForwards, interactiveElements, period, addToAlbums } = params;
16
16
  let { media } = params;
17
17
  if (typeof media === "string") {
18
18
  media = {
@@ -39,7 +39,8 @@ async function sendStory(client, params) {
39
39
  entities,
40
40
  privacyRules,
41
41
  randomId: longUtils.randomLong(),
42
- period
42
+ period,
43
+ albums: addToAlbums
43
44
  });
44
45
  return findInUpdate._findStoryInUpdate(client, res);
45
46
  }
@@ -48,4 +48,8 @@ export declare function sendStory(client: ITelegramClient, params: {
48
48
  * @default 86400
49
49
  */
50
50
  period?: number;
51
+ /**
52
+ * IDs of albums to add the story to
53
+ */
54
+ addToAlbums?: number[];
51
55
  }): Promise<Story>;
@@ -48,4 +48,8 @@ export declare function sendStory(client: ITelegramClient, params: {
48
48
  * @default 86400
49
49
  */
50
50
  period?: number;
51
+ /**
52
+ * IDs of albums to add the story to
53
+ */
54
+ addToAlbums?: number[];
51
55
  }): Promise<Story>;
@@ -5,7 +5,7 @@ import { _normalizeInputText } from "../misc/normalize-text.js";
5
5
  import { resolvePeer } from "../users/resolve-peer.js";
6
6
  import { _findStoryInUpdate } from "./find-in-update.js";
7
7
  async function sendStory(client, params) {
8
- const { peer = "me", pinned, forbidForwards, interactiveElements, period } = params;
8
+ const { peer = "me", pinned, forbidForwards, interactiveElements, period, addToAlbums } = params;
9
9
  let { media } = params;
10
10
  if (typeof media === "string") {
11
11
  media = {
@@ -32,7 +32,8 @@ async function sendStory(client, params) {
32
32
  entities,
33
33
  privacyRules,
34
34
  randomId: randomLong(),
35
- period
35
+ period,
36
+ albums: addToAlbums
36
37
  });
37
38
  return _findStoryInUpdate(client, res);
38
39
  }
@@ -174,6 +174,8 @@ export { iterSearchHashtag } from './methods/messages/search-hashtag.js';
174
174
  export type { SearchHashtagOffset } from './methods/messages/search-hashtag.js';
175
175
  export { searchMessages } from './methods/messages/search-messages.js';
176
176
  export type { SearchMessagesOffset } from './methods/messages/search-messages.js';
177
+ export { searchPostsGlobal } from './methods/messages/search-posts-global.js';
178
+ export type { SearchPostsGlobalOffset } from './methods/messages/search-posts-global.js';
177
179
  export { answerText } from './methods/messages/send-answer.js';
178
180
  export { answerMedia } from './methods/messages/send-answer.js';
179
181
  export { answerMediaGroup } from './methods/messages/send-answer.js';