@mtcute/core 0.22.3 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/client.cjs +1 -1
  2. package/client.js +1 -1
  3. package/highlevel/base.cjs +1 -0
  4. package/highlevel/base.js +1 -0
  5. package/highlevel/client.d.cts +7 -3
  6. package/highlevel/client.d.ts +7 -3
  7. package/highlevel/methods/auth/send-code.cjs +8 -2
  8. package/highlevel/methods/auth/send-code.d.cts +4 -2
  9. package/highlevel/methods/auth/send-code.d.ts +4 -2
  10. package/highlevel/methods/auth/send-code.js +8 -2
  11. package/highlevel/methods/auth/start.cjs +6 -1
  12. package/highlevel/methods/auth/start.d.cts +1 -1
  13. package/highlevel/methods/auth/start.d.ts +1 -1
  14. package/highlevel/methods/auth/start.js +6 -1
  15. package/highlevel/methods/chats/open-chat.cjs +1 -1
  16. package/highlevel/methods/chats/open-chat.js +1 -1
  17. package/highlevel/methods/dialogs/find-dialogs.cjs +3 -1
  18. package/highlevel/methods/dialogs/find-dialogs.js +3 -1
  19. package/highlevel/methods/dialogs/get-peer-dialogs.cjs +49 -11
  20. package/highlevel/methods/dialogs/get-peer-dialogs.d.cts +1 -1
  21. package/highlevel/methods/dialogs/get-peer-dialogs.d.ts +1 -1
  22. package/highlevel/methods/dialogs/get-peer-dialogs.js +49 -11
  23. package/highlevel/methods/files/normalize-input-file.d.cts +1 -0
  24. package/highlevel/methods/files/normalize-input-file.d.ts +1 -0
  25. package/highlevel/methods/files/normalize-input-media.cjs +13 -6
  26. package/highlevel/methods/files/normalize-input-media.d.cts +1 -0
  27. package/highlevel/methods/files/normalize-input-media.d.ts +1 -0
  28. package/highlevel/methods/files/normalize-input-media.js +13 -6
  29. package/highlevel/methods/files/upload-file.cjs +6 -3
  30. package/highlevel/methods/files/upload-file.d.cts +1 -0
  31. package/highlevel/methods/files/upload-file.d.ts +1 -0
  32. package/highlevel/methods/files/upload-file.js +6 -3
  33. package/highlevel/methods/messages/send-common.d.cts +1 -0
  34. package/highlevel/methods/messages/send-common.d.ts +1 -0
  35. package/highlevel/methods/messages/send-media-group.cjs +3 -2
  36. package/highlevel/methods/messages/send-media-group.js +3 -2
  37. package/highlevel/methods/messages/send-media.cjs +3 -2
  38. package/highlevel/methods/messages/send-media.js +3 -2
  39. package/highlevel/methods/messages/send-text.cjs +1 -1
  40. package/highlevel/methods/messages/send-text.js +1 -1
  41. package/highlevel/methods/users/resolve-peer-many.cjs +8 -43
  42. package/highlevel/methods/users/resolve-peer-many.js +9 -44
  43. package/highlevel/storage/service/peers.cjs +37 -9
  44. package/highlevel/storage/service/peers.d.cts +4 -0
  45. package/highlevel/storage/service/peers.d.ts +4 -0
  46. package/highlevel/storage/service/peers.js +38 -10
  47. package/highlevel/storage/storage.cjs +3 -0
  48. package/highlevel/storage/storage.d.cts +1 -0
  49. package/highlevel/storage/storage.d.ts +1 -0
  50. package/highlevel/storage/storage.js +3 -0
  51. package/highlevel/types/conversation.cjs +3 -4
  52. package/highlevel/types/conversation.js +3 -4
  53. package/highlevel/types/messages/message-action.cjs +11 -0
  54. package/highlevel/types/messages/message-action.d.cts +15 -1
  55. package/highlevel/types/messages/message-action.d.ts +15 -1
  56. package/highlevel/types/messages/message-action.js +11 -0
  57. package/highlevel/types/peers/full-user.cjs +8 -0
  58. package/highlevel/types/peers/full-user.d.cts +4 -0
  59. package/highlevel/types/peers/full-user.d.ts +4 -0
  60. package/highlevel/types/peers/full-user.js +8 -0
  61. package/highlevel/types/peers/peers-index.cjs +10 -0
  62. package/highlevel/types/peers/peers-index.d.cts +1 -0
  63. package/highlevel/types/peers/peers-index.d.ts +1 -0
  64. package/highlevel/types/peers/peers-index.js +10 -0
  65. package/highlevel/types/premium/business-connection.cjs +3 -3
  66. package/highlevel/types/premium/business-connection.d.cts +2 -2
  67. package/highlevel/types/premium/business-connection.d.ts +2 -2
  68. package/highlevel/types/premium/business-connection.js +3 -3
  69. package/highlevel/types/premium/saved-star-gift.cjs +2 -2
  70. package/highlevel/types/premium/saved-star-gift.d.cts +2 -2
  71. package/highlevel/types/premium/saved-star-gift.d.ts +2 -2
  72. package/highlevel/types/premium/saved-star-gift.js +2 -2
  73. package/highlevel/types/premium/stars-gift-unique.cjs +35 -5
  74. package/highlevel/types/premium/stars-gift-unique.d.cts +23 -3
  75. package/highlevel/types/premium/stars-gift-unique.d.ts +23 -3
  76. package/highlevel/types/premium/stars-gift-unique.js +35 -5
  77. package/highlevel/types/premium/stars-transaction.cjs +4 -0
  78. package/highlevel/types/premium/stars-transaction.d.cts +2 -0
  79. package/highlevel/types/premium/stars-transaction.d.ts +2 -0
  80. package/highlevel/types/premium/stars-transaction.js +4 -0
  81. package/highlevel/updates/manager.cjs +4 -4
  82. package/highlevel/updates/manager.js +4 -4
  83. package/highlevel/worker/storage.cjs +4 -0
  84. package/highlevel/worker/storage.d.cts +2 -0
  85. package/highlevel/worker/storage.d.ts +2 -0
  86. package/highlevel/worker/storage.js +4 -0
  87. package/network/authorization.cjs +1 -1
  88. package/network/authorization.js +1 -1
  89. package/network/middlewares/flood-waiter.cjs +20 -4
  90. package/network/middlewares/flood-waiter.d.cts +9 -2
  91. package/network/middlewares/flood-waiter.d.ts +9 -2
  92. package/network/middlewares/flood-waiter.js +20 -4
  93. package/network/mtproto-session.cjs +3 -4
  94. package/network/mtproto-session.d.cts +1 -1
  95. package/network/mtproto-session.d.ts +1 -1
  96. package/network/mtproto-session.js +3 -4
  97. package/network/network-manager.cjs +3 -3
  98. package/network/network-manager.d.cts +1 -1
  99. package/network/network-manager.d.ts +1 -1
  100. package/network/network-manager.js +3 -3
  101. package/network/persistent-connection.cjs +1 -0
  102. package/network/persistent-connection.js +1 -0
  103. package/network/session-connection.cjs +7 -5
  104. package/network/session-connection.js +7 -5
  105. package/package.json +7 -7
  106. package/utils/binary/compat.cjs +2 -0
  107. package/utils/binary/compat.js +2 -0
  108. package/utils/early-timer.cjs +12 -7
  109. package/utils/early-timer.d.cts +3 -3
  110. package/utils/early-timer.d.ts +3 -3
  111. package/utils/early-timer.js +12 -7
@@ -349,7 +349,7 @@ class Conversation {
349
349
  throw new errors.MtArgumentError("Provide message for which to wait for read for");
350
350
  }
351
351
  const [dialog] = await getPeerDialogs.getPeerDialogs(this.client, this._inputPeer);
352
- if (dialog.lastRead >= msgId) return;
352
+ if (!dialog || dialog.lastRead >= msgId) return;
353
353
  const promise = new utils.Deferred();
354
354
  let timer;
355
355
  if (timeout !== null) {
@@ -425,10 +425,9 @@ class Conversation {
425
425
  }
426
426
  _processRecentEdits() {
427
427
  if (!this._recentEdits.length) return;
428
- const iter = this._recentEdits[Symbol.iterator]();
429
428
  let it;
430
- while (!(it = iter.next()).done) {
431
- this._onEditMessage(it.value, true);
429
+ while (it = this._recentEdits.popFront()) {
430
+ this._onEditMessage(it, true);
432
431
  }
433
432
  }
434
433
  }
@@ -342,7 +342,7 @@ class Conversation {
342
342
  throw new MtArgumentError("Provide message for which to wait for read for");
343
343
  }
344
344
  const [dialog] = await getPeerDialogs(this.client, this._inputPeer);
345
- if (dialog.lastRead >= msgId) return;
345
+ if (!dialog || dialog.lastRead >= msgId) return;
346
346
  const promise = new Deferred();
347
347
  let timer;
348
348
  if (timeout !== null) {
@@ -418,10 +418,9 @@ class Conversation {
418
418
  }
419
419
  _processRecentEdits() {
420
420
  if (!this._recentEdits.length) return;
421
- const iter = this._recentEdits[Symbol.iterator]();
422
421
  let it;
423
- while (!(it = iter.next()).done) {
424
- this._onEditMessage(it.value, true);
422
+ while (it = this._recentEdits.popFront()) {
423
+ this._onEditMessage(it, true);
425
424
  }
426
425
  }
427
426
  }
@@ -321,6 +321,17 @@ function _messageActionFromTl(act) {
321
321
  toId: act.peer ? peerUtils.getMarkedPeerId(act.peer) : void 0,
322
322
  savedId: act.savedId
323
323
  };
324
+ case "messageActionPaidMessagesPrice":
325
+ return {
326
+ type: "messages_paid",
327
+ stars: act.stars
328
+ };
329
+ case "messageActionPaidMessagesRefunded":
330
+ return {
331
+ type: "messages_refunded",
332
+ stars: act.stars,
333
+ count: act.count
334
+ };
324
335
  default:
325
336
  return null;
326
337
  }
@@ -430,6 +430,20 @@ export interface ActionStarGift {
430
430
  toId?: number;
431
431
  savedId?: Long;
432
432
  }
433
- export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | null;
433
+ /** Paid messages were paid for */
434
+ export interface ActionPaidMessagesPaid {
435
+ readonly type: 'messages_paid';
436
+ /** Amount of Telegram Stars paid */
437
+ stars: tl.Long;
438
+ }
439
+ /** Paid messages were refunded */
440
+ export interface ActionPaidMessagesRefunded {
441
+ readonly type: 'messages_refunded';
442
+ /** Amount of Telegram Stars refunded */
443
+ stars: tl.Long;
444
+ /** Count of messages refunded */
445
+ count: number;
446
+ }
447
+ export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | null;
434
448
  /** @internal */
435
449
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
@@ -430,6 +430,20 @@ export interface ActionStarGift {
430
430
  toId?: number;
431
431
  savedId?: Long;
432
432
  }
433
- export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | null;
433
+ /** Paid messages were paid for */
434
+ export interface ActionPaidMessagesPaid {
435
+ readonly type: 'messages_paid';
436
+ /** Amount of Telegram Stars paid */
437
+ stars: tl.Long;
438
+ }
439
+ /** Paid messages were refunded */
440
+ export interface ActionPaidMessagesRefunded {
441
+ readonly type: 'messages_refunded';
442
+ /** Amount of Telegram Stars refunded */
443
+ stars: tl.Long;
444
+ /** Count of messages refunded */
445
+ count: number;
446
+ }
447
+ export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGift | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | null;
434
448
  /** @internal */
435
449
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
@@ -314,6 +314,17 @@ function _messageActionFromTl(act) {
314
314
  toId: act.peer ? getMarkedPeerId(act.peer) : void 0,
315
315
  savedId: act.savedId
316
316
  };
317
+ case "messageActionPaidMessagesPrice":
318
+ return {
319
+ type: "messages_paid",
320
+ stars: act.stars
321
+ };
322
+ case "messageActionPaidMessagesRefunded":
323
+ return {
324
+ type: "messages_refunded",
325
+ stars: act.stars,
326
+ count: act.count
327
+ };
317
328
  default:
318
329
  return null;
319
330
  }
@@ -194,6 +194,14 @@ class FullUser extends user.User {
194
194
  get ttlPeriod() {
195
195
  return this.full?.ttlPeriod ?? null;
196
196
  }
197
+ /** Whether the "Gifts" tab should be shown */
198
+ get showGifts() {
199
+ return this.full.displayGiftsButton;
200
+ }
201
+ /** Information about the user's gift receive settings */
202
+ get disallowedGifts() {
203
+ return this.full.disallowedGifts ?? null;
204
+ }
197
205
  /**
198
206
  * If this is a business account, information about the business.
199
207
  */
@@ -109,6 +109,10 @@ export declare class FullUser extends User {
109
109
  * TTL of all messages in this chat, in seconds
110
110
  */
111
111
  get ttlPeriod(): number | null;
112
+ /** Whether the "Gifts" tab should be shown */
113
+ get showGifts(): boolean;
114
+ /** Information about the user's gift receive settings */
115
+ get disallowedGifts(): tl.TypeDisallowedGiftsSettings | null;
112
116
  /**
113
117
  * If this is a business account, information about the business.
114
118
  */
@@ -109,6 +109,10 @@ export declare class FullUser extends User {
109
109
  * TTL of all messages in this chat, in seconds
110
110
  */
111
111
  get ttlPeriod(): number | null;
112
+ /** Whether the "Gifts" tab should be shown */
113
+ get showGifts(): boolean;
114
+ /** Information about the user's gift receive settings */
115
+ get disallowedGifts(): tl.TypeDisallowedGiftsSettings | null;
112
116
  /**
113
117
  * If this is a business account, information about the business.
114
118
  */
@@ -187,6 +187,14 @@ class FullUser extends User$2 {
187
187
  get ttlPeriod() {
188
188
  return this.full?.ttlPeriod ?? null;
189
189
  }
190
+ /** Whether the "Gifts" tab should be shown */
191
+ get showGifts() {
192
+ return this.full.displayGiftsButton;
193
+ }
194
+ /** Information about the user's gift receive settings */
195
+ get disallowedGifts() {
196
+ return this.full.disallowedGifts ?? null;
197
+ }
190
198
  /**
191
199
  * If this is a business account, information about the business.
192
200
  */
@@ -56,5 +56,15 @@ class PeersIndex {
56
56
  return this.chat(peer.channelId);
57
57
  }
58
58
  }
59
+ has(peer) {
60
+ switch (peer._) {
61
+ case "peerUser":
62
+ return this.users.has(peer.userId);
63
+ case "peerChat":
64
+ return this.chats.has(peer.chatId);
65
+ case "peerChannel":
66
+ return this.chats.has(peer.channelId);
67
+ }
68
+ }
59
69
  }
60
70
  exports.PeersIndex = PeersIndex;
@@ -12,4 +12,5 @@ export declare class PeersIndex {
12
12
  user(id: number): tl.TypeUser;
13
13
  chat(id: number): tl.TypeChat;
14
14
  get(peer: tl.TypePeer): tl.TypeUser | tl.TypeChat;
15
+ has(peer: tl.TypePeer): boolean;
15
16
  }
@@ -12,4 +12,5 @@ export declare class PeersIndex {
12
12
  user(id: number): tl.TypeUser;
13
13
  chat(id: number): tl.TypeChat;
14
14
  get(peer: tl.TypePeer): tl.TypeUser | tl.TypeChat;
15
+ has(peer: tl.TypePeer): boolean;
15
16
  }
@@ -49,6 +49,16 @@ class PeersIndex {
49
49
  return this.chat(peer.channelId);
50
50
  }
51
51
  }
52
+ has(peer) {
53
+ switch (peer._) {
54
+ case "peerUser":
55
+ return this.users.has(peer.userId);
56
+ case "peerChat":
57
+ return this.chats.has(peer.chatId);
58
+ case "peerChannel":
59
+ return this.chats.has(peer.channelId);
60
+ }
61
+ }
52
62
  }
53
63
  export {
54
64
  PeersIndex
@@ -29,9 +29,9 @@ class BusinessConnection {
29
29
  get date() {
30
30
  return new Date(this.raw.date * 1e3);
31
31
  }
32
- /** Whether the bot can reply on behalf of the user */
33
- get canReply() {
34
- return this.raw.canReply;
32
+ /** What can the connected bot do on behalf of the user */
33
+ get rights() {
34
+ return this.raw.rights ?? null;
35
35
  }
36
36
  /** Business account user that created the business connection */
37
37
  get user() {
@@ -16,8 +16,8 @@ export declare class BusinessConnection {
16
16
  get dcId(): number;
17
17
  /** Date when the connection was created */
18
18
  get date(): Date;
19
- /** Whether the bot can reply on behalf of the user */
20
- get canReply(): boolean;
19
+ /** What can the connected bot do on behalf of the user */
20
+ get rights(): tl.TypeBusinessBotRights | null;
21
21
  /** Business account user that created the business connection */
22
22
  get user(): User;
23
23
  }
@@ -16,8 +16,8 @@ export declare class BusinessConnection {
16
16
  get dcId(): number;
17
17
  /** Date when the connection was created */
18
18
  get date(): Date;
19
- /** Whether the bot can reply on behalf of the user */
20
- get canReply(): boolean;
19
+ /** What can the connected bot do on behalf of the user */
20
+ get rights(): tl.TypeBusinessBotRights | null;
21
21
  /** Business account user that created the business connection */
22
22
  get user(): User;
23
23
  }
@@ -22,9 +22,9 @@ class BusinessConnection {
22
22
  get date() {
23
23
  return new Date(this.raw.date * 1e3);
24
24
  }
25
- /** Whether the bot can reply on behalf of the user */
26
- get canReply() {
27
- return this.raw.canReply;
25
+ /** What can the connected bot do on behalf of the user */
26
+ get rights() {
27
+ return this.raw.rights ?? null;
28
28
  }
29
29
  /** Business account user that created the business connection */
30
30
  get user() {
@@ -62,11 +62,11 @@ class SavedStarGift {
62
62
  get savedId() {
63
63
  return this.raw.savedId ?? null;
64
64
  }
65
- /** Amount of stars the gift can be converted to by the recipient */
65
+ /** Amount of stars the gift can be converted to */
66
66
  get convertStars() {
67
67
  return this.raw.convertStars ?? null;
68
68
  }
69
- /** Amount of stars needed to upgrade the gift to a unique gift */
69
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
70
70
  get upgradeStars() {
71
71
  return this.raw.upgradeStars ?? null;
72
72
  }
@@ -30,9 +30,9 @@ export declare class SavedStarGift {
30
30
  get messageId(): number | null;
31
31
  /** ID of the saved gift */
32
32
  get savedId(): tl.Long | null;
33
- /** Amount of stars the gift can be converted to by the recipient */
33
+ /** Amount of stars the gift can be converted to */
34
34
  get convertStars(): tl.Long | null;
35
- /** Amount of stars needed to upgrade the gift to a unique gift */
35
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
36
36
  get upgradeStars(): tl.Long | null;
37
37
  /** Amount of stars needed to transfer the gift */
38
38
  get transferStars(): tl.Long | null;
@@ -30,9 +30,9 @@ export declare class SavedStarGift {
30
30
  get messageId(): number | null;
31
31
  /** ID of the saved gift */
32
32
  get savedId(): tl.Long | null;
33
- /** Amount of stars the gift can be converted to by the recipient */
33
+ /** Amount of stars the gift can be converted to */
34
34
  get convertStars(): tl.Long | null;
35
- /** Amount of stars needed to upgrade the gift to a unique gift */
35
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
36
36
  get upgradeStars(): tl.Long | null;
37
37
  /** Amount of stars needed to transfer the gift */
38
38
  get transferStars(): tl.Long | null;
@@ -55,11 +55,11 @@ class SavedStarGift {
55
55
  get savedId() {
56
56
  return this.raw.savedId ?? null;
57
57
  }
58
- /** Amount of stars the gift can be converted to by the recipient */
58
+ /** Amount of stars the gift can be converted to */
59
59
  get convertStars() {
60
60
  return this.raw.convertStars ?? null;
61
61
  }
62
- /** Amount of stars needed to upgrade the gift to a unique gift */
62
+ /** Amount of stars **already paid** to upgrade the gift (e.g. by the sender) */
63
63
  get upgradeStars() {
64
64
  return this.raw.upgradeStars ?? null;
65
65
  }
@@ -6,6 +6,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const utils = require("@fuman/utils");
9
+ const peerUtils = require("../../../utils/peer-utils.cjs");
9
10
  const inspectable = require("../../utils/inspectable.cjs");
10
11
  const memoize = require("../../utils/memoize.cjs");
11
12
  const documentUtils = require("../media/document-utils.cjs");
@@ -62,14 +63,34 @@ class StarGiftUniqueOriginalDetails {
62
63
  this.raw = raw;
63
64
  this._peers = _peers;
64
65
  }
65
- /** ID of the user who sent the original star gift */
66
+ /**
67
+ * Peer who sent the original star gift, if available
68
+ *
69
+ * > Note: in some cases, {@link senderId} might be available, but not this field.
70
+ * > In such cases, you should try fetching the peer manually using {@link getPeer})
71
+ */
66
72
  get sender() {
67
- return this.raw.senderId ? peer.parsePeer(this.raw.senderId, this._peers) : null;
68
- }
69
- /** ID of the user who received the original star gift */
73
+ if (!this.raw.senderId) return null;
74
+ if (!this._peers.has(this.raw.senderId)) return null;
75
+ return peer.parsePeer(this.raw.senderId, this._peers);
76
+ }
77
+ /** ID of the peer who sent the original star gift */
78
+ get senderId() {
79
+ return this.raw.senderId ? peerUtils.getMarkedPeerId(this.raw.senderId) : null;
80
+ }
81
+ /**
82
+ * Peer who received the original star gift, if available
83
+ *
84
+ * > Note: {@link recipientId} is always available. If ID is available, but this field throws an error,
85
+ * > you should try fetching the peer manually using {@link getPeer})
86
+ */
70
87
  get recipient() {
71
88
  return peer.parsePeer(this.raw.recipientId, this._peers);
72
89
  }
90
+ /** ID of the peer who received the original star gift */
91
+ get recipientId() {
92
+ return peerUtils.getMarkedPeerId(this.raw.recipientId);
93
+ }
73
94
  /** Date when the original star gift was sent */
74
95
  get date() {
75
96
  return new Date(this.raw.date * 1e3);
@@ -116,11 +137,20 @@ class StarGiftUnique {
116
137
  get slug() {
117
138
  return this.raw.slug;
118
139
  }
119
- /** ID of the peer who owns this gift, if available */
140
+ /**
141
+ * ID of the peer who owns this gift, if available
142
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
143
+ * > in which cases please use `tg.getPeer(ownerId)` manually
144
+ */
120
145
  get owner() {
121
146
  if (!this.raw.ownerId) return null;
147
+ if (!this._peers.has(this.raw.ownerId)) return null;
122
148
  return peer.parsePeer(this.raw.ownerId, this._peers);
123
149
  }
150
+ /** ID of the peer who owns this gift, if available */
151
+ get ownerId() {
152
+ return this.raw.ownerId ? peerUtils.getMarkedPeerId(this.raw.ownerId) : null;
153
+ }
124
154
  /** Name of the user who owns this gift, if available */
125
155
  get ownerName() {
126
156
  return this.raw.ownerName ?? null;
@@ -31,10 +31,24 @@ export declare class StarGiftUniqueOriginalDetails {
31
31
  readonly raw: tl.RawStarGiftAttributeOriginalDetails;
32
32
  readonly _peers: PeersIndex;
33
33
  constructor(raw: tl.RawStarGiftAttributeOriginalDetails, _peers: PeersIndex);
34
- /** ID of the user who sent the original star gift */
34
+ /**
35
+ * Peer who sent the original star gift, if available
36
+ *
37
+ * > Note: in some cases, {@link senderId} might be available, but not this field.
38
+ * > In such cases, you should try fetching the peer manually using {@link getPeer})
39
+ */
35
40
  get sender(): Peer | null;
36
- /** ID of the user who received the original star gift */
41
+ /** ID of the peer who sent the original star gift */
42
+ get senderId(): number | null;
43
+ /**
44
+ * Peer who received the original star gift, if available
45
+ *
46
+ * > Note: {@link recipientId} is always available. If ID is available, but this field throws an error,
47
+ * > you should try fetching the peer manually using {@link getPeer})
48
+ */
37
49
  get recipient(): Peer;
50
+ /** ID of the peer who received the original star gift */
51
+ get recipientId(): number;
38
52
  /** Date when the original star gift was sent */
39
53
  get date(): Date;
40
54
  /** Message attached to the original star gift */
@@ -57,8 +71,14 @@ export declare class StarGiftUnique {
57
71
  get title(): string;
58
72
  /** Slug of the gift */
59
73
  get slug(): string;
60
- /** ID of the peer who owns this gift, if available */
74
+ /**
75
+ * ID of the peer who owns this gift, if available
76
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
77
+ * > in which cases please use `tg.getPeer(ownerId)` manually
78
+ */
61
79
  get owner(): Peer | null;
80
+ /** ID of the peer who owns this gift, if available */
81
+ get ownerId(): number | null;
62
82
  /** Name of the user who owns this gift, if available */
63
83
  get ownerName(): string | null;
64
84
  get availabilityIssued(): number;
@@ -31,10 +31,24 @@ export declare class StarGiftUniqueOriginalDetails {
31
31
  readonly raw: tl.RawStarGiftAttributeOriginalDetails;
32
32
  readonly _peers: PeersIndex;
33
33
  constructor(raw: tl.RawStarGiftAttributeOriginalDetails, _peers: PeersIndex);
34
- /** ID of the user who sent the original star gift */
34
+ /**
35
+ * Peer who sent the original star gift, if available
36
+ *
37
+ * > Note: in some cases, {@link senderId} might be available, but not this field.
38
+ * > In such cases, you should try fetching the peer manually using {@link getPeer})
39
+ */
35
40
  get sender(): Peer | null;
36
- /** ID of the user who received the original star gift */
41
+ /** ID of the peer who sent the original star gift */
42
+ get senderId(): number | null;
43
+ /**
44
+ * Peer who received the original star gift, if available
45
+ *
46
+ * > Note: {@link recipientId} is always available. If ID is available, but this field throws an error,
47
+ * > you should try fetching the peer manually using {@link getPeer})
48
+ */
37
49
  get recipient(): Peer;
50
+ /** ID of the peer who received the original star gift */
51
+ get recipientId(): number;
38
52
  /** Date when the original star gift was sent */
39
53
  get date(): Date;
40
54
  /** Message attached to the original star gift */
@@ -57,8 +71,14 @@ export declare class StarGiftUnique {
57
71
  get title(): string;
58
72
  /** Slug of the gift */
59
73
  get slug(): string;
60
- /** ID of the peer who owns this gift, if available */
74
+ /**
75
+ * ID of the peer who owns this gift, if available
76
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
77
+ * > in which cases please use `tg.getPeer(ownerId)` manually
78
+ */
61
79
  get owner(): Peer | null;
80
+ /** ID of the peer who owns this gift, if available */
81
+ get ownerId(): number | null;
62
82
  /** Name of the user who owns this gift, if available */
63
83
  get ownerName(): string | null;
64
84
  get availabilityIssued(): number;
@@ -1,4 +1,5 @@
1
1
  import { assert } from "@fuman/utils";
2
+ import { getMarkedPeerId } from "../../../utils/peer-utils.js";
2
3
  import { makeInspectable } from "../../utils/inspectable.js";
3
4
  import { memoizeGetters } from "../../utils/memoize.js";
4
5
  import { parseDocument } from "../media/document-utils.js";
@@ -55,14 +56,34 @@ class StarGiftUniqueOriginalDetails {
55
56
  this.raw = raw;
56
57
  this._peers = _peers;
57
58
  }
58
- /** ID of the user who sent the original star gift */
59
+ /**
60
+ * Peer who sent the original star gift, if available
61
+ *
62
+ * > Note: in some cases, {@link senderId} might be available, but not this field.
63
+ * > In such cases, you should try fetching the peer manually using {@link getPeer})
64
+ */
59
65
  get sender() {
60
- return this.raw.senderId ? parsePeer(this.raw.senderId, this._peers) : null;
61
- }
62
- /** ID of the user who received the original star gift */
66
+ if (!this.raw.senderId) return null;
67
+ if (!this._peers.has(this.raw.senderId)) return null;
68
+ return parsePeer(this.raw.senderId, this._peers);
69
+ }
70
+ /** ID of the peer who sent the original star gift */
71
+ get senderId() {
72
+ return this.raw.senderId ? getMarkedPeerId(this.raw.senderId) : null;
73
+ }
74
+ /**
75
+ * Peer who received the original star gift, if available
76
+ *
77
+ * > Note: {@link recipientId} is always available. If ID is available, but this field throws an error,
78
+ * > you should try fetching the peer manually using {@link getPeer})
79
+ */
63
80
  get recipient() {
64
81
  return parsePeer(this.raw.recipientId, this._peers);
65
82
  }
83
+ /** ID of the peer who received the original star gift */
84
+ get recipientId() {
85
+ return getMarkedPeerId(this.raw.recipientId);
86
+ }
66
87
  /** Date when the original star gift was sent */
67
88
  get date() {
68
89
  return new Date(this.raw.date * 1e3);
@@ -109,11 +130,20 @@ class StarGiftUnique {
109
130
  get slug() {
110
131
  return this.raw.slug;
111
132
  }
112
- /** ID of the peer who owns this gift, if available */
133
+ /**
134
+ * ID of the peer who owns this gift, if available
135
+ * > Note: in some cases, only {@link ownerId} is available, and not {@link owner},
136
+ * > in which cases please use `tg.getPeer(ownerId)` manually
137
+ */
113
138
  get owner() {
114
139
  if (!this.raw.ownerId) return null;
140
+ if (!this._peers.has(this.raw.ownerId)) return null;
115
141
  return parsePeer(this.raw.ownerId, this._peers);
116
142
  }
143
+ /** ID of the peer who owns this gift, if available */
144
+ get ownerId() {
145
+ return this.raw.ownerId ? getMarkedPeerId(this.raw.ownerId) : null;
146
+ }
117
147
  /** Name of the user who owns this gift, if available */
118
148
  get ownerName() {
119
149
  return this.raw.ownerName ?? null;
@@ -177,6 +177,10 @@ class StarsTransaction {
177
177
  return { type: "unsupported" };
178
178
  }
179
179
  }
180
+ /** Whether this transaction was made by a business bot */
181
+ get viaBusinessBot() {
182
+ return this.raw.businessTransfer;
183
+ }
180
184
  }
181
185
  const StarsTransaction$1 = /* @__PURE__ */ inspectable.makeInspectable(StarsTransaction);
182
186
  const StarsTransaction$2 = /* @__PURE__ */ memoize.memoizeGetters(StarsTransaction$1, ["amount", "type"]);
@@ -160,4 +160,6 @@ export declare class StarsTransaction {
160
160
  get date(): Date;
161
161
  /** Type of this transaction */
162
162
  get type(): StarsTransactionType;
163
+ /** Whether this transaction was made by a business bot */
164
+ get viaBusinessBot(): boolean;
163
165
  }
@@ -160,4 +160,6 @@ export declare class StarsTransaction {
160
160
  get date(): Date;
161
161
  /** Type of this transaction */
162
162
  get type(): StarsTransactionType;
163
+ /** Whether this transaction was made by a business bot */
164
+ get viaBusinessBot(): boolean;
163
165
  }
@@ -170,6 +170,10 @@ class StarsTransaction {
170
170
  return { type: "unsupported" };
171
171
  }
172
172
  }
173
+ /** Whether this transaction was made by a business bot */
174
+ get viaBusinessBot() {
175
+ return this.raw.businessTransfer;
176
+ }
173
177
  }
174
178
  const StarsTransaction$1 = /* @__PURE__ */ makeInspectable(StarsTransaction);
175
179
  const StarsTransaction$2 = /* @__PURE__ */ memoizeGetters(StarsTransaction$1, ["amount", "type"]);
@@ -1225,7 +1225,7 @@ class UpdatesManager {
1225
1225
  pending.ptsBefore,
1226
1226
  diff
1227
1227
  );
1228
- pending.timeout = Date.now() + 500;
1228
+ pending.timeout = performance.now() + 500;
1229
1229
  pendingPtsUpdatesPostponed.add(pending);
1230
1230
  postponedTimer.emitBefore(pending.timeout);
1231
1231
  } else if (diff > -1e6) {
@@ -1294,7 +1294,7 @@ class UpdatesManager {
1294
1294
  continue;
1295
1295
  }
1296
1296
  if (localPts < pending.ptsBefore) {
1297
- const now = Date.now();
1297
+ const now = performance.now();
1298
1298
  if (now < pending.timeout) {
1299
1299
  log.debug(
1300
1300
  "postponed %s (cid = %d) is still waiting (%dms left) (current pts %d, need %d)",
@@ -1348,7 +1348,7 @@ class UpdatesManager {
1348
1348
  pending.qtsBefore,
1349
1349
  diff
1350
1350
  );
1351
- pending.timeout = Date.now() + 500;
1351
+ pending.timeout = performance.now() + 500;
1352
1352
  pendingQtsUpdatesPostponed.add(pending);
1353
1353
  postponedTimer.emitBefore(pending.timeout);
1354
1354
  } else {
@@ -1382,7 +1382,7 @@ class UpdatesManager {
1382
1382
  continue;
1383
1383
  }
1384
1384
  if (this.qts < pending.qtsBefore) {
1385
- const now = Date.now();
1385
+ const now = performance.now();
1386
1386
  if (now < pending.timeout) {
1387
1387
  log.debug(
1388
1388
  "postponed %s is still waiting (%dms left) (current qts %d, need %d)",