teleproto 1.223.1 → 1.223.2

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 (66) hide show
  1. package/Version.d.ts +1 -1
  2. package/Version.js +1 -1
  3. package/client/2fa.js +35 -2
  4. package/client/TelegramClient.d.ts +44 -4
  5. package/client/TelegramClient.js +27 -3
  6. package/client/buttons.d.ts +12 -1
  7. package/client/buttons.js +12 -1
  8. package/client/chats.js +53 -10
  9. package/client/dialogs.d.ts +8 -1
  10. package/client/dialogs.js +43 -3
  11. package/client/downloads.js +5 -5
  12. package/client/messageParse.js +36 -3
  13. package/client/messages.d.ts +37 -4
  14. package/client/messages.js +95 -14
  15. package/client/telegramBaseClient.d.ts +51 -2
  16. package/client/telegramBaseClient.js +11 -3
  17. package/client/updates.d.ts +47 -5
  18. package/client/updates.js +712 -22
  19. package/client/uploads.d.ts +9 -2
  20. package/client/uploads.js +53 -9
  21. package/client/users.d.ts +48 -5
  22. package/client/users.js +113 -34
  23. package/entityCache.d.ts +8 -0
  24. package/entityCache.js +8 -0
  25. package/events/Album.d.ts +1 -1
  26. package/events/CallbackQuery.d.ts +1 -1
  27. package/events/InlineQuery.d.ts +1 -1
  28. package/events/MessageRead.d.ts +1 -1
  29. package/events/NewMessage.d.ts +1 -1
  30. package/events/Raw.d.ts +1 -1
  31. package/events/UserUpdate.d.ts +1 -1
  32. package/events/common.d.ts +1 -1
  33. package/events/common.js +8 -8
  34. package/extensions/PromisedNetSockets.d.ts +7 -0
  35. package/extensions/PromisedNetSockets.js +7 -0
  36. package/extensions/html.js +2 -2
  37. package/network/MTProtoSender.d.ts +12 -4
  38. package/network/MTProtoSender.js +82 -15
  39. package/network/MTProtoState.js +13 -13
  40. package/network/RequestState.d.ts +1 -0
  41. package/network/RequestState.js +1 -0
  42. package/network/UpdateConnectionState.d.ts +7 -0
  43. package/network/UpdateConnectionState.js +12 -0
  44. package/network/connection/TCPMTProxy.d.ts +94 -0
  45. package/network/connection/TCPMTProxy.js +21 -0
  46. package/network/index.d.ts +1 -7
  47. package/network/index.js +2 -9
  48. package/package.json +1 -1
  49. package/requestIter.d.ts +2 -2
  50. package/requestIter.js +1 -2
  51. package/sessions/Memory.d.ts +9 -1
  52. package/sessions/Memory.js +58 -17
  53. package/sessions/StoreSession.d.ts +12 -0
  54. package/sessions/StoreSession.js +12 -0
  55. package/tl/core/GZIPPacked.js +2 -2
  56. package/tl/core/RPCResult.js +3 -3
  57. package/tl/custom/button.d.ts +26 -5
  58. package/tl/custom/button.js +74 -7
  59. package/tl/custom/chatGetter.js +3 -3
  60. package/tl/custom/dialog.d.ts +1 -1
  61. package/tl/custom/draft.d.ts +1 -1
  62. package/tl/custom/inlineResult.d.ts +1 -1
  63. package/tl/custom/inlineResults.d.ts +1 -1
  64. package/tl/custom/message.d.ts +4 -1
  65. package/tl/custom/message.js +53 -0
  66. package/tl/custom/senderGetter.d.ts +1 -1
package/Version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "1.223.1";
1
+ export declare const version = "1.223.2";
package/Version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "1.223.1";
4
+ exports.version = "1.223.2";
package/client/2fa.js CHANGED
@@ -1,10 +1,43 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.updateTwoFaSettings = updateTwoFaSettings;
4
37
  const Helpers_1 = require("../Helpers");
5
38
  const Password_1 = require("../Password");
6
39
  const tl_1 = require("../tl");
7
- const index_1 = require("../index");
40
+ const errors = __importStar(require("../errors"));
8
41
  /**
9
42
  * Changes the 2FA settings of the logged in user.
10
43
  Note that this method may be *incredibly* slow depending on the
@@ -85,7 +118,7 @@ async function updateTwoFaSettings(client, { isCheckPassword, currentPassword, n
85
118
  }));
86
119
  }
87
120
  catch (e) {
88
- if (e instanceof index_1.errors.EmailUnconfirmedError) {
121
+ if (e instanceof errors.EmailUnconfirmedError) {
89
122
  // eslint-disable-next-line no-constant-condition
90
123
  while (true) {
91
124
  try {
@@ -708,6 +708,33 @@ export declare class TelegramClient extends TelegramBaseClient {
708
708
  * ```
709
709
  */
710
710
  markAsRead(entity: EntityLike, message?: MessageIDLike | MessageIDLike[], markAsReadParams?: messageMethods.MarkAsReadParams): Promise<boolean>;
711
+ /**
712
+ * Sends a reaction to a message.
713
+ *
714
+ * @param entity - The chat/channel where the message is.
715
+ * @param messageId - The message ID to react to.
716
+ * @param reaction - Array of reactions. Use Api.ReactionEmoji or Api.ReactionCustomEmoji.
717
+ * @param big - Whether to show a big animation.
718
+ * @example
719
+ * ```ts
720
+ * await client.sendReaction(chat, 123, [new Api.ReactionEmoji({ emoticon: "👍" })]);
721
+ * ```
722
+ */
723
+ sendReaction(entity: EntityLike, messageId: number, reaction?: Api.TypeReaction[], big?: boolean): Promise<Api.TypeUpdates>;
724
+ /**
725
+ * Gets users who reacted to a message.
726
+ *
727
+ * @param entity - The chat/channel where the message is.
728
+ * @param messageId - The message ID.
729
+ * @param params.reaction - Filter by specific emoji string.
730
+ * @param params.limit - Maximum number of users to return.
731
+ * @param params.offset - Pagination offset.
732
+ */
733
+ getReactionUsers(entity: EntityLike, messageId: number, params?: {
734
+ reaction?: string;
735
+ limit?: number;
736
+ offset?: string;
737
+ }): Promise<Api.messages.MessageReactionsList>;
711
738
  /**
712
739
  * Iterator over the dialogs (open conversations/subscribed channels) sequentially.<br/>
713
740
  * The order is the same as the one seen in official applications. (dialogs that had recent messages come first)
@@ -804,10 +831,23 @@ export declare class TelegramClient extends TelegramBaseClient {
804
831
  * await client.kickParticipant(chat, 'me');
805
832
  */
806
833
  kickParticipant(entity: EntityLike, participant: EntityLike): Promise<Api.TypeMessage | Map<number, Api.Message> | (Api.Message | undefined)[] | undefined>;
807
- /** TODO */
808
- on(event: any): (f: {
809
- (event: any): void;
810
- }) => (event: any) => void;
834
+ /**
835
+ * Decorator-style event handler registration.
836
+ * Returns a function that accepts a callback and registers it for the given event.
837
+ *
838
+ * @example
839
+ * ```ts
840
+ * client.on(new NewMessage({ incoming: true }))(async (event) => {
841
+ * console.log(event.message.text);
842
+ * });
843
+ * ```
844
+ */
845
+ on(event: NewMessage): (f: (event: NewMessageEvent) => void) => void;
846
+ on(event: CallbackQuery): (f: (event: CallbackQueryEvent) => void) => void;
847
+ on(event: Album): (f: (event: AlbumEvent) => void) => void;
848
+ on(event: EditedMessage): (f: (event: EditedMessageEvent) => void) => void;
849
+ on(event: DeletedMessage): (f: (event: DeletedMessageEvent) => void) => void;
850
+ on(event?: EventBuilder): (f: (event: any) => void) => void;
811
851
  /**
812
852
  * Registers a new event handler callback.<br/>
813
853
  * <br/>
@@ -786,6 +786,33 @@ class TelegramClient extends telegramBaseClient_1.TelegramBaseClient {
786
786
  markAsRead(entity, message, markAsReadParams) {
787
787
  return messageMethods.markAsRead(this, entity, message, markAsReadParams);
788
788
  }
789
+ /**
790
+ * Sends a reaction to a message.
791
+ *
792
+ * @param entity - The chat/channel where the message is.
793
+ * @param messageId - The message ID to react to.
794
+ * @param reaction - Array of reactions. Use Api.ReactionEmoji or Api.ReactionCustomEmoji.
795
+ * @param big - Whether to show a big animation.
796
+ * @example
797
+ * ```ts
798
+ * await client.sendReaction(chat, 123, [new Api.ReactionEmoji({ emoticon: "👍" })]);
799
+ * ```
800
+ */
801
+ sendReaction(entity, messageId, reaction, big) {
802
+ return messageMethods.sendReaction(this, entity, messageId, reaction, big);
803
+ }
804
+ /**
805
+ * Gets users who reacted to a message.
806
+ *
807
+ * @param entity - The chat/channel where the message is.
808
+ * @param messageId - The message ID.
809
+ * @param params.reaction - Filter by specific emoji string.
810
+ * @param params.limit - Maximum number of users to return.
811
+ * @param params.offset - Pagination offset.
812
+ */
813
+ getReactionUsers(entity, messageId, params) {
814
+ return messageMethods.getReactionUsers(this, entity, messageId, params);
815
+ }
789
816
  //endregion
790
817
  //region dialogs
791
818
  /**
@@ -896,9 +923,6 @@ class TelegramClient extends telegramBaseClient_1.TelegramBaseClient {
896
923
  kickParticipant(entity, participant) {
897
924
  return chatMethods.kickParticipant(this, entity, participant);
898
925
  }
899
- //endregion
900
- //region updates
901
- /** TODO */
902
926
  on(event) {
903
927
  return updateMethods.on(this, event);
904
928
  }
@@ -1,4 +1,15 @@
1
1
  import { Api } from "../tl";
2
2
  import type { ButtonLike } from "../define";
3
- /** @hidden */
3
+ /**
4
+ * Converts a flexible button input into a Telegram {@link Api.TypeReplyMarkup}.
5
+ *
6
+ * Accepts a single button, a row of buttons, a grid (array of rows), or an existing
7
+ * `ReplyMarkup` object. Automatically detects whether buttons are inline or normal
8
+ * and wraps them in the appropriate markup type.
9
+ *
10
+ * @param buttons - The button(s) to convert. Can be a {@link ButtonLike}, an array, or a 2D array.
11
+ * @param inlineOnly - If `true`, forces inline-only mode (throws if normal buttons are found).
12
+ * @returns The constructed reply markup, or `undefined` if no buttons were provided.
13
+ * @hidden
14
+ */
4
15
  export declare function buildReplyMarkup(buttons: Api.TypeReplyMarkup | undefined | ButtonLike | ButtonLike[] | ButtonLike[][], inlineOnly?: boolean): Api.TypeReplyMarkup | undefined;
package/client/buttons.js CHANGED
@@ -6,7 +6,18 @@ const button_1 = require("../tl/custom/button");
6
6
  const messageButton_1 = require("../tl/custom/messageButton");
7
7
  const Helpers_1 = require("../Helpers");
8
8
  // ButtonMethods
9
- /** @hidden */
9
+ /**
10
+ * Converts a flexible button input into a Telegram {@link Api.TypeReplyMarkup}.
11
+ *
12
+ * Accepts a single button, a row of buttons, a grid (array of rows), or an existing
13
+ * `ReplyMarkup` object. Automatically detects whether buttons are inline or normal
14
+ * and wraps them in the appropriate markup type.
15
+ *
16
+ * @param buttons - The button(s) to convert. Can be a {@link ButtonLike}, an array, or a 2D array.
17
+ * @param inlineOnly - If `true`, forces inline-only mode (throws if normal buttons are found).
18
+ * @returns The constructed reply markup, or `undefined` if no buttons were provided.
19
+ * @hidden
20
+ */
10
21
  function buildReplyMarkup(buttons, inlineOnly = false) {
11
22
  if (buttons == undefined) {
12
23
  return undefined;
package/client/chats.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -9,13 +42,23 @@ exports.getParticipants = getParticipants;
9
42
  exports.kickParticipant = kickParticipant;
10
43
  const Helpers_1 = require("../Helpers");
11
44
  const requestIter_1 = require("../requestIter");
12
- const __1 = require("..");
45
+ const helpers = __importStar(require("../Helpers"));
46
+ const utils = __importStar(require("../Utils"));
13
47
  const tl_1 = require("../tl");
14
48
  const big_integer_1 = __importDefault(require("big-integer"));
15
49
  const Utils_1 = require("../Utils");
16
50
  const _MAX_PARTICIPANTS_CHUNK_SIZE = 200;
17
51
  const _MAX_ADMIN_LOG_CHUNK_SIZE = 100;
18
52
  const _MAX_PROFILE_PHOTO_CHUNK_SIZE = 100;
53
+ /**
54
+ * Sends a chat action (e.g. "typing…") that repeats at a fixed interval until stopped.
55
+ *
56
+ * Supported action strings: `"typing"`, `"contact"`, `"game"`, `"location"`,
57
+ * `"record-audio"` / `"record-voice"`, `"record-round"`, `"record-video"`,
58
+ * `"audio"` / `"voice"` / `"song"`, `"round"`, `"video"`, `"photo"`,
59
+ * `"document"` / `"file"`, `"cancel"`.
60
+ * @internal
61
+ */
19
62
  class _ChatAction {
20
63
  constructor(client, chat, action, params = {
21
64
  delay: 4,
@@ -102,12 +145,12 @@ class _ParticipantsIter extends requestIter_1.RequestIter {
102
145
  }
103
146
  }
104
147
  entity = await this.client.getInputEntity(entity);
105
- const ty = __1.helpers._entityType(entity);
106
- if (search && (filter || ty != __1.helpers._EntityType.CHANNEL)) {
148
+ const ty = helpers._entityType(entity);
149
+ if (search && (filter || ty != helpers._EntityType.CHANNEL)) {
107
150
  // We need to 'search' ourselves unless we have a PeerChannel
108
151
  search = search.toLowerCase();
109
152
  this.filterEntity = (entity) => {
110
- return (__1.utils
153
+ return (utils
111
154
  .getDisplayName(entity)
112
155
  .toLowerCase()
113
156
  .includes(search) ||
@@ -121,7 +164,7 @@ class _ParticipantsIter extends requestIter_1.RequestIter {
121
164
  }
122
165
  // Only used for channels, but we should always set the attribute
123
166
  this.requests = [];
124
- if (ty == __1.helpers._EntityType.CHANNEL) {
167
+ if (ty == helpers._EntityType.CHANNEL) {
125
168
  if (showTotal) {
126
169
  const channel = await this.client.invoke(new tl_1.Api.channels.GetFullChannel({
127
170
  channel: entity,
@@ -144,7 +187,7 @@ class _ParticipantsIter extends requestIter_1.RequestIter {
144
187
  hash: big_integer_1.default.zero,
145
188
  }));
146
189
  }
147
- else if (ty == __1.helpers._EntityType.CHAT) {
190
+ else if (ty == helpers._EntityType.CHAT) {
148
191
  if (!("chatId" in entity)) {
149
192
  throw new Error("Found chat without id " + JSON.stringify(entity));
150
193
  }
@@ -262,7 +305,7 @@ class _AdminLogIter extends requestIter_1.RequestIter {
262
305
  const r = await this.client.invoke(this.request);
263
306
  const entities = new Map();
264
307
  for (const entity of [...r.users, ...r.chats]) {
265
- entities.set(__1.utils.getPeerId(entity), entity);
308
+ entities.set(utils.getPeerId(entity), entity);
266
309
  }
267
310
  const eventIds = [];
268
311
  for (const e of r.events) {
@@ -300,15 +343,15 @@ async function kickParticipant(client, entity, participant) {
300
343
  const user = await client.getInputEntity(participant);
301
344
  let resp;
302
345
  let request;
303
- const type = __1.helpers._entityType(peer);
304
- if (type === __1.helpers._EntityType.CHAT) {
346
+ const type = helpers._entityType(peer);
347
+ if (type === helpers._EntityType.CHAT) {
305
348
  request = new tl_1.Api.messages.DeleteChatUser({
306
349
  chatId: (0, Helpers_1.returnBigInt)((0, Utils_1.getPeerId)(entity)),
307
350
  userId: (0, Helpers_1.returnBigInt)((0, Utils_1.getPeerId)(participant)),
308
351
  });
309
352
  resp = await client.invoke(request);
310
353
  }
311
- else if (type === __1.helpers._EntityType.CHANNEL) {
354
+ else if (type === helpers._EntityType.CHANNEL) {
312
355
  if (user instanceof tl_1.Api.InputPeerSelf) {
313
356
  request = new tl_1.Api.channels.LeaveChannel({
314
357
  channel: peer,
@@ -1,6 +1,6 @@
1
1
  import { Api } from "../tl";
2
2
  import { RequestIter } from "../requestIter";
3
- import { TelegramClient } from "../index";
3
+ import type { TelegramClient } from "./TelegramClient";
4
4
  import { Dialog } from "../tl/custom/dialog";
5
5
  import { DateLike, EntityLike } from "../define";
6
6
  import { TotalList } from "../Helpers";
@@ -12,6 +12,13 @@ export interface DialogsIterInterface {
12
12
  ignoreMigrated: boolean;
13
13
  folder: number;
14
14
  }
15
+ /**
16
+ * Async iterator over the user's dialogs (conversations).
17
+ *
18
+ * Fetches dialogs in chunks, supports date/ID offsets, folder filtering,
19
+ * and can skip pinned or migrated chats. Used internally by `iterDialogs` / `getDialogs`.
20
+ * @internal
21
+ */
15
22
  export declare class _DialogsIter extends RequestIter {
16
23
  private request?;
17
24
  private seen?;
package/client/dialogs.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -8,7 +41,7 @@ exports.iterDialogs = iterDialogs;
8
41
  exports.getDialogs = getDialogs;
9
42
  const tl_1 = require("../tl");
10
43
  const requestIter_1 = require("../requestIter");
11
- const index_1 = require("../index");
44
+ const utils = __importStar(require("../Utils"));
12
45
  const dialog_1 = require("../tl/custom/dialog");
13
46
  const big_integer_1 = __importDefault(require("big-integer"));
14
47
  const Logger_1 = require("../extensions/Logger");
@@ -31,6 +64,13 @@ function _dialogMessageKey(peer, messageId) {
31
64
  messageId,
32
65
  ]);
33
66
  }
67
+ /**
68
+ * Async iterator over the user's dialogs (conversations).
69
+ *
70
+ * Fetches dialogs in chunks, supports date/ID offsets, folder filtering,
71
+ * and can skip pinned or migrated chats. Used internally by `iterDialogs` / `getDialogs`.
72
+ * @internal
73
+ */
34
74
  class _DialogsIter extends requestIter_1.RequestIter {
35
75
  async _init({ offsetDate, offsetId, offsetPeer, ignorePinned, ignoreMigrated, folder, }) {
36
76
  this.request = new tl_1.Api.messages.GetDialogs({
@@ -83,7 +123,7 @@ class _DialogsIter extends requestIter_1.RequestIter {
83
123
  entity instanceof tl_1.Api.ChatEmpty) {
84
124
  continue;
85
125
  }
86
- entities.set(index_1.utils.getPeerId(entity), entity);
126
+ entities.set(utils.getPeerId(entity), entity);
87
127
  }
88
128
  for (const m of r.messages) {
89
129
  let message = m;
@@ -117,7 +157,7 @@ class _DialogsIter extends requestIter_1.RequestIter {
117
157
  continue;
118
158
  }
119
159
  }
120
- const peerId = index_1.utils.getPeerId(d.peer);
160
+ const peerId = utils.getPeerId(d.peer);
121
161
  if (!this.seen.has(peerId)) {
122
162
  this.seen.add(peerId);
123
163
  if (!entities.has(peerId)) {
@@ -56,7 +56,7 @@ exports.downloadProfilePhoto = downloadProfilePhoto;
56
56
  const tl_1 = require("../tl");
57
57
  const Utils_1 = require("../Utils");
58
58
  const Helpers_1 = require("../Helpers");
59
- const __1 = require("..");
59
+ const utils = __importStar(require("../Utils"));
60
60
  const requestIter_1 = require("../requestIter");
61
61
  const errors_1 = require("../errors");
62
62
  const fs_1 = require("fs");
@@ -196,7 +196,7 @@ exports.GenericDownloadIter = GenericDownloadIter;
196
196
  function iterDownload(client, { file, offset = big_integer_1.default.zero, stride, limit, chunkSize, requestSize = MAX_CHUNK_SIZE, fileSize, dcId, msgData, }) {
197
197
  // we're ignoring here to make it more flexible (which is probably a bad idea)
198
198
  // @ts-ignore
199
- const info = __1.utils.getFileInfo(file);
199
+ const info = utils.getFileInfo(file);
200
200
  if (info.dcId != undefined) {
201
201
  dcId = info.dcId;
202
202
  }
@@ -284,7 +284,7 @@ async function downloadFileV2(client, inputLocation, { outputFile = undefined, p
284
284
  partSizeKb = 64;
285
285
  }
286
286
  else {
287
- partSizeKb = __1.utils.getAppropriatedPartSize(fileSize);
287
+ partSizeKb = utils.getAppropriatedPartSize(fileSize);
288
288
  }
289
289
  }
290
290
  const partSize = Math.floor(partSizeKb * 1024);
@@ -414,7 +414,7 @@ async function _downloadDocument(client, doc, outputFile, date, thumb, progressC
414
414
  }
415
415
  let size;
416
416
  if (thumb == undefined) {
417
- outputFile = getProperFilename(outputFile, "document", "." + (__1.utils.getExtension(doc) || "bin"), date);
417
+ outputFile = getProperFilename(outputFile, "document", "." + (utils.getExtension(doc) || "bin"), date);
418
418
  }
419
419
  else {
420
420
  outputFile = getProperFilename(outputFile, "photo", ".jpg", date);
@@ -599,7 +599,7 @@ async function downloadProfilePhoto(client, entity, fileParams) {
599
599
  photo instanceof tl_1.Api.ChatPhoto) {
600
600
  dcId = photo.dcId;
601
601
  loc = new tl_1.Api.InputPeerPhotoFileLocation({
602
- peer: __1.utils.getInputPeer(entity),
602
+ peer: utils.getInputPeer(entity),
603
603
  photoId: photo.photoId,
604
604
  big: fileParams.isBig,
605
605
  });
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -9,7 +42,7 @@ exports._parseMessageText = _parseMessageText;
9
42
  exports._getResponseMessage = _getResponseMessage;
10
43
  const Utils_1 = require("../Utils");
11
44
  const tl_1 = require("../tl");
12
- const index_1 = require("../index");
45
+ const utils = __importStar(require("../Utils"));
13
46
  const Helpers_1 = require("../Helpers");
14
47
  const big_integer_1 = __importDefault(require("big-integer"));
15
48
  exports.DEFAULT_DELIMITERS = {
@@ -74,7 +107,7 @@ function _getResponseMessage(client, request, result, inputChat) {
74
107
  result instanceof tl_1.Api.UpdatesCombined) {
75
108
  updates = result.updates;
76
109
  for (const x of [...result.users, ...result.chats]) {
77
- entities.set(index_1.utils.getPeerId(x), x);
110
+ entities.set(utils.getPeerId(x), x);
78
111
  }
79
112
  }
80
113
  else {
@@ -126,7 +159,7 @@ function _getResponseMessage(client, request, result, inputChat) {
126
159
  if (request.media.poll.id == update.pollId) {
127
160
  const m = new tl_1.Api.Message({
128
161
  id: request.id,
129
- peerId: index_1.utils.getPeerId(request.peer),
162
+ peerId: utils.getPeerId(request.peer),
130
163
  media: new tl_1.Api.MessageMediaPoll({
131
164
  poll: update.poll,
132
165
  results: update.results,
@@ -2,7 +2,8 @@ import { Api } from "../tl";
2
2
  import type { DateLike, EntityLike, FileLike, MarkupLike, MessageIDLike, MessageLike } from "../define";
3
3
  import { RequestIter } from "../requestIter";
4
4
  import { TotalList } from "../Helpers";
5
- import type { TelegramClient } from "..";
5
+ import type { TelegramClient } from "./TelegramClient";
6
+ import { BigInteger } from "big-integer";
6
7
  interface MessageIterParams {
7
8
  entity: EntityLike;
8
9
  offsetId: number;
@@ -15,6 +16,14 @@ interface MessageIterParams {
15
16
  search: string;
16
17
  replyTo: MessageIDLike;
17
18
  }
19
+ /**
20
+ * Async iterator over messages in a chat.
21
+ *
22
+ * Fetches messages in chunks from the Telegram API, supporting forward/reverse
23
+ * iteration, date offsets, sender filtering, text search, and reply threading.
24
+ * Used internally by `iterMessages` / `getMessages`.
25
+ * @internal
26
+ */
18
27
  export declare class _MessagesIter extends RequestIter {
19
28
  entity?: Api.TypeInputPeer;
20
29
  request?: Api.messages.SearchGlobal | Api.messages.GetReplies | Api.messages.GetHistory | Api.messages.Search;
@@ -155,6 +164,12 @@ export interface SendMessageParams {
155
164
  * Used for threads to reply to a specific thread
156
165
  */
157
166
  topMsgId?: number | Api.Message;
167
+ /** Send the message as a specific entity (channel/user). */
168
+ sendAs?: EntityLike;
169
+ /** Message effect ID (animation/visual effect). */
170
+ effect?: BigInteger;
171
+ /** If true, media will be shown below the text instead of above. */
172
+ invertMedia?: boolean;
158
173
  }
159
174
  /** interface used for forwarding messages */
160
175
  export interface ForwardMessagesParams {
@@ -171,6 +186,14 @@ export interface ForwardMessagesParams {
171
186
  noforwards?: boolean;
172
187
  /** Used for threads to reply to a specific thread */
173
188
  topMsgId?: number | Api.Message;
189
+ /** Send the forwarded message as a specific entity (channel/user). */
190
+ sendAs?: EntityLike;
191
+ /** Message effect ID (animation/visual effect). */
192
+ effect?: BigInteger;
193
+ /** If true, drop media captions when forwarding. */
194
+ dropMediaCaptions?: boolean;
195
+ /** If true, forward the game score along with the message. */
196
+ withMyScore?: boolean;
174
197
  }
175
198
  /** Interface for editing messages */
176
199
  export interface EditMessageParams {
@@ -200,6 +223,8 @@ export interface EditMessageParams {
200
223
  buttons?: MarkupLike;
201
224
  /** If set, the message won't be edited immediately, and instead it will be scheduled to be automatically edited at a later time. */
202
225
  schedule?: DateLike;
226
+ /** If true, media will be shown below the text instead of above. */
227
+ invertMedia?: boolean;
203
228
  }
204
229
  /** Interface for editing messages */
205
230
  export interface UpdatePinMessageParams {
@@ -236,13 +261,13 @@ entity: EntityLike,
236
261
  /** The message to be sent, or another message object to resend as a copy.<br/>
237
262
  * The maximum length for a message is 35,000 bytes or 4,096 characters.<br/>
238
263
  * Longer messages will not be sliced automatically, and you should slice them manually if the text to send is longer than said length. */
239
- { message, replyTo, attributes, parseMode, formattingEntities, linkPreview, file, thumb, forceDocument, clearDraft, buttons, silent, supportStreaming, schedule, noforwards, commentTo, topMsgId, }?: SendMessageParams): Promise<Api.Message>;
264
+ { message, replyTo, attributes, parseMode, formattingEntities, linkPreview, file, thumb, forceDocument, clearDraft, buttons, silent, supportStreaming, schedule, noforwards, commentTo, topMsgId, sendAs, effect, invertMedia, }?: SendMessageParams): Promise<Api.Message>;
240
265
  /** @hidden */
241
- export declare function forwardMessages(client: TelegramClient, entity: EntityLike, { messages, fromPeer, silent, schedule, noforwards, dropAuthor, topMsgId, }: ForwardMessagesParams & {
266
+ export declare function forwardMessages(client: TelegramClient, entity: EntityLike, { messages, fromPeer, silent, schedule, noforwards, dropAuthor, topMsgId, sendAs, effect, dropMediaCaptions, withMyScore, }: ForwardMessagesParams & {
242
267
  topMsgId?: number | Api.Message;
243
268
  }): Promise<Api.Message[]>;
244
269
  /** @hidden */
245
- export declare function editMessage(client: TelegramClient, entity: EntityLike, { message, text, parseMode, formattingEntities, linkPreview, file, forceDocument, buttons, schedule, }: EditMessageParams): Promise<Api.Message>;
270
+ export declare function editMessage(client: TelegramClient, entity: EntityLike, { message, text, parseMode, formattingEntities, linkPreview, file, forceDocument, buttons, schedule, invertMedia, }: EditMessageParams): Promise<Api.Message>;
246
271
  /** @hidden */
247
272
  export declare function deleteMessages(client: TelegramClient, entity: EntityLike | undefined, messageIds: MessageIDLike[], { revoke }: {
248
273
  revoke?: boolean | undefined;
@@ -260,4 +285,12 @@ export declare function getCommentData(client: TelegramClient, entity: EntityLik
260
285
  entity: Api.TypeInputPeer;
261
286
  replyTo: number;
262
287
  }>;
288
+ /** @hidden */
289
+ export declare function sendReaction(client: TelegramClient, entity: EntityLike, messageId: number, reaction?: Api.TypeReaction[], big?: boolean): Promise<Api.TypeUpdates>;
290
+ /** @hidden */
291
+ export declare function getReactionUsers(client: TelegramClient, entity: EntityLike, messageId: number, params?: {
292
+ reaction?: string;
293
+ limit?: number;
294
+ offset?: string;
295
+ }): Promise<Api.messages.MessageReactionsList>;
263
296
  export {};