@mtcute/core 0.28.1 → 0.28.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 (73) hide show
  1. package/client.cjs +8 -0
  2. package/client.js +8 -0
  3. package/highlevel/client.d.cts +55 -3
  4. package/highlevel/client.d.ts +55 -3
  5. package/highlevel/methods/chats/edit-chat-member-rank.cjs +19 -0
  6. package/highlevel/methods/chats/edit-chat-member-rank.d.cts +13 -0
  7. package/highlevel/methods/chats/edit-chat-member-rank.d.ts +13 -0
  8. package/highlevel/methods/chats/edit-chat-member-rank.js +14 -0
  9. package/highlevel/methods/chats/get-creator-after-leave.cjs +20 -4
  10. package/highlevel/methods/chats/get-creator-after-leave.d.cts +2 -2
  11. package/highlevel/methods/chats/get-creator-after-leave.d.ts +2 -2
  12. package/highlevel/methods/chats/get-creator-after-leave.js +21 -5
  13. package/highlevel/methods/chats/toggle-content-protection.cjs +3 -2
  14. package/highlevel/methods/chats/toggle-content-protection.d.cts +4 -1
  15. package/highlevel/methods/chats/toggle-content-protection.d.ts +4 -1
  16. package/highlevel/methods/chats/toggle-content-protection.js +3 -2
  17. package/highlevel/methods/chats/transfer-chat-ownership.cjs +36 -0
  18. package/highlevel/methods/chats/transfer-chat-ownership.d.cts +16 -0
  19. package/highlevel/methods/chats/transfer-chat-ownership.d.ts +16 -0
  20. package/highlevel/methods/chats/transfer-chat-ownership.js +31 -0
  21. package/highlevel/methods/files/upload-file.cjs +2 -2
  22. package/highlevel/methods/files/upload-file.js +2 -2
  23. package/highlevel/methods/users/resolve-peer.cjs +4 -4
  24. package/highlevel/methods/users/resolve-peer.js +4 -4
  25. package/highlevel/methods.d.cts +2 -0
  26. package/highlevel/methods.d.ts +2 -0
  27. package/highlevel/types/messages/message-action.cjs +13 -0
  28. package/highlevel/types/messages/message-action.d.cts +19 -1
  29. package/highlevel/types/messages/message-action.d.ts +19 -1
  30. package/highlevel/types/messages/message-action.js +13 -0
  31. package/highlevel/types/messages/message.cjs +4 -0
  32. package/highlevel/types/messages/message.d.cts +2 -0
  33. package/highlevel/types/messages/message.d.ts +2 -0
  34. package/highlevel/types/messages/message.js +4 -0
  35. package/highlevel/types/peers/chat-event/actions.cjs +7 -0
  36. package/highlevel/types/peers/chat-event/actions.d.cts +11 -1
  37. package/highlevel/types/peers/chat-event/actions.d.ts +11 -1
  38. package/highlevel/types/peers/chat-event/actions.js +7 -0
  39. package/highlevel/types/peers/chat-event/filters.cjs +1 -0
  40. package/highlevel/types/peers/chat-event/filters.js +1 -0
  41. package/highlevel/types/peers/chat-member.cjs +5 -8
  42. package/highlevel/types/peers/chat-member.d.cts +2 -2
  43. package/highlevel/types/peers/chat-member.d.ts +2 -2
  44. package/highlevel/types/peers/chat-member.js +5 -8
  45. package/highlevel/types/peers/full-user.cjs +14 -0
  46. package/highlevel/types/peers/full-user.d.cts +10 -0
  47. package/highlevel/types/peers/full-user.d.ts +10 -0
  48. package/highlevel/types/peers/full-user.js +14 -0
  49. package/highlevel/utils/file-utils.cjs +2 -2
  50. package/highlevel/utils/file-utils.d.cts +1 -1
  51. package/highlevel/utils/file-utils.d.ts +1 -1
  52. package/highlevel/utils/file-utils.js +2 -2
  53. package/methods.cjs +4 -0
  54. package/methods.js +4 -0
  55. package/network/network-manager.cjs +1 -1
  56. package/network/network-manager.js +1 -1
  57. package/network/server-salt.cjs +4 -8
  58. package/network/server-salt.js +4 -8
  59. package/package.json +3 -3
  60. package/utils/binary/compat.cjs +8 -0
  61. package/utils/binary/compat.js +8 -0
  62. package/utils/date-entity-format.cjs +48 -0
  63. package/utils/date-entity-format.d.cts +24 -0
  64. package/utils/date-entity-format.d.ts +24 -0
  65. package/utils/date-entity-format.js +43 -0
  66. package/utils/date-entity-format.test.d.cts +1 -0
  67. package/utils/date-entity-format.test.d.ts +1 -0
  68. package/utils/index.d.cts +1 -0
  69. package/utils/index.d.ts +1 -0
  70. package/utils/links/bots.cjs +3 -0
  71. package/utils/links/bots.js +3 -0
  72. package/utils.cjs +3 -0
  73. package/utils.js +3 -0
@@ -0,0 +1,16 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputPeerLike } from '../../types/peers/peer.js';
3
+ /**
4
+ * Transfer ownership of a chat/channel/supergroup to another user.
5
+ *
6
+ * You must be the creator of the chat to use this method,
7
+ * and your account must have 2FA enabled.
8
+ */
9
+ export declare function transferChatOwnership(client: ITelegramClient, params: {
10
+ /** ID of the chat/channel/supergroup to transfer */
11
+ chatId: InputPeerLike;
12
+ /** ID of the user to transfer ownership to */
13
+ userId: InputPeerLike;
14
+ /** Your 2FA password */
15
+ password: string;
16
+ }): Promise<void>;
@@ -0,0 +1,31 @@
1
+ import { isInputPeerChannel, toInputChannel } from "../../utils/peer-utils.js";
2
+ import { resolvePeer, resolveUser } from "../users/resolve-peer.js";
3
+ async function transferChatOwnership(client, params) {
4
+ const { chatId, userId } = params;
5
+ const peer = await resolvePeer(client, chatId);
6
+ const user = await resolveUser(client, userId);
7
+ const password = await client.computeSrpParams(
8
+ await client.call({ _: "account.getPassword" }),
9
+ params.password
10
+ );
11
+ let res;
12
+ if (isInputPeerChannel(peer)) {
13
+ res = await client.call({
14
+ _: "channels.editCreator",
15
+ channel: toInputChannel(peer),
16
+ userId: user,
17
+ password
18
+ });
19
+ } else {
20
+ res = await client.call({
21
+ _: "messages.editChatCreator",
22
+ peer,
23
+ userId: user,
24
+ password
25
+ });
26
+ }
27
+ client.handleClientUpdate(res);
28
+ }
29
+ export {
30
+ transferChatOwnership
31
+ };
@@ -95,9 +95,9 @@ async function uploadFile(client, params) {
95
95
  let partSizeKb = params.partSize;
96
96
  if (!partSizeKb) {
97
97
  if (fileSize === -1) {
98
- partSizeKb = params.estimatedSize ? fileUtils.determinePartSize(params.estimatedSize) : 64;
98
+ partSizeKb = params.estimatedSize ? fileUtils.determinePartSize(params.estimatedSize, true) : 64;
99
99
  } else {
100
- partSizeKb = fileUtils.determinePartSize(fileSize);
100
+ partSizeKb = fileUtils.determinePartSize(fileSize, true);
101
101
  }
102
102
  }
103
103
  if (partSizeKb > 512) {
@@ -88,9 +88,9 @@ async function uploadFile(client, params) {
88
88
  let partSizeKb = params.partSize;
89
89
  if (!partSizeKb) {
90
90
  if (fileSize === -1) {
91
- partSizeKb = params.estimatedSize ? determinePartSize(params.estimatedSize) : 64;
91
+ partSizeKb = params.estimatedSize ? determinePartSize(params.estimatedSize, true) : 64;
92
92
  } else {
93
- partSizeKb = determinePartSize(fileSize);
93
+ partSizeKb = determinePartSize(fileSize, true);
94
94
  }
95
95
  }
96
96
  if (partSizeKb > 512) {
@@ -119,14 +119,14 @@ async function resolvePeer(client, peerId, force = false) {
119
119
  if (cached && (cached._ === "channel" || cached._ === "user")) {
120
120
  const [username] = peerUtils$1.extractUsernames(cached);
121
121
  if (username) {
122
- const resolved = await resolvePeer(client, username, true);
123
- if (peerUtils.getMarkedPeerId(resolved) === peerId) {
122
+ const resolved = await resolvePeer(client, username, true).catch(() => null);
123
+ if (resolved && peerUtils.getMarkedPeerId(resolved) === peerId) {
124
124
  return resolved;
125
125
  }
126
126
  }
127
127
  if (cached._ === "user" && cached.phone) {
128
- const resolved = await resolvePhoneNumber.resolvePhoneNumber(client, cached.phone, true);
129
- if (peerUtils.getMarkedPeerId(resolved) === peerId) {
128
+ const resolved = await resolvePhoneNumber.resolvePhoneNumber(client, cached.phone, true).catch(() => null);
129
+ if (resolved && peerUtils.getMarkedPeerId(resolved) === peerId) {
130
130
  return resolved;
131
131
  }
132
132
  }
@@ -112,14 +112,14 @@ async function resolvePeer(client, peerId, force = false) {
112
112
  if (cached && (cached._ === "channel" || cached._ === "user")) {
113
113
  const [username] = extractUsernames(cached);
114
114
  if (username) {
115
- const resolved = await resolvePeer(client, username, true);
116
- if (getMarkedPeerId(resolved) === peerId) {
115
+ const resolved = await resolvePeer(client, username, true).catch(() => null);
116
+ if (resolved && getMarkedPeerId(resolved) === peerId) {
117
117
  return resolved;
118
118
  }
119
119
  }
120
120
  if (cached._ === "user" && cached.phone) {
121
- const resolved = await resolvePhoneNumber(client, cached.phone, true);
122
- if (getMarkedPeerId(resolved) === peerId) {
121
+ const resolved = await resolvePhoneNumber(client, cached.phone, true).catch(() => null);
122
+ if (resolved && getMarkedPeerId(resolved) === peerId) {
123
123
  return resolved;
124
124
  }
125
125
  }
@@ -45,6 +45,7 @@ export { deleteGroup } from './methods/chats/delete-group.js';
45
45
  export { deleteHistory } from './methods/chats/delete-history.js';
46
46
  export { deleteUserHistory } from './methods/chats/delete-user-history.js';
47
47
  export { editAdminRights } from './methods/chats/edit-admin-rights.js';
48
+ export { editChatMemberRank } from './methods/chats/edit-chat-member-rank.js';
48
49
  export { getChatEventLog } from './methods/chats/get-chat-event-log.js';
49
50
  export { getChatMember } from './methods/chats/get-chat-member.js';
50
51
  export { getChatMembers } from './methods/chats/get-chat-members.js';
@@ -83,6 +84,7 @@ export { toggleContentProtection } from './methods/chats/toggle-content-protecti
83
84
  export { toggleFragmentUsername } from './methods/chats/toggle-fragment-username.js';
84
85
  export { toggleJoinRequests } from './methods/chats/toggle-join-requests.js';
85
86
  export { toggleJoinToSend } from './methods/chats/toggle-join-to-send.js';
87
+ export { transferChatOwnership } from './methods/chats/transfer-chat-ownership.js';
86
88
  export { unarchiveChats } from './methods/chats/unarchive-chats.js';
87
89
  export { unbanChatMember } from './methods/chats/unban-chat-member.js';
88
90
  export { addContact } from './methods/contacts/add-contact.js';
@@ -45,6 +45,7 @@ export { deleteGroup } from './methods/chats/delete-group.js';
45
45
  export { deleteHistory } from './methods/chats/delete-history.js';
46
46
  export { deleteUserHistory } from './methods/chats/delete-user-history.js';
47
47
  export { editAdminRights } from './methods/chats/edit-admin-rights.js';
48
+ export { editChatMemberRank } from './methods/chats/edit-chat-member-rank.js';
48
49
  export { getChatEventLog } from './methods/chats/get-chat-event-log.js';
49
50
  export { getChatMember } from './methods/chats/get-chat-member.js';
50
51
  export { getChatMembers } from './methods/chats/get-chat-members.js';
@@ -83,6 +84,7 @@ export { toggleContentProtection } from './methods/chats/toggle-content-protecti
83
84
  export { toggleFragmentUsername } from './methods/chats/toggle-fragment-username.js';
84
85
  export { toggleJoinRequests } from './methods/chats/toggle-join-requests.js';
85
86
  export { toggleJoinToSend } from './methods/chats/toggle-join-to-send.js';
87
+ export { transferChatOwnership } from './methods/chats/transfer-chat-ownership.js';
86
88
  export { unarchiveChats } from './methods/chats/unarchive-chats.js';
87
89
  export { unbanChatMember } from './methods/chats/unban-chat-member.js';
88
90
  export { addContact } from './methods/contacts/add-contact.js';
@@ -436,6 +436,19 @@ function _messageActionFromTl(act) {
436
436
  type: "change_creator",
437
437
  newCreator: new user.User(this._peers.user(act.newCreatorId))
438
438
  };
439
+ case "messageActionNoForwardsToggle":
440
+ return {
441
+ type: "no_forwards_toggle",
442
+ prevValue: act.prevValue,
443
+ newValue: act.newValue
444
+ };
445
+ case "messageActionNoForwardsRequest":
446
+ return {
447
+ type: "no_forwards_request",
448
+ expired: act.expired,
449
+ prevValue: act.prevValue,
450
+ newValue: act.newValue
451
+ };
439
452
  default:
440
453
  return null;
441
454
  }
@@ -573,6 +573,24 @@ export interface ActionSuggestBirthday {
573
573
  /** Birthday */
574
574
  birthday: tl.RawBirthday;
575
575
  }
576
+ /** Content protection (no-forwards) was toggled */
577
+ export interface ActionNoForwardsToggle {
578
+ readonly type: 'no_forwards_toggle';
579
+ /** Previous value */
580
+ prevValue: boolean;
581
+ /** New value */
582
+ newValue: boolean;
583
+ }
584
+ /** Content protection (no-forwards) toggle was requested */
585
+ export interface ActionNoForwardsRequest {
586
+ readonly type: 'no_forwards_request';
587
+ /** Whether this request has expired */
588
+ expired: boolean;
589
+ /** Previous value */
590
+ prevValue: boolean;
591
+ /** New value */
592
+ newValue: boolean;
593
+ }
576
594
  /** Group creator has left the group, and a new creator has been assigned but not yet made one */
577
595
  export interface ActionNewCreatorPending {
578
596
  readonly type: 'new_creator_pending';
@@ -585,7 +603,7 @@ export interface ActionChangeCreator {
585
603
  /** New creator */
586
604
  newCreator: User;
587
605
  }
588
- 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 | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | null;
606
+ 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 | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | ActionNoForwardsToggle | ActionNoForwardsRequest | null;
589
607
  /** @internal */
590
608
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
591
609
  export {};
@@ -573,6 +573,24 @@ export interface ActionSuggestBirthday {
573
573
  /** Birthday */
574
574
  birthday: tl.RawBirthday;
575
575
  }
576
+ /** Content protection (no-forwards) was toggled */
577
+ export interface ActionNoForwardsToggle {
578
+ readonly type: 'no_forwards_toggle';
579
+ /** Previous value */
580
+ prevValue: boolean;
581
+ /** New value */
582
+ newValue: boolean;
583
+ }
584
+ /** Content protection (no-forwards) toggle was requested */
585
+ export interface ActionNoForwardsRequest {
586
+ readonly type: 'no_forwards_request';
587
+ /** Whether this request has expired */
588
+ expired: boolean;
589
+ /** Previous value */
590
+ prevValue: boolean;
591
+ /** New value */
592
+ newValue: boolean;
593
+ }
576
594
  /** Group creator has left the group, and a new creator has been assigned but not yet made one */
577
595
  export interface ActionNewCreatorPending {
578
596
  readonly type: 'new_creator_pending';
@@ -585,7 +603,7 @@ export interface ActionChangeCreator {
585
603
  /** New creator */
586
604
  newCreator: User;
587
605
  }
588
- 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 | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | null;
606
+ 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 | ActionThemeChangedUnique | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarGifted | ActionStarsPrize | ActionStarGiftSent | ActionStarGiftUpgradePaid | ActionStarGiftUpgraded | ActionStarGiftBoughtResale | ActionStarGiftTransferred | ActionStarGiftAssigned | ActionPaidMessagesPaid | ActionPaidMessagesRefunded | ActionTodoCompletions | ActionTodoAppendTasks | ActionTonGift | ActionSuggestBirthday | ActionStarGiftPurchaseOffer | ActionStarGiftPurchaseOfferDeclined | ActionStarGiftBoughtOffer | ActionStarGiftCrafted | ActionNewCreatorPending | ActionChangeCreator | ActionNoForwardsToggle | ActionNoForwardsRequest | null;
589
607
  /** @internal */
590
608
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
591
609
  export {};
@@ -429,6 +429,19 @@ function _messageActionFromTl(act) {
429
429
  type: "change_creator",
430
430
  newCreator: new User$2(this._peers.user(act.newCreatorId))
431
431
  };
432
+ case "messageActionNoForwardsToggle":
433
+ return {
434
+ type: "no_forwards_toggle",
435
+ prevValue: act.prevValue,
436
+ newValue: act.newValue
437
+ };
438
+ case "messageActionNoForwardsRequest":
439
+ return {
440
+ type: "no_forwards_request",
441
+ expired: act.expired,
442
+ prevValue: act.prevValue,
443
+ newValue: act.newValue
444
+ };
432
445
  default:
433
446
  return null;
434
447
  }
@@ -95,6 +95,10 @@ class Message {
95
95
  get hasUnreadMedia() {
96
96
  return this.raw.mediaUnread;
97
97
  }
98
+ /** For messages in groups chats, the rank of the sender, if any */
99
+ get fromRank() {
100
+ return this.raw._ === "message" ? this.raw.fromRank ?? null : null;
101
+ }
98
102
  /** Whether this is a broadcast channel post */
99
103
  get isChannelPost() {
100
104
  return this.raw._ === "message" && this.raw.post;
@@ -74,6 +74,8 @@ export declare class Message {
74
74
  get isSilent(): boolean;
75
75
  /** Whether there are unread media attachments in this message */
76
76
  get hasUnreadMedia(): boolean;
77
+ /** For messages in groups chats, the rank of the sender, if any */
78
+ get fromRank(): string | null;
77
79
  /** Whether this is a broadcast channel post */
78
80
  get isChannelPost(): boolean;
79
81
  /**
@@ -74,6 +74,8 @@ export declare class Message {
74
74
  get isSilent(): boolean;
75
75
  /** Whether there are unread media attachments in this message */
76
76
  get hasUnreadMedia(): boolean;
77
+ /** For messages in groups chats, the rank of the sender, if any */
78
+ get fromRank(): string | null;
77
79
  /** Whether this is a broadcast channel post */
78
80
  get isChannelPost(): boolean;
79
81
  /**
@@ -88,6 +88,10 @@ class Message {
88
88
  get hasUnreadMedia() {
89
89
  return this.raw.mediaUnread;
90
90
  }
91
+ /** For messages in groups chats, the rank of the sender, if any */
92
+ get fromRank() {
93
+ return this.raw._ === "message" ? this.raw.fromRank ?? null : null;
94
+ }
91
95
  /** Whether this is a broadcast channel post */
92
96
  get isChannelPost() {
93
97
  return this.raw._ === "message" && this.raw.post;
@@ -284,6 +284,13 @@ function _actionFromTl(e, peers, peerId) {
284
284
  type: "toggle_autotranslation",
285
285
  enabled: e.newValue
286
286
  };
287
+ case "channelAdminLogEventActionParticipantEditRank":
288
+ return {
289
+ type: "participant_rank_edited",
290
+ user: new user.User(peers.user(e.userId)),
291
+ prevRank: e.prevRank,
292
+ newRank: e.newRank
293
+ };
287
294
  default:
288
295
  return null;
289
296
  }
@@ -325,6 +325,16 @@ export interface ChatActionToggleAntiSpam {
325
325
  /** Whether the chat now has aggressive anti-spam enabled */
326
326
  enabled: boolean;
327
327
  }
328
+ /** Participant rank was edited */
329
+ export interface ChatActionParticipantRankEdited {
330
+ type: 'participant_rank_edited';
331
+ /** User whose rank was edited */
332
+ user: User;
333
+ /** Previous rank */
334
+ prevRank: string;
335
+ /** New rank */
336
+ newRank: string;
337
+ }
328
338
  /** Auto-translation has been toggled */
329
339
  export interface ChatActionToggleAutotranslation {
330
340
  type: 'toggle_autotranslation';
@@ -332,6 +342,6 @@ export interface ChatActionToggleAutotranslation {
332
342
  enabled: boolean;
333
343
  }
334
344
  /** Chat event action (`null` if unsupported) */
335
- export type ChatAction = ChatActionUserJoined | ChatActionUserLeft | ChatActionUserInvited | ChatActionTitleChanged | ChatActionDescriptionChanged | ChatActionUsernameChanged | ChatActionUsernamesChanged | ChatActionPhotoChanged | ChatActionInvitesToggled | ChatActionSignaturesToggled | ChatActionMessagePinned | ChatActionMessageEdited | ChatActionMessageDeleted | ChatActionUserPermissionsChanged | ChatActionUserAdminPermissionsChanged | ChatActionStickersetChanged | ChatActionHistoryToggled | ChatActionDefaultPermissionsChanged | ChatActionPollStopped | ChatActionLinkedChatChanged | ChatActionLocationChanged | ChatActionSlowModeChanged | ChatActionCallStarted | ChatActionCallEnded | ChatActionCallSettingChanged | ChatActionUserJoinedInvite | ChatActionInviteLinkDeleted | ChatActionInviteLinkEdited | ChatActionInviteLinkRevoked | ChatActionUserJoinedApproved | ChatActionTtlChanged | ChatActionNoForwardsToggled | ChatActionForumToggled | ChatActionTopicCreated | ChatActionTopicEdited | ChatActionTopicDeleted | ChatActionSignatureProfilesToggled | ChatActionSubscriptionExtended | ChatActionAvailableReactionsChanged | ChatActionEmojiStatusChanged | ChatActionEmojiStickersetChanged | ChatActionPeerColorChanged | ChatActionWallpaperChanged | ChatActionMessageSent | ChatActionToggleAntiSpam | ChatActionToggleAutotranslation | null;
345
+ export type ChatAction = ChatActionUserJoined | ChatActionUserLeft | ChatActionUserInvited | ChatActionTitleChanged | ChatActionDescriptionChanged | ChatActionUsernameChanged | ChatActionUsernamesChanged | ChatActionPhotoChanged | ChatActionInvitesToggled | ChatActionSignaturesToggled | ChatActionMessagePinned | ChatActionMessageEdited | ChatActionMessageDeleted | ChatActionUserPermissionsChanged | ChatActionUserAdminPermissionsChanged | ChatActionStickersetChanged | ChatActionHistoryToggled | ChatActionDefaultPermissionsChanged | ChatActionPollStopped | ChatActionLinkedChatChanged | ChatActionLocationChanged | ChatActionSlowModeChanged | ChatActionCallStarted | ChatActionCallEnded | ChatActionCallSettingChanged | ChatActionUserJoinedInvite | ChatActionInviteLinkDeleted | ChatActionInviteLinkEdited | ChatActionInviteLinkRevoked | ChatActionUserJoinedApproved | ChatActionTtlChanged | ChatActionNoForwardsToggled | ChatActionForumToggled | ChatActionTopicCreated | ChatActionTopicEdited | ChatActionTopicDeleted | ChatActionSignatureProfilesToggled | ChatActionSubscriptionExtended | ChatActionAvailableReactionsChanged | ChatActionEmojiStatusChanged | ChatActionEmojiStickersetChanged | ChatActionPeerColorChanged | ChatActionWallpaperChanged | ChatActionMessageSent | ChatActionToggleAntiSpam | ChatActionToggleAutotranslation | ChatActionParticipantRankEdited | null;
336
346
  /** @internal */
337
347
  export declare function _actionFromTl(e: tl.TypeChannelAdminLogEventAction, peers: PeersIndex, peerId: number): ChatAction;
@@ -325,6 +325,16 @@ export interface ChatActionToggleAntiSpam {
325
325
  /** Whether the chat now has aggressive anti-spam enabled */
326
326
  enabled: boolean;
327
327
  }
328
+ /** Participant rank was edited */
329
+ export interface ChatActionParticipantRankEdited {
330
+ type: 'participant_rank_edited';
331
+ /** User whose rank was edited */
332
+ user: User;
333
+ /** Previous rank */
334
+ prevRank: string;
335
+ /** New rank */
336
+ newRank: string;
337
+ }
328
338
  /** Auto-translation has been toggled */
329
339
  export interface ChatActionToggleAutotranslation {
330
340
  type: 'toggle_autotranslation';
@@ -332,6 +342,6 @@ export interface ChatActionToggleAutotranslation {
332
342
  enabled: boolean;
333
343
  }
334
344
  /** Chat event action (`null` if unsupported) */
335
- export type ChatAction = ChatActionUserJoined | ChatActionUserLeft | ChatActionUserInvited | ChatActionTitleChanged | ChatActionDescriptionChanged | ChatActionUsernameChanged | ChatActionUsernamesChanged | ChatActionPhotoChanged | ChatActionInvitesToggled | ChatActionSignaturesToggled | ChatActionMessagePinned | ChatActionMessageEdited | ChatActionMessageDeleted | ChatActionUserPermissionsChanged | ChatActionUserAdminPermissionsChanged | ChatActionStickersetChanged | ChatActionHistoryToggled | ChatActionDefaultPermissionsChanged | ChatActionPollStopped | ChatActionLinkedChatChanged | ChatActionLocationChanged | ChatActionSlowModeChanged | ChatActionCallStarted | ChatActionCallEnded | ChatActionCallSettingChanged | ChatActionUserJoinedInvite | ChatActionInviteLinkDeleted | ChatActionInviteLinkEdited | ChatActionInviteLinkRevoked | ChatActionUserJoinedApproved | ChatActionTtlChanged | ChatActionNoForwardsToggled | ChatActionForumToggled | ChatActionTopicCreated | ChatActionTopicEdited | ChatActionTopicDeleted | ChatActionSignatureProfilesToggled | ChatActionSubscriptionExtended | ChatActionAvailableReactionsChanged | ChatActionEmojiStatusChanged | ChatActionEmojiStickersetChanged | ChatActionPeerColorChanged | ChatActionWallpaperChanged | ChatActionMessageSent | ChatActionToggleAntiSpam | ChatActionToggleAutotranslation | null;
345
+ export type ChatAction = ChatActionUserJoined | ChatActionUserLeft | ChatActionUserInvited | ChatActionTitleChanged | ChatActionDescriptionChanged | ChatActionUsernameChanged | ChatActionUsernamesChanged | ChatActionPhotoChanged | ChatActionInvitesToggled | ChatActionSignaturesToggled | ChatActionMessagePinned | ChatActionMessageEdited | ChatActionMessageDeleted | ChatActionUserPermissionsChanged | ChatActionUserAdminPermissionsChanged | ChatActionStickersetChanged | ChatActionHistoryToggled | ChatActionDefaultPermissionsChanged | ChatActionPollStopped | ChatActionLinkedChatChanged | ChatActionLocationChanged | ChatActionSlowModeChanged | ChatActionCallStarted | ChatActionCallEnded | ChatActionCallSettingChanged | ChatActionUserJoinedInvite | ChatActionInviteLinkDeleted | ChatActionInviteLinkEdited | ChatActionInviteLinkRevoked | ChatActionUserJoinedApproved | ChatActionTtlChanged | ChatActionNoForwardsToggled | ChatActionForumToggled | ChatActionTopicCreated | ChatActionTopicEdited | ChatActionTopicDeleted | ChatActionSignatureProfilesToggled | ChatActionSubscriptionExtended | ChatActionAvailableReactionsChanged | ChatActionEmojiStatusChanged | ChatActionEmojiStickersetChanged | ChatActionPeerColorChanged | ChatActionWallpaperChanged | ChatActionMessageSent | ChatActionToggleAntiSpam | ChatActionToggleAutotranslation | ChatActionParticipantRankEdited | null;
336
346
  /** @internal */
337
347
  export declare function _actionFromTl(e: tl.TypeChannelAdminLogEventAction, peers: PeersIndex, peerId: number): ChatAction;
@@ -277,6 +277,13 @@ function _actionFromTl(e, peers, peerId) {
277
277
  type: "toggle_autotranslation",
278
278
  enabled: e.newValue
279
279
  };
280
+ case "channelAdminLogEventActionParticipantEditRank":
281
+ return {
282
+ type: "participant_rank_edited",
283
+ user: new User$2(peers.user(e.userId)),
284
+ prevRank: e.prevRank,
285
+ newRank: e.newRank
286
+ };
280
287
  default:
281
288
  return null;
282
289
  }
@@ -100,6 +100,7 @@ function normalizeChatEventFilters(input) {
100
100
  case "wallpaper_changed":
101
101
  case "toggle_anti_spam":
102
102
  case "toggle_autotranslation":
103
+ case "participant_rank_edited":
103
104
  serverFilter.invite = true;
104
105
  serverFilter.invites = true;
105
106
  serverFilter.join = true;
@@ -93,6 +93,7 @@ function normalizeChatEventFilters(input) {
93
93
  case "wallpaper_changed":
94
94
  case "toggle_anti_spam":
95
95
  case "toggle_autotranslation":
96
+ case "participant_rank_edited":
96
97
  serverFilter.invite = true;
97
98
  serverFilter.invites = true;
98
99
  serverFilter.join = true;
@@ -50,18 +50,15 @@ class ChatMember {
50
50
  }
51
51
  }
52
52
  /**
53
- * Custom title (for creators and admins).
53
+ * Custom title (rank) of the chat member.
54
54
  *
55
- * `null` for non-admins and in case custom title is not set.
55
+ * `null` in case custom title (rank) is not set.
56
56
  */
57
57
  get title() {
58
- switch (this.raw._) {
59
- case "channelParticipantCreator":
60
- case "channelParticipantAdmin":
61
- return this.raw.rank ?? null;
62
- default:
63
- return null;
58
+ if ("rank" in this.raw) {
59
+ return this.raw.rank ?? null;
64
60
  }
61
+ return null;
65
62
  }
66
63
  /**
67
64
  * Date when the user has joined the chat.
@@ -28,9 +28,9 @@ export declare class ChatMember {
28
28
  */
29
29
  get status(): ChatMemberStatus;
30
30
  /**
31
- * Custom title (for creators and admins).
31
+ * Custom title (rank) of the chat member.
32
32
  *
33
- * `null` for non-admins and in case custom title is not set.
33
+ * `null` in case custom title (rank) is not set.
34
34
  */
35
35
  get title(): string | null;
36
36
  /**
@@ -28,9 +28,9 @@ export declare class ChatMember {
28
28
  */
29
29
  get status(): ChatMemberStatus;
30
30
  /**
31
- * Custom title (for creators and admins).
31
+ * Custom title (rank) of the chat member.
32
32
  *
33
- * `null` for non-admins and in case custom title is not set.
33
+ * `null` in case custom title (rank) is not set.
34
34
  */
35
35
  get title(): string | null;
36
36
  /**
@@ -43,18 +43,15 @@ class ChatMember {
43
43
  }
44
44
  }
45
45
  /**
46
- * Custom title (for creators and admins).
46
+ * Custom title (rank) of the chat member.
47
47
  *
48
- * `null` for non-admins and in case custom title is not set.
48
+ * `null` in case custom title (rank) is not set.
49
49
  */
50
50
  get title() {
51
- switch (this.raw._) {
52
- case "channelParticipantCreator":
53
- case "channelParticipantAdmin":
54
- return this.raw.rank ?? null;
55
- default:
56
- return null;
51
+ if ("rank" in this.raw) {
52
+ return this.raw.rank ?? null;
57
53
  }
54
+ return null;
58
55
  }
59
56
  /**
60
57
  * Date when the user has joined the chat.
@@ -199,6 +199,20 @@ class FullUser extends user.User {
199
199
  get ttlPeriod() {
200
200
  return this.full?.ttlPeriod ?? null;
201
201
  }
202
+ /**
203
+ * Whether the current user has enabled content protection for own messages in DMs with this user,
204
+ * i.e. our outgoing messages to this user will be `noforwards`.
205
+ */
206
+ get contentProtectionOutgoing() {
207
+ return this.full.noforwardsMyEnabled;
208
+ }
209
+ /**
210
+ * Whether this user has enabled content protection for their messages in DMs with the current user,
211
+ * i.e. our incoming messages from this user will be `noforwards`.
212
+ */
213
+ get contentProtectionIncoming() {
214
+ return this.full.noforwardsPeerEnabled;
215
+ }
202
216
  /** Whether the "Gifts" tab should be shown */
203
217
  get showGifts() {
204
218
  return this.full.displayGiftsButton;
@@ -113,6 +113,16 @@ export declare class FullUser extends User {
113
113
  * TTL of all messages in this chat, in seconds
114
114
  */
115
115
  get ttlPeriod(): number | null;
116
+ /**
117
+ * Whether the current user has enabled content protection for own messages in DMs with this user,
118
+ * i.e. our outgoing messages to this user will be `noforwards`.
119
+ */
120
+ get contentProtectionOutgoing(): boolean;
121
+ /**
122
+ * Whether this user has enabled content protection for their messages in DMs with the current user,
123
+ * i.e. our incoming messages from this user will be `noforwards`.
124
+ */
125
+ get contentProtectionIncoming(): boolean;
116
126
  /** Whether the "Gifts" tab should be shown */
117
127
  get showGifts(): boolean;
118
128
  /** Information about the user's gift receive settings */
@@ -113,6 +113,16 @@ export declare class FullUser extends User {
113
113
  * TTL of all messages in this chat, in seconds
114
114
  */
115
115
  get ttlPeriod(): number | null;
116
+ /**
117
+ * Whether the current user has enabled content protection for own messages in DMs with this user,
118
+ * i.e. our outgoing messages to this user will be `noforwards`.
119
+ */
120
+ get contentProtectionOutgoing(): boolean;
121
+ /**
122
+ * Whether this user has enabled content protection for their messages in DMs with the current user,
123
+ * i.e. our incoming messages from this user will be `noforwards`.
124
+ */
125
+ get contentProtectionIncoming(): boolean;
116
126
  /** Whether the "Gifts" tab should be shown */
117
127
  get showGifts(): boolean;
118
128
  /** Information about the user's gift receive settings */
@@ -192,6 +192,20 @@ class FullUser extends User$2 {
192
192
  get ttlPeriod() {
193
193
  return this.full?.ttlPeriod ?? null;
194
194
  }
195
+ /**
196
+ * Whether the current user has enabled content protection for own messages in DMs with this user,
197
+ * i.e. our outgoing messages to this user will be `noforwards`.
198
+ */
199
+ get contentProtectionOutgoing() {
200
+ return this.full.noforwardsMyEnabled;
201
+ }
202
+ /**
203
+ * Whether this user has enabled content protection for their messages in DMs with the current user,
204
+ * i.e. our incoming messages from this user will be `noforwards`.
205
+ */
206
+ get contentProtectionIncoming() {
207
+ return this.full.noforwardsPeerEnabled;
208
+ }
195
209
  /** Whether the "Gifts" tab should be shown */
196
210
  get showGifts() {
197
211
  return this.full.displayGiftsButton;
@@ -7,11 +7,11 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const utils = require("@fuman/utils");
9
9
  const errors = require("../../types/errors.cjs");
10
- function determinePartSize(fileSize) {
10
+ function determinePartSize(fileSize, forUpload = false) {
11
11
  if (fileSize <= 262078465) return 128;
12
12
  if (fileSize <= 786432e3) return 256;
13
13
  if (fileSize <= 2097152e3) return 512;
14
- return 1024;
14
+ return forUpload ? 512 : 1024;
15
15
  }
16
16
  function isProbablyPlainText(buf) {
17
17
  return !buf.some(
@@ -3,7 +3,7 @@ import { tl } from '@mtcute/tl';
3
3
  * Given file size, determine the appropriate chunk size (in KB)
4
4
  * for upload/download operations.
5
5
  */
6
- export declare function determinePartSize(fileSize: number): number;
6
+ export declare function determinePartSize(fileSize: number, forUpload?: boolean): number;
7
7
  /**
8
8
  * Returns `true` if all bytes in `buf` are printable ASCII characters
9
9
  */
@@ -3,7 +3,7 @@ import { tl } from '@mtcute/tl';
3
3
  * Given file size, determine the appropriate chunk size (in KB)
4
4
  * for upload/download operations.
5
5
  */
6
- export declare function determinePartSize(fileSize: number): number;
6
+ export declare function determinePartSize(fileSize: number, forUpload?: boolean): number;
7
7
  /**
8
8
  * Returns `true` if all bytes in `buf` are printable ASCII characters
9
9
  */
@@ -1,10 +1,10 @@
1
1
  import { u8, utf8, hex } from "@fuman/utils";
2
2
  import { MtArgumentError } from "../../types/errors.js";
3
- function determinePartSize(fileSize) {
3
+ function determinePartSize(fileSize, forUpload = false) {
4
4
  if (fileSize <= 262078465) return 128;
5
5
  if (fileSize <= 786432e3) return 256;
6
6
  if (fileSize <= 2097152e3) return 512;
7
- return 1024;
7
+ return forUpload ? 512 : 1024;
8
8
  }
9
9
  function isProbablyPlainText(buf) {
10
10
  return !buf.some(