@mtcute/core 0.30.2 → 0.31.0

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 (233) hide show
  1. package/client.cjs +73 -0
  2. package/client.js +73 -0
  3. package/highlevel/client.d.cts +344 -114
  4. package/highlevel/client.d.ts +344 -114
  5. package/highlevel/methods/auth/sign-in-qr.cjs +2 -0
  6. package/highlevel/methods/auth/sign-in-qr.js +2 -0
  7. package/highlevel/methods/auth/sign-in-qr.test.d.cts +1 -0
  8. package/highlevel/methods/auth/sign-in-qr.test.d.ts +1 -0
  9. package/highlevel/methods/chats/join-chat.cjs +1 -1
  10. package/highlevel/methods/chats/join-chat.d.cts +2 -1
  11. package/highlevel/methods/chats/join-chat.d.ts +2 -1
  12. package/highlevel/methods/chats/join-chat.js +1 -1
  13. package/highlevel/methods/chats/transfer-chat-ownership.cjs +6 -17
  14. package/highlevel/methods/chats/transfer-chat-ownership.js +6 -17
  15. package/highlevel/methods/communities/ban-community-participant.cjs +30 -0
  16. package/highlevel/methods/communities/ban-community-participant.d.cts +20 -0
  17. package/highlevel/methods/communities/ban-community-participant.d.ts +20 -0
  18. package/highlevel/methods/communities/ban-community-participant.js +25 -0
  19. package/highlevel/methods/communities/create-community.cjs +29 -0
  20. package/highlevel/methods/communities/create-community.d.cts +22 -0
  21. package/highlevel/methods/communities/create-community.d.ts +22 -0
  22. package/highlevel/methods/communities/create-community.js +24 -0
  23. package/highlevel/methods/communities/get-community-link-requests.cjs +27 -0
  24. package/highlevel/methods/communities/get-community-link-requests.d.cts +17 -0
  25. package/highlevel/methods/communities/get-community-link-requests.d.ts +17 -0
  26. package/highlevel/methods/communities/get-community-link-requests.js +22 -0
  27. package/highlevel/methods/communities/get-community-participant-chats.cjs +24 -0
  28. package/highlevel/methods/communities/get-community-participant-chats.d.cts +17 -0
  29. package/highlevel/methods/communities/get-community-participant-chats.d.ts +17 -0
  30. package/highlevel/methods/communities/get-community-participant-chats.js +19 -0
  31. package/highlevel/methods/communities/get-joined-communities.cjs +21 -0
  32. package/highlevel/methods/communities/get-joined-communities.d.cts +6 -0
  33. package/highlevel/methods/communities/get-joined-communities.d.ts +6 -0
  34. package/highlevel/methods/communities/get-joined-communities.js +16 -0
  35. package/highlevel/methods/communities/hide-community-link-request.cjs +30 -0
  36. package/highlevel/methods/communities/hide-community-link-request.d.cts +22 -0
  37. package/highlevel/methods/communities/hide-community-link-request.d.ts +22 -0
  38. package/highlevel/methods/communities/hide-community-link-request.js +25 -0
  39. package/highlevel/methods/communities/link-community-peer.cjs +32 -0
  40. package/highlevel/methods/communities/link-community-peer.d.cts +22 -0
  41. package/highlevel/methods/communities/link-community-peer.d.ts +22 -0
  42. package/highlevel/methods/communities/link-community-peer.js +27 -0
  43. package/highlevel/methods/communities/toggle-community-collapsed.cjs +18 -0
  44. package/highlevel/methods/communities/toggle-community-collapsed.d.cts +16 -0
  45. package/highlevel/methods/communities/toggle-community-collapsed.d.ts +16 -0
  46. package/highlevel/methods/communities/toggle-community-collapsed.js +13 -0
  47. package/highlevel/methods/ephemeral/delete-ephemeral-message.cjs +20 -0
  48. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.cts +13 -0
  49. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.ts +13 -0
  50. package/highlevel/methods/ephemeral/delete-ephemeral-message.js +15 -0
  51. package/highlevel/methods/ephemeral/edit-ephemeral-message.cjs +33 -0
  52. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.cts +25 -0
  53. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.ts +25 -0
  54. package/highlevel/methods/ephemeral/edit-ephemeral-message.js +28 -0
  55. package/highlevel/methods/ephemeral/find-in-update.cjs +27 -0
  56. package/highlevel/methods/ephemeral/find-in-update.d.cts +8 -0
  57. package/highlevel/methods/ephemeral/find-in-update.d.ts +8 -0
  58. package/highlevel/methods/ephemeral/find-in-update.js +22 -0
  59. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.cjs +31 -0
  60. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.cts +29 -0
  61. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.ts +29 -0
  62. package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.js +26 -0
  63. package/highlevel/methods/ephemeral/send-ephemeral-message.cjs +38 -0
  64. package/highlevel/methods/ephemeral/send-ephemeral-message.d.cts +29 -0
  65. package/highlevel/methods/ephemeral/send-ephemeral-message.d.ts +29 -0
  66. package/highlevel/methods/ephemeral/send-ephemeral-message.js +33 -0
  67. package/highlevel/methods/files/download-iterable.cjs +4 -2
  68. package/highlevel/methods/files/download-iterable.js +4 -2
  69. package/highlevel/methods/files/download-iterable.test.d.cts +1 -0
  70. package/highlevel/methods/files/download-iterable.test.d.ts +1 -0
  71. package/highlevel/methods/files/download-stream.cjs +5 -6
  72. package/highlevel/methods/files/download-stream.js +5 -6
  73. package/highlevel/methods/forums/create-forum-topic.d.cts +7 -0
  74. package/highlevel/methods/forums/create-forum-topic.d.ts +7 -0
  75. package/highlevel/methods/forums/delete-forum-topic-history.d.cts +1 -1
  76. package/highlevel/methods/forums/delete-forum-topic-history.d.ts +1 -1
  77. package/highlevel/methods/forums/edit-forum-topic.cjs +1 -1
  78. package/highlevel/methods/forums/edit-forum-topic.d.cts +2 -2
  79. package/highlevel/methods/forums/edit-forum-topic.d.ts +2 -2
  80. package/highlevel/methods/forums/edit-forum-topic.js +1 -1
  81. package/highlevel/methods/forums/get-forum-topics-by-id.cjs +5 -1
  82. package/highlevel/methods/forums/get-forum-topics-by-id.d.cts +9 -1
  83. package/highlevel/methods/forums/get-forum-topics-by-id.d.ts +9 -1
  84. package/highlevel/methods/forums/get-forum-topics-by-id.js +5 -1
  85. package/highlevel/methods/forums/get-forum-topics-by-id.test.d.cts +1 -0
  86. package/highlevel/methods/forums/get-forum-topics-by-id.test.d.ts +1 -0
  87. package/highlevel/methods/forums/get-forum-topics.cjs +1 -1
  88. package/highlevel/methods/forums/get-forum-topics.js +1 -1
  89. package/highlevel/methods/forums/toggle-forum-topic-closed.d.cts +1 -1
  90. package/highlevel/methods/forums/toggle-forum-topic-closed.d.ts +1 -1
  91. package/highlevel/methods/forums/toggle-forum-topic-pinned.d.cts +1 -1
  92. package/highlevel/methods/forums/toggle-forum-topic-pinned.d.ts +1 -1
  93. package/highlevel/methods/forums/toggle-general-topic-hidden.cjs +2 -2
  94. package/highlevel/methods/forums/toggle-general-topic-hidden.js +3 -3
  95. package/highlevel/methods/messages/send-common.d.cts +7 -1
  96. package/highlevel/methods/messages/send-common.d.ts +7 -1
  97. package/highlevel/methods/messages/send-text.cjs +70 -4
  98. package/highlevel/methods/messages/send-text.js +70 -4
  99. package/highlevel/methods/users/resolve-peer.cjs +11 -1
  100. package/highlevel/methods/users/resolve-peer.js +11 -1
  101. package/highlevel/methods.d.cts +16 -0
  102. package/highlevel/methods.d.ts +16 -0
  103. package/highlevel/storage/service/peers.cjs +25 -0
  104. package/highlevel/storage/service/peers.js +25 -0
  105. package/highlevel/storage/service/peers.test.d.cts +1 -0
  106. package/highlevel/storage/service/peers.test.d.ts +1 -0
  107. package/highlevel/types/conversation.cjs +8 -0
  108. package/highlevel/types/conversation.d.cts +1 -0
  109. package/highlevel/types/conversation.d.ts +1 -0
  110. package/highlevel/types/conversation.js +10 -2
  111. package/highlevel/types/conversation.test.d.cts +1 -0
  112. package/highlevel/types/conversation.test.d.ts +1 -0
  113. package/highlevel/types/messages/ephemeral-message.cjs +103 -0
  114. package/highlevel/types/messages/ephemeral-message.d.cts +55 -0
  115. package/highlevel/types/messages/ephemeral-message.d.ts +55 -0
  116. package/highlevel/types/messages/ephemeral-message.js +98 -0
  117. package/highlevel/types/messages/index.d.cts +1 -0
  118. package/highlevel/types/messages/index.d.ts +1 -0
  119. package/highlevel/types/messages/message-action.cjs +6 -0
  120. package/highlevel/types/messages/message-action.d.cts +8 -1
  121. package/highlevel/types/messages/message-action.d.ts +8 -1
  122. package/highlevel/types/messages/message-action.js +6 -0
  123. package/highlevel/types/messages/replied-message.cjs +5 -1
  124. package/highlevel/types/messages/replied-message.d.cts +5 -1
  125. package/highlevel/types/messages/replied-message.d.ts +5 -1
  126. package/highlevel/types/messages/replied-message.js +5 -1
  127. package/highlevel/types/peers/chat.cjs +23 -3
  128. package/highlevel/types/peers/chat.d.cts +8 -3
  129. package/highlevel/types/peers/chat.d.ts +8 -3
  130. package/highlevel/types/peers/chat.js +24 -4
  131. package/highlevel/types/peers/community-peer.cjs +60 -0
  132. package/highlevel/types/peers/community-peer.d.cts +37 -0
  133. package/highlevel/types/peers/community-peer.d.ts +37 -0
  134. package/highlevel/types/peers/community-peer.js +55 -0
  135. package/highlevel/types/peers/full-chat.cjs +20 -5
  136. package/highlevel/types/peers/full-chat.d.cts +5 -0
  137. package/highlevel/types/peers/full-chat.d.ts +5 -0
  138. package/highlevel/types/peers/full-chat.js +20 -5
  139. package/highlevel/types/peers/index.d.cts +1 -0
  140. package/highlevel/types/peers/index.d.ts +1 -0
  141. package/highlevel/types/peers/peer.cjs +2 -0
  142. package/highlevel/types/peers/peer.js +2 -0
  143. package/highlevel/types/peers/user.cjs +6 -0
  144. package/highlevel/types/peers/user.d.cts +2 -0
  145. package/highlevel/types/peers/user.d.ts +2 -0
  146. package/highlevel/types/peers/user.js +6 -0
  147. package/highlevel/types/updates/delete-ephemeral-messages-update.cjs +27 -0
  148. package/highlevel/types/updates/delete-ephemeral-messages-update.d.cts +15 -0
  149. package/highlevel/types/updates/delete-ephemeral-messages-update.d.ts +15 -0
  150. package/highlevel/types/updates/delete-ephemeral-messages-update.js +22 -0
  151. package/highlevel/types/updates/ephemeral-callback-query.cjs +61 -0
  152. package/highlevel/types/updates/ephemeral-callback-query.d.cts +38 -0
  153. package/highlevel/types/updates/ephemeral-callback-query.d.ts +38 -0
  154. package/highlevel/types/updates/ephemeral-callback-query.js +56 -0
  155. package/highlevel/types/updates/index.d.cts +16 -2
  156. package/highlevel/types/updates/index.d.ts +16 -2
  157. package/highlevel/types/updates/parse-update.cjs +12 -1
  158. package/highlevel/types/updates/parse-update.js +12 -1
  159. package/highlevel/updates/manager.cjs +31 -13
  160. package/highlevel/updates/manager.d.cts +1 -0
  161. package/highlevel/updates/manager.d.ts +1 -0
  162. package/highlevel/updates/manager.js +31 -13
  163. package/highlevel/updates/manager.test.d.cts +1 -0
  164. package/highlevel/updates/manager.test.d.ts +1 -0
  165. package/highlevel/utils/stream-utils.cjs +8 -4
  166. package/highlevel/utils/stream-utils.js +8 -4
  167. package/highlevel/utils/stream-utils.test.d.cts +1 -0
  168. package/highlevel/utils/stream-utils.test.d.ts +1 -0
  169. package/highlevel/utils/walk-page-blocks.cjs +4 -0
  170. package/highlevel/utils/walk-page-blocks.js +4 -0
  171. package/index.cjs +10 -0
  172. package/index.js +11 -1
  173. package/methods.cjs +27 -0
  174. package/methods.js +27 -0
  175. package/network/client.cjs +4 -3
  176. package/network/client.d.cts +1 -0
  177. package/network/client.d.ts +1 -0
  178. package/network/client.js +4 -3
  179. package/network/middlewares/flood-waiter.cjs +2 -2
  180. package/network/middlewares/flood-waiter.js +2 -2
  181. package/network/middlewares/internal-errors.cjs +1 -1
  182. package/network/middlewares/internal-errors.js +1 -1
  183. package/network/middlewares/media-throttle.cjs +1 -1
  184. package/network/middlewares/media-throttle.js +1 -1
  185. package/network/mtproxy/index.cjs +4 -3
  186. package/network/mtproxy/index.d.cts +2 -2
  187. package/network/mtproxy/index.d.ts +2 -2
  188. package/network/mtproxy/index.js +4 -3
  189. package/network/network-manager.cjs +44 -16
  190. package/network/network-manager.d.cts +10 -3
  191. package/network/network-manager.d.ts +10 -3
  192. package/network/network-manager.js +45 -17
  193. package/network/network-manager.test.d.cts +1 -0
  194. package/network/network-manager.test.d.ts +1 -0
  195. package/network/persistent-connection.cjs +10 -2
  196. package/network/persistent-connection.js +10 -2
  197. package/network/session-connection.cjs +3 -0
  198. package/network/session-connection.js +3 -0
  199. package/network/transports/abstract.cjs +16 -0
  200. package/network/transports/abstract.d.cts +8 -2
  201. package/network/transports/abstract.d.ts +8 -2
  202. package/network/transports/abstract.js +17 -1
  203. package/network/transports/obfuscated.cjs +3 -1
  204. package/network/transports/obfuscated.js +3 -1
  205. package/package.json +6 -6
  206. package/tl/api-schema.json +1 -1
  207. package/tl/binary/reader.cjs +90 -15
  208. package/tl/binary/reader.js +90 -15
  209. package/tl/binary/writer.cjs +385 -80
  210. package/tl/binary/writer.js +385 -80
  211. package/tl/compat/reader.cjs +11 -0
  212. package/tl/compat/reader.js +11 -0
  213. package/tl/index.d.cts +12380 -4272
  214. package/tl/index.d.ts +12380 -4272
  215. package/tl/inner-tl.cjs +70 -20
  216. package/tl/inner-tl.js +70 -20
  217. package/tl/raw-errors.json +1 -1
  218. package/utils/abort-signal.cjs +1 -12
  219. package/utils/abort-signal.js +1 -12
  220. package/utils/abort-signal.test.d.cts +1 -0
  221. package/utils/abort-signal.test.d.ts +1 -0
  222. package/utils/binary/compat.cjs +14 -0
  223. package/utils/binary/compat.js +14 -0
  224. package/utils/early-timer.cjs +3 -11
  225. package/utils/early-timer.js +3 -11
  226. package/utils/early-timer.test.d.cts +1 -0
  227. package/utils/early-timer.test.d.ts +1 -0
  228. package/utils/function-utils.cjs +9 -4
  229. package/utils/function-utils.js +9 -4
  230. package/utils/links/bots.cjs +3 -0
  231. package/utils/links/bots.js +3 -0
  232. package/utils/peer-utils.cjs +8 -0
  233. package/utils/peer-utils.js +8 -0
@@ -0,0 +1,98 @@
1
+ import { memoizeGetters } from "../../utils/memoize.js";
2
+ import { parsePeer } from "../peers/peer.js";
3
+ import { User as User$2 } from "../peers/user.js";
4
+ import { MessageEntity as MessageEntity$2 } from "./message-entity.js";
5
+ import { _messageMediaFromTl } from "./message-media.js";
6
+ import { makeInspectable } from "../../utils/inspectable.js";
7
+ class EphemeralMessage {
8
+ constructor(raw, _peers) {
9
+ this.raw = raw;
10
+ this._peers = _peers;
11
+ }
12
+ /** ID of this message (unique within the chat and receiver) */
13
+ get id() {
14
+ return this.raw.id;
15
+ }
16
+ /** Whether this message is outgoing */
17
+ get isOutgoing() {
18
+ return this.raw.out;
19
+ }
20
+ /** Sender of this message (usually the bot) */
21
+ get sender() {
22
+ return parsePeer(this.raw.fromId, this._peers);
23
+ }
24
+ /** Chat where this message was sent */
25
+ get chat() {
26
+ return parsePeer(this.raw.peerId, this._peers);
27
+ }
28
+ /** ID of the user this message is visible to */
29
+ get receiverId() {
30
+ return this.raw.receiverId;
31
+ }
32
+ /**
33
+ * User this message is visible to.
34
+ *
35
+ * Might not be available in some cases (e.g. in the message
36
+ * returned from {@link TelegramClient.sendEphemeralMessage},
37
+ * since the server does not send the receiver entity there) —
38
+ * use {@link receiverId} instead.
39
+ */
40
+ get receiver() {
41
+ const user = this._peers.users.get(this.raw.receiverId);
42
+ if (!user || user._ === "userEmpty") return null;
43
+ return new User$2(user);
44
+ }
45
+ /** ID of the topic this message was sent to, if any */
46
+ get topicId() {
47
+ return this.raw.topMsgId ?? null;
48
+ }
49
+ /** Date when this message was sent */
50
+ get date() {
51
+ return new Date(this.raw.date * 1e3);
52
+ }
53
+ /** Message text */
54
+ get text() {
55
+ return this.raw.message;
56
+ }
57
+ /** Message text/caption entities (may be empty) */
58
+ get entities() {
59
+ const entities = [];
60
+ if (this.raw.entities?.length) {
61
+ for (const ent of this.raw.entities) {
62
+ entities.push(new MessageEntity$2(ent, this.raw.message));
63
+ }
64
+ }
65
+ return entities;
66
+ }
67
+ get textWithEntities() {
68
+ return {
69
+ text: this.raw.message,
70
+ entities: this.raw.entities
71
+ };
72
+ }
73
+ /**
74
+ * Message media. `null` for text-only messages
75
+ * and for unsupported media types.
76
+ *
77
+ * For unsupported media types, use `.raw.media` directly.
78
+ */
79
+ get media() {
80
+ if (!this.raw.media || this.raw.media._ === "messageMediaEmpty") {
81
+ return null;
82
+ }
83
+ return _messageMediaFromTl(this._peers, this.raw.media);
84
+ }
85
+ /** Reply markup attached to this message, if any */
86
+ get replyMarkup() {
87
+ return this.raw.replyMarkup ?? null;
88
+ }
89
+ /** Information about the message this message is a reply to, if any */
90
+ get replyTo() {
91
+ return this.raw.replyTo ?? null;
92
+ }
93
+ }
94
+ const EphemeralMessage$1 = /* @__PURE__ */ memoizeGetters(EphemeralMessage, ["sender", "chat", "receiver", "entities", "media"]);
95
+ const EphemeralMessage$2 = /* @__PURE__ */ makeInspectable(EphemeralMessage$1);
96
+ export {
97
+ EphemeralMessage$2 as EphemeralMessage
98
+ };
@@ -1,5 +1,6 @@
1
1
  export * from './dialog.js';
2
2
  export * from './draft-message.js';
3
+ export * from './ephemeral-message.js';
3
4
  export * from './fact-check.js';
4
5
  export * from './input-message-id.js';
5
6
  export * from './message-action.js';
@@ -1,5 +1,6 @@
1
1
  export * from './dialog.js';
2
2
  export * from './draft-message.js';
3
+ export * from './ephemeral-message.js';
3
4
  export * from './fact-check.js';
4
5
  export * from './input-message-id.js';
5
6
  export * from './message-action.js';
@@ -9,6 +9,7 @@ const Long = require("long");
9
9
  const peerUtils = require("../../../utils/peer-utils.cjs");
10
10
  const typeAssertions = require("../../../utils/type-assertions.cjs");
11
11
  const photo = require("../media/photo.cjs");
12
+ const chat = require("../peers/chat.cjs");
12
13
  const peer = require("../peers/peer.cjs");
13
14
  const user = require("../peers/user.cjs");
14
15
  const starGiftUnique = require("../premium/star-gift-unique.cjs");
@@ -471,6 +472,11 @@ function _messageActionFromTl(act) {
471
472
  type: "managed_bot_created",
472
473
  botId: act.botId
473
474
  };
475
+ case "messageActionChangeCommunity":
476
+ return {
477
+ type: "change_community",
478
+ community: act.communityId ? new chat.Chat(this._peers.chat(act.communityId)) : null
479
+ };
474
480
  default:
475
481
  return null;
476
482
  }
@@ -3,6 +3,7 @@ import { TextWithEntities } from '../misc/entities.js';
3
3
  import { Peer } from '../peers/peer.js';
4
4
  import { Message } from './message.js';
5
5
  import { Photo } from '../media/photo.js';
6
+ import { Chat } from '../peers/chat.js';
6
7
  import { User } from '../peers/user.js';
7
8
  import { StarGiftUnique } from '../premium/star-gift-unique.js';
8
9
  import { StarGift } from '../premium/star-gift.js';
@@ -609,6 +610,12 @@ export interface ActionManagedBotCreated {
609
610
  /** ID of the created bot */
610
611
  readonly botId: number;
611
612
  }
613
+ /** Community linked to the chat was changed */
614
+ export interface ActionChangeCommunity {
615
+ readonly type: 'change_community';
616
+ /** The new community, or `null` if the chat was unlinked from a community */
617
+ readonly community: Chat | null;
618
+ }
612
619
  /** Group creator has left the group, and a new creator has been assigned but not yet made one */
613
620
  export interface ActionNewCreatorPending {
614
621
  readonly type: 'new_creator_pending';
@@ -621,7 +628,7 @@ export interface ActionChangeCreator {
621
628
  /** New creator */
622
629
  newCreator: User;
623
630
  }
624
- 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 | ActionPollAppendAnswer | ActionPollDeleteAnswer | ActionManagedBotCreated | null;
631
+ 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 | ActionPollAppendAnswer | ActionPollDeleteAnswer | ActionManagedBotCreated | ActionChangeCommunity | null;
625
632
  /** @internal */
626
633
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
627
634
  export {};
@@ -3,6 +3,7 @@ import { TextWithEntities } from '../misc/entities.js';
3
3
  import { Peer } from '../peers/peer.js';
4
4
  import { Message } from './message.js';
5
5
  import { Photo } from '../media/photo.js';
6
+ import { Chat } from '../peers/chat.js';
6
7
  import { User } from '../peers/user.js';
7
8
  import { StarGiftUnique } from '../premium/star-gift-unique.js';
8
9
  import { StarGift } from '../premium/star-gift.js';
@@ -609,6 +610,12 @@ export interface ActionManagedBotCreated {
609
610
  /** ID of the created bot */
610
611
  readonly botId: number;
611
612
  }
613
+ /** Community linked to the chat was changed */
614
+ export interface ActionChangeCommunity {
615
+ readonly type: 'change_community';
616
+ /** The new community, or `null` if the chat was unlinked from a community */
617
+ readonly community: Chat | null;
618
+ }
612
619
  /** Group creator has left the group, and a new creator has been assigned but not yet made one */
613
620
  export interface ActionNewCreatorPending {
614
621
  readonly type: 'new_creator_pending';
@@ -621,7 +628,7 @@ export interface ActionChangeCreator {
621
628
  /** New creator */
622
629
  newCreator: User;
623
630
  }
624
- 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 | ActionPollAppendAnswer | ActionPollDeleteAnswer | ActionManagedBotCreated | null;
631
+ 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 | ActionPollAppendAnswer | ActionPollDeleteAnswer | ActionManagedBotCreated | ActionChangeCommunity | null;
625
632
  /** @internal */
626
633
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
627
634
  export {};
@@ -2,6 +2,7 @@ import Long from "long";
2
2
  import { getMarkedPeerId } from "../../../utils/peer-utils.js";
3
3
  import { assertTypeIsNot } from "../../../utils/type-assertions.js";
4
4
  import { Photo as Photo$2 } from "../media/photo.js";
5
+ import { Chat as Chat$2 } from "../peers/chat.js";
5
6
  import { parsePeer } from "../peers/peer.js";
6
7
  import { User as User$2 } from "../peers/user.js";
7
8
  import { StarGiftUnique as StarGiftUnique$2 } from "../premium/star-gift-unique.js";
@@ -464,6 +465,11 @@ function _messageActionFromTl(act) {
464
465
  type: "managed_bot_created",
465
466
  botId: act.botId
466
467
  };
468
+ case "messageActionChangeCommunity":
469
+ return {
470
+ type: "change_community",
471
+ community: act.communityId ? new Chat$2(this._peers.chat(act.communityId)) : null
472
+ };
467
473
  default:
468
474
  return null;
469
475
  }
@@ -56,7 +56,11 @@ class RepliedMessageInfo {
56
56
  get id() {
57
57
  return this.raw.replyToMsgId ?? null;
58
58
  }
59
- /** ID of the replies thread where this message belongs to */
59
+ /**
60
+ * ID of the replies thread where this message belongs to
61
+ *
62
+ * For private chats with "threaded mode" enabled, this is the canonical topic ID
63
+ */
60
64
  get threadId() {
61
65
  if (this.raw.forumTopic) {
62
66
  return this.raw.replyToTopId ?? this.raw.replyToMsgId ?? null;
@@ -54,7 +54,11 @@ export declare class RepliedMessageInfo {
54
54
  * For non-`private` origin, ID of the replied-to message in the original chat.
55
55
  */
56
56
  get id(): number | null;
57
- /** ID of the replies thread where this message belongs to */
57
+ /**
58
+ * ID of the replies thread where this message belongs to
59
+ *
60
+ * For private chats with "threaded mode" enabled, this is the canonical topic ID
61
+ */
58
62
  get threadId(): number | null;
59
63
  /** If this is a reply to a specific todo item, ID of that item */
60
64
  get todoItemId(): number | null;
@@ -54,7 +54,11 @@ export declare class RepliedMessageInfo {
54
54
  * For non-`private` origin, ID of the replied-to message in the original chat.
55
55
  */
56
56
  get id(): number | null;
57
- /** ID of the replies thread where this message belongs to */
57
+ /**
58
+ * ID of the replies thread where this message belongs to
59
+ *
60
+ * For private chats with "threaded mode" enabled, this is the canonical topic ID
61
+ */
58
62
  get threadId(): number | null;
59
63
  /** If this is a reply to a specific todo item, ID of that item */
60
64
  get todoItemId(): number | null;
@@ -49,7 +49,11 @@ class RepliedMessageInfo {
49
49
  get id() {
50
50
  return this.raw.replyToMsgId ?? null;
51
51
  }
52
- /** ID of the replies thread where this message belongs to */
52
+ /**
53
+ * ID of the replies thread where this message belongs to
54
+ *
55
+ * For private chats with "threaded mode" enabled, this is the canonical topic ID
56
+ */
53
57
  get threadId() {
54
58
  if (this.raw.forumTopic) {
55
59
  return this.raw.replyToTopId ?? this.raw.replyToMsgId ?? null;
@@ -26,6 +26,8 @@ class Chat {
26
26
  case "channel":
27
27
  case "chatForbidden":
28
28
  case "channelForbidden":
29
+ case "community":
30
+ case "communityForbidden":
29
31
  break;
30
32
  default:
31
33
  throw new errors.MtTypeAssertionError("peer", "user | chat | channel", peer._);
@@ -82,6 +84,8 @@ class Chat {
82
84
  };
83
85
  case "channel":
84
86
  case "channelForbidden":
87
+ case "community":
88
+ case "communityForbidden":
85
89
  if (this.raw.min) {
86
90
  return {
87
91
  _: "mtcute.dummyInputPeerMinChannel",
@@ -104,6 +108,9 @@ class Chat {
104
108
  case "chat":
105
109
  case "chatForbidden":
106
110
  return "group";
111
+ case "community":
112
+ case "communityForbidden":
113
+ return "community";
107
114
  case "channel":
108
115
  case "channelForbidden":
109
116
  if (this.raw._ === "channel" && this.raw.gigagroup) {
@@ -119,10 +126,10 @@ class Chat {
119
126
  }
120
127
  }
121
128
  /**
122
- * Whether this chat is a group chat (i.e. not a channel)
129
+ * Whether this chat is a group chat (i.e. not a channel or a community)
123
130
  */
124
131
  get isGroup() {
125
- return this.chatType !== "channel";
132
+ return this.chatType !== "channel" && this.chatType !== "community";
126
133
  }
127
134
  /**
128
135
  * Whether this chat has been verified by Telegram.
@@ -176,7 +183,7 @@ class Chat {
176
183
  * Consider also checking for {@link isLikelyUnavailable}.
177
184
  */
178
185
  get isBanned() {
179
- return this.raw._ === "chatForbidden" || this.raw._ === "channelForbidden";
186
+ return this.raw._ === "chatForbidden" || this.raw._ === "channelForbidden" || this.raw._ === "communityForbidden";
180
187
  }
181
188
  /**
182
189
  * Whether the chat is likely not available (e.g. because the user was banned from there),
@@ -186,9 +193,12 @@ class Chat {
186
193
  switch (this.raw._) {
187
194
  case "chatForbidden":
188
195
  case "channelForbidden":
196
+ case "communityForbidden":
189
197
  return true;
190
198
  case "chat":
191
199
  return this.raw.left || this.raw.deactivated;
200
+ case "community":
201
+ return this.raw.left;
192
202
  case "channel":
193
203
  return this.raw.left && this.raw.username === void 0 && this.raw.usernames === void 0 && (this.raw.broadcast || this.raw.megagroup && !this.raw.hasLink);
194
204
  }
@@ -200,6 +210,7 @@ class Chat {
200
210
  switch (this.raw._) {
201
211
  case "channel":
202
212
  case "chat":
213
+ case "community":
203
214
  return !this.raw.left;
204
215
  default:
205
216
  return false;
@@ -261,6 +272,15 @@ class Chat {
261
272
  get monoforumLinkedChatId() {
262
273
  return this.raw._ === "channel" ? this.raw.linkedMonoforumId ?? null : null;
263
274
  }
275
+ /** Marked ID of the community this channel is linked to, if any */
276
+ get linkedCommunityId() {
277
+ if (this.raw._ !== "channel" || !this.raw.linkedCommunityId) return null;
278
+ return peerUtils.toggleChannelIdMark(this.raw.linkedCommunityId);
279
+ }
280
+ /** Whether this community is collapsed in the dialogs list */
281
+ get isCollapsedInDialogs() {
282
+ return this.raw._ === "community" && this.raw.collapsedInDialogs;
283
+ }
264
284
  /** Chat title */
265
285
  get title() {
266
286
  return this.raw.title;
@@ -11,8 +11,9 @@ import { ChatPhoto } from './chat-photo.js';
11
11
  * - `channel`: Broadcast channel
12
12
  * - `gigagroup`: Gigagroup aka Broadcast group
13
13
  * - `monoforum`: Monoforum (chat for direct messages to channel administrators)
14
+ * - `community`: Community (a collection of linked chats)
14
15
  */
15
- export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup' | 'monoforum';
16
+ export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup' | 'monoforum' | 'community';
16
17
  /**
17
18
  * A chat.
18
19
  */
@@ -21,7 +22,7 @@ export declare class Chat {
21
22
  /**
22
23
  * Raw peer object that this {@link Chat} represents.
23
24
  */
24
- readonly raw: tl.RawChat | tl.RawChannel | tl.RawChatForbidden | tl.RawChannelForbidden;
25
+ readonly raw: tl.RawChat | tl.RawChannel | tl.RawChatForbidden | tl.RawChannelForbidden | tl.RawCommunity | tl.RawCommunityForbidden;
25
26
  constructor(peer: tl.TypeChat);
26
27
  /** Marked ID of this chat */
27
28
  get id(): number;
@@ -63,7 +64,7 @@ export declare class Chat {
63
64
  /** Type of chat */
64
65
  get chatType(): ChatType;
65
66
  /**
66
- * Whether this chat is a group chat (i.e. not a channel)
67
+ * Whether this chat is a group chat (i.e. not a channel or a community)
67
68
  */
68
69
  get isGroup(): boolean;
69
70
  /**
@@ -143,6 +144,10 @@ export declare class Chat {
143
144
  * - `monoforum`: this field contains the ID of the channel that this monoforum is linked to
144
145
  */
145
146
  get monoforumLinkedChatId(): number | null;
147
+ /** Marked ID of the community this channel is linked to, if any */
148
+ get linkedCommunityId(): number | null;
149
+ /** Whether this community is collapsed in the dialogs list */
150
+ get isCollapsedInDialogs(): boolean;
146
151
  /** Chat title */
147
152
  get title(): string;
148
153
  /** Chat username (if available) */
@@ -11,8 +11,9 @@ import { ChatPhoto } from './chat-photo.js';
11
11
  * - `channel`: Broadcast channel
12
12
  * - `gigagroup`: Gigagroup aka Broadcast group
13
13
  * - `monoforum`: Monoforum (chat for direct messages to channel administrators)
14
+ * - `community`: Community (a collection of linked chats)
14
15
  */
15
- export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup' | 'monoforum';
16
+ export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup' | 'monoforum' | 'community';
16
17
  /**
17
18
  * A chat.
18
19
  */
@@ -21,7 +22,7 @@ export declare class Chat {
21
22
  /**
22
23
  * Raw peer object that this {@link Chat} represents.
23
24
  */
24
- readonly raw: tl.RawChat | tl.RawChannel | tl.RawChatForbidden | tl.RawChannelForbidden;
25
+ readonly raw: tl.RawChat | tl.RawChannel | tl.RawChatForbidden | tl.RawChannelForbidden | tl.RawCommunity | tl.RawCommunityForbidden;
25
26
  constructor(peer: tl.TypeChat);
26
27
  /** Marked ID of this chat */
27
28
  get id(): number;
@@ -63,7 +64,7 @@ export declare class Chat {
63
64
  /** Type of chat */
64
65
  get chatType(): ChatType;
65
66
  /**
66
- * Whether this chat is a group chat (i.e. not a channel)
67
+ * Whether this chat is a group chat (i.e. not a channel or a community)
67
68
  */
68
69
  get isGroup(): boolean;
69
70
  /**
@@ -143,6 +144,10 @@ export declare class Chat {
143
144
  * - `monoforum`: this field contains the ID of the channel that this monoforum is linked to
144
145
  */
145
146
  get monoforumLinkedChatId(): number | null;
147
+ /** Marked ID of the community this channel is linked to, if any */
148
+ get linkedCommunityId(): number | null;
149
+ /** Whether this community is collapsed in the dialogs list */
150
+ get isCollapsedInDialogs(): boolean;
146
151
  /** Chat title */
147
152
  get title(): string;
148
153
  /** Chat username (if available) */
@@ -1,5 +1,5 @@
1
1
  import { MtTypeAssertionError, MtArgumentError } from "../../../types/errors.js";
2
- import { getMarkedPeerId } from "../../../utils/peer-utils.js";
2
+ import { getMarkedPeerId, toggleChannelIdMark } from "../../../utils/peer-utils.js";
3
3
  import { memoizeGetters } from "../../utils/memoize.js";
4
4
  import { MessageEntity as MessageEntity$2 } from "../messages/message-entity.js";
5
5
  import { EmojiStatus as EmojiStatus$1 } from "../reactions/emoji-status.js";
@@ -19,6 +19,8 @@ class Chat {
19
19
  case "channel":
20
20
  case "chatForbidden":
21
21
  case "channelForbidden":
22
+ case "community":
23
+ case "communityForbidden":
22
24
  break;
23
25
  default:
24
26
  throw new MtTypeAssertionError("peer", "user | chat | channel", peer._);
@@ -75,6 +77,8 @@ class Chat {
75
77
  };
76
78
  case "channel":
77
79
  case "channelForbidden":
80
+ case "community":
81
+ case "communityForbidden":
78
82
  if (this.raw.min) {
79
83
  return {
80
84
  _: "mtcute.dummyInputPeerMinChannel",
@@ -97,6 +101,9 @@ class Chat {
97
101
  case "chat":
98
102
  case "chatForbidden":
99
103
  return "group";
104
+ case "community":
105
+ case "communityForbidden":
106
+ return "community";
100
107
  case "channel":
101
108
  case "channelForbidden":
102
109
  if (this.raw._ === "channel" && this.raw.gigagroup) {
@@ -112,10 +119,10 @@ class Chat {
112
119
  }
113
120
  }
114
121
  /**
115
- * Whether this chat is a group chat (i.e. not a channel)
122
+ * Whether this chat is a group chat (i.e. not a channel or a community)
116
123
  */
117
124
  get isGroup() {
118
- return this.chatType !== "channel";
125
+ return this.chatType !== "channel" && this.chatType !== "community";
119
126
  }
120
127
  /**
121
128
  * Whether this chat has been verified by Telegram.
@@ -169,7 +176,7 @@ class Chat {
169
176
  * Consider also checking for {@link isLikelyUnavailable}.
170
177
  */
171
178
  get isBanned() {
172
- return this.raw._ === "chatForbidden" || this.raw._ === "channelForbidden";
179
+ return this.raw._ === "chatForbidden" || this.raw._ === "channelForbidden" || this.raw._ === "communityForbidden";
173
180
  }
174
181
  /**
175
182
  * Whether the chat is likely not available (e.g. because the user was banned from there),
@@ -179,9 +186,12 @@ class Chat {
179
186
  switch (this.raw._) {
180
187
  case "chatForbidden":
181
188
  case "channelForbidden":
189
+ case "communityForbidden":
182
190
  return true;
183
191
  case "chat":
184
192
  return this.raw.left || this.raw.deactivated;
193
+ case "community":
194
+ return this.raw.left;
185
195
  case "channel":
186
196
  return this.raw.left && this.raw.username === void 0 && this.raw.usernames === void 0 && (this.raw.broadcast || this.raw.megagroup && !this.raw.hasLink);
187
197
  }
@@ -193,6 +203,7 @@ class Chat {
193
203
  switch (this.raw._) {
194
204
  case "channel":
195
205
  case "chat":
206
+ case "community":
196
207
  return !this.raw.left;
197
208
  default:
198
209
  return false;
@@ -254,6 +265,15 @@ class Chat {
254
265
  get monoforumLinkedChatId() {
255
266
  return this.raw._ === "channel" ? this.raw.linkedMonoforumId ?? null : null;
256
267
  }
268
+ /** Marked ID of the community this channel is linked to, if any */
269
+ get linkedCommunityId() {
270
+ if (this.raw._ !== "channel" || !this.raw.linkedCommunityId) return null;
271
+ return toggleChannelIdMark(this.raw.linkedCommunityId);
272
+ }
273
+ /** Whether this community is collapsed in the dialogs list */
274
+ get isCollapsedInDialogs() {
275
+ return this.raw._ === "community" && this.raw.collapsedInDialogs;
276
+ }
257
277
  /** Chat title */
258
278
  get title() {
259
279
  return this.raw.title;
@@ -0,0 +1,60 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS bundles are deprecated. They will be removed completely in one of the upcoming releases. No support is provided for CommonJS users. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
+ console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
+ }
6
+ "use strict";
7
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
+ const memoize = require("../../utils/memoize.cjs");
9
+ const peer = require("./peer.cjs");
10
+ const user = require("./user.cjs");
11
+ const inspectable = require("../../utils/inspectable.cjs");
12
+ class CommunityPeer {
13
+ constructor(raw, _peers) {
14
+ this.raw = raw;
15
+ this._peers = _peers;
16
+ }
17
+ /** The linked peer itself */
18
+ get peer() {
19
+ return peer.parsePeer(this.raw.peer, this._peers);
20
+ }
21
+ /**
22
+ * Whether this peer is visible in the community's peer list,
23
+ * or `null` if this information is not available
24
+ */
25
+ get isVisible() {
26
+ return this.raw.visible ?? null;
27
+ }
28
+ /** Whether the current user can view the history of this peer */
29
+ get canViewHistory() {
30
+ return this.raw.canViewHistory;
31
+ }
32
+ }
33
+ const CommunityPeer$1 = /* @__PURE__ */ memoize.memoizeGetters(CommunityPeer, ["peer"]);
34
+ const CommunityPeer$2 = /* @__PURE__ */ inspectable.makeInspectable(CommunityPeer$1);
35
+ class CommunityPeerRequest {
36
+ constructor(raw, _peers) {
37
+ this.raw = raw;
38
+ this._peers = _peers;
39
+ }
40
+ /** The peer that is requested to be linked */
41
+ get peer() {
42
+ return peer.parsePeer(this.raw.peer, this._peers);
43
+ }
44
+ /** User who has requested the link */
45
+ get requestedBy() {
46
+ return new user.User(this._peers.user(this.raw.requestedBy));
47
+ }
48
+ /** Whether the peer is requested to be visible in the community's peer list */
49
+ get isVisible() {
50
+ return this.raw.visible;
51
+ }
52
+ /** Date when the request was sent */
53
+ get date() {
54
+ return new Date(this.raw.date * 1e3);
55
+ }
56
+ }
57
+ const CommunityPeerRequest$1 = /* @__PURE__ */ memoize.memoizeGetters(CommunityPeerRequest, ["peer", "requestedBy"]);
58
+ const CommunityPeerRequest$2 = /* @__PURE__ */ inspectable.makeInspectable(CommunityPeerRequest$1);
59
+ exports.CommunityPeer = CommunityPeer$2;
60
+ exports.CommunityPeerRequest = CommunityPeerRequest$2;
@@ -0,0 +1,37 @@
1
+ import { tl } from '../../../tl/index.js';
2
+ import { Peer } from './peer.js';
3
+ import { PeersIndex } from './peers-index.js';
4
+ import { User } from './user.js';
5
+ /**
6
+ * A chat or user linked to a community
7
+ */
8
+ export declare class CommunityPeer {
9
+ readonly raw: tl.RawCommunityPeer;
10
+ readonly _peers: PeersIndex;
11
+ constructor(raw: tl.RawCommunityPeer, _peers: PeersIndex);
12
+ /** The linked peer itself */
13
+ get peer(): Peer;
14
+ /**
15
+ * Whether this peer is visible in the community's peer list,
16
+ * or `null` if this information is not available
17
+ */
18
+ get isVisible(): boolean | null;
19
+ /** Whether the current user can view the history of this peer */
20
+ get canViewHistory(): boolean;
21
+ }
22
+ /**
23
+ * A pending request to link a peer to a community
24
+ */
25
+ export declare class CommunityPeerRequest {
26
+ readonly raw: tl.RawCommunityPeerRequest;
27
+ readonly _peers: PeersIndex;
28
+ constructor(raw: tl.RawCommunityPeerRequest, _peers: PeersIndex);
29
+ /** The peer that is requested to be linked */
30
+ get peer(): Peer;
31
+ /** User who has requested the link */
32
+ get requestedBy(): User;
33
+ /** Whether the peer is requested to be visible in the community's peer list */
34
+ get isVisible(): boolean;
35
+ /** Date when the request was sent */
36
+ get date(): Date;
37
+ }