@mtcute/core 0.29.6 → 0.29.7

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 (62) hide show
  1. package/client.cjs +8 -0
  2. package/client.js +8 -0
  3. package/highlevel/client.d.cts +19 -1
  4. package/highlevel/client.d.ts +19 -1
  5. package/highlevel/methods/bots/answer-bot-guest-chat-query.cjs +26 -0
  6. package/highlevel/methods/bots/answer-bot-guest-chat-query.d.cts +12 -0
  7. package/highlevel/methods/bots/answer-bot-guest-chat-query.d.ts +12 -0
  8. package/highlevel/methods/bots/answer-bot-guest-chat-query.js +21 -0
  9. package/highlevel/methods/messages/send-copy-group.cjs +5 -9
  10. package/highlevel/methods/messages/send-copy-group.js +5 -9
  11. package/highlevel/methods.d.cts +1 -0
  12. package/highlevel/methods.d.ts +1 -0
  13. package/highlevel/storage/service/peers.cjs +1 -0
  14. package/highlevel/storage/service/peers.js +1 -0
  15. package/highlevel/types/media/poll.cjs +14 -0
  16. package/highlevel/types/media/poll.d.cts +6 -0
  17. package/highlevel/types/media/poll.d.ts +6 -0
  18. package/highlevel/types/media/poll.js +14 -0
  19. package/highlevel/types/messages/message.cjs +10 -1
  20. package/highlevel/types/messages/message.d.cts +5 -0
  21. package/highlevel/types/messages/message.d.ts +5 -0
  22. package/highlevel/types/messages/message.js +10 -1
  23. package/highlevel/types/peers/chat-permissions.cjs +6 -0
  24. package/highlevel/types/peers/chat-permissions.d.cts +4 -0
  25. package/highlevel/types/peers/chat-permissions.d.ts +4 -0
  26. package/highlevel/types/peers/chat-permissions.js +6 -0
  27. package/highlevel/types/peers/user.cjs +4 -0
  28. package/highlevel/types/peers/user.d.cts +2 -0
  29. package/highlevel/types/peers/user.d.ts +2 -0
  30. package/highlevel/types/peers/user.js +4 -0
  31. package/highlevel/types/updates/bot-guest-chat-query.cjs +39 -0
  32. package/highlevel/types/updates/bot-guest-chat-query.d.cts +21 -0
  33. package/highlevel/types/updates/bot-guest-chat-query.d.ts +21 -0
  34. package/highlevel/types/updates/bot-guest-chat-query.js +34 -0
  35. package/highlevel/types/updates/index.d.cts +5 -1
  36. package/highlevel/types/updates/index.d.ts +5 -1
  37. package/highlevel/types/updates/parse-update.cjs +3 -0
  38. package/highlevel/types/updates/parse-update.js +3 -0
  39. package/highlevel/updates/manager.cjs +23 -3
  40. package/highlevel/updates/manager.d.cts +1 -0
  41. package/highlevel/updates/manager.d.ts +1 -0
  42. package/highlevel/updates/manager.js +23 -3
  43. package/index.cjs +2 -0
  44. package/index.js +2 -0
  45. package/methods.cjs +2 -0
  46. package/methods.js +2 -0
  47. package/network/network-manager.cjs +1 -1
  48. package/network/network-manager.js +1 -1
  49. package/package.json +1 -1
  50. package/tl/api-schema.json +1 -1
  51. package/tl/binary/reader.cjs +85 -40
  52. package/tl/binary/reader.js +85 -40
  53. package/tl/binary/writer.cjs +349 -143
  54. package/tl/binary/writer.js +349 -143
  55. package/tl/compat/reader.cjs +8 -0
  56. package/tl/compat/reader.js +8 -0
  57. package/tl/index.d.cts +2071 -179
  58. package/tl/index.d.ts +2071 -179
  59. package/tl/inner-tl.cjs +17 -5
  60. package/tl/inner-tl.js +17 -5
  61. package/utils/binary/compat.cjs +5 -0
  62. package/utils/binary/compat.js +5 -0
@@ -0,0 +1,39 @@
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 message = require("../messages/message.cjs");
10
+ const inspectable = require("../../utils/inspectable.cjs");
11
+ class BotGuestChatQuery {
12
+ constructor(raw, _peers) {
13
+ this.raw = raw;
14
+ this._peers = _peers;
15
+ }
16
+ /**
17
+ * Unique query ID
18
+ */
19
+ get id() {
20
+ return this.raw.queryId;
21
+ }
22
+ /**
23
+ * Message containing the query that was sent to the bot
24
+ */
25
+ get message() {
26
+ return new message.Message(this.raw.message, this._peers);
27
+ }
28
+ /** Message that {@link message} is a reply to, if available */
29
+ get replyToMessage() {
30
+ if (!this.message.replyToMessage || !this.raw.referenceMessages) return null;
31
+ if (!this.message.replyToMessage.originIs("same_chat")) return null;
32
+ const replyToId = this.message.replyToMessage.id;
33
+ const raw = this.raw.referenceMessages.find((it) => it.id === replyToId);
34
+ return raw ? new message.Message(raw, this._peers) : null;
35
+ }
36
+ }
37
+ const BotGuestChatQuery$1 = /* @__PURE__ */ memoize.memoizeGetters(BotGuestChatQuery, ["message", "replyToMessage"]);
38
+ const BotGuestChatQuery$2 = /* @__PURE__ */ inspectable.makeInspectable(BotGuestChatQuery$1);
39
+ exports.BotGuestChatQuery = BotGuestChatQuery$2;
@@ -0,0 +1,21 @@
1
+ import { tl } from '../../../tl/index.js';
2
+ import { PeersIndex } from '../peers/index.js';
3
+ import { Message } from '../messages/message.js';
4
+ /**
5
+ * Query received in a bot guest chat
6
+ */
7
+ export declare class BotGuestChatQuery {
8
+ readonly raw: tl.RawUpdateBotGuestChatQuery;
9
+ readonly _peers: PeersIndex;
10
+ constructor(raw: tl.RawUpdateBotGuestChatQuery, _peers: PeersIndex);
11
+ /**
12
+ * Unique query ID
13
+ */
14
+ get id(): tl.Long;
15
+ /**
16
+ * Message containing the query that was sent to the bot
17
+ */
18
+ get message(): Message;
19
+ /** Message that {@link message} is a reply to, if available */
20
+ get replyToMessage(): Message | null;
21
+ }
@@ -0,0 +1,21 @@
1
+ import { tl } from '../../../tl/index.js';
2
+ import { PeersIndex } from '../peers/index.js';
3
+ import { Message } from '../messages/message.js';
4
+ /**
5
+ * Query received in a bot guest chat
6
+ */
7
+ export declare class BotGuestChatQuery {
8
+ readonly raw: tl.RawUpdateBotGuestChatQuery;
9
+ readonly _peers: PeersIndex;
10
+ constructor(raw: tl.RawUpdateBotGuestChatQuery, _peers: PeersIndex);
11
+ /**
12
+ * Unique query ID
13
+ */
14
+ get id(): tl.Long;
15
+ /**
16
+ * Message containing the query that was sent to the bot
17
+ */
18
+ get message(): Message;
19
+ /** Message that {@link message} is a reply to, if available */
20
+ get replyToMessage(): Message | null;
21
+ }
@@ -0,0 +1,34 @@
1
+ import { memoizeGetters } from "../../utils/memoize.js";
2
+ import { Message as Message$2 } from "../messages/message.js";
3
+ import { makeInspectable } from "../../utils/inspectable.js";
4
+ class BotGuestChatQuery {
5
+ constructor(raw, _peers) {
6
+ this.raw = raw;
7
+ this._peers = _peers;
8
+ }
9
+ /**
10
+ * Unique query ID
11
+ */
12
+ get id() {
13
+ return this.raw.queryId;
14
+ }
15
+ /**
16
+ * Message containing the query that was sent to the bot
17
+ */
18
+ get message() {
19
+ return new Message$2(this.raw.message, this._peers);
20
+ }
21
+ /** Message that {@link message} is a reply to, if available */
22
+ get replyToMessage() {
23
+ if (!this.message.replyToMessage || !this.raw.referenceMessages) return null;
24
+ if (!this.message.replyToMessage.originIs("same_chat")) return null;
25
+ const replyToId = this.message.replyToMessage.id;
26
+ const raw = this.raw.referenceMessages.find((it) => it.id === replyToId);
27
+ return raw ? new Message$2(raw, this._peers) : null;
28
+ }
29
+ }
30
+ const BotGuestChatQuery$1 = /* @__PURE__ */ memoizeGetters(BotGuestChatQuery, ["message", "replyToMessage"]);
31
+ const BotGuestChatQuery$2 = /* @__PURE__ */ makeInspectable(BotGuestChatQuery$1);
32
+ export {
33
+ BotGuestChatQuery$2 as BotGuestChatQuery
34
+ };
@@ -1,5 +1,6 @@
1
1
  import { BusinessConnection, Message } from '../../types/index.js';
2
2
  import { BotChatJoinRequestUpdate } from './bot-chat-join-request.js';
3
+ import { BotGuestChatQuery } from './bot-guest-chat-query.js';
3
4
  import { BotReactionCountUpdate, BotReactionUpdate } from './bot-reaction.js';
4
5
  import { BotStoppedUpdate } from './bot-stopped.js';
5
6
  import { BusinessMessage } from './business-message.js';
@@ -19,7 +20,7 @@ import { StoryUpdate } from './story-update.js';
19
20
  import { UserStatusUpdate } from './user-status-update.js';
20
21
  import { UserTypingUpdate } from './user-typing-update.js';
21
22
  export type { ChatMemberUpdateType } from './chat-member-update.js';
22
- export { BotChatJoinRequestUpdate, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessMessage, CallbackQuery, ChatJoinRequestUpdate, ChatMemberUpdate, ChosenInlineResult, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, PollUpdate, PollVoteUpdate, PreCheckoutQuery, StoryUpdate, UserStatusUpdate, UserTypingUpdate, };
23
+ export { BotChatJoinRequestUpdate, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessMessage, CallbackQuery, ChatJoinRequestUpdate, ChatMemberUpdate, ChosenInlineResult, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, PollUpdate, PollVoteUpdate, PreCheckoutQuery, StoryUpdate, UserStatusUpdate, UserTypingUpdate, };
23
24
  export type ParsedUpdate = {
24
25
  name: 'new_message';
25
26
  data: Message;
@@ -38,6 +39,9 @@ export type ParsedUpdate = {
38
39
  } | {
39
40
  name: 'inline_query';
40
41
  data: InlineQuery;
42
+ } | {
43
+ name: 'bot_guest_chat_query';
44
+ data: BotGuestChatQuery;
41
45
  } | {
42
46
  name: 'chosen_inline_result';
43
47
  data: ChosenInlineResult;
@@ -1,5 +1,6 @@
1
1
  import { BusinessConnection, Message } from '../../types/index.js';
2
2
  import { BotChatJoinRequestUpdate } from './bot-chat-join-request.js';
3
+ import { BotGuestChatQuery } from './bot-guest-chat-query.js';
3
4
  import { BotReactionCountUpdate, BotReactionUpdate } from './bot-reaction.js';
4
5
  import { BotStoppedUpdate } from './bot-stopped.js';
5
6
  import { BusinessMessage } from './business-message.js';
@@ -19,7 +20,7 @@ import { StoryUpdate } from './story-update.js';
19
20
  import { UserStatusUpdate } from './user-status-update.js';
20
21
  import { UserTypingUpdate } from './user-typing-update.js';
21
22
  export type { ChatMemberUpdateType } from './chat-member-update.js';
22
- export { BotChatJoinRequestUpdate, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessMessage, CallbackQuery, ChatJoinRequestUpdate, ChatMemberUpdate, ChosenInlineResult, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, PollUpdate, PollVoteUpdate, PreCheckoutQuery, StoryUpdate, UserStatusUpdate, UserTypingUpdate, };
23
+ export { BotChatJoinRequestUpdate, BotGuestChatQuery, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessMessage, CallbackQuery, ChatJoinRequestUpdate, ChatMemberUpdate, ChosenInlineResult, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, PollUpdate, PollVoteUpdate, PreCheckoutQuery, StoryUpdate, UserStatusUpdate, UserTypingUpdate, };
23
24
  export type ParsedUpdate = {
24
25
  name: 'new_message';
25
26
  data: Message;
@@ -38,6 +39,9 @@ export type ParsedUpdate = {
38
39
  } | {
39
40
  name: 'inline_query';
40
41
  data: InlineQuery;
42
+ } | {
43
+ name: 'bot_guest_chat_query';
44
+ data: BotGuestChatQuery;
41
45
  } | {
42
46
  name: 'chosen_inline_result';
43
47
  data: ChosenInlineResult;
@@ -7,6 +7,7 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  const callbackQuery = require("./callback-query.cjs");
9
9
  const botChatJoinRequest = require("./bot-chat-join-request.cjs");
10
+ const botGuestChatQuery = require("./bot-guest-chat-query.cjs");
10
11
  const botReaction = require("./bot-reaction.cjs");
11
12
  const botStopped = require("./bot-stopped.cjs");
12
13
  const businessMessage = require("./business-message.cjs");
@@ -43,6 +44,8 @@ function _parseUpdate({ update, peers }) {
43
44
  return { name: "chat_member", data: new chatMemberUpdate.ChatMemberUpdate(update, peers) };
44
45
  case "updateBotInlineQuery":
45
46
  return { name: "inline_query", data: new inlineQuery.InlineQuery(update, peers) };
47
+ case "updateBotGuestChatQuery":
48
+ return { name: "bot_guest_chat_query", data: new botGuestChatQuery.BotGuestChatQuery(update, peers) };
46
49
  case "updateBotInlineSend":
47
50
  return { name: "chosen_inline_result", data: new chosenInlineResult.ChosenInlineResult(update, peers) };
48
51
  case "updateBotCallbackQuery":
@@ -1,5 +1,6 @@
1
1
  import { BusinessCallbackQuery as BusinessCallbackQuery$2, InlineCallbackQuery as InlineCallbackQuery$2, CallbackQuery as CallbackQuery$2 } from "./callback-query.js";
2
2
  import { BotChatJoinRequestUpdate as BotChatJoinRequestUpdate$2 } from "./bot-chat-join-request.js";
3
+ import { BotGuestChatQuery as BotGuestChatQuery$2 } from "./bot-guest-chat-query.js";
3
4
  import { BotReactionCountUpdate as BotReactionCountUpdate$2, BotReactionUpdate as BotReactionUpdate$2 } from "./bot-reaction.js";
4
5
  import { BotStoppedUpdate as BotStoppedUpdate$2 } from "./bot-stopped.js";
5
6
  import { BusinessMessage } from "./business-message.js";
@@ -36,6 +37,8 @@ function _parseUpdate({ update, peers }) {
36
37
  return { name: "chat_member", data: new ChatMemberUpdate$2(update, peers) };
37
38
  case "updateBotInlineQuery":
38
39
  return { name: "inline_query", data: new InlineQuery$2(update, peers) };
40
+ case "updateBotGuestChatQuery":
41
+ return { name: "bot_guest_chat_query", data: new BotGuestChatQuery$2(update, peers) };
39
42
  case "updateBotInlineSend":
40
43
  return { name: "chosen_inline_result", data: new ChosenInlineResult$2(update, peers) };
41
44
  case "updateBotCallbackQuery":
@@ -93,6 +93,9 @@ class UpdatesManager {
93
93
  cptsMod = /* @__PURE__ */ new Map();
94
94
  channelDiffTimeouts = /* @__PURE__ */ new Map();
95
95
  channelsOpened = /* @__PURE__ */ new Map();
96
+ // channels we got CHANNEL_PRIVATE for when fetching diff — skip gap handling.
97
+ // invalidated when an updateChannel for that channel arrives
98
+ inaccessibleChannels = /* @__PURE__ */ new Set();
96
99
  log;
97
100
  _onCatchingUp = () => {
98
101
  };
@@ -114,6 +117,7 @@ class UpdatesManager {
114
117
  this.stopLoop();
115
118
  this.cpts.clear();
116
119
  this.cptsMod.clear();
120
+ this.inaccessibleChannels.clear();
117
121
  this.pts = this.qts = this.date = this.seq = void 0;
118
122
  }
119
123
  async prepare() {
@@ -489,6 +493,7 @@ class UpdatesManager {
489
493
  return missing;
490
494
  }
491
495
  if (!await fetchPeer(msg.viaBotId)) return missing;
496
+ if (!await fetchPeer(msg.guestchatViaFrom)) return missing;
492
497
  if (msg.entities) {
493
498
  for (const ent of msg.entities) {
494
499
  if (ent._ === "messageEntityMentionName") {
@@ -567,6 +572,7 @@ class UpdatesManager {
567
572
  store(msg.fromId);
568
573
  if (msg._ === "message") {
569
574
  store(msg.viaBotId);
575
+ store(msg.guestchatViaFrom);
570
576
  store(msg.fwdFrom?.fromId);
571
577
  if (msg.media) {
572
578
  switch (msg.media._) {
@@ -732,14 +738,20 @@ class UpdatesManager {
732
738
  channelId,
733
739
  this._fetchChannelDifference(channelId, fallbackPts).catch((err) => {
734
740
  this.log.warn("error fetching difference for %d: %e", channelId, err);
735
- if (innerTl.RpcError.is("PERSISTENT_TIMESTAMP_INVALID")) {
741
+ if (innerTl.RpcError.is(err, "PERSISTENT_TIMESTAMP_INVALID")) {
736
742
  this.log.warn("received PERSISTENT_TIMESTAMP_INVALID, resetting channel pts value");
737
743
  this.cpts.delete(channelId);
738
744
  this.cptsMod.delete(channelId);
739
745
  }
746
+ if (innerTl.RpcError.is(err, "CHANNEL_PRIVATE") || innerTl.RpcError.is(err, "CHANNEL_INVALID")) {
747
+ this.log.debug("channel %d is inaccessible, skipping gap fills until updateChannel", channelId);
748
+ this.inaccessibleChannels.add(channelId);
749
+ this.cpts.delete(channelId);
750
+ this.cptsMod.delete(channelId);
751
+ }
740
752
  }).then((ok) => {
741
753
  requestedDiff.delete(channelId);
742
- if (!ok) {
754
+ if (!ok && !this.inaccessibleChannels.has(channelId)) {
743
755
  this.log.debug("channel difference for %d failed, falling back to common diff", channelId);
744
756
  this._fetchDifferenceLater(requestedDiff);
745
757
  }
@@ -940,6 +952,13 @@ class UpdatesManager {
940
952
  }
941
953
  break;
942
954
  }
955
+ case "updateChannel": {
956
+ const channel = pending.peers.chat(upd.channelId);
957
+ if (channel._ !== "channelForbidden") {
958
+ this.inaccessibleChannels.delete(upd.channelId);
959
+ }
960
+ break;
961
+ }
943
962
  case "updateConfig":
944
963
  client.mt.network.config.update(true).catch((err) => client.onError.emit(utils.unknownToError(err)));
945
964
  break;
@@ -1257,7 +1276,8 @@ class UpdatesManager {
1257
1276
  );
1258
1277
  continue;
1259
1278
  }
1260
- if (diff < 0) {
1279
+ const isInaccessibleChannel = pending.channelId && this.inaccessibleChannels.has(pending.channelId);
1280
+ if (diff < 0 && !isInaccessibleChannel) {
1261
1281
  if (diff > -3) {
1262
1282
  log.debug(
1263
1283
  "postponing %s for 0.5s (cid = %d) because small gap detected (by pts: exp %d, got %d, diff=%d)",
@@ -39,6 +39,7 @@ export declare class UpdatesManager {
39
39
  cptsMod: Map<number, number>;
40
40
  channelDiffTimeouts: Map<number, timers.Timer>;
41
41
  channelsOpened: Map<number, number>;
42
+ inaccessibleChannels: Set<number>;
42
43
  log: Logger;
43
44
  private _onCatchingUp;
44
45
  private _channelPtsLimit;
@@ -39,6 +39,7 @@ export declare class UpdatesManager {
39
39
  cptsMod: Map<number, number>;
40
40
  channelDiffTimeouts: Map<number, timers.Timer>;
41
41
  channelsOpened: Map<number, number>;
42
+ inaccessibleChannels: Set<number>;
42
43
  log: Logger;
43
44
  private _onCatchingUp;
44
45
  private _channelPtsLimit;
@@ -86,6 +86,9 @@ class UpdatesManager {
86
86
  cptsMod = /* @__PURE__ */ new Map();
87
87
  channelDiffTimeouts = /* @__PURE__ */ new Map();
88
88
  channelsOpened = /* @__PURE__ */ new Map();
89
+ // channels we got CHANNEL_PRIVATE for when fetching diff — skip gap handling.
90
+ // invalidated when an updateChannel for that channel arrives
91
+ inaccessibleChannels = /* @__PURE__ */ new Set();
89
92
  log;
90
93
  _onCatchingUp = () => {
91
94
  };
@@ -107,6 +110,7 @@ class UpdatesManager {
107
110
  this.stopLoop();
108
111
  this.cpts.clear();
109
112
  this.cptsMod.clear();
113
+ this.inaccessibleChannels.clear();
110
114
  this.pts = this.qts = this.date = this.seq = void 0;
111
115
  }
112
116
  async prepare() {
@@ -482,6 +486,7 @@ class UpdatesManager {
482
486
  return missing;
483
487
  }
484
488
  if (!await fetchPeer(msg.viaBotId)) return missing;
489
+ if (!await fetchPeer(msg.guestchatViaFrom)) return missing;
485
490
  if (msg.entities) {
486
491
  for (const ent of msg.entities) {
487
492
  if (ent._ === "messageEntityMentionName") {
@@ -560,6 +565,7 @@ class UpdatesManager {
560
565
  store(msg.fromId);
561
566
  if (msg._ === "message") {
562
567
  store(msg.viaBotId);
568
+ store(msg.guestchatViaFrom);
563
569
  store(msg.fwdFrom?.fromId);
564
570
  if (msg.media) {
565
571
  switch (msg.media._) {
@@ -725,14 +731,20 @@ class UpdatesManager {
725
731
  channelId,
726
732
  this._fetchChannelDifference(channelId, fallbackPts).catch((err) => {
727
733
  this.log.warn("error fetching difference for %d: %e", channelId, err);
728
- if (RpcError.is("PERSISTENT_TIMESTAMP_INVALID")) {
734
+ if (RpcError.is(err, "PERSISTENT_TIMESTAMP_INVALID")) {
729
735
  this.log.warn("received PERSISTENT_TIMESTAMP_INVALID, resetting channel pts value");
730
736
  this.cpts.delete(channelId);
731
737
  this.cptsMod.delete(channelId);
732
738
  }
739
+ if (RpcError.is(err, "CHANNEL_PRIVATE") || RpcError.is(err, "CHANNEL_INVALID")) {
740
+ this.log.debug("channel %d is inaccessible, skipping gap fills until updateChannel", channelId);
741
+ this.inaccessibleChannels.add(channelId);
742
+ this.cpts.delete(channelId);
743
+ this.cptsMod.delete(channelId);
744
+ }
733
745
  }).then((ok) => {
734
746
  requestedDiff.delete(channelId);
735
- if (!ok) {
747
+ if (!ok && !this.inaccessibleChannels.has(channelId)) {
736
748
  this.log.debug("channel difference for %d failed, falling back to common diff", channelId);
737
749
  this._fetchDifferenceLater(requestedDiff);
738
750
  }
@@ -933,6 +945,13 @@ class UpdatesManager {
933
945
  }
934
946
  break;
935
947
  }
948
+ case "updateChannel": {
949
+ const channel = pending.peers.chat(upd.channelId);
950
+ if (channel._ !== "channelForbidden") {
951
+ this.inaccessibleChannels.delete(upd.channelId);
952
+ }
953
+ break;
954
+ }
936
955
  case "updateConfig":
937
956
  client.mt.network.config.update(true).catch((err) => client.onError.emit(unknownToError(err)));
938
957
  break;
@@ -1250,7 +1269,8 @@ class UpdatesManager {
1250
1269
  );
1251
1270
  continue;
1252
1271
  }
1253
- if (diff < 0) {
1272
+ const isInaccessibleChannel = pending.channelId && this.inaccessibleChannels.has(pending.channelId);
1273
+ if (diff < 0 && !isInaccessibleChannel) {
1254
1274
  if (diff > -3) {
1255
1275
  log.debug(
1256
1276
  "postponing %s for 0.5s (cid = %d) because small gap detected (by pts: exp %d, got %d, diff=%d)",
package/index.cjs CHANGED
@@ -118,6 +118,7 @@ const storyInteractions = require("./highlevel/types/stories/story-interactions.
118
118
  const storyViewer = require("./highlevel/types/stories/story-viewer.cjs");
119
119
  const story$1 = require("./highlevel/types/stories/story.cjs");
120
120
  const botChatJoinRequest = require("./highlevel/types/updates/bot-chat-join-request.cjs");
121
+ const botGuestChatQuery = require("./highlevel/types/updates/bot-guest-chat-query.cjs");
121
122
  const botReaction = require("./highlevel/types/updates/bot-reaction.cjs");
122
123
  const botStopped = require("./highlevel/types/updates/bot-stopped.cjs");
123
124
  const callbackQuery = require("./highlevel/types/updates/callback-query.cjs");
@@ -297,6 +298,7 @@ exports.StoryViewer = storyViewer.StoryViewer;
297
298
  exports.StoryViewersList = storyViewer.StoryViewersList;
298
299
  exports.Story = story$1.Story;
299
300
  exports.BotChatJoinRequestUpdate = botChatJoinRequest.BotChatJoinRequestUpdate;
301
+ exports.BotGuestChatQuery = botGuestChatQuery.BotGuestChatQuery;
300
302
  exports.BotReactionCountUpdate = botReaction.BotReactionCountUpdate;
301
303
  exports.BotReactionUpdate = botReaction.BotReactionUpdate;
302
304
  exports.BotStoppedUpdate = botStopped.BotStoppedUpdate;
package/index.js CHANGED
@@ -111,6 +111,7 @@ import { StoryInteractions } from "./highlevel/types/stories/story-interactions.
111
111
  import { StoryRepost, StoryViewer, StoryViewersList } from "./highlevel/types/stories/story-viewer.js";
112
112
  import { Story } from "./highlevel/types/stories/story.js";
113
113
  import { BotChatJoinRequestUpdate } from "./highlevel/types/updates/bot-chat-join-request.js";
114
+ import { BotGuestChatQuery } from "./highlevel/types/updates/bot-guest-chat-query.js";
114
115
  import { BotReactionCountUpdate, BotReactionUpdate } from "./highlevel/types/updates/bot-reaction.js";
115
116
  import { BotStoppedUpdate } from "./highlevel/types/updates/bot-stopped.js";
116
117
  import { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery } from "./highlevel/types/updates/callback-query.js";
@@ -163,6 +164,7 @@ export {
163
164
  BoostStats,
164
165
  BotChatJoinRequestUpdate,
165
166
  inner as BotCommands,
167
+ BotGuestChatQuery,
166
168
  BotInfo,
167
169
  factories$1 as BotInline,
168
170
  factories as BotInlineMessage,
package/methods.cjs CHANGED
@@ -18,6 +18,7 @@ const signIn = require("./highlevel/methods/auth/sign-in.cjs");
18
18
  const startTest = require("./highlevel/methods/auth/start-test.cjs");
19
19
  const start = require("./highlevel/methods/auth/start.cjs");
20
20
  const utils = require("./highlevel/methods/auth/utils.cjs");
21
+ const answerBotGuestChatQuery = require("./highlevel/methods/bots/answer-bot-guest-chat-query.cjs");
21
22
  const answerCallbackQuery = require("./highlevel/methods/bots/answer-callback-query.cjs");
22
23
  const answerInlineQuery = require("./highlevel/methods/bots/answer-inline-query.cjs");
23
24
  const answerPreCheckoutQuery = require("./highlevel/methods/bots/answer-pre-checkout-query.cjs");
@@ -299,6 +300,7 @@ exports.signIn = signIn.signIn;
299
300
  exports.startTest = startTest.startTest;
300
301
  exports.start = start.start;
301
302
  exports.isSelfPeer = utils.isSelfPeer;
303
+ exports.answerBotGuestChatQuery = answerBotGuestChatQuery.answerBotGuestChatQuery;
302
304
  exports.answerCallbackQuery = answerCallbackQuery.answerCallbackQuery;
303
305
  exports.answerInlineQuery = answerInlineQuery.answerInlineQuery;
304
306
  exports.answerPreCheckoutQuery = answerPreCheckoutQuery.answerPreCheckoutQuery;
package/methods.js CHANGED
@@ -11,6 +11,7 @@ import { signIn } from "./highlevel/methods/auth/sign-in.js";
11
11
  import { startTest } from "./highlevel/methods/auth/start-test.js";
12
12
  import { start } from "./highlevel/methods/auth/start.js";
13
13
  import { isSelfPeer } from "./highlevel/methods/auth/utils.js";
14
+ import { answerBotGuestChatQuery } from "./highlevel/methods/bots/answer-bot-guest-chat-query.js";
14
15
  import { answerCallbackQuery } from "./highlevel/methods/bots/answer-callback-query.js";
15
16
  import { answerInlineQuery } from "./highlevel/methods/bots/answer-inline-query.js";
16
17
  import { answerPreCheckoutQuery } from "./highlevel/methods/bots/answer-pre-checkout-query.js";
@@ -289,6 +290,7 @@ export {
289
290
  addChatMembers,
290
291
  addContact,
291
292
  addStickerToSet,
293
+ answerBotGuestChatQuery,
292
294
  answerCallbackQuery,
293
295
  answerInlineQuery,
294
296
  answerMedia,
@@ -226,7 +226,7 @@ class NetworkManager {
226
226
  _: "initConnection",
227
227
  deviceModel,
228
228
  systemVersion: "1.0",
229
- appVersion: "0.29.6",
229
+ appVersion: "0.29.7",
230
230
  systemLangCode: "en",
231
231
  langPack: "",
232
232
  // "langPacks are for official apps only"
@@ -219,7 +219,7 @@ class NetworkManager {
219
219
  _: "initConnection",
220
220
  deviceModel,
221
221
  systemVersion: "1.0",
222
- appVersion: "0.29.6",
222
+ appVersion: "0.29.7",
223
223
  systemLangCode: "en",
224
224
  langPack: "",
225
225
  // "langPacks are for official apps only"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtcute/core",
3
3
  "type": "module",
4
- "version": "0.29.6",
4
+ "version": "0.29.7",
5
5
  "description": "Type-safe library for MTProto (Telegram API)",
6
6
  "license": "MIT",
7
7
  "scripts": {},