@mtcute/core 0.24.1 → 0.24.3

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 (57) hide show
  1. package/client.cjs +7 -0
  2. package/client.js +8 -1
  3. package/highlevel/client.d.cts +17 -0
  4. package/highlevel/client.d.ts +17 -0
  5. package/highlevel/methods/chats/get-message-author.cjs +20 -0
  6. package/highlevel/methods/chats/get-message-author.d.cts +3 -0
  7. package/highlevel/methods/chats/get-message-author.d.ts +3 -0
  8. package/highlevel/methods/chats/get-message-author.js +15 -0
  9. package/highlevel/methods/forums/toggle-forum.cjs +12 -1
  10. package/highlevel/methods/forums/toggle-forum.d.cts +14 -0
  11. package/highlevel/methods/forums/toggle-forum.d.ts +14 -0
  12. package/highlevel/methods/forums/toggle-forum.js +13 -2
  13. package/highlevel/methods/messages/forward-messages.cjs +9 -2
  14. package/highlevel/methods/messages/forward-messages.d.cts +7 -0
  15. package/highlevel/methods/messages/forward-messages.d.ts +7 -0
  16. package/highlevel/methods/messages/forward-messages.js +9 -2
  17. package/highlevel/methods/messages/send-common.cjs +7 -1
  18. package/highlevel/methods/messages/send-common.d.cts +7 -0
  19. package/highlevel/methods/messages/send-common.d.ts +7 -0
  20. package/highlevel/methods/messages/send-common.js +7 -1
  21. package/highlevel/methods.d.cts +2 -0
  22. package/highlevel/methods.d.ts +2 -0
  23. package/highlevel/types/media/input-media/factories.cjs +1 -0
  24. package/highlevel/types/media/input-media/factories.js +1 -0
  25. package/highlevel/types/messages/message-action.d.cts +2 -0
  26. package/highlevel/types/messages/message-action.d.ts +2 -0
  27. package/highlevel/types/peers/chat.cjs +19 -0
  28. package/highlevel/types/peers/chat.d.cts +13 -1
  29. package/highlevel/types/peers/chat.d.ts +13 -1
  30. package/highlevel/types/peers/chat.js +19 -0
  31. package/highlevel/types/peers/full-chat.cjs +10 -0
  32. package/highlevel/types/peers/full-chat.d.cts +6 -0
  33. package/highlevel/types/peers/full-chat.d.ts +6 -0
  34. package/highlevel/types/peers/full-chat.js +10 -0
  35. package/highlevel/types/peers/peer.d.cts +1 -1
  36. package/highlevel/types/peers/peer.d.ts +1 -1
  37. package/highlevel/types/updates/history-read-update.cjs +21 -0
  38. package/highlevel/types/updates/history-read-update.d.cts +7 -2
  39. package/highlevel/types/updates/history-read-update.d.ts +7 -2
  40. package/highlevel/types/updates/history-read-update.js +21 -0
  41. package/highlevel/updates/manager.cjs +10 -1
  42. package/highlevel/updates/manager.js +12 -3
  43. package/methods.cjs +3 -0
  44. package/methods.js +4 -1
  45. package/network/middlewares/internal-errors.cjs +3 -0
  46. package/network/middlewares/internal-errors.js +3 -0
  47. package/network/network-manager.cjs +1 -1
  48. package/network/network-manager.js +1 -1
  49. package/network/persistent-connection.cjs +2 -1
  50. package/network/persistent-connection.js +3 -2
  51. package/network/server-salt.cjs +12 -2
  52. package/network/server-salt.js +12 -2
  53. package/package.json +7 -7
  54. package/utils/binary/compat.cjs +4 -0
  55. package/utils/binary/compat.js +4 -0
  56. package/utils/peer-utils.cjs +2 -8
  57. package/utils/peer-utils.js +3 -9
package/client.cjs CHANGED
@@ -57,6 +57,7 @@ const getChatPreview = require("./highlevel/methods/chats/get-chat-preview.cjs")
57
57
  const getChat = require("./highlevel/methods/chats/get-chat.cjs");
58
58
  const getFullChat = require("./highlevel/methods/chats/get-full-chat.cjs");
59
59
  const getFullUser = require("./highlevel/methods/chats/get-full-user.cjs");
60
+ const getMessageAuthor = require("./highlevel/methods/chats/get-message-author.cjs");
60
61
  const getNearbyChats = require("./highlevel/methods/chats/get-nearby-chats.cjs");
61
62
  const getPeer = require("./highlevel/methods/chats/get-peer.cjs");
62
63
  const getSimilarChannels = require("./highlevel/methods/chats/get-similar-channels.cjs");
@@ -593,6 +594,9 @@ TelegramClient.prototype.getFullChat = function(...args) {
593
594
  TelegramClient.prototype.getFullUser = function(...args) {
594
595
  return getFullUser.getFullUser(this._client, ...args);
595
596
  };
597
+ TelegramClient.prototype.getMessageAuthor = function(...args) {
598
+ return getMessageAuthor.getMessageAuthor(this._client, ...args);
599
+ };
596
600
  TelegramClient.prototype.getNearbyChats = function(...args) {
597
601
  return getNearbyChats.getNearbyChats(this._client, ...args);
598
602
  };
@@ -779,6 +783,9 @@ TelegramClient.prototype.toggleForumTopicPinned = function(...args) {
779
783
  TelegramClient.prototype.toggleForum = function(...args) {
780
784
  return toggleForum.toggleForum(this._client, ...args);
781
785
  };
786
+ TelegramClient.prototype.updateForumSettings = function(...args) {
787
+ return toggleForum.updateForumSettings(this._client, ...args);
788
+ };
782
789
  TelegramClient.prototype.toggleGeneralTopicHidden = function(...args) {
783
790
  return toggleGeneralTopicHidden.toggleGeneralTopicHidden(this._client, ...args);
784
791
  };
package/client.js CHANGED
@@ -50,6 +50,7 @@ import { getChatPreview } from "./highlevel/methods/chats/get-chat-preview.js";
50
50
  import { getChat } from "./highlevel/methods/chats/get-chat.js";
51
51
  import { getFullChat } from "./highlevel/methods/chats/get-full-chat.js";
52
52
  import { getFullUser } from "./highlevel/methods/chats/get-full-user.js";
53
+ import { getMessageAuthor } from "./highlevel/methods/chats/get-message-author.js";
53
54
  import { getNearbyChats } from "./highlevel/methods/chats/get-nearby-chats.js";
54
55
  import { getPeer } from "./highlevel/methods/chats/get-peer.js";
55
56
  import { getSimilarChannels } from "./highlevel/methods/chats/get-similar-channels.js";
@@ -109,7 +110,7 @@ import { iterForumTopics } from "./highlevel/methods/forums/iter-forum-topics.js
109
110
  import { reorderPinnedForumTopics } from "./highlevel/methods/forums/reorder-pinned-forum-topics.js";
110
111
  import { toggleForumTopicClosed } from "./highlevel/methods/forums/toggle-forum-topic-closed.js";
111
112
  import { toggleForumTopicPinned } from "./highlevel/methods/forums/toggle-forum-topic-pinned.js";
112
- import { toggleForum } from "./highlevel/methods/forums/toggle-forum.js";
113
+ import { toggleForum, updateForumSettings } from "./highlevel/methods/forums/toggle-forum.js";
113
114
  import { toggleGeneralTopicHidden } from "./highlevel/methods/forums/toggle-general-topic-hidden.js";
114
115
  import { createInviteLink } from "./highlevel/methods/invite-links/create-invite-link.js";
115
116
  import { editInviteLink } from "./highlevel/methods/invite-links/edit-invite-link.js";
@@ -586,6 +587,9 @@ TelegramClient.prototype.getFullChat = function(...args) {
586
587
  TelegramClient.prototype.getFullUser = function(...args) {
587
588
  return getFullUser(this._client, ...args);
588
589
  };
590
+ TelegramClient.prototype.getMessageAuthor = function(...args) {
591
+ return getMessageAuthor(this._client, ...args);
592
+ };
589
593
  TelegramClient.prototype.getNearbyChats = function(...args) {
590
594
  return getNearbyChats(this._client, ...args);
591
595
  };
@@ -772,6 +776,9 @@ TelegramClient.prototype.toggleForumTopicPinned = function(...args) {
772
776
  TelegramClient.prototype.toggleForum = function(...args) {
773
777
  return toggleForum(this._client, ...args);
774
778
  };
779
+ TelegramClient.prototype.updateForumSettings = function(...args) {
780
+ return updateForumSettings(this._client, ...args);
781
+ };
775
782
  TelegramClient.prototype.toggleGeneralTopicHidden = function(...args) {
776
783
  return toggleGeneralTopicHidden(this._client, ...args);
777
784
  };
@@ -1290,6 +1290,7 @@ export interface TelegramClient extends ITelegramClient {
1290
1290
  * @param userId ID of the user or their username
1291
1291
  */
1292
1292
  getFullUser(userId: InputPeerLike): Promise<FullUser>;
1293
+ getMessageAuthor(message: InputMessageId): Promise<User>;
1293
1294
  /**
1294
1295
  * Get nearby chats
1295
1296
  *
@@ -2335,8 +2336,24 @@ export interface TelegramClient extends ITelegramClient {
2335
2336
  *
2336
2337
  * @param chatId Chat ID or username
2337
2338
  * @param [enabled=false] Whether the supergroup should be a forum
2339
+ * @deprecated Use {@link updateForumSettings} instead
2338
2340
  */
2339
2341
  toggleForum(chatId: InputPeerLike, enabled?: boolean): Promise<void>;
2342
+ /**
2343
+ * Update forum settings of a supergroup.
2344
+ *
2345
+ * Only owner of the supergroup can change this setting.
2346
+ *
2347
+ * **Available**: 👤 users only
2348
+ *
2349
+ * @param chatId Chat ID or username
2350
+ * @param settings New settings. `null` is a shorthand for `{ isForum: false }`
2351
+ */
2352
+ updateForumSettings(chatId: InputPeerLike, settings: null | {
2353
+ /** Whether the supergroup should be a forum */
2354
+ isForum: boolean;
2355
+ threadsMode: 'list' | 'tabs';
2356
+ }): Promise<void>;
2340
2357
  /**
2341
2358
  * Toggle whether "General" topic in a forum is hidden or not
2342
2359
  *
@@ -1290,6 +1290,7 @@ export interface TelegramClient extends ITelegramClient {
1290
1290
  * @param userId ID of the user or their username
1291
1291
  */
1292
1292
  getFullUser(userId: InputPeerLike): Promise<FullUser>;
1293
+ getMessageAuthor(message: InputMessageId): Promise<User>;
1293
1294
  /**
1294
1295
  * Get nearby chats
1295
1296
  *
@@ -2335,8 +2336,24 @@ export interface TelegramClient extends ITelegramClient {
2335
2336
  *
2336
2337
  * @param chatId Chat ID or username
2337
2338
  * @param [enabled=false] Whether the supergroup should be a forum
2339
+ * @deprecated Use {@link updateForumSettings} instead
2338
2340
  */
2339
2341
  toggleForum(chatId: InputPeerLike, enabled?: boolean): Promise<void>;
2342
+ /**
2343
+ * Update forum settings of a supergroup.
2344
+ *
2345
+ * Only owner of the supergroup can change this setting.
2346
+ *
2347
+ * **Available**: 👤 users only
2348
+ *
2349
+ * @param chatId Chat ID or username
2350
+ * @param settings New settings. `null` is a shorthand for `{ isForum: false }`
2351
+ */
2352
+ updateForumSettings(chatId: InputPeerLike, settings: null | {
2353
+ /** Whether the supergroup should be a forum */
2354
+ isForum: boolean;
2355
+ threadsMode: 'list' | 'tabs';
2356
+ }): Promise<void>;
2340
2357
  /**
2341
2358
  * Toggle whether "General" topic in a forum is hidden or not
2342
2359
  *
@@ -0,0 +1,20 @@
1
+ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
+ console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. 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 resolvePeer = require("../users/resolve-peer.cjs");
9
+ const inputMessageId = require("../../types/messages/input-message-id.cjs");
10
+ const user = require("../../types/peers/user.cjs");
11
+ async function getMessageAuthor(client, message) {
12
+ const { chatId, message: msgId } = inputMessageId.normalizeInputMessageId(message);
13
+ const res = await client.call({
14
+ _: "channels.getMessageAuthor",
15
+ channel: await resolvePeer.resolveChannel(client, chatId),
16
+ id: msgId
17
+ });
18
+ return new user.User(res);
19
+ }
20
+ exports.getMessageAuthor = getMessageAuthor;
@@ -0,0 +1,3 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputMessageId, User } from '../../types/index.js';
3
+ export declare function getMessageAuthor(client: ITelegramClient, message: InputMessageId): Promise<User>;
@@ -0,0 +1,3 @@
1
+ import { ITelegramClient } from '../../client.types.js';
2
+ import { InputMessageId, User } from '../../types/index.js';
3
+ export declare function getMessageAuthor(client: ITelegramClient, message: InputMessageId): Promise<User>;
@@ -0,0 +1,15 @@
1
+ import { resolveChannel } from "../users/resolve-peer.js";
2
+ import { normalizeInputMessageId } from "../../types/messages/input-message-id.js";
3
+ import { User as User$2 } from "../../types/peers/user.js";
4
+ async function getMessageAuthor(client, message) {
5
+ const { chatId, message: msgId } = normalizeInputMessageId(message);
6
+ const res = await client.call({
7
+ _: "channels.getMessageAuthor",
8
+ channel: await resolveChannel(client, chatId),
9
+ id: msgId
10
+ });
11
+ return new User$2(res);
12
+ }
13
+ export {
14
+ getMessageAuthor
15
+ };
@@ -10,8 +10,19 @@ async function toggleForum(client, chatId, enabled = false) {
10
10
  const res = await client.call({
11
11
  _: "channels.toggleForum",
12
12
  channel: await resolvePeer.resolveChannel(client, chatId),
13
- enabled
13
+ enabled,
14
+ tabs: false
15
+ });
16
+ client.handleClientUpdate(res);
17
+ }
18
+ async function updateForumSettings(client, chatId, settings) {
19
+ const res = await client.call({
20
+ _: "channels.toggleForum",
21
+ channel: await resolvePeer.resolveChannel(client, chatId),
22
+ enabled: settings?.isForum ?? false,
23
+ tabs: settings?.threadsMode === "tabs"
14
24
  });
15
25
  client.handleClientUpdate(res);
16
26
  }
17
27
  exports.toggleForum = toggleForum;
28
+ exports.updateForumSettings = updateForumSettings;
@@ -7,5 +7,19 @@ import { InputPeerLike } from '../../types/index.js';
7
7
  *
8
8
  * @param chatId Chat ID or username
9
9
  * @param enabled Whether the supergroup should be a forum
10
+ * @deprecated Use {@link updateForumSettings} instead
10
11
  */
11
12
  export declare function toggleForum(client: ITelegramClient, chatId: InputPeerLike, enabled?: boolean): Promise<void>;
13
+ /**
14
+ * Update forum settings of a supergroup.
15
+ *
16
+ * Only owner of the supergroup can change this setting.
17
+ *
18
+ * @param chatId Chat ID or username
19
+ * @param settings New settings. `null` is a shorthand for `{ isForum: false }`
20
+ */
21
+ export declare function updateForumSettings(client: ITelegramClient, chatId: InputPeerLike, settings: null | {
22
+ /** Whether the supergroup should be a forum */
23
+ isForum: boolean;
24
+ threadsMode: 'list' | 'tabs';
25
+ }): Promise<void>;
@@ -7,5 +7,19 @@ import { InputPeerLike } from '../../types/index.js';
7
7
  *
8
8
  * @param chatId Chat ID or username
9
9
  * @param enabled Whether the supergroup should be a forum
10
+ * @deprecated Use {@link updateForumSettings} instead
10
11
  */
11
12
  export declare function toggleForum(client: ITelegramClient, chatId: InputPeerLike, enabled?: boolean): Promise<void>;
13
+ /**
14
+ * Update forum settings of a supergroup.
15
+ *
16
+ * Only owner of the supergroup can change this setting.
17
+ *
18
+ * @param chatId Chat ID or username
19
+ * @param settings New settings. `null` is a shorthand for `{ isForum: false }`
20
+ */
21
+ export declare function updateForumSettings(client: ITelegramClient, chatId: InputPeerLike, settings: null | {
22
+ /** Whether the supergroup should be a forum */
23
+ isForum: boolean;
24
+ threadsMode: 'list' | 'tabs';
25
+ }): Promise<void>;
@@ -3,10 +3,21 @@ async function toggleForum(client, chatId, enabled = false) {
3
3
  const res = await client.call({
4
4
  _: "channels.toggleForum",
5
5
  channel: await resolveChannel(client, chatId),
6
- enabled
6
+ enabled,
7
+ tabs: false
8
+ });
9
+ client.handleClientUpdate(res);
10
+ }
11
+ async function updateForumSettings(client, chatId, settings) {
12
+ const res = await client.call({
13
+ _: "channels.toggleForum",
14
+ channel: await resolveChannel(client, chatId),
15
+ enabled: settings?.isForum ?? false,
16
+ tabs: settings?.threadsMode === "tabs"
7
17
  });
8
18
  client.handleClientUpdate(res);
9
19
  }
10
20
  export {
11
- toggleForum
21
+ toggleForum,
22
+ updateForumSettings
12
23
  };
@@ -26,7 +26,9 @@ async function forwardMessagesById(client, params) {
26
26
  noAuthor,
27
27
  noCaption,
28
28
  allowPaidFloodskip,
29
- videoTimestamp
29
+ videoTimestamp,
30
+ toThreadId,
31
+ toMonoforumPeer
30
32
  } = params;
31
33
  if (messages.length > 100) {
32
34
  throw new errors.MtArgumentError("You can forward no more than 100 messages at once");
@@ -48,7 +50,12 @@ async function forwardMessagesById(client, params) {
48
50
  quickReplyShortcut: sendCommon._normalizeQuickReplyShortcut(params.quickReply),
49
51
  allowPaidFloodskip,
50
52
  videoTimestamp,
51
- allowPaidStars: params.allowPaidMessages
53
+ allowPaidStars: params.allowPaidMessages,
54
+ topMsgId: toThreadId,
55
+ replyTo: toMonoforumPeer ? {
56
+ _: "inputReplyToMonoForum",
57
+ monoforumPeerId: await resolvePeer.resolvePeer(client, toMonoforumPeer)
58
+ } : void 0
52
59
  });
53
60
  utils.assertIsUpdatesGroup("messages.forwardMessages", res);
54
61
  client.handleClientUpdate(res, !params.shouldDispatch);
@@ -4,6 +4,13 @@ import { InputPeerLike, Message } from '../../types/index.js';
4
4
  export interface ForwardMessageOptions {
5
5
  /** Destination chat ID, username, phone, `"me"` or `"self"` */
6
6
  toChatId: InputPeerLike;
7
+ /** When forwarding to forums, ID of the thread to forward to */
8
+ toThreadId?: number;
9
+ /**
10
+ * When forwarding to a monoforum you are an admin of,
11
+ * you **must** pass an ID of a peer you are sending the message to.
12
+ */
13
+ toMonoforumPeer?: InputPeerLike;
7
14
  /**
8
15
  * Whether to forward silently (also applies to caption message).
9
16
  */
@@ -4,6 +4,13 @@ import { InputPeerLike, Message } from '../../types/index.js';
4
4
  export interface ForwardMessageOptions {
5
5
  /** Destination chat ID, username, phone, `"me"` or `"self"` */
6
6
  toChatId: InputPeerLike;
7
+ /** When forwarding to forums, ID of the thread to forward to */
8
+ toThreadId?: number;
9
+ /**
10
+ * When forwarding to a monoforum you are an admin of,
11
+ * you **must** pass an ID of a peer you are sending the message to.
12
+ */
13
+ toMonoforumPeer?: InputPeerLike;
7
14
  /**
8
15
  * Whether to forward silently (also applies to caption message).
9
16
  */
@@ -19,7 +19,9 @@ async function forwardMessagesById(client, params) {
19
19
  noAuthor,
20
20
  noCaption,
21
21
  allowPaidFloodskip,
22
- videoTimestamp
22
+ videoTimestamp,
23
+ toThreadId,
24
+ toMonoforumPeer
23
25
  } = params;
24
26
  if (messages.length > 100) {
25
27
  throw new MtArgumentError("You can forward no more than 100 messages at once");
@@ -41,7 +43,12 @@ async function forwardMessagesById(client, params) {
41
43
  quickReplyShortcut: _normalizeQuickReplyShortcut(params.quickReply),
42
44
  allowPaidFloodskip,
43
45
  videoTimestamp,
44
- allowPaidStars: params.allowPaidMessages
46
+ allowPaidStars: params.allowPaidMessages,
47
+ topMsgId: toThreadId,
48
+ replyTo: toMonoforumPeer ? {
49
+ _: "inputReplyToMonoForum",
50
+ monoforumPeerId: await resolvePeer(client, toMonoforumPeer)
51
+ } : void 0
45
52
  });
46
53
  assertIsUpdatesGroup("messages.forwardMessages", res);
47
54
  client.handleClientUpdate(res, !params.shouldDispatch);
@@ -55,7 +55,13 @@ async function _processCommonSendParameters(client, chatId, params) {
55
55
  replyToPeerId: replyToPeer,
56
56
  quoteText: params.quote?.text,
57
57
  quoteEntities: params.quote?.entities,
58
- quoteOffset: params.quoteOffset
58
+ quoteOffset: params.quoteOffset,
59
+ monoforumPeerId: params.toMonoforumPeer ? await resolvePeer.resolvePeer(client, params.toMonoforumPeer) : void 0
60
+ };
61
+ } else if (params.toMonoforumPeer) {
62
+ tlReplyTo = {
63
+ _: "inputReplyToMonoForum",
64
+ monoforumPeerId: await resolvePeer.resolvePeer(client, params.toMonoforumPeer)
59
65
  };
60
66
  } else if (params.replyToStory) {
61
67
  tlReplyTo = {
@@ -12,6 +12,13 @@ export interface CommonSendParams {
12
12
  * Can also be a message from another chat, in which case a quote will be sent.
13
13
  */
14
14
  replyTo?: number | Message;
15
+ /**
16
+ * When the chat is a monoforum you are an admin of, you **must** pass an
17
+ * ID of a peer you are sending the message to.
18
+ *
19
+ * Otherwise, you will get a `REPLY_TO_MONOFORUM_PEER_INVALID` error.
20
+ */
21
+ toMonoforumPeer?: InputPeerLike;
15
22
  /**
16
23
  * Whether to throw an error if {@link replyTo}
17
24
  * message does not exist.
@@ -12,6 +12,13 @@ export interface CommonSendParams {
12
12
  * Can also be a message from another chat, in which case a quote will be sent.
13
13
  */
14
14
  replyTo?: number | Message;
15
+ /**
16
+ * When the chat is a monoforum you are an admin of, you **must** pass an
17
+ * ID of a peer you are sending the message to.
18
+ *
19
+ * Otherwise, you will get a `REPLY_TO_MONOFORUM_PEER_INVALID` error.
20
+ */
21
+ toMonoforumPeer?: InputPeerLike;
15
22
  /**
16
23
  * Whether to throw an error if {@link replyTo}
17
24
  * message does not exist.
@@ -48,7 +48,13 @@ async function _processCommonSendParameters(client, chatId, params) {
48
48
  replyToPeerId: replyToPeer,
49
49
  quoteText: params.quote?.text,
50
50
  quoteEntities: params.quote?.entities,
51
- quoteOffset: params.quoteOffset
51
+ quoteOffset: params.quoteOffset,
52
+ monoforumPeerId: params.toMonoforumPeer ? await resolvePeer(client, params.toMonoforumPeer) : void 0
53
+ };
54
+ } else if (params.toMonoforumPeer) {
55
+ tlReplyTo = {
56
+ _: "inputReplyToMonoForum",
57
+ monoforumPeerId: await resolvePeer(client, params.toMonoforumPeer)
52
58
  };
53
59
  } else if (params.replyToStory) {
54
60
  tlReplyTo = {
@@ -53,6 +53,7 @@ export { getChatPreview } from './methods/chats/get-chat-preview.js';
53
53
  export { getChat } from './methods/chats/get-chat.js';
54
54
  export { getFullChat } from './methods/chats/get-full-chat.js';
55
55
  export { getFullUser } from './methods/chats/get-full-user.js';
56
+ export { getMessageAuthor } from './methods/chats/get-message-author.js';
56
57
  export { getNearbyChats } from './methods/chats/get-nearby-chats.js';
57
58
  export { getPeer } from './methods/chats/get-peer.js';
58
59
  export { getSimilarChannels } from './methods/chats/get-similar-channels.js';
@@ -115,6 +116,7 @@ export { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-
115
116
  export { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed.js';
116
117
  export { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned.js';
117
118
  export { toggleForum } from './methods/forums/toggle-forum.js';
119
+ export { updateForumSettings } from './methods/forums/toggle-forum.js';
118
120
  export { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden.js';
119
121
  export { createInviteLink } from './methods/invite-links/create-invite-link.js';
120
122
  export { editInviteLink } from './methods/invite-links/edit-invite-link.js';
@@ -53,6 +53,7 @@ export { getChatPreview } from './methods/chats/get-chat-preview.js';
53
53
  export { getChat } from './methods/chats/get-chat.js';
54
54
  export { getFullChat } from './methods/chats/get-full-chat.js';
55
55
  export { getFullUser } from './methods/chats/get-full-user.js';
56
+ export { getMessageAuthor } from './methods/chats/get-message-author.js';
56
57
  export { getNearbyChats } from './methods/chats/get-nearby-chats.js';
57
58
  export { getPeer } from './methods/chats/get-peer.js';
58
59
  export { getSimilarChannels } from './methods/chats/get-similar-channels.js';
@@ -115,6 +116,7 @@ export { reorderPinnedForumTopics } from './methods/forums/reorder-pinned-forum-
115
116
  export { toggleForumTopicClosed } from './methods/forums/toggle-forum-topic-closed.js';
116
117
  export { toggleForumTopicPinned } from './methods/forums/toggle-forum-topic-pinned.js';
117
118
  export { toggleForum } from './methods/forums/toggle-forum.js';
119
+ export { updateForumSettings } from './methods/forums/toggle-forum.js';
118
120
  export { toggleGeneralTopicHidden } from './methods/forums/toggle-general-topic-hidden.js';
119
121
  export { createInviteLink } from './methods/invite-links/create-invite-link.js';
120
122
  export { editInviteLink } from './methods/invite-links/edit-invite-link.js';
@@ -70,6 +70,7 @@ function geoLive(latitude, longitude, params = {}) {
70
70
  function dice(emoji, params) {
71
71
  const ret = params;
72
72
  ret.type = "dice";
73
+ ret.emoji = emoji;
73
74
  return ret;
74
75
  }
75
76
  function contact(params) {
@@ -63,6 +63,7 @@ function geoLive(latitude, longitude, params = {}) {
63
63
  function dice(emoji, params) {
64
64
  const ret = params;
65
65
  ret.type = "dice";
66
+ ret.emoji = emoji;
66
67
  return ret;
67
68
  }
68
69
  function contact(params) {
@@ -441,6 +441,8 @@ export interface ActionPaidMessagesPaid {
441
441
  readonly type: 'messages_paid';
442
442
  /** Amount of Telegram Stars paid */
443
443
  stars: tl.Long;
444
+ /** Whether the stars were paid for a direct message to channel administrators */
445
+ broadcastDirect?: boolean;
444
446
  }
445
447
  /** Paid messages were refunded */
446
448
  export interface ActionPaidMessagesRefunded {
@@ -441,6 +441,8 @@ export interface ActionPaidMessagesPaid {
441
441
  readonly type: 'messages_paid';
442
442
  /** Amount of Telegram Stars paid */
443
443
  stars: tl.Long;
444
+ /** Whether the stars were paid for a direct message to channel administrators */
445
+ broadcastDirect?: boolean;
444
446
  }
445
447
  /** Paid messages were refunded */
446
448
  export interface ActionPaidMessagesRefunded {
@@ -108,6 +108,8 @@ class Chat {
108
108
  case "channelForbidden":
109
109
  if (this.raw._ === "channel" && this.raw.gigagroup) {
110
110
  return "gigagroup";
111
+ } else if (this.raw._ === "channel" && this.raw.monoforum) {
112
+ return "monoforum";
111
113
  } else if (this.raw.broadcast) {
112
114
  return "channel";
113
115
  } else if (this.raw.megagroup) {
@@ -242,6 +244,23 @@ class Chat {
242
244
  get hasAutoTranslation() {
243
245
  return this.raw._ === "channel" && this.raw.autotranslation;
244
246
  }
247
+ /** Whether this forum should display threads as tabs instead of a list */
248
+ get hasForumTabs() {
249
+ return this.raw._ === "channel" && this.raw.forumTabs;
250
+ }
251
+ /** Whether this broadcast channel has direct messages to channel administrators enabled */
252
+ get hasBroadcastDirect() {
253
+ return this.raw._ === "channel" && this.raw.broadcastMessagesAllowed;
254
+ }
255
+ /**
256
+ * Depending on {@link chatType}:
257
+ * - `channel`: this field might contain the ID of the linked monoforum,
258
+ * if this broadcast channel has a linked monoforum
259
+ * - `monoforum`: this field contains the ID of the channel that this monoforum is linked to
260
+ */
261
+ get monoforumLinkedChatId() {
262
+ return this.raw._ === "channel" ? this.raw.linkedMonoforumId ?? null : null;
263
+ }
245
264
  /** Chat title */
246
265
  get title() {
247
266
  return this.raw.title;
@@ -10,8 +10,9 @@ import { ChatPhoto } from './chat-photo.js';
10
10
  * - `supergroup`: Supergroup
11
11
  * - `channel`: Broadcast channel
12
12
  * - `gigagroup`: Gigagroup aka Broadcast group
13
+ * - `monoforum`: Monoforum (chat for direct messages to channel administrators)
13
14
  */
14
- export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup';
15
+ export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup' | 'monoforum';
15
16
  /**
16
17
  * A chat.
17
18
  */
@@ -131,6 +132,17 @@ export declare class Chat {
131
132
  get hasSignatures(): boolean;
132
133
  /** Whether this chat/channel has auto-translation enabled */
133
134
  get hasAutoTranslation(): boolean;
135
+ /** Whether this forum should display threads as tabs instead of a list */
136
+ get hasForumTabs(): boolean;
137
+ /** Whether this broadcast channel has direct messages to channel administrators enabled */
138
+ get hasBroadcastDirect(): boolean;
139
+ /**
140
+ * Depending on {@link chatType}:
141
+ * - `channel`: this field might contain the ID of the linked monoforum,
142
+ * if this broadcast channel has a linked monoforum
143
+ * - `monoforum`: this field contains the ID of the channel that this monoforum is linked to
144
+ */
145
+ get monoforumLinkedChatId(): number | null;
134
146
  /** Chat title */
135
147
  get title(): string;
136
148
  /** Chat username (if available) */
@@ -10,8 +10,9 @@ import { ChatPhoto } from './chat-photo.js';
10
10
  * - `supergroup`: Supergroup
11
11
  * - `channel`: Broadcast channel
12
12
  * - `gigagroup`: Gigagroup aka Broadcast group
13
+ * - `monoforum`: Monoforum (chat for direct messages to channel administrators)
13
14
  */
14
- export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup';
15
+ export type ChatType = 'group' | 'supergroup' | 'channel' | 'gigagroup' | 'monoforum';
15
16
  /**
16
17
  * A chat.
17
18
  */
@@ -131,6 +132,17 @@ export declare class Chat {
131
132
  get hasSignatures(): boolean;
132
133
  /** Whether this chat/channel has auto-translation enabled */
133
134
  get hasAutoTranslation(): boolean;
135
+ /** Whether this forum should display threads as tabs instead of a list */
136
+ get hasForumTabs(): boolean;
137
+ /** Whether this broadcast channel has direct messages to channel administrators enabled */
138
+ get hasBroadcastDirect(): boolean;
139
+ /**
140
+ * Depending on {@link chatType}:
141
+ * - `channel`: this field might contain the ID of the linked monoforum,
142
+ * if this broadcast channel has a linked monoforum
143
+ * - `monoforum`: this field contains the ID of the channel that this monoforum is linked to
144
+ */
145
+ get monoforumLinkedChatId(): number | null;
134
146
  /** Chat title */
135
147
  get title(): string;
136
148
  /** Chat username (if available) */
@@ -101,6 +101,8 @@ class Chat {
101
101
  case "channelForbidden":
102
102
  if (this.raw._ === "channel" && this.raw.gigagroup) {
103
103
  return "gigagroup";
104
+ } else if (this.raw._ === "channel" && this.raw.monoforum) {
105
+ return "monoforum";
104
106
  } else if (this.raw.broadcast) {
105
107
  return "channel";
106
108
  } else if (this.raw.megagroup) {
@@ -235,6 +237,23 @@ class Chat {
235
237
  get hasAutoTranslation() {
236
238
  return this.raw._ === "channel" && this.raw.autotranslation;
237
239
  }
240
+ /** Whether this forum should display threads as tabs instead of a list */
241
+ get hasForumTabs() {
242
+ return this.raw._ === "channel" && this.raw.forumTabs;
243
+ }
244
+ /** Whether this broadcast channel has direct messages to channel administrators enabled */
245
+ get hasBroadcastDirect() {
246
+ return this.raw._ === "channel" && this.raw.broadcastMessagesAllowed;
247
+ }
248
+ /**
249
+ * Depending on {@link chatType}:
250
+ * - `channel`: this field might contain the ID of the linked monoforum,
251
+ * if this broadcast channel has a linked monoforum
252
+ * - `monoforum`: this field contains the ID of the channel that this monoforum is linked to
253
+ */
254
+ get monoforumLinkedChatId() {
255
+ return this.raw._ === "channel" ? this.raw.linkedMonoforumId ?? null : null;
256
+ }
238
257
  /** Chat title */
239
258
  get title() {
240
259
  return this.raw.title;
@@ -253,6 +253,16 @@ class FullChat extends chat.Chat {
253
253
  if (!this.full.linkedChatId) return null;
254
254
  return new chat.Chat(this.peers.chat(this.full.linkedChatId));
255
255
  }
256
+ /**
257
+ * Information about a linked monoforum chat:
258
+ * - for channels: the linked monoforum
259
+ * - for monoforums: the channel this monoforum is linked to
260
+ */
261
+ get monoforumLinkedChat() {
262
+ if (this.raw._ !== "channel") return null;
263
+ if (!this.raw.linkedMonoforumId) return null;
264
+ return new chat.Chat(this.peers.chat(this.raw.linkedMonoforumId));
265
+ }
256
266
  /**
257
267
  * TTL of all messages in this chat, in seconds
258
268
  */
@@ -138,6 +138,12 @@ export declare class FullChat extends Chat {
138
138
  * - for supergroups: the linked channel
139
139
  */
140
140
  get linkedChat(): Chat | null;
141
+ /**
142
+ * Information about a linked monoforum chat:
143
+ * - for channels: the linked monoforum
144
+ * - for monoforums: the channel this monoforum is linked to
145
+ */
146
+ get monoforumLinkedChat(): Chat | null;
141
147
  /**
142
148
  * TTL of all messages in this chat, in seconds
143
149
  */