@mtcute/core 0.30.3 → 0.32.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.
- package/client.cjs +85 -0
- package/client.js +85 -0
- package/highlevel/client.d.cts +411 -116
- package/highlevel/client.d.ts +411 -116
- package/highlevel/methods/auth/sign-in-qr.cjs +2 -0
- package/highlevel/methods/auth/sign-in-qr.js +2 -0
- package/highlevel/methods/auth/sign-in-qr.test.d.cts +1 -0
- package/highlevel/methods/auth/sign-in-qr.test.d.ts +1 -0
- package/highlevel/methods/chats/build-peers-index.cjs +45 -0
- package/highlevel/methods/chats/build-peers-index.d.cts +13 -0
- package/highlevel/methods/chats/build-peers-index.d.ts +13 -0
- package/highlevel/methods/chats/build-peers-index.js +40 -0
- package/highlevel/methods/chats/join-chat.cjs +1 -1
- package/highlevel/methods/chats/join-chat.d.cts +2 -1
- package/highlevel/methods/chats/join-chat.d.ts +2 -1
- package/highlevel/methods/chats/join-chat.js +1 -1
- package/highlevel/methods/chats/transfer-chat-ownership.cjs +6 -17
- package/highlevel/methods/chats/transfer-chat-ownership.js +6 -17
- package/highlevel/methods/communities/ban-community-participant.cjs +30 -0
- package/highlevel/methods/communities/ban-community-participant.d.cts +20 -0
- package/highlevel/methods/communities/ban-community-participant.d.ts +20 -0
- package/highlevel/methods/communities/ban-community-participant.js +25 -0
- package/highlevel/methods/communities/create-community.cjs +29 -0
- package/highlevel/methods/communities/create-community.d.cts +22 -0
- package/highlevel/methods/communities/create-community.d.ts +22 -0
- package/highlevel/methods/communities/create-community.js +24 -0
- package/highlevel/methods/communities/get-community-link-requests.cjs +27 -0
- package/highlevel/methods/communities/get-community-link-requests.d.cts +17 -0
- package/highlevel/methods/communities/get-community-link-requests.d.ts +17 -0
- package/highlevel/methods/communities/get-community-link-requests.js +22 -0
- package/highlevel/methods/communities/get-community-participant-chats.cjs +24 -0
- package/highlevel/methods/communities/get-community-participant-chats.d.cts +17 -0
- package/highlevel/methods/communities/get-community-participant-chats.d.ts +17 -0
- package/highlevel/methods/communities/get-community-participant-chats.js +19 -0
- package/highlevel/methods/communities/get-joined-communities.cjs +21 -0
- package/highlevel/methods/communities/get-joined-communities.d.cts +6 -0
- package/highlevel/methods/communities/get-joined-communities.d.ts +6 -0
- package/highlevel/methods/communities/get-joined-communities.js +16 -0
- package/highlevel/methods/communities/hide-community-link-request.cjs +30 -0
- package/highlevel/methods/communities/hide-community-link-request.d.cts +22 -0
- package/highlevel/methods/communities/hide-community-link-request.d.ts +22 -0
- package/highlevel/methods/communities/hide-community-link-request.js +25 -0
- package/highlevel/methods/communities/link-community-peer.cjs +32 -0
- package/highlevel/methods/communities/link-community-peer.d.cts +22 -0
- package/highlevel/methods/communities/link-community-peer.d.ts +22 -0
- package/highlevel/methods/communities/link-community-peer.js +27 -0
- package/highlevel/methods/communities/toggle-community-collapsed.cjs +18 -0
- package/highlevel/methods/communities/toggle-community-collapsed.d.cts +16 -0
- package/highlevel/methods/communities/toggle-community-collapsed.d.ts +16 -0
- package/highlevel/methods/communities/toggle-community-collapsed.js +13 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.cjs +17 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.cts +8 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.ts +8 -0
- package/highlevel/methods/ephemeral/delete-all-welcome-messages.js +12 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.cjs +20 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.d.cts +13 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.d.ts +13 -0
- package/highlevel/methods/ephemeral/delete-ephemeral-message.js +15 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.cjs +18 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.d.cts +9 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.d.ts +9 -0
- package/highlevel/methods/ephemeral/delete-welcome-message.js +13 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.cjs +41 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.d.cts +39 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.d.ts +39 -0
- package/highlevel/methods/ephemeral/edit-ephemeral-message.js +36 -0
- package/highlevel/methods/ephemeral/find-in-update.cjs +27 -0
- package/highlevel/methods/ephemeral/find-in-update.d.cts +8 -0
- package/highlevel/methods/ephemeral/find-in-update.d.ts +8 -0
- package/highlevel/methods/ephemeral/find-in-update.js +22 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.cjs +31 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.cts +29 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.d.ts +29 -0
- package/highlevel/methods/ephemeral/get-ephemeral-callback-answer.js +26 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.cjs +29 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.d.cts +8 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.d.ts +8 -0
- package/highlevel/methods/ephemeral/get-welcome-messages.js +24 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.cjs +48 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.d.cts +47 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.d.ts +47 -0
- package/highlevel/methods/ephemeral/send-ephemeral-message.js +43 -0
- package/highlevel/methods/files/download-iterable.cjs +7 -2
- package/highlevel/methods/files/download-iterable.js +7 -2
- package/highlevel/methods/files/download-iterable.test.d.cts +1 -0
- package/highlevel/methods/files/download-iterable.test.d.ts +1 -0
- package/highlevel/methods/files/download-stream.cjs +5 -6
- package/highlevel/methods/files/download-stream.js +5 -6
- package/highlevel/methods/files/normalize-input-media.cjs +25 -4
- package/highlevel/methods/files/normalize-input-media.js +25 -4
- package/highlevel/methods/forums/create-forum-topic.d.cts +7 -0
- package/highlevel/methods/forums/create-forum-topic.d.ts +7 -0
- package/highlevel/methods/forums/delete-forum-topic-history.d.cts +1 -1
- package/highlevel/methods/forums/delete-forum-topic-history.d.ts +1 -1
- package/highlevel/methods/forums/edit-forum-topic.cjs +2 -2
- package/highlevel/methods/forums/edit-forum-topic.d.cts +2 -2
- package/highlevel/methods/forums/edit-forum-topic.d.ts +2 -2
- package/highlevel/methods/forums/edit-forum-topic.js +2 -2
- package/highlevel/methods/forums/get-forum-topics-by-id.cjs +5 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.d.cts +9 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.d.ts +9 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.js +5 -1
- package/highlevel/methods/forums/get-forum-topics-by-id.test.d.cts +1 -0
- package/highlevel/methods/forums/get-forum-topics-by-id.test.d.ts +1 -0
- package/highlevel/methods/forums/get-forum-topics.cjs +1 -1
- package/highlevel/methods/forums/get-forum-topics.js +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.cjs +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.d.cts +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.d.ts +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-closed.js +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-pinned.d.cts +1 -1
- package/highlevel/methods/forums/toggle-forum-topic-pinned.d.ts +1 -1
- package/highlevel/methods/forums/toggle-general-topic-hidden.cjs +3 -3
- package/highlevel/methods/forums/toggle-general-topic-hidden.js +4 -4
- package/highlevel/methods/gifts/buy-resale-gift.cjs +5 -2
- package/highlevel/methods/gifts/buy-resale-gift.d.cts +11 -1
- package/highlevel/methods/gifts/buy-resale-gift.d.ts +11 -1
- package/highlevel/methods/gifts/buy-resale-gift.js +5 -2
- package/highlevel/methods/messages/forward-messages.cjs +1 -0
- package/highlevel/methods/messages/forward-messages.d.cts +2 -0
- package/highlevel/methods/messages/forward-messages.d.ts +2 -0
- package/highlevel/methods/messages/forward-messages.js +1 -0
- package/highlevel/methods/messages/normalize-rich-message.cjs +3 -0
- package/highlevel/methods/messages/normalize-rich-message.js +3 -0
- package/highlevel/methods/messages/send-common.d.cts +7 -1
- package/highlevel/methods/messages/send-common.d.ts +7 -1
- package/highlevel/methods/messages/send-text.cjs +70 -35
- package/highlevel/methods/messages/send-text.js +70 -35
- package/highlevel/methods/messages/send-typing.d.cts +3 -3
- package/highlevel/methods/messages/send-typing.d.ts +3 -3
- package/highlevel/methods/messages/set-typing.cjs +1 -1
- package/highlevel/methods/messages/set-typing.d.cts +2 -2
- package/highlevel/methods/messages/set-typing.d.ts +2 -2
- package/highlevel/methods/messages/set-typing.js +1 -1
- package/highlevel/methods/users/resolve-peer.cjs +11 -1
- package/highlevel/methods/users/resolve-peer.js +11 -1
- package/highlevel/methods.d.cts +19 -0
- package/highlevel/methods.d.ts +19 -0
- package/highlevel/storage/service/peers.cjs +25 -0
- package/highlevel/storage/service/peers.js +25 -0
- package/highlevel/storage/service/peers.test.d.cts +1 -0
- package/highlevel/storage/service/peers.test.d.ts +1 -0
- package/highlevel/types/bots/keyboards/builder.cjs +5 -5
- package/highlevel/types/bots/keyboards/builder.d.cts +8 -9
- package/highlevel/types/bots/keyboards/builder.d.ts +8 -9
- package/highlevel/types/bots/keyboards/builder.js +5 -5
- package/highlevel/types/bots/keyboards/factories.cjs +51 -103
- package/highlevel/types/bots/keyboards/factories.d.cts +58 -89
- package/highlevel/types/bots/keyboards/factories.d.ts +58 -89
- package/highlevel/types/bots/keyboards/factories.js +51 -103
- package/highlevel/types/bots/keyboards/index.d.cts +3 -3
- package/highlevel/types/bots/keyboards/index.d.ts +3 -3
- package/highlevel/types/bots/keyboards/normalize.cjs +131 -0
- package/highlevel/types/bots/keyboards/normalize.d.cts +10 -0
- package/highlevel/types/bots/keyboards/normalize.d.ts +10 -0
- package/highlevel/types/bots/keyboards/normalize.js +126 -0
- package/highlevel/types/bots/keyboards/types.d.cts +160 -4
- package/highlevel/types/bots/keyboards/types.d.ts +160 -4
- package/highlevel/types/conversation.cjs +8 -0
- package/highlevel/types/conversation.d.cts +1 -0
- package/highlevel/types/conversation.d.ts +1 -0
- package/highlevel/types/conversation.js +10 -2
- package/highlevel/types/conversation.test.d.cts +1 -0
- package/highlevel/types/conversation.test.d.ts +1 -0
- package/highlevel/types/messages/dialog.cjs +8 -1
- package/highlevel/types/messages/dialog.d.cts +3 -0
- package/highlevel/types/messages/dialog.d.ts +3 -0
- package/highlevel/types/messages/dialog.js +8 -1
- package/highlevel/types/messages/dialog.test.d.cts +1 -0
- package/highlevel/types/messages/dialog.test.d.ts +1 -0
- package/highlevel/types/messages/ephemeral-message.cjs +135 -0
- package/highlevel/types/messages/ephemeral-message.d.cts +75 -0
- package/highlevel/types/messages/ephemeral-message.d.ts +75 -0
- package/highlevel/types/messages/ephemeral-message.js +130 -0
- package/highlevel/types/messages/index.d.cts +1 -0
- package/highlevel/types/messages/index.d.ts +1 -0
- package/highlevel/types/messages/message-action.cjs +14 -1
- package/highlevel/types/messages/message-action.d.cts +18 -1
- package/highlevel/types/messages/message-action.d.ts +18 -1
- package/highlevel/types/messages/message-action.js +14 -1
- package/highlevel/types/messages/message.cjs +7 -2
- package/highlevel/types/messages/message.d.cts +2 -2
- package/highlevel/types/messages/message.d.ts +2 -2
- package/highlevel/types/messages/message.js +8 -3
- package/highlevel/types/messages/replied-message.cjs +5 -1
- package/highlevel/types/messages/replied-message.d.cts +5 -1
- package/highlevel/types/messages/replied-message.d.ts +5 -1
- package/highlevel/types/messages/replied-message.js +5 -1
- package/highlevel/types/messages/rich/inner.cjs +37 -0
- package/highlevel/types/messages/rich/inner.d.cts +19 -0
- package/highlevel/types/messages/rich/inner.d.ts +19 -0
- package/highlevel/types/messages/rich/inner.js +37 -0
- package/highlevel/types/peers/chat.cjs +23 -3
- package/highlevel/types/peers/chat.d.cts +8 -3
- package/highlevel/types/peers/chat.d.ts +8 -3
- package/highlevel/types/peers/chat.js +24 -4
- package/highlevel/types/peers/community-peer.cjs +60 -0
- package/highlevel/types/peers/community-peer.d.cts +37 -0
- package/highlevel/types/peers/community-peer.d.ts +37 -0
- package/highlevel/types/peers/community-peer.js +55 -0
- package/highlevel/types/peers/full-chat.cjs +24 -5
- package/highlevel/types/peers/full-chat.d.cts +7 -0
- package/highlevel/types/peers/full-chat.d.ts +7 -0
- package/highlevel/types/peers/full-chat.js +24 -5
- package/highlevel/types/peers/index.d.cts +1 -0
- package/highlevel/types/peers/index.d.ts +1 -0
- package/highlevel/types/peers/peer.cjs +2 -0
- package/highlevel/types/peers/peer.js +2 -0
- package/highlevel/types/peers/typing-status.d.cts +4 -1
- package/highlevel/types/peers/typing-status.d.ts +4 -1
- package/highlevel/types/peers/user.cjs +6 -0
- package/highlevel/types/peers/user.d.cts +2 -0
- package/highlevel/types/peers/user.d.ts +2 -0
- package/highlevel/types/peers/user.js +6 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.cjs +27 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.d.cts +15 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.d.ts +15 -0
- package/highlevel/types/updates/delete-ephemeral-messages-update.js +22 -0
- package/highlevel/types/updates/ephemeral-callback-query.cjs +69 -0
- package/highlevel/types/updates/ephemeral-callback-query.d.cts +44 -0
- package/highlevel/types/updates/ephemeral-callback-query.d.ts +44 -0
- package/highlevel/types/updates/ephemeral-callback-query.js +64 -0
- package/highlevel/types/updates/index.d.cts +16 -2
- package/highlevel/types/updates/index.d.ts +16 -2
- package/highlevel/types/updates/parse-update.cjs +12 -1
- package/highlevel/types/updates/parse-update.js +12 -1
- package/highlevel/types/updates/user-typing-update.cjs +18 -0
- package/highlevel/types/updates/user-typing-update.d.cts +9 -0
- package/highlevel/types/updates/user-typing-update.d.ts +9 -0
- package/highlevel/types/updates/user-typing-update.js +18 -0
- package/highlevel/updates/manager.cjs +71 -41
- package/highlevel/updates/manager.d.cts +1 -0
- package/highlevel/updates/manager.d.ts +1 -0
- package/highlevel/updates/manager.js +71 -41
- package/highlevel/updates/manager.test.d.cts +1 -0
- package/highlevel/updates/manager.test.d.ts +1 -0
- package/highlevel/utils/stream-utils.cjs +8 -4
- package/highlevel/utils/stream-utils.js +8 -4
- package/highlevel/utils/stream-utils.test.d.cts +1 -0
- package/highlevel/utils/stream-utils.test.d.ts +1 -0
- package/highlevel/utils/walk-page-blocks.cjs +9 -0
- package/highlevel/utils/walk-page-blocks.js +9 -0
- package/index.cjs +10 -0
- package/index.js +11 -1
- package/methods.cjs +33 -0
- package/methods.js +33 -0
- package/network/client.cjs +4 -3
- package/network/client.d.cts +1 -0
- package/network/client.d.ts +1 -0
- package/network/client.js +4 -3
- package/network/middlewares/flood-waiter.cjs +2 -2
- package/network/middlewares/flood-waiter.js +2 -2
- package/network/middlewares/internal-errors.cjs +1 -1
- package/network/middlewares/internal-errors.js +1 -1
- package/network/middlewares/media-throttle.cjs +1 -1
- package/network/middlewares/media-throttle.js +1 -1
- package/network/mtproto-session.cjs +9 -2
- package/network/mtproto-session.d.cts +3 -1
- package/network/mtproto-session.d.ts +3 -1
- package/network/mtproto-session.js +9 -2
- package/network/mtproxy/index.cjs +4 -3
- package/network/mtproxy/index.d.cts +2 -2
- package/network/mtproxy/index.d.ts +2 -2
- package/network/mtproxy/index.js +4 -3
- package/network/network-manager.cjs +44 -16
- package/network/network-manager.d.cts +10 -3
- package/network/network-manager.d.ts +10 -3
- package/network/network-manager.js +45 -17
- package/network/network-manager.test.d.cts +1 -0
- package/network/network-manager.test.d.ts +1 -0
- package/network/persistent-connection.cjs +10 -2
- package/network/persistent-connection.js +10 -2
- package/network/session-connection.cjs +15 -6
- package/network/session-connection.js +15 -6
- package/network/session-connection.test.d.cts +1 -0
- package/network/session-connection.test.d.ts +1 -0
- package/network/transports/abstract.cjs +16 -0
- package/network/transports/abstract.d.cts +8 -2
- package/network/transports/abstract.d.ts +8 -2
- package/network/transports/abstract.js +17 -1
- package/network/transports/obfuscated.cjs +3 -1
- package/network/transports/obfuscated.js +3 -1
- package/package.json +6 -6
- package/tl/api-schema.json +1 -1
- package/tl/binary/reader.cjs +221 -103
- package/tl/binary/reader.js +221 -103
- package/tl/binary/writer.cjs +693 -277
- package/tl/binary/writer.js +693 -277
- package/tl/compat/reader.cjs +93 -0
- package/tl/compat/reader.js +93 -0
- package/tl/index.d.cts +12529 -4762
- package/tl/index.d.ts +12529 -4762
- package/tl/inner-tl.cjs +90 -24
- package/tl/inner-tl.js +90 -24
- package/tl/raw-errors.json +1 -1
- package/tl/rpc-error.test.d.cts +1 -0
- package/tl/rpc-error.test.d.ts +1 -0
- package/utils/abort-signal.cjs +1 -12
- package/utils/abort-signal.js +1 -12
- package/utils/abort-signal.test.d.cts +1 -0
- package/utils/abort-signal.test.d.ts +1 -0
- package/utils/binary/compat.cjs +189 -29
- package/utils/binary/compat.js +189 -29
- package/utils/early-timer.cjs +3 -11
- package/utils/early-timer.js +3 -11
- package/utils/early-timer.test.d.cts +1 -0
- package/utils/early-timer.test.d.ts +1 -0
- package/utils/function-utils.cjs +9 -4
- package/utils/function-utils.js +9 -4
- package/utils/links/bots.cjs +10 -2
- package/utils/links/bots.js +10 -2
- package/utils/peer-utils.cjs +8 -0
- package/utils/peer-utils.js +8 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { tl } from '../../../tl/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ParsedReplyMarkup } from '../bots/keyboards/index.js';
|
|
3
3
|
import { TextWithEntities } from '../misc/index.js';
|
|
4
4
|
import { Peer } from '../peers/peer.js';
|
|
5
5
|
import { PeersIndex } from '../peers/peers-index.js';
|
|
@@ -232,7 +232,7 @@ export declare class Message {
|
|
|
232
232
|
/**
|
|
233
233
|
* Reply markup provided with this message, if any.
|
|
234
234
|
*/
|
|
235
|
-
get markup():
|
|
235
|
+
get markup(): ParsedReplyMarkup | null;
|
|
236
236
|
/**
|
|
237
237
|
* Whether this message can be forwarded
|
|
238
238
|
*
|
|
@@ -16,7 +16,7 @@ import { RepliedMessageInfo as RepliedMessageInfo$2 } from "./replied-message.js
|
|
|
16
16
|
import { RichMessage as RichMessage$2 } from "./rich/rich-message.js";
|
|
17
17
|
import { SuggestedPostInfo as SuggestedPostInfo$1 } from "./suggested-post.js";
|
|
18
18
|
import { makeInspectable } from "../../utils/inspectable.js";
|
|
19
|
-
import { _rowsTo2d } from "../bots/keyboards/factories.js";
|
|
19
|
+
import { _inlineRowsTo2d, _rowsTo2d } from "../bots/keyboards/factories.js";
|
|
20
20
|
class Message {
|
|
21
21
|
constructor(raw, _peers, isScheduled = false) {
|
|
22
22
|
this._peers = _peers;
|
|
@@ -372,7 +372,8 @@ class Message {
|
|
|
372
372
|
return {
|
|
373
373
|
type: "force_reply",
|
|
374
374
|
singleUse: rm.singleUse,
|
|
375
|
-
selective: rm.selective
|
|
375
|
+
selective: rm.selective,
|
|
376
|
+
placeholder: rm.placeholder
|
|
376
377
|
};
|
|
377
378
|
case "replyKeyboardMarkup":
|
|
378
379
|
return {
|
|
@@ -380,12 +381,16 @@ class Message {
|
|
|
380
381
|
resize: rm.resize,
|
|
381
382
|
singleUse: rm.singleUse,
|
|
382
383
|
selective: rm.selective,
|
|
384
|
+
persistent: rm.persistent,
|
|
385
|
+
forceReply: rm.forceReply,
|
|
386
|
+
placeholder: rm.placeholder,
|
|
383
387
|
buttons: _rowsTo2d(rm.rows)
|
|
384
388
|
};
|
|
385
389
|
case "replyInlineMarkup":
|
|
386
390
|
return {
|
|
387
391
|
type: "inline",
|
|
388
|
-
|
|
392
|
+
forceReply: rm.forceReply,
|
|
393
|
+
buttons: _inlineRowsTo2d(rm.rows)
|
|
389
394
|
};
|
|
390
395
|
default:
|
|
391
396
|
assertNever();
|
|
@@ -56,7 +56,11 @@ class RepliedMessageInfo {
|
|
|
56
56
|
get id() {
|
|
57
57
|
return this.raw.replyToMsgId ?? null;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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;
|
|
@@ -6,7 +6,9 @@ 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 Long = require("long");
|
|
9
|
+
const errors = require("../../../../types/errors.cjs");
|
|
9
10
|
const entities = require("../../../utils/entities.cjs");
|
|
11
|
+
const normalize = require("../../bots/keyboards/normalize.cjs");
|
|
10
12
|
const RICH_EMPTY = { _: "textEmpty" };
|
|
11
13
|
function normalizeRichText(text) {
|
|
12
14
|
if (typeof text === "string") return { _: "textPlain", text };
|
|
@@ -55,6 +57,38 @@ function blockquote(content, caption) {
|
|
|
55
57
|
}
|
|
56
58
|
return { _: "pageBlockBlockquote", text: normalizeRichText(content), caption: normalizedCaption };
|
|
57
59
|
}
|
|
60
|
+
function normalizeButton(btn, text) {
|
|
61
|
+
if ("_" in btn) {
|
|
62
|
+
if (btn._ !== "keyboardInlineButton") {
|
|
63
|
+
throw new errors.MtArgumentError("reply keyboard buttons cannot be used in rich messages");
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
text: normalizeRichText(text ?? btn.text),
|
|
67
|
+
type: btn.type,
|
|
68
|
+
style: void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
text: normalizeRichText(text ?? btn.text),
|
|
73
|
+
type: normalize._toInlineButtonType(btn),
|
|
74
|
+
style: normalize._toRichButtonStyle(btn.style)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function textButton(button2, text) {
|
|
78
|
+
return { _: "textButton", ...normalizeButton(button2, text) };
|
|
79
|
+
}
|
|
80
|
+
function button(button2, text) {
|
|
81
|
+
return { _: "pageButton", ...normalizeButton(button2, text) };
|
|
82
|
+
}
|
|
83
|
+
function buttonRow(buttons, params = {}) {
|
|
84
|
+
return {
|
|
85
|
+
_: "pageBlockButtonRow",
|
|
86
|
+
alignLeft: params.align === "left" || void 0,
|
|
87
|
+
alignCenter: params.align === "center" || void 0,
|
|
88
|
+
alignRight: params.align === "right" || void 0,
|
|
89
|
+
buttons: buttons.map((it) => "_" in it && it._ === "pageButton" ? it : button(it))
|
|
90
|
+
};
|
|
91
|
+
}
|
|
58
92
|
function pullquote(text, caption) {
|
|
59
93
|
return {
|
|
60
94
|
_: "pageBlockPullquote",
|
|
@@ -196,6 +230,8 @@ function audio(file, params = {}) {
|
|
|
196
230
|
exports.anchor = anchor;
|
|
197
231
|
exports.audio = audio;
|
|
198
232
|
exports.blockquote = blockquote;
|
|
233
|
+
exports.button = button;
|
|
234
|
+
exports.buttonRow = buttonRow;
|
|
199
235
|
exports.collage = collage;
|
|
200
236
|
exports.details = details;
|
|
201
237
|
exports.divider = divider;
|
|
@@ -215,5 +251,6 @@ exports.slideshow = slideshow;
|
|
|
215
251
|
exports.table = table;
|
|
216
252
|
exports.tableCell = tableCell;
|
|
217
253
|
exports.tableRow = tableRow;
|
|
254
|
+
exports.textButton = textButton;
|
|
218
255
|
exports.thinking = thinking;
|
|
219
256
|
exports.video = video;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { tl } from '../../../../tl/index.js';
|
|
2
|
+
import { InputInlineKeyboardButton } from '../../bots/keyboards/types.js';
|
|
2
3
|
import { InputMediaAudio, InputMediaPhoto, InputMediaVideo } from '../../media/index.js';
|
|
3
4
|
import { InputText } from '../../misc/entities.js';
|
|
4
5
|
import { InputPageBlock, InputPageBlockOrFile, InputPageBlockWithFile } from './types.js';
|
|
@@ -48,6 +49,24 @@ export declare function preformatted(text: InputRichText, language?: string): tl
|
|
|
48
49
|
* containing other blocks (`pageBlockBlockquoteBlocks`).
|
|
49
50
|
*/
|
|
50
51
|
export declare function blockquote(content: InputRichText | InputPageBlockOrFile[], caption?: InputRichText): tl.RawPageBlockBlockquote | Block<'pageBlockBlockquoteBlocks'>;
|
|
52
|
+
/**
|
|
53
|
+
* Create an inline button inside rich text
|
|
54
|
+
*
|
|
55
|
+
* @param button Button to render (see {@link BotKeyboard})
|
|
56
|
+
* @param text Rich text to use as the button label, defaults to the button's own text
|
|
57
|
+
*/
|
|
58
|
+
export declare function textButton(button: InputInlineKeyboardButton, text?: InputRichText): tl.RawTextButton;
|
|
59
|
+
/** Create a button to be used inside a {@link buttonRow} */
|
|
60
|
+
export declare function button(button: InputInlineKeyboardButton, text?: InputRichText): tl.RawPageButton;
|
|
61
|
+
/**
|
|
62
|
+
* Create a row of buttons
|
|
63
|
+
*
|
|
64
|
+
* @param buttons Buttons in the row (see {@link BotKeyboard}), or raw `pageButton`s
|
|
65
|
+
* @param params Alignment of the row
|
|
66
|
+
*/
|
|
67
|
+
export declare function buttonRow(buttons: (InputInlineKeyboardButton | tl.RawPageButton)[], params?: {
|
|
68
|
+
align?: 'left' | 'center' | 'right';
|
|
69
|
+
}): tl.RawPageBlockButtonRow;
|
|
51
70
|
/** Create a pullquote block */
|
|
52
71
|
export declare function pullquote(text: InputRichText, caption?: InputRichText): tl.RawPageBlockPullquote;
|
|
53
72
|
/** Create a map block */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { tl } from '../../../../tl/index.js';
|
|
2
|
+
import { InputInlineKeyboardButton } from '../../bots/keyboards/types.js';
|
|
2
3
|
import { InputMediaAudio, InputMediaPhoto, InputMediaVideo } from '../../media/index.js';
|
|
3
4
|
import { InputText } from '../../misc/entities.js';
|
|
4
5
|
import { InputPageBlock, InputPageBlockOrFile, InputPageBlockWithFile } from './types.js';
|
|
@@ -48,6 +49,24 @@ export declare function preformatted(text: InputRichText, language?: string): tl
|
|
|
48
49
|
* containing other blocks (`pageBlockBlockquoteBlocks`).
|
|
49
50
|
*/
|
|
50
51
|
export declare function blockquote(content: InputRichText | InputPageBlockOrFile[], caption?: InputRichText): tl.RawPageBlockBlockquote | Block<'pageBlockBlockquoteBlocks'>;
|
|
52
|
+
/**
|
|
53
|
+
* Create an inline button inside rich text
|
|
54
|
+
*
|
|
55
|
+
* @param button Button to render (see {@link BotKeyboard})
|
|
56
|
+
* @param text Rich text to use as the button label, defaults to the button's own text
|
|
57
|
+
*/
|
|
58
|
+
export declare function textButton(button: InputInlineKeyboardButton, text?: InputRichText): tl.RawTextButton;
|
|
59
|
+
/** Create a button to be used inside a {@link buttonRow} */
|
|
60
|
+
export declare function button(button: InputInlineKeyboardButton, text?: InputRichText): tl.RawPageButton;
|
|
61
|
+
/**
|
|
62
|
+
* Create a row of buttons
|
|
63
|
+
*
|
|
64
|
+
* @param buttons Buttons in the row (see {@link BotKeyboard}), or raw `pageButton`s
|
|
65
|
+
* @param params Alignment of the row
|
|
66
|
+
*/
|
|
67
|
+
export declare function buttonRow(buttons: (InputInlineKeyboardButton | tl.RawPageButton)[], params?: {
|
|
68
|
+
align?: 'left' | 'center' | 'right';
|
|
69
|
+
}): tl.RawPageBlockButtonRow;
|
|
51
70
|
/** Create a pullquote block */
|
|
52
71
|
export declare function pullquote(text: InputRichText, caption?: InputRichText): tl.RawPageBlockPullquote;
|
|
53
72
|
/** Create a map block */
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Long from "long";
|
|
2
|
+
import { MtArgumentError } from "../../../../types/errors.js";
|
|
2
3
|
import { textWithEntitiesToRichText } from "../../../utils/entities.js";
|
|
4
|
+
import { _toRichButtonStyle, _toInlineButtonType } from "../../bots/keyboards/normalize.js";
|
|
3
5
|
const RICH_EMPTY = { _: "textEmpty" };
|
|
4
6
|
function normalizeRichText(text) {
|
|
5
7
|
if (typeof text === "string") return { _: "textPlain", text };
|
|
@@ -48,6 +50,38 @@ function blockquote(content, caption) {
|
|
|
48
50
|
}
|
|
49
51
|
return { _: "pageBlockBlockquote", text: normalizeRichText(content), caption: normalizedCaption };
|
|
50
52
|
}
|
|
53
|
+
function normalizeButton(btn, text) {
|
|
54
|
+
if ("_" in btn) {
|
|
55
|
+
if (btn._ !== "keyboardInlineButton") {
|
|
56
|
+
throw new MtArgumentError("reply keyboard buttons cannot be used in rich messages");
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
text: normalizeRichText(text ?? btn.text),
|
|
60
|
+
type: btn.type,
|
|
61
|
+
style: void 0
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
text: normalizeRichText(text ?? btn.text),
|
|
66
|
+
type: _toInlineButtonType(btn),
|
|
67
|
+
style: _toRichButtonStyle(btn.style)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function textButton(button2, text) {
|
|
71
|
+
return { _: "textButton", ...normalizeButton(button2, text) };
|
|
72
|
+
}
|
|
73
|
+
function button(button2, text) {
|
|
74
|
+
return { _: "pageButton", ...normalizeButton(button2, text) };
|
|
75
|
+
}
|
|
76
|
+
function buttonRow(buttons, params = {}) {
|
|
77
|
+
return {
|
|
78
|
+
_: "pageBlockButtonRow",
|
|
79
|
+
alignLeft: params.align === "left" || void 0,
|
|
80
|
+
alignCenter: params.align === "center" || void 0,
|
|
81
|
+
alignRight: params.align === "right" || void 0,
|
|
82
|
+
buttons: buttons.map((it) => "_" in it && it._ === "pageButton" ? it : button(it))
|
|
83
|
+
};
|
|
84
|
+
}
|
|
51
85
|
function pullquote(text, caption) {
|
|
52
86
|
return {
|
|
53
87
|
_: "pageBlockPullquote",
|
|
@@ -190,6 +224,8 @@ export {
|
|
|
190
224
|
anchor,
|
|
191
225
|
audio,
|
|
192
226
|
blockquote,
|
|
227
|
+
button,
|
|
228
|
+
buttonRow,
|
|
193
229
|
collage,
|
|
194
230
|
details,
|
|
195
231
|
divider,
|
|
@@ -209,6 +245,7 @@ export {
|
|
|
209
245
|
table,
|
|
210
246
|
tableCell,
|
|
211
247
|
tableRow,
|
|
248
|
+
textButton,
|
|
212
249
|
thinking,
|
|
213
250
|
video
|
|
214
251
|
};
|
|
@@ -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
|
+
}
|