@mtcute/core 0.12.2 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/cjs/highlevel/client.d.ts +83 -2
  2. package/cjs/highlevel/client.js +20 -1
  3. package/cjs/highlevel/client.js.map +1 -1
  4. package/cjs/highlevel/methods/_imports.js.map +1 -1
  5. package/cjs/highlevel/methods/_init.js +1 -1
  6. package/cjs/highlevel/methods/_init.js.map +1 -1
  7. package/cjs/highlevel/methods/bots/get-callback-answer.d.ts +11 -0
  8. package/cjs/highlevel/methods/bots/get-callback-answer.js +10 -2
  9. package/cjs/highlevel/methods/bots/get-callback-answer.js.map +1 -1
  10. package/cjs/highlevel/methods/chats/archive-chats.js +2 -1
  11. package/cjs/highlevel/methods/chats/archive-chats.js.map +1 -1
  12. package/cjs/highlevel/methods/dialogs/find-dialogs.d.ts +12 -0
  13. package/cjs/highlevel/methods/dialogs/find-dialogs.js +88 -0
  14. package/cjs/highlevel/methods/dialogs/find-dialogs.js.map +1 -0
  15. package/cjs/highlevel/methods/dialogs/get-peer-dialogs.js +2 -1
  16. package/cjs/highlevel/methods/dialogs/get-peer-dialogs.js.map +1 -1
  17. package/cjs/highlevel/methods/dialogs/iter-dialogs.js +3 -1
  18. package/cjs/highlevel/methods/dialogs/iter-dialogs.js.map +1 -1
  19. package/cjs/highlevel/methods/messages/_business-connection.d.ts +2 -1
  20. package/cjs/highlevel/methods/messages/_business-connection.js.map +1 -1
  21. package/cjs/highlevel/methods/messages/get-available-effects.d.ts +6 -0
  22. package/cjs/highlevel/methods/messages/get-available-effects.js +26 -0
  23. package/cjs/highlevel/methods/messages/get-available-effects.js.map +1 -0
  24. package/cjs/highlevel/methods/messages/get-fact-check.d.ts +11 -0
  25. package/cjs/highlevel/methods/messages/get-fact-check.js +27 -0
  26. package/cjs/highlevel/methods/messages/get-fact-check.js.map +1 -0
  27. package/cjs/highlevel/methods/messages/search-hashtag.d.ts +44 -0
  28. package/cjs/highlevel/methods/messages/search-hashtag.js +75 -0
  29. package/cjs/highlevel/methods/messages/search-hashtag.js.map +1 -0
  30. package/cjs/highlevel/methods/messages/send-common.d.ts +5 -0
  31. package/cjs/highlevel/methods/messages/send-common.js.map +1 -1
  32. package/cjs/highlevel/methods/messages/send-media-group.js +1 -0
  33. package/cjs/highlevel/methods/messages/send-media-group.js.map +1 -1
  34. package/cjs/highlevel/methods/messages/send-media.js +1 -0
  35. package/cjs/highlevel/methods/messages/send-media.js.map +1 -1
  36. package/cjs/highlevel/methods/messages/send-text.js +1 -0
  37. package/cjs/highlevel/methods/messages/send-text.js.map +1 -1
  38. package/cjs/highlevel/methods/misc/normalize-privacy-rules.js +2 -1
  39. package/cjs/highlevel/methods/misc/normalize-privacy-rules.js.map +1 -1
  40. package/cjs/highlevel/methods/users/resolve-peer-many.d.ts +6 -2
  41. package/cjs/highlevel/methods/users/resolve-peer-many.js +22 -6
  42. package/cjs/highlevel/methods/users/resolve-peer-many.js.map +1 -1
  43. package/cjs/highlevel/methods/users/resolve-peer.js +30 -11
  44. package/cjs/highlevel/methods/users/resolve-peer.js.map +1 -1
  45. package/cjs/highlevel/methods.d.ts +6 -0
  46. package/cjs/highlevel/methods.js +15 -4
  47. package/cjs/highlevel/methods.js.map +1 -1
  48. package/cjs/highlevel/types/conversation.js +1 -1
  49. package/cjs/highlevel/types/conversation.js.map +1 -1
  50. package/cjs/highlevel/types/messages/dialog.d.ts +2 -2
  51. package/cjs/highlevel/types/messages/dialog.js +2 -3
  52. package/cjs/highlevel/types/messages/dialog.js.map +1 -1
  53. package/cjs/highlevel/types/messages/fact-check.d.ts +30 -0
  54. package/cjs/highlevel/types/messages/fact-check.js +56 -0
  55. package/cjs/highlevel/types/messages/fact-check.js.map +1 -0
  56. package/cjs/highlevel/types/messages/index.d.ts +2 -0
  57. package/cjs/highlevel/types/messages/index.js +2 -0
  58. package/cjs/highlevel/types/messages/index.js.map +1 -1
  59. package/cjs/highlevel/types/messages/message-effect.d.ts +20 -0
  60. package/cjs/highlevel/types/messages/message-effect.js +69 -0
  61. package/cjs/highlevel/types/messages/message-effect.js.map +1 -0
  62. package/cjs/highlevel/types/messages/message-entity.d.ts +4 -1
  63. package/cjs/highlevel/types/messages/message-entity.js +1 -1
  64. package/cjs/highlevel/types/messages/message-entity.js.map +1 -1
  65. package/cjs/highlevel/types/messages/message.d.ts +12 -0
  66. package/cjs/highlevel/types/messages/message.js +23 -0
  67. package/cjs/highlevel/types/messages/message.js.map +1 -1
  68. package/cjs/network/client.d.ts +1 -2
  69. package/cjs/network/client.js +3 -3
  70. package/cjs/network/client.js.map +1 -1
  71. package/cjs/network/network-manager.js +1 -1
  72. package/cjs/network/session-connection.js +1 -1
  73. package/cjs/network/session-connection.js.map +1 -1
  74. package/cjs/platform.js +3 -7
  75. package/cjs/platform.js.map +1 -1
  76. package/esm/highlevel/client.d.ts +83 -2
  77. package/esm/highlevel/client.js +20 -1
  78. package/esm/highlevel/client.js.map +1 -1
  79. package/esm/highlevel/methods/_imports.js.map +1 -1
  80. package/esm/highlevel/methods/_init.js +1 -1
  81. package/esm/highlevel/methods/_init.js.map +1 -1
  82. package/esm/highlevel/methods/bots/get-callback-answer.d.ts +11 -0
  83. package/esm/highlevel/methods/bots/get-callback-answer.js +10 -2
  84. package/esm/highlevel/methods/bots/get-callback-answer.js.map +1 -1
  85. package/esm/highlevel/methods/chats/archive-chats.js +2 -1
  86. package/esm/highlevel/methods/chats/archive-chats.js.map +1 -1
  87. package/esm/highlevel/methods/dialogs/find-dialogs.d.ts +12 -0
  88. package/esm/highlevel/methods/dialogs/find-dialogs.js +84 -0
  89. package/esm/highlevel/methods/dialogs/find-dialogs.js.map +1 -0
  90. package/esm/highlevel/methods/dialogs/get-peer-dialogs.js +2 -1
  91. package/esm/highlevel/methods/dialogs/get-peer-dialogs.js.map +1 -1
  92. package/esm/highlevel/methods/dialogs/iter-dialogs.js +3 -1
  93. package/esm/highlevel/methods/dialogs/iter-dialogs.js.map +1 -1
  94. package/esm/highlevel/methods/messages/_business-connection.d.ts +2 -1
  95. package/esm/highlevel/methods/messages/_business-connection.js.map +1 -1
  96. package/esm/highlevel/methods/messages/get-available-effects.d.ts +6 -0
  97. package/esm/highlevel/methods/messages/get-available-effects.js +22 -0
  98. package/esm/highlevel/methods/messages/get-available-effects.js.map +1 -0
  99. package/esm/highlevel/methods/messages/get-fact-check.d.ts +11 -0
  100. package/esm/highlevel/methods/messages/get-fact-check.js +23 -0
  101. package/esm/highlevel/methods/messages/get-fact-check.js.map +1 -0
  102. package/esm/highlevel/methods/messages/search-hashtag.d.ts +44 -0
  103. package/esm/highlevel/methods/messages/search-hashtag.js +70 -0
  104. package/esm/highlevel/methods/messages/search-hashtag.js.map +1 -0
  105. package/esm/highlevel/methods/messages/send-common.d.ts +5 -0
  106. package/esm/highlevel/methods/messages/send-common.js.map +1 -1
  107. package/esm/highlevel/methods/messages/send-media-group.js +1 -0
  108. package/esm/highlevel/methods/messages/send-media-group.js.map +1 -1
  109. package/esm/highlevel/methods/messages/send-media.js +1 -0
  110. package/esm/highlevel/methods/messages/send-media.js.map +1 -1
  111. package/esm/highlevel/methods/messages/send-text.js +1 -0
  112. package/esm/highlevel/methods/messages/send-text.js.map +1 -1
  113. package/esm/highlevel/methods/misc/normalize-privacy-rules.js +2 -1
  114. package/esm/highlevel/methods/misc/normalize-privacy-rules.js.map +1 -1
  115. package/esm/highlevel/methods/users/resolve-peer-many.d.ts +6 -2
  116. package/esm/highlevel/methods/users/resolve-peer-many.js +22 -6
  117. package/esm/highlevel/methods/users/resolve-peer-many.js.map +1 -1
  118. package/esm/highlevel/methods/users/resolve-peer.js +30 -11
  119. package/esm/highlevel/methods/users/resolve-peer.js.map +1 -1
  120. package/esm/highlevel/methods.d.ts +6 -0
  121. package/esm/highlevel/methods.js +5 -0
  122. package/esm/highlevel/methods.js.map +1 -1
  123. package/esm/highlevel/types/conversation.js +1 -1
  124. package/esm/highlevel/types/conversation.js.map +1 -1
  125. package/esm/highlevel/types/messages/dialog.d.ts +2 -2
  126. package/esm/highlevel/types/messages/dialog.js +2 -3
  127. package/esm/highlevel/types/messages/dialog.js.map +1 -1
  128. package/esm/highlevel/types/messages/fact-check.d.ts +30 -0
  129. package/esm/highlevel/types/messages/fact-check.js +53 -0
  130. package/esm/highlevel/types/messages/fact-check.js.map +1 -0
  131. package/esm/highlevel/types/messages/index.d.ts +2 -0
  132. package/esm/highlevel/types/messages/index.js +2 -0
  133. package/esm/highlevel/types/messages/index.js.map +1 -1
  134. package/esm/highlevel/types/messages/message-effect.d.ts +20 -0
  135. package/esm/highlevel/types/messages/message-effect.js +66 -0
  136. package/esm/highlevel/types/messages/message-effect.js.map +1 -0
  137. package/esm/highlevel/types/messages/message-entity.d.ts +4 -1
  138. package/esm/highlevel/types/messages/message-entity.js +1 -1
  139. package/esm/highlevel/types/messages/message-entity.js.map +1 -1
  140. package/esm/highlevel/types/messages/message.d.ts +12 -0
  141. package/esm/highlevel/types/messages/message.js +23 -0
  142. package/esm/highlevel/types/messages/message.js.map +1 -1
  143. package/esm/network/client.d.ts +1 -2
  144. package/esm/network/client.js +3 -3
  145. package/esm/network/client.js.map +1 -1
  146. package/esm/network/network-manager.js +1 -1
  147. package/esm/network/session-connection.js +1 -1
  148. package/esm/network/session-connection.js.map +1 -1
  149. package/esm/platform.js +3 -7
  150. package/esm/platform.js.map +1 -1
  151. package/package.json +4 -4
@@ -0,0 +1,66 @@
1
+ import { MtTypeAssertionError } from '../../../types/errors.js';
2
+ import { makeInspectable } from '../../utils/inspectable.js';
3
+ import { memoizeGetters } from '../../utils/memoize.js';
4
+ import { parseSticker } from '../media/document-utils.js';
5
+ class MessageEffect {
6
+ raw;
7
+ documentsMap;
8
+ constructor(raw, documentsMap) {
9
+ this.raw = raw;
10
+ this.documentsMap = documentsMap;
11
+ }
12
+ /** Whether Telegram Premium is required to use this effect */
13
+ get isPremiumRequired() {
14
+ return this.raw.premiumRequired;
15
+ }
16
+ /** ID of this effect */
17
+ get id() {
18
+ return this.raw.id;
19
+ }
20
+ /** Emoji representint this reaction */
21
+ get emoji() {
22
+ return this.raw.emoticon;
23
+ }
24
+ /** Sticker representing a static icon for this effect (if any) */
25
+ get staticIcon() {
26
+ if (!this.raw.staticIconId)
27
+ return null;
28
+ const document = this.documentsMap.get(this.raw.staticIconId);
29
+ if (!document)
30
+ return null;
31
+ const parsed = parseSticker(document);
32
+ if (!parsed) {
33
+ throw new MtTypeAssertionError('MessageEffect.staticIcon', 'sticker', 'null');
34
+ }
35
+ return parsed;
36
+ }
37
+ /** Animated icon representing the effect */
38
+ get icon() {
39
+ const document = this.documentsMap.get(this.raw.effectStickerId);
40
+ if (!document) {
41
+ throw new MtTypeAssertionError('MessageEffect.effect', 'document', 'null');
42
+ }
43
+ const parsed = parseSticker(document);
44
+ if (!parsed) {
45
+ throw new MtTypeAssertionError('MessageEffect.effect', 'sticker', 'null');
46
+ }
47
+ return parsed;
48
+ }
49
+ /** The animation itself */
50
+ get animation() {
51
+ if (!this.raw.effectAnimationId)
52
+ return null;
53
+ const document = this.documentsMap.get(this.raw.effectAnimationId);
54
+ if (!document)
55
+ return null;
56
+ const parsed = parseSticker(document);
57
+ if (!parsed) {
58
+ throw new MtTypeAssertionError('MessageEffect.effectAnimation', 'sticker', 'null');
59
+ }
60
+ return parsed;
61
+ }
62
+ }
63
+ const MessageEffect$1 = /*#__PURE__*/memoizeGetters(MessageEffect, ['staticIcon', 'icon', 'animation']);
64
+ const MessageEffect$2 = /*#__PURE__*/makeInspectable(MessageEffect$1, );
65
+ //# sourceMappingURL=message-effect.js.map
66
+ export { MessageEffect$2 as MessageEffect }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-effect.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message-effect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC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,MAAM,CAAC,CAAA;QAC9E,CAAC;QAED,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;QAErC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,oBAAoB,CAAC,sBAAsB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QAC7E,CAAC;QAED,OAAO,MAAM,CAAA;IACjB,CAAC;IAED,2BAA2B;IAC3B,IAAI,SAAS;QACT,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB;YAAE,OAAO,IAAI,CAAA;QAE5C,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;QAClE,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAA;QAE1B,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;QAErC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,oBAAoB,CAAC,+BAA+B,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QACtF,CAAC;QAED,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ;AAED,cAAc,CAAC,aAAa,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;AAClE,eAAe,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../types/errors.js'\nimport { LongMap } from '../../../utils/long-utils.js'\nimport { makeInspectable } from '../../utils/inspectable.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { parseSticker } from '../media/document-utils.js'\nimport { Sticker } from '../media/sticker.js'\n\nexport class MessageEffect {\n constructor(\n readonly raw: tl.RawAvailableEffect,\n readonly documentsMap: LongMap<tl.RawDocument>,\n ) {}\n\n /** Whether Telegram Premium is required to use this effect */\n get isPremiumRequired(): boolean {\n return this.raw.premiumRequired!\n }\n\n /** ID of this effect */\n get id(): tl.Long {\n return this.raw.id\n }\n\n /** Emoji representint this reaction */\n get emoji(): string {\n return this.raw.emoticon\n }\n\n /** Sticker representing a static icon for this effect (if any) */\n get staticIcon(): Sticker | null {\n if (!this.raw.staticIconId) return null\n\n const document = this.documentsMap.get(this.raw.staticIconId)\n if (!document) return null\n\n const parsed = parseSticker(document)\n\n if (!parsed) {\n throw new MtTypeAssertionError('MessageEffect.staticIcon', 'sticker', 'null')\n }\n\n return parsed\n }\n\n /** Animated icon representing the effect */\n get icon(): Sticker {\n const document = this.documentsMap.get(this.raw.effectStickerId)\n\n if (!document) {\n throw new MtTypeAssertionError('MessageEffect.effect', 'document', 'null')\n }\n\n const parsed = parseSticker(document)\n\n if (!parsed) {\n throw new MtTypeAssertionError('MessageEffect.effect', 'sticker', 'null')\n }\n\n return parsed\n }\n\n /** The animation itself */\n get animation(): Sticker | null {\n if (!this.raw.effectAnimationId) return null\n\n const document = this.documentsMap.get(this.raw.effectAnimationId)\n if (!document) return null\n\n const parsed = parseSticker(document)\n\n if (!parsed) {\n throw new MtTypeAssertionError('MessageEffect.effectAnimation', 'sticker', 'null')\n }\n\n return parsed\n }\n}\n\nmemoizeGetters(MessageEffect, ['staticIcon', 'icon', 'animation'])\nmakeInspectable(MessageEffect)\n"]}
@@ -20,7 +20,10 @@ import { tl } from '@mtcute/tl';
20
20
  * - 'emoji': A custom emoji. `.emojiId` contains the emoji ID.
21
21
  */
22
22
  export type MessageEntityParams = {
23
- kind: 'mention' | 'hashtag' | 'cashtag' | 'bot_command' | 'url' | 'email' | 'phone_number' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code' | 'blockquote' | 'bank_card' | 'unknown';
23
+ kind: 'mention' | 'hashtag' | 'cashtag' | 'bot_command' | 'url' | 'email' | 'phone_number' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code' | 'bank_card' | 'unknown';
24
+ } | {
25
+ kind: 'blockquote';
26
+ collapsible: boolean;
24
27
  } | {
25
28
  kind: 'pre';
26
29
  language?: string;
@@ -70,7 +70,7 @@ class MessageEntity {
70
70
  case 'messageEntityMentionName':
71
71
  return { kind: 'text_mention', userId: this.raw.userId };
72
72
  case 'messageEntityBlockquote':
73
- return { kind: 'blockquote' };
73
+ return { kind: 'blockquote', collapsible: this.raw.collapsed };
74
74
  case 'messageEntityCustomEmoji':
75
75
  return { kind: 'emoji', emojiId: this.raw.documentId };
76
76
  case 'messageEntityBankCard':
@@ -1 +1 @@
1
- {"version":3,"file":"message-entity.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message-entity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAoDvD;;GAEG;AACH,MAAM,OAAO,aAAa;IAET;IACA;IAFb,YACa,GAAyB,EACzB,KAAc;QADd,QAAG,GAAH,GAAG,CAAsB;QACzB,UAAK,GAAL,KAAK,CAAS;IACxB,CAAC;IAEJ;;;;OAIG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,QAAQ,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACjB,KAAK,sBAAsB;gBACvB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;YAC9B,KAAK,sBAAsB;gBACvB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;YAC9B,KAAK,sBAAsB;gBACvB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;YAC9B,KAAK,yBA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E,CAAA;YAC1D,KAAK,uBAAuB;gBACxB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;QACpC,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAED;;;;;OAKG;IACH,IAAI,IAAI;QACJ,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAA;QAE1B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/E,CAAC;IAED;;;;OAIG;IACH,EAAE,CACE,IAAO;QAEP,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAA;IACpC,CAAC;CACJ;AAED,cAAc,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;AACzC,eAAe,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\n\n/**\n * Params of the entity. `.kind` can be:\n * - 'mention': `@username`.\n * - 'hashtag': `#hashtag`.\n * - 'cashtag': `$USD`.\n * - 'bot_command': `/start`.\n * - 'url': `https://example.com`\n * - 'email': `example@example.com`.\n * - 'phone_number': `+42000`.\n * - 'bold': **bold text**.\n * - 'italic': *italic text*.\n * - 'underline': <u>underlined</u> text.\n * - 'strikethrough': <s>strikethrough</s> text.\n * - 'code': `monospaced` string.\n * - 'pre': `monospaced` block. `.language` contains the language of the block (if available).\n * - 'text_link': for clickable text URLs.\n * - 'text_mention': for user mention by name. `.userId` contains the ID of the mentioned user.\n * - 'blockquote': A blockquote\n * - 'emoji': A custom emoji. `.emojiId` contains the emoji ID.\n */\nexport type MessageEntityParams =\n | {\n kind:\n | 'mention'\n | 'hashtag'\n | 'cashtag'\n | 'bot_command'\n | 'url'\n | 'email'\n | 'phone_number'\n | 'bold'\n | 'italic'\n | 'underline'\n | 'strikethrough'\n | 'spoiler'\n | 'code'\n | 'blockquote'\n | 'bank_card'\n | 'unknown'\n }\n | { kind: 'pre'; language?: string }\n | { kind: 'text_link'; url: string }\n | { kind: 'text_mention'; userId: number }\n | { kind: 'emoji'; emojiId: tl.Long }\n\n/**\n * Kind of the entity. For more information, see {@link MessageEntityParams}\n */\nexport type MessageEntityKind = MessageEntityParams['kind']\n\n/**\n * One special entity in a text message (like mention, hashtag, URL, etc.)\n */\nexport class MessageEntity {\n constructor(\n readonly raw: tl.TypeMessageEntity,\n readonly _text?: string,\n ) {}\n\n /**\n * Offset in UTF-16 code units to the start of the entity.\n *\n * Since JS strings are UTF-16, you can use this as-is\n */\n get offset() {\n return this.raw.offset\n }\n\n /**\n * Length of the entity in UTF-16 code units.\n *\n * Since JS strings are UTF-16, you can use this as-is\n */\n get length() {\n return this.raw.length\n }\n\n /**\n * Kind of the entity (see {@link MessageEntityParams})\n */\n get kind(): MessageEntityKind {\n return this.params.kind\n }\n\n /**\n * Params of the entity\n */\n get params(): MessageEntityParams {\n switch (this.raw._) {\n case 'messageEntityMention':\n return { kind: 'mention' }\n case 'messageEntityHashtag':\n return { kind: 'hashtag' }\n case 'messageEntityCashtag':\n return { kind: 'cashtag' }\n case 'messageEntityBotCommand':\n return { kind: 'bot_command' }\n case 'messageEntityUrl':\n return { kind: 'url' }\n case 'messageEntityEmail':\n return { kind: 'email' }\n case 'messageEntityPhone':\n return { kind: 'phone_number' }\n case 'messageEntityBold':\n return { kind: 'bold' }\n case 'messageEntityItalic':\n return { kind: 'italic' }\n case 'messageEntityUnderline':\n return { kind: 'underline' }\n case 'messageEntityStrike':\n return { kind: 'strikethrough' }\n case 'messageEntitySpoiler':\n return { kind: 'spoiler' }\n case 'messageEntityCode':\n return { kind: 'code' }\n case 'messageEntityPre':\n return { kind: 'pre', language: this.raw.language }\n case 'messageEntityTextUrl':\n return { kind: 'text_link', url: this.raw.url }\n case 'messageEntityMentionName':\n return { kind: 'text_mention', userId: this.raw.userId }\n case 'messageEntityBlockquote':\n return { kind: 'blockquote' }\n case 'messageEntityCustomEmoji':\n return { kind: 'emoji', emojiId: this.raw.documentId }\n case 'messageEntityBankCard':\n return { kind: 'bank_card' }\n }\n\n return { kind: 'unknown' }\n }\n\n /**\n * Text contained in this entity.\n *\n * > **Note**: This does not take into account that entities may overlap,\n * > and is only useful for simple cases.\n */\n get text(): string {\n if (!this._text) return ''\n\n return this._text.slice(this.raw.offset, this.raw.offset + this.raw.length)\n }\n\n /**\n * Checks if this entity is of the given type, and adjusts the type accordingly.\n * @param kind\n * @returns\n */\n is<const T extends MessageEntityKind>(\n kind: T,\n ): this is MessageEntity & { params: Extract<MessageEntityParams, { kind: T }>; kind: T } {\n return this.params.kind === kind\n }\n}\n\nmemoizeGetters(MessageEntity, ['params'])\nmakeInspectable(MessageEntity)\n"]}
1
+ {"version":3,"file":"message-entity.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message-entity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAoDvD;;GAEG;AACH,MAAM,OAAO,aAAa;IAET;IACA;IAFb,YACa,GAAyB,EACzB,KAAc;QADd,QAAG,GAAH,GAAG,CAAsB;QACzB,UAAK,GAAL,KAAK,CAAS;IACxB,CAAC;IAEJ;;;;OAIG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;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;gBAC3B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAA;YAC5D,KAAK,yBAAyB;gBAC1B,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,SAAU,EAAE,CAAA;YACnE,KAAK,0BAA0B;gBAC3B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAA;YAC1D,KAAK,uBAAuB;gBACxB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;QACpC,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAC9B,CAAC;IAED;;;;;OAKG;IACH,IAAI,IAAI;QACJ,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAA;QAE1B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/E,CAAC;IAED;;;;OAIG;IACH,EAAE,CACE,IAAO;QAEP,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAA;IACpC,CAAC;CACJ;AAED,cAAc,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;AACzC,eAAe,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\n\n/**\n * Params of the entity. `.kind` can be:\n * - 'mention': `@username`.\n * - 'hashtag': `#hashtag`.\n * - 'cashtag': `$USD`.\n * - 'bot_command': `/start`.\n * - 'url': `https://example.com`\n * - 'email': `example@example.com`.\n * - 'phone_number': `+42000`.\n * - 'bold': **bold text**.\n * - 'italic': *italic text*.\n * - 'underline': <u>underlined</u> text.\n * - 'strikethrough': <s>strikethrough</s> text.\n * - 'code': `monospaced` string.\n * - 'pre': `monospaced` block. `.language` contains the language of the block (if available).\n * - 'text_link': for clickable text URLs.\n * - 'text_mention': for user mention by name. `.userId` contains the ID of the mentioned user.\n * - 'blockquote': A blockquote\n * - 'emoji': A custom emoji. `.emojiId` contains the emoji ID.\n */\nexport type MessageEntityParams =\n | {\n kind:\n | 'mention'\n | 'hashtag'\n | 'cashtag'\n | 'bot_command'\n | 'url'\n | 'email'\n | 'phone_number'\n | 'bold'\n | 'italic'\n | 'underline'\n | 'strikethrough'\n | 'spoiler'\n | 'code'\n | 'bank_card'\n | 'unknown'\n }\n | { kind: 'blockquote'; collapsible: boolean }\n | { kind: 'pre'; language?: string }\n | { kind: 'text_link'; url: string }\n | { kind: 'text_mention'; userId: number }\n | { kind: 'emoji'; emojiId: tl.Long }\n\n/**\n * Kind of the entity. For more information, see {@link MessageEntityParams}\n */\nexport type MessageEntityKind = MessageEntityParams['kind']\n\n/**\n * One special entity in a text message (like mention, hashtag, URL, etc.)\n */\nexport class MessageEntity {\n constructor(\n readonly raw: tl.TypeMessageEntity,\n readonly _text?: string,\n ) {}\n\n /**\n * Offset in UTF-16 code units to the start of the entity.\n *\n * Since JS strings are UTF-16, you can use this as-is\n */\n get offset() {\n return this.raw.offset\n }\n\n /**\n * Length of the entity in UTF-16 code units.\n *\n * Since JS strings are UTF-16, you can use this as-is\n */\n get length() {\n return this.raw.length\n }\n\n /**\n * Kind of the entity (see {@link MessageEntityParams})\n */\n get kind(): MessageEntityKind {\n return this.params.kind\n }\n\n /**\n * Params of the entity\n */\n get params(): MessageEntityParams {\n switch (this.raw._) {\n case 'messageEntityMention':\n return { kind: 'mention' }\n case 'messageEntityHashtag':\n return { kind: 'hashtag' }\n case 'messageEntityCashtag':\n return { kind: 'cashtag' }\n case 'messageEntityBotCommand':\n return { kind: 'bot_command' }\n case 'messageEntityUrl':\n return { kind: 'url' }\n case 'messageEntityEmail':\n return { kind: 'email' }\n case 'messageEntityPhone':\n return { kind: 'phone_number' }\n case 'messageEntityBold':\n return { kind: 'bold' }\n case 'messageEntityItalic':\n return { kind: 'italic' }\n case 'messageEntityUnderline':\n return { kind: 'underline' }\n case 'messageEntityStrike':\n return { kind: 'strikethrough' }\n case 'messageEntitySpoiler':\n return { kind: 'spoiler' }\n case 'messageEntityCode':\n return { kind: 'code' }\n case 'messageEntityPre':\n return { kind: 'pre', language: this.raw.language }\n case 'messageEntityTextUrl':\n return { kind: 'text_link', url: this.raw.url }\n case 'messageEntityMentionName':\n return { kind: 'text_mention', userId: this.raw.userId }\n case 'messageEntityBlockquote':\n return { kind: 'blockquote', collapsible: this.raw.collapsed! }\n case 'messageEntityCustomEmoji':\n return { kind: 'emoji', emojiId: this.raw.documentId }\n case 'messageEntityBankCard':\n return { kind: 'bank_card' }\n }\n\n return { kind: 'unknown' }\n }\n\n /**\n * Text contained in this entity.\n *\n * > **Note**: This does not take into account that entities may overlap,\n * > and is only useful for simple cases.\n */\n get text(): string {\n if (!this._text) return ''\n\n return this._text.slice(this.raw.offset, this.raw.offset + this.raw.length)\n }\n\n /**\n * Checks if this entity is of the given type, and adjusts the type accordingly.\n * @param kind\n * @returns\n */\n is<const T extends MessageEntityKind>(\n kind: T,\n ): this is MessageEntity & { params: Extract<MessageEntityParams, { kind: T }>; kind: T } {\n return this.params.kind === kind\n }\n}\n\nmemoizeGetters(MessageEntity, ['params'])\nmakeInspectable(MessageEntity)\n"]}
@@ -5,6 +5,7 @@ import { Chat } from '../peers/chat.js';
5
5
  import { Peer } from '../peers/peer.js';
6
6
  import { PeersIndex } from '../peers/peers-index.js';
7
7
  import { User } from '../peers/user.js';
8
+ import { FactCheck } from './fact-check.js';
8
9
  import { MessageAction } from './message-action.js';
9
10
  import { MessageEntity } from './message-entity.js';
10
11
  import { MessageForwardInfo } from './message-forward.js';
@@ -226,7 +227,18 @@ export declare class Message {
226
227
  * `false` for service mesasges and private restricted chats/chanenls
227
228
  */
228
229
  get canBeForwarded(): boolean;
230
+ /**
231
+ * Reactions added to this message, if any
232
+ */
229
233
  get reactions(): MessageReactions | null;
234
+ /**
235
+ * Information about fact-check added to the message, if any
236
+ */
237
+ get factCheck(): FactCheck | null;
238
+ /**
239
+ * If this message was sent with a message effect, ID of the effect
240
+ */
241
+ get effectId(): tl.Long | null;
230
242
  /**
231
243
  * Generated permalink to this message, only for groups and channels
232
244
  *
@@ -8,6 +8,7 @@ import { BotKeyboard } from '../bots/keyboards/index.js';
8
8
  import { Chat } from '../peers/chat.js';
9
9
  import { parsePeer } from '../peers/peer.js';
10
10
  import { User } from '../peers/user.js';
11
+ import { FactCheck } from './fact-check.js';
11
12
  import { _messageActionFromTl } from './message-action.js';
12
13
  import { MessageEntity } from './message-entity.js';
13
14
  import { MessageForwardInfo } from './message-forward.js';
@@ -399,12 +400,33 @@ class Message {
399
400
  get canBeForwarded() {
400
401
  return this.raw._ === 'message' && !this.raw.noforwards;
401
402
  }
403
+ /**
404
+ * Reactions added to this message, if any
405
+ */
402
406
  get reactions() {
403
407
  if (this.raw._ === 'messageService' || !this.raw.reactions) {
404
408
  return null;
405
409
  }
406
410
  return new MessageReactions(this.raw.id, getMarkedPeerId(this.raw.peerId), this.raw.reactions, this._peers);
407
411
  }
412
+ /**
413
+ * Information about fact-check added to the message, if any
414
+ */
415
+ get factCheck() {
416
+ if (this.raw._ === 'messageService')
417
+ return null;
418
+ if (!this.raw.factcheck || this.raw.factcheck.hash.isZero())
419
+ return null;
420
+ return new FactCheck(this.raw.factcheck);
421
+ }
422
+ /**
423
+ * If this message was sent with a message effect, ID of the effect
424
+ */
425
+ get effectId() {
426
+ if (this.raw._ === 'messageService')
427
+ return null;
428
+ return this.raw.effect ?? null;
429
+ }
408
430
  /**
409
431
  * Generated permalink to this message, only for groups and channels
410
432
  *
@@ -431,6 +453,7 @@ const Message$1 = /*#__PURE__*/memoizeGetters(Message, [
431
453
  'media',
432
454
  'markup',
433
455
  'reactions',
456
+ 'factCheck',
434
457
  ]);
435
458
  const Message$2 = /*#__PURE__*/makeInspectable(Message$1, ['isScheduled'], ['link']);
436
459
  //# sourceMappingURL=message.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAe,MAAM,4BAA4B,CAAA;AAErE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAQ,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,oBAAoB,EAAiB,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAgB,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;GAEG;AACH,MAAM,OAAO,OAAO;IAQH;IAKA;IAZb;;OAEG;IACM,GAAG,CAAsC;IAElD,YACI,GAAmB,EACV,MAAkB;I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AAC,QAAQ,KAAK,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC1E,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACrB,OAAO,gBAAgB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,EAAE,EAAE,CAAA;YAC1D,CAAC;YAED,OAAO,kBAAkB,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAA;QAC3E,CAAC;QAED,MAAM,IAAI,eAAe,CAAC,oCAAoC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IACvF,CAAC;CACJ;AAED,cAAc,CAAC,OAAO,EAAE;IACpB,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;IACT,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,WAAW;CACd,CAAC,CAAA;AACF,eAAe,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtArgumentError } from '../../../types/errors.js'\nimport { assertNever } from '../../../types/utils.js'\nimport { getMarkedPeerId, toggleChannelIdMark } from '../../../utils/peer-utils.js'\nimport { assertTypeIsNot } from '../../../utils/type-assertions.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { BotKeyboard, ReplyMarkup } from '../bots/keyboards/index.js'\nimport { TextWithEntities } from '../misc/index.js'\nimport { Chat } from '../peers/chat.js'\nimport { parsePeer, Peer } from '../peers/peer.js'\nimport { PeersIndex } from '../peers/peers-index.js'\nimport { User } from '../peers/user.js'\nimport { _messageActionFromTl, MessageAction } from './message-action.js'\nimport { MessageEntity } from './message-entity.js'\nimport { MessageForwardInfo } from './message-forward.js'\nimport { _messageMediaFromTl, MessageMedia } from './message-media.js'\nimport { MessageReactions } from './message-reactions.js'\nimport { MessageRepliesInfo } from './message-replies.js'\nimport { RepliedMessageInfo } from './replied-message.js'\n\n/**\n * A Telegram message.\n */\nexport class Message {\n /**\n * Raw TL object.\n */\n readonly raw: tl.RawMessage | tl.RawMessageService\n\n constructor(\n raw: tl.TypeMessage,\n readonly _peers: PeersIndex,\n /**\n * Whether the message is scheduled.\n * If it is, then its {@link date} is set to future.\n */\n readonly isScheduled = false,\n ) {\n assertTypeIsNot('Message#ctor', raw, 'messageEmpty')\n\n this.raw = raw\n }\n\n /** Unique message identifier inside this chat */\n get id(): number {\n return this.raw.id\n }\n\n /**\n * For channel posts, number of views\n *\n * `null` for service messages and non-post messages.\n */\n get views(): number | null {\n return this.raw._ === 'message' ? this.raw.views ?? null : null\n }\n\n /**\n * For channel posts, number of forwards\n *\n * `null` for service messages and non-post messages, or\n * if the current user is not an admin in the channel\n */\n get forwards(): number | null {\n return this.raw._ === 'message' ? this.raw.forwards ?? null : null\n }\n\n /**\n * For channel posts with signatures enabled, name of the post author\n */\n get signature(): string | null {\n return this.raw._ === 'message' ? this.raw.postAuthor ?? null : null\n }\n\n /**\n * Whether the message is incoming or outgoing:\n * - Messages received from other chats are incoming (`outgoing = false`)\n * - Messages sent by you to other chats are outgoing (`outgoing = true`)\n * - Messages to yourself (i.e. *Saved Messages*) are incoming (`outgoing = false`)\n */\n get isOutgoing(): boolean {\n return this.raw.out!\n }\n\n /**\n * Whether this message is a service message\n */\n get isService(): boolean {\n return this.raw._ === 'messageService'\n }\n\n /** Whether this message has content protection (i.e. disabled forwards) */\n get isContentProtected(): boolean {\n return this.raw._ === 'message' && this.raw.noforwards!\n }\n\n /**\n * Whether the message was sent by an implicit action, for example,\n * as an away or a greeting business message, or as a scheduled message\n */\n get isFromOffline(): boolean {\n return this.raw._ === 'message' && this.raw.offline!\n }\n\n /** Whether this is a silent message (no notification triggered) */\n get isSilent(): boolean {\n return this.raw.silent!\n }\n\n /** Whether there are unread media attachments in this message */\n get hasUnreadMedia(): boolean {\n return this.raw.mediaUnread!\n }\n\n /** Whether this is a broadcast channel post */\n get isChannelPost(): boolean {\n return this.raw._ === 'message' && this.raw.post!\n }\n\n /**\n * Whether this message was automatically sent from a scheduled message.\n *\n * **Note**: for messages sent by other users, this is always `false`.\n */\n get isFromScheduled(): boolean {\n return this.raw._ === 'message' && this.raw.fromScheduled!\n }\n\n /** Whether the message is pinned in the current chat */\n get isPinned(): boolean {\n return this.raw._ === 'message' && this.raw.pinned!\n }\n\n /** Whether the message should be considered unedited, even if {@link editDate} ≠ null */\n get hideEditMark(): boolean {\n return this.raw._ === 'message' && this.raw.editHide!\n }\n\n /**\n * If set, any eventual webpage preview should be shown on top of\n * the message instead of at the bottom.\n */\n get invertMedia(): boolean {\n return this.raw._ === 'message' && this.raw.invertMedia!\n }\n\n /**\n * Multiple media messages with the same grouped ID\n * indicate an album or media group\n *\n * `null` for service messages and non-grouped messages\n */\n get groupedId(): tl.Long | null {\n return this.raw._ === 'message' ? this.raw.groupedId ?? null : null\n }\n\n /**\n * Same as {@link groupedId}, but is globally unique across chats.\n */\n get groupedIdUnique(): string | null {\n if (!(this.raw._ === 'message' && this.raw.groupedId !== undefined)) return null\n\n return `${this.raw.groupedId.low}|${this.raw.groupedId.high}|${getMarkedPeerId(this.raw.peerId)}`\n }\n\n /**\n * Message sender.\n *\n * Usually is a {@link User}, but can be a {@link Chat}\n * in case the message was sent by an anonymous admin, anonymous premium user,\n * or if the message is a forwarded channel post.\n *\n * If the message was sent by an anonymous admin,\n * sender will equal to {@link chat}.\n *\n * If the message is a forwarded channel post,\n * sender is the channel itself.\n */\n get sender(): Peer {\n const from = this.raw.fromId\n\n if (!from) {\n if (this.raw.peerId._ === 'peerUser') {\n return new User(this._peers.user(this.raw.peerId.userId))\n }\n\n // anon admin, return the chat\n return this.chat\n }\n\n return parsePeer(from, this._peers)\n }\n\n /**\n * Number of boosts applied to this {@link chat} by the sender\n */\n get senderBoostCount(): number {\n if (this.raw._ !== 'message') return 0\n\n return this.raw.fromBoostsApplied ?? 0\n }\n\n /**\n * Conversation the message belongs to\n */\n get chat(): Chat {\n return Chat._parseFromMessage(this.raw, this._peers)\n }\n\n /**\n * Date when the message was sent\n */\n get date(): Date {\n return new Date(this.raw.date * 1000)\n }\n\n /**\n * Date when the message was last edited\n */\n get editDate(): Date | null {\n if (this.raw._ === 'messageService') return null\n\n return this.raw.editDate ? new Date(this.raw.editDate * 1000) : null\n }\n\n /**\n * If this message is a forward, contains info about it.\n */\n get forward(): MessageForwardInfo | null {\n if (this.raw._ !== 'message' || !this.raw.fwdFrom) {\n return null\n }\n\n return new MessageForwardInfo(this.raw.fwdFrom, this._peers)\n }\n\n /**\n * Whether the message is a channel post that was\n * automatically forwarded to the connected discussion group\n */\n get isAutomaticForward(): boolean {\n if (this.raw._ === 'messageService' || !this.raw.fwdFrom) return false\n\n const fwd = this.raw.fwdFrom\n\n return Boolean(\n this.chat.chatType === 'supergroup' &&\n fwd.savedFromMsgId &&\n fwd.savedFromPeer?._ === 'peerChannel' &&\n getMarkedPeerId(fwd.savedFromPeer) !== getMarkedPeerId(this.raw.peerId),\n )\n }\n\n /**\n * Information about comments (for channels) or replies (for groups)\n */\n get replies(): MessageRepliesInfo | null {\n if (this.raw._ !== 'message' || !this.raw.replies) return null\n\n return new MessageRepliesInfo(this.raw.replies, this._peers)\n }\n\n /**\n * For replies, information about the that is being replied to.\n *\n * Mutually exclusive with {@link replyToStory}\n */\n get replyToMessage(): RepliedMessageInfo | null {\n if (this.raw.replyTo?._ !== 'messageReplyHeader') return null\n\n return new RepliedMessageInfo(this.raw.replyTo, this._peers)\n }\n\n /**\n * For replies, information about the story that is being replied to\n *\n * Mutually exclusive with {@link replyToMessage}\n */\n get replyToStory(): tl.RawMessageReplyStoryHeader | null {\n if (this.raw.replyTo?._ !== 'messageReplyStoryHeader') return null\n\n return this.raw.replyTo\n }\n\n /** Whether this message is in a forum topic */\n get isTopicMessage(): boolean {\n if (this.raw.replyTo?._ !== 'messageReplyHeader') return false\n\n return this.raw.replyTo.forumTopic!\n }\n\n /**\n * Whether this message contains mention of the current user\n */\n get isMention(): boolean {\n return this.raw.mentioned!\n }\n\n /**\n * If non-null, this message is not actually sent, and is\n * instead inside a group of \"quick reply\" messages\n * under the given shortcut ID\n */\n get quickReplyShortcutId(): number | null {\n if (this.raw._ === 'messageService') return null\n\n return this.raw.quickReplyShortcutId ?? null\n }\n\n /**\n * If this message is generated from an inline query,\n * information about the bot which generated it\n */\n get viaBot(): User | null {\n if (this.raw._ === 'messageService' || !this.raw.viaBotId) {\n return null\n }\n\n return new User(this._peers.user(this.raw.viaBotId))\n }\n\n /**\n * If this message was sent by a business bot on behalf of {@link sender},\n * information about the business bot.\n *\n * **Note**: only available to the business account and the bot itself.\n */\n get viaBusinessBot(): User | null {\n if (this.raw._ === 'messageService' || !this.raw.viaBusinessBotId) {\n return null\n }\n\n return new User(this._peers.user(this.raw.viaBusinessBotId))\n }\n\n /**\n * Message text or media caption.\n *\n * Empty string for service messages\n * (you should handle i18n yourself)\n */\n get text(): string {\n return this.raw._ === 'messageService' ? '' : this.raw.message\n }\n\n /**\n * Message text/caption entities (may be empty)\n */\n get entities(): ReadonlyArray<MessageEntity> {\n const entities: MessageEntity[] = []\n\n if (this.raw._ === 'message' && this.raw.entities?.length) {\n for (const ent of this.raw.entities) {\n entities.push(new MessageEntity(ent, this.raw.message))\n }\n }\n\n return entities\n }\n\n get textWithEntities(): TextWithEntities {\n if (this.raw._ === 'messageService') return { text: '', entities: [] }\n\n return {\n text: this.raw.message,\n entities: this.raw.entities,\n }\n }\n\n /**\n * Message action. `null` for non-service messages\n * or for unsupported events.\n *\n * For unsupported events, use `.raw.action` directly.\n */\n get action(): MessageAction | null {\n if (this.raw._ === 'message') {\n return null\n }\n\n return _messageActionFromTl.call(this, this.raw.action)\n }\n\n /**\n * Message media. `null` for text-only and service messages\n * and for unsupported media types.\n *\n * For unsupported media types, use `.raw.media` directly.\n */\n get media(): MessageMedia {\n if (this.raw._ === 'messageService' || !this.raw.media || this.raw.media._ === 'messageMediaEmpty') {\n return null\n }\n\n return _messageMediaFromTl(this._peers, this.raw.media)\n }\n\n /**\n * Whether this is a premium media\n * (e.g. >2gb file or fullscreen sticker)\n * that was forwarded without author by a non-premium user\n */\n get isForwardedPremiumMedia(): boolean {\n return this.raw._ === 'message' && this.raw.media?._ === 'messageMediaDocument' && this.raw.media.nopremium!\n }\n\n /**\n * TTL period of the message, in seconds.\n */\n get ttlPeriod(): number | null {\n return this.raw.ttlPeriod ?? null\n }\n\n /**\n * Reply markup provided with this message, if any.\n */\n get markup(): ReplyMarkup | null {\n if (this.raw._ === 'messageService' || !this.raw.replyMarkup) {\n return null\n }\n\n const rm = this.raw.replyMarkup\n\n switch (rm._) {\n case 'replyKeyboardHide':\n return {\n type: 'reply_hide',\n selective: rm.selective,\n }\n case 'replyKeyboardForceReply':\n return {\n type: 'force_reply',\n singleUse: rm.singleUse,\n selective: rm.selective,\n }\n case 'replyKeyboardMarkup':\n return {\n type: 'reply',\n resize: rm.resize,\n singleUse: rm.singleUse,\n selective: rm.selective,\n buttons: BotKeyboard._rowsTo2d(rm.rows),\n }\n case 'replyInlineMarkup':\n return {\n type: 'inline',\n buttons: BotKeyboard._rowsTo2d(rm.rows),\n }\n default:\n assertNever(rm)\n }\n }\n\n /**\n * Whether this message can be forwarded\n *\n * `false` for service mesasges and private restricted chats/chanenls\n */\n get canBeForwarded(): boolean {\n return this.raw._ === 'message' && !this.raw.noforwards\n }\n\n get reactions(): MessageReactions | null {\n if (this.raw._ === 'messageService' || !this.raw.reactions) {\n return null\n }\n\n return new MessageReactions(this.raw.id, getMarkedPeerId(this.raw.peerId), this.raw.reactions, this._peers)\n }\n\n /**\n * Generated permalink to this message, only for groups and channels\n *\n * @throws MtArgumentError In case the chat does not support message links\n */\n get link(): string {\n if (this.chat.chatType === 'supergroup' || this.chat.chatType === 'channel') {\n if (this.chat.username) {\n return `https://t.me/${this.chat.username}/${this.id}`\n }\n\n return `https://t.me/c/${toggleChannelIdMark(this.chat.id)}/${this.id}`\n }\n\n throw new MtArgumentError(`Cannot generate message link for ${this.chat.chatType}`)\n }\n}\n\nmemoizeGetters(Message, [\n 'sender',\n 'chat',\n 'forward',\n 'replies',\n 'viaBot',\n 'entities',\n 'action',\n 'media',\n 'markup',\n 'reactions',\n])\nmakeInspectable(Message, ['isScheduled'], ['link'])\n"]}
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAe,MAAM,4BAA4B,CAAA;AAErE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAQ,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAiB,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,mBAAmB,EAAgB,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sB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AS;IACT,SAAS;IACT,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,WAAW;IACX,WAAW;CACd,CAAC,CAAA;AACF,eAAe,CAAC,OAAO,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtArgumentError } from '../../../types/errors.js'\nimport { assertNever } from '../../../types/utils.js'\nimport { getMarkedPeerId, toggleChannelIdMark } from '../../../utils/peer-utils.js'\nimport { assertTypeIsNot } from '../../../utils/type-assertions.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { BotKeyboard, ReplyMarkup } from '../bots/keyboards/index.js'\nimport { TextWithEntities } from '../misc/index.js'\nimport { Chat } from '../peers/chat.js'\nimport { parsePeer, Peer } from '../peers/peer.js'\nimport { PeersIndex } from '../peers/peers-index.js'\nimport { User } from '../peers/user.js'\nimport { FactCheck } from './fact-check.js'\nimport { _messageActionFromTl, MessageAction } from './message-action.js'\nimport { MessageEntity } from './message-entity.js'\nimport { MessageForwardInfo } from './message-forward.js'\nimport { _messageMediaFromTl, MessageMedia } from './message-media.js'\nimport { MessageReactions } from './message-reactions.js'\nimport { MessageRepliesInfo } from './message-replies.js'\nimport { RepliedMessageInfo } from './replied-message.js'\n\n/**\n * A Telegram message.\n */\nexport class Message {\n /**\n * Raw TL object.\n */\n readonly raw: tl.RawMessage | tl.RawMessageService\n\n constructor(\n raw: tl.TypeMessage,\n readonly _peers: PeersIndex,\n /**\n * Whether the message is scheduled.\n * If it is, then its {@link date} is set to future.\n */\n readonly isScheduled = false,\n ) {\n assertTypeIsNot('Message#ctor', raw, 'messageEmpty')\n\n this.raw = raw\n }\n\n /** Unique message identifier inside this chat */\n get id(): number {\n return this.raw.id\n }\n\n /**\n * For channel posts, number of views\n *\n * `null` for service messages and non-post messages.\n */\n get views(): number | null {\n return this.raw._ === 'message' ? this.raw.views ?? null : null\n }\n\n /**\n * For channel posts, number of forwards\n *\n * `null` for service messages and non-post messages, or\n * if the current user is not an admin in the channel\n */\n get forwards(): number | null {\n return this.raw._ === 'message' ? this.raw.forwards ?? null : null\n }\n\n /**\n * For channel posts with signatures enabled, name of the post author\n */\n get signature(): string | null {\n return this.raw._ === 'message' ? this.raw.postAuthor ?? null : null\n }\n\n /**\n * Whether the message is incoming or outgoing:\n * - Messages received from other chats are incoming (`outgoing = false`)\n * - Messages sent by you to other chats are outgoing (`outgoing = true`)\n * - Messages to yourself (i.e. *Saved Messages*) are incoming (`outgoing = false`)\n */\n get isOutgoing(): boolean {\n return this.raw.out!\n }\n\n /**\n * Whether this message is a service message\n */\n get isService(): boolean {\n return this.raw._ === 'messageService'\n }\n\n /** Whether this message has content protection (i.e. disabled forwards) */\n get isContentProtected(): boolean {\n return this.raw._ === 'message' && this.raw.noforwards!\n }\n\n /**\n * Whether the message was sent by an implicit action, for example,\n * as an away or a greeting business message, or as a scheduled message\n */\n get isFromOffline(): boolean {\n return this.raw._ === 'message' && this.raw.offline!\n }\n\n /** Whether this is a silent message (no notification triggered) */\n get isSilent(): boolean {\n return this.raw.silent!\n }\n\n /** Whether there are unread media attachments in this message */\n get hasUnreadMedia(): boolean {\n return this.raw.mediaUnread!\n }\n\n /** Whether this is a broadcast channel post */\n get isChannelPost(): boolean {\n return this.raw._ === 'message' && this.raw.post!\n }\n\n /**\n * Whether this message was automatically sent from a scheduled message.\n *\n * **Note**: for messages sent by other users, this is always `false`.\n */\n get isFromScheduled(): boolean {\n return this.raw._ === 'message' && this.raw.fromScheduled!\n }\n\n /** Whether the message is pinned in the current chat */\n get isPinned(): boolean {\n return this.raw._ === 'message' && this.raw.pinned!\n }\n\n /** Whether the message should be considered unedited, even if {@link editDate} ≠ null */\n get hideEditMark(): boolean {\n return this.raw._ === 'message' && this.raw.editHide!\n }\n\n /**\n * If set, any eventual webpage preview should be shown on top of\n * the message instead of at the bottom.\n */\n get invertMedia(): boolean {\n return this.raw._ === 'message' && this.raw.invertMedia!\n }\n\n /**\n * Multiple media messages with the same grouped ID\n * indicate an album or media group\n *\n * `null` for service messages and non-grouped messages\n */\n get groupedId(): tl.Long | null {\n return this.raw._ === 'message' ? this.raw.groupedId ?? null : null\n }\n\n /**\n * Same as {@link groupedId}, but is globally unique across chats.\n */\n get groupedIdUnique(): string | null {\n if (!(this.raw._ === 'message' && this.raw.groupedId !== undefined)) return null\n\n return `${this.raw.groupedId.low}|${this.raw.groupedId.high}|${getMarkedPeerId(this.raw.peerId)}`\n }\n\n /**\n * Message sender.\n *\n * Usually is a {@link User}, but can be a {@link Chat}\n * in case the message was sent by an anonymous admin, anonymous premium user,\n * or if the message is a forwarded channel post.\n *\n * If the message was sent by an anonymous admin,\n * sender will equal to {@link chat}.\n *\n * If the message is a forwarded channel post,\n * sender is the channel itself.\n */\n get sender(): Peer {\n const from = this.raw.fromId\n\n if (!from) {\n if (this.raw.peerId._ === 'peerUser') {\n return new User(this._peers.user(this.raw.peerId.userId))\n }\n\n // anon admin, return the chat\n return this.chat\n }\n\n return parsePeer(from, this._peers)\n }\n\n /**\n * Number of boosts applied to this {@link chat} by the sender\n */\n get senderBoostCount(): number {\n if (this.raw._ !== 'message') return 0\n\n return this.raw.fromBoostsApplied ?? 0\n }\n\n /**\n * Conversation the message belongs to\n */\n get chat(): Chat {\n return Chat._parseFromMessage(this.raw, this._peers)\n }\n\n /**\n * Date when the message was sent\n */\n get date(): Date {\n return new Date(this.raw.date * 1000)\n }\n\n /**\n * Date when the message was last edited\n */\n get editDate(): Date | null {\n if (this.raw._ === 'messageService') return null\n\n return this.raw.editDate ? new Date(this.raw.editDate * 1000) : null\n }\n\n /**\n * If this message is a forward, contains info about it.\n */\n get forward(): MessageForwardInfo | null {\n if (this.raw._ !== 'message' || !this.raw.fwdFrom) {\n return null\n }\n\n return new MessageForwardInfo(this.raw.fwdFrom, this._peers)\n }\n\n /**\n * Whether the message is a channel post that was\n * automatically forwarded to the connected discussion group\n */\n get isAutomaticForward(): boolean {\n if (this.raw._ === 'messageService' || !this.raw.fwdFrom) return false\n\n const fwd = this.raw.fwdFrom\n\n return Boolean(\n this.chat.chatType === 'supergroup' &&\n fwd.savedFromMsgId &&\n fwd.savedFromPeer?._ === 'peerChannel' &&\n getMarkedPeerId(fwd.savedFromPeer) !== getMarkedPeerId(this.raw.peerId),\n )\n }\n\n /**\n * Information about comments (for channels) or replies (for groups)\n */\n get replies(): MessageRepliesInfo | null {\n if (this.raw._ !== 'message' || !this.raw.replies) return null\n\n return new MessageRepliesInfo(this.raw.replies, this._peers)\n }\n\n /**\n * For replies, information about the that is being replied to.\n *\n * Mutually exclusive with {@link replyToStory}\n */\n get replyToMessage(): RepliedMessageInfo | null {\n if (this.raw.replyTo?._ !== 'messageReplyHeader') return null\n\n return new RepliedMessageInfo(this.raw.replyTo, this._peers)\n }\n\n /**\n * For replies, information about the story that is being replied to\n *\n * Mutually exclusive with {@link replyToMessage}\n */\n get replyToStory(): tl.RawMessageReplyStoryHeader | null {\n if (this.raw.replyTo?._ !== 'messageReplyStoryHeader') return null\n\n return this.raw.replyTo\n }\n\n /** Whether this message is in a forum topic */\n get isTopicMessage(): boolean {\n if (this.raw.replyTo?._ !== 'messageReplyHeader') return false\n\n return this.raw.replyTo.forumTopic!\n }\n\n /**\n * Whether this message contains mention of the current user\n */\n get isMention(): boolean {\n return this.raw.mentioned!\n }\n\n /**\n * If non-null, this message is not actually sent, and is\n * instead inside a group of \"quick reply\" messages\n * under the given shortcut ID\n */\n get quickReplyShortcutId(): number | null {\n if (this.raw._ === 'messageService') return null\n\n return this.raw.quickReplyShortcutId ?? null\n }\n\n /**\n * If this message is generated from an inline query,\n * information about the bot which generated it\n */\n get viaBot(): User | null {\n if (this.raw._ === 'messageService' || !this.raw.viaBotId) {\n return null\n }\n\n return new User(this._peers.user(this.raw.viaBotId))\n }\n\n /**\n * If this message was sent by a business bot on behalf of {@link sender},\n * information about the business bot.\n *\n * **Note**: only available to the business account and the bot itself.\n */\n get viaBusinessBot(): User | null {\n if (this.raw._ === 'messageService' || !this.raw.viaBusinessBotId) {\n return null\n }\n\n return new User(this._peers.user(this.raw.viaBusinessBotId))\n }\n\n /**\n * Message text or media caption.\n *\n * Empty string for service messages\n * (you should handle i18n yourself)\n */\n get text(): string {\n return this.raw._ === 'messageService' ? '' : this.raw.message\n }\n\n /**\n * Message text/caption entities (may be empty)\n */\n get entities(): ReadonlyArray<MessageEntity> {\n const entities: MessageEntity[] = []\n\n if (this.raw._ === 'message' && this.raw.entities?.length) {\n for (const ent of this.raw.entities) {\n entities.push(new MessageEntity(ent, this.raw.message))\n }\n }\n\n return entities\n }\n\n get textWithEntities(): TextWithEntities {\n if (this.raw._ === 'messageService') return { text: '', entities: [] }\n\n return {\n text: this.raw.message,\n entities: this.raw.entities,\n }\n }\n\n /**\n * Message action. `null` for non-service messages\n * or for unsupported events.\n *\n * For unsupported events, use `.raw.action` directly.\n */\n get action(): MessageAction | null {\n if (this.raw._ === 'message') {\n return null\n }\n\n return _messageActionFromTl.call(this, this.raw.action)\n }\n\n /**\n * Message media. `null` for text-only and service messages\n * and for unsupported media types.\n *\n * For unsupported media types, use `.raw.media` directly.\n */\n get media(): MessageMedia {\n if (this.raw._ === 'messageService' || !this.raw.media || this.raw.media._ === 'messageMediaEmpty') {\n return null\n }\n\n return _messageMediaFromTl(this._peers, this.raw.media)\n }\n\n /**\n * Whether this is a premium media\n * (e.g. >2gb file or fullscreen sticker)\n * that was forwarded without author by a non-premium user\n */\n get isForwardedPremiumMedia(): boolean {\n return this.raw._ === 'message' && this.raw.media?._ === 'messageMediaDocument' && this.raw.media.nopremium!\n }\n\n /**\n * TTL period of the message, in seconds.\n */\n get ttlPeriod(): number | null {\n return this.raw.ttlPeriod ?? null\n }\n\n /**\n * Reply markup provided with this message, if any.\n */\n get markup(): ReplyMarkup | null {\n if (this.raw._ === 'messageService' || !this.raw.replyMarkup) {\n return null\n }\n\n const rm = this.raw.replyMarkup\n\n switch (rm._) {\n case 'replyKeyboardHide':\n return {\n type: 'reply_hide',\n selective: rm.selective,\n }\n case 'replyKeyboardForceReply':\n return {\n type: 'force_reply',\n singleUse: rm.singleUse,\n selective: rm.selective,\n }\n case 'replyKeyboardMarkup':\n return {\n type: 'reply',\n resize: rm.resize,\n singleUse: rm.singleUse,\n selective: rm.selective,\n buttons: BotKeyboard._rowsTo2d(rm.rows),\n }\n case 'replyInlineMarkup':\n return {\n type: 'inline',\n buttons: BotKeyboard._rowsTo2d(rm.rows),\n }\n default:\n assertNever(rm)\n }\n }\n\n /**\n * Whether this message can be forwarded\n *\n * `false` for service mesasges and private restricted chats/chanenls\n */\n get canBeForwarded(): boolean {\n return this.raw._ === 'message' && !this.raw.noforwards\n }\n\n /**\n * Reactions added to this message, if any\n */\n get reactions(): MessageReactions | null {\n if (this.raw._ === 'messageService' || !this.raw.reactions) {\n return null\n }\n\n return new MessageReactions(this.raw.id, getMarkedPeerId(this.raw.peerId), this.raw.reactions, this._peers)\n }\n\n /**\n * Information about fact-check added to the message, if any\n */\n get factCheck(): FactCheck | null {\n if (this.raw._ === 'messageService') return null\n if (!this.raw.factcheck || this.raw.factcheck.hash.isZero()) return null\n\n return new FactCheck(this.raw.factcheck)\n }\n\n /**\n * If this message was sent with a message effect, ID of the effect\n */\n get effectId(): tl.Long | null {\n if (this.raw._ === 'messageService') return null\n\n return this.raw.effect ?? null\n }\n\n /**\n * Generated permalink to this message, only for groups and channels\n *\n * @throws MtArgumentError In case the chat does not support message links\n */\n get link(): string {\n if (this.chat.chatType === 'supergroup' || this.chat.chatType === 'channel') {\n if (this.chat.username) {\n return `https://t.me/${this.chat.username}/${this.id}`\n }\n\n return `https://t.me/c/${toggleChannelIdMark(this.chat.id)}/${this.id}`\n }\n\n throw new MtArgumentError(`Cannot generate message link for ${this.chat.chatType}`)\n }\n}\n\nmemoizeGetters(Message, [\n 'sender',\n 'chat',\n 'forward',\n 'replies',\n 'viaBot',\n 'entities',\n 'action',\n 'media',\n 'markup',\n 'reactions',\n 'factCheck',\n])\nmakeInspectable(Message, ['isScheduled'], ['link'])\n"]}
@@ -9,7 +9,6 @@ import { ConfigManager } from './config-manager.js';
9
9
  import { NetworkManager, NetworkManagerExtraParams, RpcCallOptions } from './network-manager.js';
10
10
  import { PersistentConnectionParams } from './persistent-connection.js';
11
11
  import { ReconnectionStrategy } from './reconnection.js';
12
- import { SessionConnection } from './session-connection.js';
13
12
  import { TransportFactory } from './transports/index.js';
14
13
  /** Options for {@link MtClient} */
15
14
  export interface MtClientOptions {
@@ -196,7 +195,7 @@ export declare class MtClient extends EventEmitter {
196
195
  readonly log: Logger;
197
196
  readonly network: NetworkManager;
198
197
  constructor(params: MtClientOptions);
199
- emitError(err: unknown, connection?: SessionConnection): void;
198
+ emitError(err: unknown): void;
200
199
  private _prepare;
201
200
  /**
202
201
  * **ADVANCED**
@@ -96,9 +96,9 @@ export class MtClient extends EventEmitter {
96
96
  ...params.network,
97
97
  }, this._config);
98
98
  }
99
- emitError(err, connection) {
99
+ emitError(err) {
100
100
  if (this._emitError) {
101
- this._emitError(err, connection);
101
+ this._emitError(err);
102
102
  }
103
103
  else {
104
104
  this.log.error('unhandled error:', err);
@@ -170,7 +170,7 @@ export class MtClient extends EventEmitter {
170
170
  * @param handler Error handler.
171
171
  */
172
172
  onError(handler) {
173
- this.emitError = handler;
173
+ this._emitError = handler;
174
174
  }
175
175
  }
176
176
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/network/client.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAA;AAC/B,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAI/E,OAAO,EAAE,cAAc,EA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AC,CAAC,SAAS,CAAA;QAE9D,+DAA+D;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IACpD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,OAA+B;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAA;IAC5B,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport EventEmitter from 'events'\n\nimport { tl } from '@mtcute/tl'\nimport { __tlReaderMap as defaultReaderMap } from '@mtcute/tl/binary/reader.js'\nimport { __tlWriterMap as defaultWriterMap } from '@mtcute/tl/binary/writer.js'\nimport { TlReaderMap, TlWriterMap } from '@mtcute/tl-runtime'\n\nimport { IMtStorageProvider } from '../storage/provider.js'\nimport { StorageManager, StorageManagerExtraOptions } from '../storage/storage.js'\nimport { MustEqual } from '../types/index.js'\nimport {\n asyncResettable,\n DcOptions,\n defaultProductionDc,\n defaultProductionIpv6Dc,\n defaultTestDc,\n defaultTestIpv6Dc,\n ICryptoProvider,\n Logger,\n LogManager,\n} from '../utils/index.js'\nimport { ConfigManager } from './config-manager.js'\nimport { NetworkManager, NetworkManagerExtraParams, RpcCallOptions } from './network-manager.js'\nimport { PersistentConnectionParams } from './persistent-connection.js'\nimport { ReconnectionStrategy } from './reconnection.js'\nimport { SessionConnection } from './session-connection.js'\nimport { TransportFactory } from './transports/index.js'\n\n/** Options for {@link MtClient} */\nexport interface MtClientOptions {\n /**\n * API ID from my.telegram.org\n */\n apiId: number\n /**\n * API hash from my.telegram.org\n */\n apiHash: string\n\n /**\n * Storage to use for this client.\n */\n storage: IMtStorageProvider\n\n /** Additional options for the storage manager */\n storageOptions?: StorageManagerExtraOptions\n\n /**\n * Cryptography provider to allow delegating\n * crypto to native addon, worker, etc.\n */\n crypto: ICryptoProvider\n\n /**\n * Whether to use IPv6 datacenters\n * (IPv6 will be preferred when choosing a DC by id)\n * (default: false)\n */\n useIpv6?: boolean\n\n /**\n * Primary DC to use for initial connection.\n * This does not mean this will be the only DC used,\n * nor that this DC will actually be primary, this only\n * determines the first DC the library will try to connect to.\n * Can be used to connect to other networks (like test DCs).\n *\n * When session already contains primary DC, this parameter is ignored.\n *\n * @default Production DC 2.\n */\n defaultDcs?: DcOptions\n\n /**\n * Whether to connect to test servers.\n *\n * If passed, {@link defaultDc} defaults to Test DC 2.\n *\n * **Must** be passed if using test servers, even if\n * you passed custom {@link defaultDc}\n */\n testMode?: boolean\n\n /**\n * Additional options for initConnection call.\n * `apiId` and `query` are not available and will be ignored.\n * Omitted values will be filled with defaults\n */\n initConnectionOptions?: Partial<Omit<tl.RawInitConnectionRequest, 'apiId' | 'query'>>\n\n /**\n * Transport factory to use in the client.\n *\n * @default platform-specific transport: WebSocket on the web, TCP in node\n */\n transport: TransportFactory\n\n /**\n * Reconnection strategy.\n *\n * @default simple reconnection strategy: first 0ms, then up to 5s (increasing by 1s)\n */\n reconnectionStrategy?: ReconnectionStrategy<PersistentConnectionParams>\n\n /**\n * Maximum duration of a flood_wait that will be waited automatically.\n * Flood waits above this threshold will throw a FloodWaitError.\n * Set to 0 to disable. Can be overridden with `throwFlood` parameter in call() params\n *\n * @default 10000\n */\n floodSleepThreshold?: number\n\n /**\n * Maximum number of retries when calling RPC methods.\n * Call is retried when InternalError or FloodWaitError is encountered.\n * Can be set to Infinity.\n *\n * @default 5\n */\n maxRetryCount?: number\n\n /**\n * If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`,\n * effectively disabling the server-sent events for the clients.\n * May be useful in some cases.\n *\n * @default false\n */\n disableUpdates?: boolean\n\n /**\n * mtcute can send all unknown RPC errors to [danog](https://github.com/danog)'s\n * [error reporting service](https://rpc.pwrtelegram.xyz/).\n *\n * This is fully anonymous (except maybe IP) and is only used to improve the library\n * and developer experience for everyone working with MTProto. This is fully opt-in,\n * and if you're too paranoid, you can disable it by manually passing `enableErrorReporting: false` to the client.\n *\n * @default false\n */\n enableErrorReporting?: boolean\n\n /**\n * If true, RPC errors will have a stack trace of the initial `.call()`\n * or `.sendForResult()` call position, which drastically improves\n * debugging experience.<br>\n * If false, they will have a stack trace of mtcute internals.\n *\n * Internally this creates a stack capture before every RPC call\n * and stores it until the result is received. This might\n * use a lot more memory than normal, thus can be disabled here.\n *\n * @default true\n */\n niceStacks?: boolean\n\n /**\n * Extra parameters for {@link NetworkManager}\n */\n network?: NetworkManagerExtraParams\n\n /**\n * Logger instance for the client.\n * If not passed, a new one will be created.\n */\n logger?: Logger\n\n /**\n * Set logging level for the client.\n * Shorthand for `client.log.level = level`.\n *\n * See static members of {@link LogManager} for possible values.\n */\n logLevel?: number\n\n /**\n * **EXPERT USE ONLY!**\n *\n * Override TL layer used for the connection.\n *\n * **Does not** change the schema used.\n */\n overrideLayer?: number\n\n /**\n * **EXPERT USE ONLY**\n *\n * Override reader map used for the connection.\n */\n readerMap?: TlReaderMap\n\n /**\n * **EXPERT USE ONLY**\n *\n * Override writer map used for the connection.\n */\n writerMap?: TlWriterMap\n}\n\n/**\n * Basic MTProto client implementation, only doing the bare minimum\n * to make RPC calls and receive low-level updates, as well as providing\n * some APIs to manage that.\n */\nexport class MtClient extends EventEmitter {\n /**\n * Crypto provider taken from {@link MtClientOptions.crypto}\n */\n readonly crypto: ICryptoProvider\n\n /** Storage manager */\n readonly storage: StorageManager\n\n /**\n * \"Test mode\" taken from {@link MtClientOptions.testMode}\n */\n protected readonly _testMode: boolean\n\n /**\n * Primary DCs taken from {@link MtClientOptions.defaultDcs},\n * loaded from session or changed by other means (like redirecting).\n */\n _defaultDcs: DcOptions\n\n private _niceStacks: boolean\n /** TL layer used by the client */\n readonly _layer: number\n /** TL readers map used by the client */\n readonly _readerMap: TlReaderMap\n /** TL writers map used by the client */\n readonly _writerMap: TlWriterMap\n\n readonly _config = new ConfigManager(() => this.call({ _: 'help.getConfig' }))\n\n private _emitError?: (err: unknown, connection?: SessionConnection) => void\n\n readonly log: Logger\n readonly network: NetworkManager\n\n constructor(readonly params: MtClientOptions) {\n super()\n\n this.log = params.logger ?? new LogManager()\n\n if (params.logLevel !== undefined) {\n this.log.mgr.level = params.logLevel\n }\n\n this.crypto = params.crypto\n this._testMode = Boolean(params.testMode)\n\n let dc = params.defaultDcs\n\n if (!dc) {\n if (params.testMode) {\n dc = params.useIpv6 ? defaultTestIpv6Dc : defaultTestDc\n } else {\n dc = params.useIpv6 ? defaultProductionIpv6Dc : defaultProductionDc\n }\n }\n\n this._defaultDcs = dc\n this._niceStacks = params.niceStacks ?? true\n\n this._layer = params.overrideLayer ?? tl.LAYER\n this._readerMap = params.readerMap ?? defaultReaderMap\n this._writerMap = params.writerMap ?? defaultWriterMap\n\n this.storage = new StorageManager({\n provider: params.storage,\n log: this.log,\n readerMap: this._readerMap,\n writerMap: this._writerMap,\n ...params.storageOptions,\n })\n\n this.network = new NetworkManager(\n {\n apiId: params.apiId,\n crypto: this.crypto,\n disableUpdates: params.disableUpdates ?? false,\n initConnectionOptions: params.initConnectionOptions,\n layer: this._layer,\n log: this.log,\n readerMap: this._readerMap,\n writerMap: this._writerMap,\n reconnectionStrategy: params.reconnectionStrategy,\n storage: this.storage,\n testMode: Boolean(params.testMode),\n transport: params.transport,\n emitError: this.emitError.bind(this),\n floodSleepThreshold: params.floodSleepThreshold ?? 10000,\n maxRetryCount: params.maxRetryCount ?? 5,\n isPremium: false,\n useIpv6: Boolean(params.useIpv6),\n enableErrorReporting: params.enableErrorReporting ?? false,\n onUsable: () => this.emit('usable'),\n onConnecting: () => this.emit('connecting'),\n onNetworkChanged: (connected) => this.emit('networkChanged', connected),\n onUpdate: (upd) => this.emit('update', upd),\n ...params.network,\n },\n this._config,\n )\n }\n\n emitError(err: unknown, connection?: SessionConnection): void {\n if (this._emitError) {\n this._emitError(err, connection)\n } else {\n this.log.error('unhandled error:', err)\n }\n }\n\n private _prepare = asyncResettable(async () => {\n await this.crypto.initialize?.()\n await this.storage.load()\n\n const primaryDc = await this.storage.dcs.fetch()\n if (primaryDc !== null) this._defaultDcs = primaryDc\n })\n\n /**\n * **ADVANCED**\n *\n * Do all the preparations, but don't connect just yet.\n * Useful when you want to do some preparations before\n * connecting, like setting up session.\n *\n * Call {@link connect} to actually connect.\n */\n prepare() {\n return this._prepare.run()\n }\n\n private _connect = asyncResettable(async () => {\n await this._prepare.run()\n await this.network.connect(this._defaultDcs)\n })\n\n /**\n * Initialize the connection to the primary DC.\n *\n * You shouldn't usually call this method directly as it is called\n * implicitly the first time you call {@link call}.\n */\n async connect(): Promise<void> {\n return this._connect.run()\n }\n\n /**\n * Close all connections and finalize the client.\n */\n async close(): Promise<void> {\n this._config.destroy()\n await this.network.destroy()\n\n await this.storage.save()\n await this.storage.destroy?.()\n\n this._prepare.reset()\n this._connect.reset()\n }\n\n /**\n * Make an RPC call.\n *\n * The connection must have been {@link connect}-ed\n * before calling this method.\n *\n * This method is still quite low-level and you shouldn't use this\n * when using high-level API provided by `@mtcute/client`.\n *\n * @param message RPC method to call\n * @param params Additional call parameters\n */\n async call<T extends tl.RpcMethod>(\n message: MustEqual<T, tl.RpcMethod>,\n params?: RpcCallOptions,\n ): Promise<tl.RpcCallReturn[T['_']]> {\n const stack = this._niceStacks ? new Error().stack : undefined\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.network.call(message, params, stack)\n }\n\n /**\n * Register an error handler for the client\n *\n * @param handler Error handler.\n */\n onError(handler: (err: unknown) => void): void {\n this.emitError = handler\n }\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/network/client.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,YAAY,MAAM,QAAQ,CAAA;AAEjC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAA;AAC/B,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAC/E,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAI/E,OAAO,EAAE,cAAc,EAA8B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+DAA+D;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IACpD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,OAA+B;QACnC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAA;IAC7B,CAAC;CACJ","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport EventEmitter from 'events'\n\nimport { tl } from '@mtcute/tl'\nimport { __tlReaderMap as defaultReaderMap } from '@mtcute/tl/binary/reader.js'\nimport { __tlWriterMap as defaultWriterMap } from '@mtcute/tl/binary/writer.js'\nimport { TlReaderMap, TlWriterMap } from '@mtcute/tl-runtime'\n\nimport { IMtStorageProvider } from '../storage/provider.js'\nimport { StorageManager, StorageManagerExtraOptions } from '../storage/storage.js'\nimport { MustEqual } from '../types/index.js'\nimport {\n asyncResettable,\n DcOptions,\n defaultProductionDc,\n defaultProductionIpv6Dc,\n defaultTestDc,\n defaultTestIpv6Dc,\n ICryptoProvider,\n Logger,\n LogManager,\n} from '../utils/index.js'\nimport { ConfigManager } from './config-manager.js'\nimport { NetworkManager, NetworkManagerExtraParams, RpcCallOptions } from './network-manager.js'\nimport { PersistentConnectionParams } from './persistent-connection.js'\nimport { ReconnectionStrategy } from './reconnection.js'\nimport { TransportFactory } from './transports/index.js'\n\n/** Options for {@link MtClient} */\nexport interface MtClientOptions {\n /**\n * API ID from my.telegram.org\n */\n apiId: number\n /**\n * API hash from my.telegram.org\n */\n apiHash: string\n\n /**\n * Storage to use for this client.\n */\n storage: IMtStorageProvider\n\n /** Additional options for the storage manager */\n storageOptions?: StorageManagerExtraOptions\n\n /**\n * Cryptography provider to allow delegating\n * crypto to native addon, worker, etc.\n */\n crypto: ICryptoProvider\n\n /**\n * Whether to use IPv6 datacenters\n * (IPv6 will be preferred when choosing a DC by id)\n * (default: false)\n */\n useIpv6?: boolean\n\n /**\n * Primary DC to use for initial connection.\n * This does not mean this will be the only DC used,\n * nor that this DC will actually be primary, this only\n * determines the first DC the library will try to connect to.\n * Can be used to connect to other networks (like test DCs).\n *\n * When session already contains primary DC, this parameter is ignored.\n *\n * @default Production DC 2.\n */\n defaultDcs?: DcOptions\n\n /**\n * Whether to connect to test servers.\n *\n * If passed, {@link defaultDc} defaults to Test DC 2.\n *\n * **Must** be passed if using test servers, even if\n * you passed custom {@link defaultDc}\n */\n testMode?: boolean\n\n /**\n * Additional options for initConnection call.\n * `apiId` and `query` are not available and will be ignored.\n * Omitted values will be filled with defaults\n */\n initConnectionOptions?: Partial<Omit<tl.RawInitConnectionRequest, 'apiId' | 'query'>>\n\n /**\n * Transport factory to use in the client.\n *\n * @default platform-specific transport: WebSocket on the web, TCP in node\n */\n transport: TransportFactory\n\n /**\n * Reconnection strategy.\n *\n * @default simple reconnection strategy: first 0ms, then up to 5s (increasing by 1s)\n */\n reconnectionStrategy?: ReconnectionStrategy<PersistentConnectionParams>\n\n /**\n * Maximum duration of a flood_wait that will be waited automatically.\n * Flood waits above this threshold will throw a FloodWaitError.\n * Set to 0 to disable. Can be overridden with `throwFlood` parameter in call() params\n *\n * @default 10000\n */\n floodSleepThreshold?: number\n\n /**\n * Maximum number of retries when calling RPC methods.\n * Call is retried when InternalError or FloodWaitError is encountered.\n * Can be set to Infinity.\n *\n * @default 5\n */\n maxRetryCount?: number\n\n /**\n * If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`,\n * effectively disabling the server-sent events for the clients.\n * May be useful in some cases.\n *\n * @default false\n */\n disableUpdates?: boolean\n\n /**\n * mtcute can send all unknown RPC errors to [danog](https://github.com/danog)'s\n * [error reporting service](https://rpc.pwrtelegram.xyz/).\n *\n * This is fully anonymous (except maybe IP) and is only used to improve the library\n * and developer experience for everyone working with MTProto. This is fully opt-in,\n * and if you're too paranoid, you can disable it by manually passing `enableErrorReporting: false` to the client.\n *\n * @default false\n */\n enableErrorReporting?: boolean\n\n /**\n * If true, RPC errors will have a stack trace of the initial `.call()`\n * or `.sendForResult()` call position, which drastically improves\n * debugging experience.<br>\n * If false, they will have a stack trace of mtcute internals.\n *\n * Internally this creates a stack capture before every RPC call\n * and stores it until the result is received. This might\n * use a lot more memory than normal, thus can be disabled here.\n *\n * @default true\n */\n niceStacks?: boolean\n\n /**\n * Extra parameters for {@link NetworkManager}\n */\n network?: NetworkManagerExtraParams\n\n /**\n * Logger instance for the client.\n * If not passed, a new one will be created.\n */\n logger?: Logger\n\n /**\n * Set logging level for the client.\n * Shorthand for `client.log.level = level`.\n *\n * See static members of {@link LogManager} for possible values.\n */\n logLevel?: number\n\n /**\n * **EXPERT USE ONLY!**\n *\n * Override TL layer used for the connection.\n *\n * **Does not** change the schema used.\n */\n overrideLayer?: number\n\n /**\n * **EXPERT USE ONLY**\n *\n * Override reader map used for the connection.\n */\n readerMap?: TlReaderMap\n\n /**\n * **EXPERT USE ONLY**\n *\n * Override writer map used for the connection.\n */\n writerMap?: TlWriterMap\n}\n\n/**\n * Basic MTProto client implementation, only doing the bare minimum\n * to make RPC calls and receive low-level updates, as well as providing\n * some APIs to manage that.\n */\nexport class MtClient extends EventEmitter {\n /**\n * Crypto provider taken from {@link MtClientOptions.crypto}\n */\n readonly crypto: ICryptoProvider\n\n /** Storage manager */\n readonly storage: StorageManager\n\n /**\n * \"Test mode\" taken from {@link MtClientOptions.testMode}\n */\n protected readonly _testMode: boolean\n\n /**\n * Primary DCs taken from {@link MtClientOptions.defaultDcs},\n * loaded from session or changed by other means (like redirecting).\n */\n _defaultDcs: DcOptions\n\n private _niceStacks: boolean\n /** TL layer used by the client */\n readonly _layer: number\n /** TL readers map used by the client */\n readonly _readerMap: TlReaderMap\n /** TL writers map used by the client */\n readonly _writerMap: TlWriterMap\n\n readonly _config = new ConfigManager(() => this.call({ _: 'help.getConfig' }))\n\n private _emitError?: (err: unknown) => void\n\n readonly log: Logger\n readonly network: NetworkManager\n\n constructor(readonly params: MtClientOptions) {\n super()\n\n this.log = params.logger ?? new LogManager()\n\n if (params.logLevel !== undefined) {\n this.log.mgr.level = params.logLevel\n }\n\n this.crypto = params.crypto\n this._testMode = Boolean(params.testMode)\n\n let dc = params.defaultDcs\n\n if (!dc) {\n if (params.testMode) {\n dc = params.useIpv6 ? defaultTestIpv6Dc : defaultTestDc\n } else {\n dc = params.useIpv6 ? defaultProductionIpv6Dc : defaultProductionDc\n }\n }\n\n this._defaultDcs = dc\n this._niceStacks = params.niceStacks ?? true\n\n this._layer = params.overrideLayer ?? tl.LAYER\n this._readerMap = params.readerMap ?? defaultReaderMap\n this._writerMap = params.writerMap ?? defaultWriterMap\n\n this.storage = new StorageManager({\n provider: params.storage,\n log: this.log,\n readerMap: this._readerMap,\n writerMap: this._writerMap,\n ...params.storageOptions,\n })\n\n this.network = new NetworkManager(\n {\n apiId: params.apiId,\n crypto: this.crypto,\n disableUpdates: params.disableUpdates ?? false,\n initConnectionOptions: params.initConnectionOptions,\n layer: this._layer,\n log: this.log,\n readerMap: this._readerMap,\n writerMap: this._writerMap,\n reconnectionStrategy: params.reconnectionStrategy,\n storage: this.storage,\n testMode: Boolean(params.testMode),\n transport: params.transport,\n emitError: this.emitError.bind(this),\n floodSleepThreshold: params.floodSleepThreshold ?? 10000,\n maxRetryCount: params.maxRetryCount ?? 5,\n isPremium: false,\n useIpv6: Boolean(params.useIpv6),\n enableErrorReporting: params.enableErrorReporting ?? false,\n onUsable: () => this.emit('usable'),\n onConnecting: () => this.emit('connecting'),\n onNetworkChanged: (connected) => this.emit('networkChanged', connected),\n onUpdate: (upd) => this.emit('update', upd),\n ...params.network,\n },\n this._config,\n )\n }\n\n emitError(err: unknown): void {\n if (this._emitError) {\n this._emitError(err)\n } else {\n this.log.error('unhandled error:', err)\n }\n }\n\n private _prepare = asyncResettable(async () => {\n await this.crypto.initialize?.()\n await this.storage.load()\n\n const primaryDc = await this.storage.dcs.fetch()\n if (primaryDc !== null) this._defaultDcs = primaryDc\n })\n\n /**\n * **ADVANCED**\n *\n * Do all the preparations, but don't connect just yet.\n * Useful when you want to do some preparations before\n * connecting, like setting up session.\n *\n * Call {@link connect} to actually connect.\n */\n prepare() {\n return this._prepare.run()\n }\n\n private _connect = asyncResettable(async () => {\n await this._prepare.run()\n await this.network.connect(this._defaultDcs)\n })\n\n /**\n * Initialize the connection to the primary DC.\n *\n * You shouldn't usually call this method directly as it is called\n * implicitly the first time you call {@link call}.\n */\n async connect(): Promise<void> {\n return this._connect.run()\n }\n\n /**\n * Close all connections and finalize the client.\n */\n async close(): Promise<void> {\n this._config.destroy()\n await this.network.destroy()\n\n await this.storage.save()\n await this.storage.destroy?.()\n\n this._prepare.reset()\n this._connect.reset()\n }\n\n /**\n * Make an RPC call.\n *\n * The connection must have been {@link connect}-ed\n * before calling this method.\n *\n * This method is still quite low-level and you shouldn't use this\n * when using high-level API provided by `@mtcute/client`.\n *\n * @param message RPC method to call\n * @param params Additional call parameters\n */\n async call<T extends tl.RpcMethod>(\n message: MustEqual<T, tl.RpcMethod>,\n params?: RpcCallOptions,\n ): Promise<tl.RpcCallReturn[T['_']]> {\n const stack = this._niceStacks ? new Error().stack : undefined\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.network.call(message, params, stack)\n }\n\n /**\n * Register an error handler for the client\n *\n * @param handler Error handler.\n */\n onError(handler: (err: unknown) => void): void {\n this._emitError = handler\n }\n}\n"]}
@@ -244,7 +244,7 @@ export class NetworkManager {
244
244
  _: 'initConnection',
245
245
  deviceModel,
246
246
  systemVersion: '1.0',
247
- appVersion: '0.12.2',
247
+ appVersion: '0.13.0',
248
248
  systemLangCode: 'en',
249
249
  langPack: '', // "langPacks are for official apps only"
250
250
  langCode: 'en',
@@ -1090,7 +1090,7 @@ export class SessionConnection extends PersistentConnection {
1090
1090
  return pending.promise;
1091
1091
  }
1092
1092
  if (timeout) {
1093
- pending.timeout = setTimeout(this._cancelRpc, timeout, pending, true);
1093
+ pending.timeout = setTimeout(() => this._cancelRpc(pending, true), timeout);
1094
1094
  }
1095
1095
  if (abortSignal) {
1096
1096
  abortSignal.addEventListener('abort', () => this._cancelRpc(pending, false, abortSignal));