@mtcute/core 0.16.0 → 0.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +2 -3
  2. package/cjs/highlevel/client.d.ts +30 -2
  3. package/cjs/highlevel/client.js.map +1 -1
  4. package/cjs/highlevel/methods/auth/run.d.ts +1 -0
  5. package/cjs/highlevel/methods/auth/run.js +1 -0
  6. package/cjs/highlevel/methods/auth/run.js.map +1 -1
  7. package/cjs/highlevel/methods/chats/delete-user-history.d.ts +5 -0
  8. package/cjs/highlevel/methods/chats/delete-user-history.js +4 -2
  9. package/cjs/highlevel/methods/chats/delete-user-history.js.map +1 -1
  10. package/cjs/highlevel/methods/files/normalize-input-media.js +1 -1
  11. package/cjs/highlevel/methods/files/normalize-input-media.js.map +1 -1
  12. package/cjs/highlevel/methods/forums/delete-forum-topic-history.d.ts +7 -1
  13. package/cjs/highlevel/methods/forums/delete-forum-topic-history.js +5 -2
  14. package/cjs/highlevel/methods/forums/delete-forum-topic-history.js.map +1 -1
  15. package/cjs/highlevel/methods/messages/delete-messages.d.ts +5 -0
  16. package/cjs/highlevel/methods/messages/delete-messages.js +4 -2
  17. package/cjs/highlevel/methods/messages/delete-messages.js.map +1 -1
  18. package/cjs/highlevel/methods/messages/read-history.d.ts +5 -0
  19. package/cjs/highlevel/methods/messages/read-history.js +11 -7
  20. package/cjs/highlevel/methods/messages/read-history.js.map +1 -1
  21. package/cjs/highlevel/methods/messages/read-reactions.d.ts +7 -1
  22. package/cjs/highlevel/methods/messages/read-reactions.js +5 -2
  23. package/cjs/highlevel/methods/messages/read-reactions.js.map +1 -1
  24. package/cjs/highlevel/methods/messages/send-common.d.ts +2 -2
  25. package/cjs/highlevel/methods/messages/send-common.js.map +1 -1
  26. package/cjs/highlevel/methods/messages/send-text.js +3 -3
  27. package/cjs/highlevel/methods/messages/send-text.js.map +1 -1
  28. package/cjs/highlevel/methods/messages/unpin-all-messages.d.ts +5 -0
  29. package/cjs/highlevel/methods/messages/unpin-all-messages.js +8 -6
  30. package/cjs/highlevel/methods/messages/unpin-all-messages.js.map +1 -1
  31. package/cjs/highlevel/types/media/video.d.ts +1 -0
  32. package/cjs/highlevel/types/media/video.js +3 -0
  33. package/cjs/highlevel/types/media/video.js.map +1 -1
  34. package/cjs/highlevel/types/messages/message-action.d.ts +15 -1
  35. package/cjs/highlevel/types/messages/message-action.js +9 -0
  36. package/cjs/highlevel/types/messages/message-action.js.map +1 -1
  37. package/cjs/highlevel/types/peers/user.d.ts +4 -0
  38. package/cjs/highlevel/types/peers/user.js +8 -0
  39. package/cjs/highlevel/types/peers/user.js.map +1 -1
  40. package/cjs/highlevel/types/stories/interactive/index.d.ts +3 -2
  41. package/cjs/highlevel/types/stories/interactive/index.js +5 -1
  42. package/cjs/highlevel/types/stories/interactive/index.js.map +1 -1
  43. package/cjs/highlevel/types/stories/interactive/weather.d.ts +15 -0
  44. package/cjs/highlevel/types/stories/interactive/weather.js +30 -0
  45. package/cjs/highlevel/types/stories/interactive/weather.js.map +1 -0
  46. package/cjs/highlevel/updates/types.d.ts +2 -0
  47. package/cjs/highlevel/updates/types.js.map +1 -1
  48. package/cjs/highlevel/worker/invoker.js +1 -1
  49. package/cjs/highlevel/worker/invoker.js.map +1 -1
  50. package/cjs/highlevel/worker/protocol.d.ts +1 -1
  51. package/cjs/highlevel/worker/protocol.js +9 -6
  52. package/cjs/highlevel/worker/protocol.js.map +1 -1
  53. package/cjs/highlevel/worker/worker.js +6 -3
  54. package/cjs/highlevel/worker/worker.js.map +1 -1
  55. package/cjs/network/network-manager.js +1 -1
  56. package/esm/highlevel/client.d.ts +30 -2
  57. package/esm/highlevel/client.js.map +1 -1
  58. package/esm/highlevel/methods/auth/run.d.ts +1 -0
  59. package/esm/highlevel/methods/auth/run.js +1 -0
  60. package/esm/highlevel/methods/auth/run.js.map +1 -1
  61. package/esm/highlevel/methods/chats/delete-user-history.d.ts +5 -0
  62. package/esm/highlevel/methods/chats/delete-user-history.js +4 -2
  63. package/esm/highlevel/methods/chats/delete-user-history.js.map +1 -1
  64. package/esm/highlevel/methods/files/normalize-input-media.js +1 -1
  65. package/esm/highlevel/methods/files/normalize-input-media.js.map +1 -1
  66. package/esm/highlevel/methods/forums/delete-forum-topic-history.d.ts +7 -1
  67. package/esm/highlevel/methods/forums/delete-forum-topic-history.js +5 -2
  68. package/esm/highlevel/methods/forums/delete-forum-topic-history.js.map +1 -1
  69. package/esm/highlevel/methods/messages/delete-messages.d.ts +5 -0
  70. package/esm/highlevel/methods/messages/delete-messages.js +4 -2
  71. package/esm/highlevel/methods/messages/delete-messages.js.map +1 -1
  72. package/esm/highlevel/methods/messages/read-history.d.ts +5 -0
  73. package/esm/highlevel/methods/messages/read-history.js +11 -7
  74. package/esm/highlevel/methods/messages/read-history.js.map +1 -1
  75. package/esm/highlevel/methods/messages/read-reactions.d.ts +7 -1
  76. package/esm/highlevel/methods/messages/read-reactions.js +5 -2
  77. package/esm/highlevel/methods/messages/read-reactions.js.map +1 -1
  78. package/esm/highlevel/methods/messages/send-common.d.ts +2 -2
  79. package/esm/highlevel/methods/messages/send-common.js.map +1 -1
  80. package/esm/highlevel/methods/messages/send-text.js +3 -3
  81. package/esm/highlevel/methods/messages/send-text.js.map +1 -1
  82. package/esm/highlevel/methods/messages/unpin-all-messages.d.ts +5 -0
  83. package/esm/highlevel/methods/messages/unpin-all-messages.js +8 -6
  84. package/esm/highlevel/methods/messages/unpin-all-messages.js.map +1 -1
  85. package/esm/highlevel/types/media/video.d.ts +1 -0
  86. package/esm/highlevel/types/media/video.js +3 -0
  87. package/esm/highlevel/types/media/video.js.map +1 -1
  88. package/esm/highlevel/types/messages/message-action.d.ts +15 -1
  89. package/esm/highlevel/types/messages/message-action.js +9 -0
  90. package/esm/highlevel/types/messages/message-action.js.map +1 -1
  91. package/esm/highlevel/types/peers/user.d.ts +4 -0
  92. package/esm/highlevel/types/peers/user.js +8 -0
  93. package/esm/highlevel/types/peers/user.js.map +1 -1
  94. package/esm/highlevel/types/stories/interactive/index.d.ts +3 -2
  95. package/esm/highlevel/types/stories/interactive/index.js +4 -1
  96. package/esm/highlevel/types/stories/interactive/index.js.map +1 -1
  97. package/esm/highlevel/types/stories/interactive/weather.d.ts +15 -0
  98. package/esm/highlevel/types/stories/interactive/weather.js +27 -0
  99. package/esm/highlevel/types/stories/interactive/weather.js.map +1 -0
  100. package/esm/highlevel/updates/types.d.ts +2 -0
  101. package/esm/highlevel/updates/types.js.map +1 -1
  102. package/esm/highlevel/worker/invoker.js +2 -2
  103. package/esm/highlevel/worker/invoker.js.map +1 -1
  104. package/esm/highlevel/worker/protocol.d.ts +1 -1
  105. package/esm/highlevel/worker/protocol.js +9 -6
  106. package/esm/highlevel/worker/protocol.js.map +1 -1
  107. package/esm/highlevel/worker/worker.js +7 -4
  108. package/esm/highlevel/worker/worker.js.map +1 -1
  109. package/esm/network/network-manager.js +1 -1
  110. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"unpin-all-messages.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/messages/unpin-all-messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAClC,MAAuB,EACvB,MAAqB,EACrB,MAKC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAEhC,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE9C,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;QAC1B,CAAC,EAAE,2BAA2B;QAC9B,IAAI;QACJ,QAAQ,EAAE,OAAO;KACpB,CAAC,CAAA;IAEF,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;IACvF,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACvE,CAAC;AACL,CAAC","sourcesContent":["import { ITelegramClient } from '../../client.types.js'\nimport { InputPeerLike } from '../../types/index.js'\nimport { createDummyUpdate } from '../../updates/utils.js'\nimport { isInputPeerChannel } from '../../utils/peer-utils.js'\nimport { resolvePeer } from '../users/resolve-peer.js'\n\n/**\n * Unpin all pinned messages in a chat.\n *\n * @param chatId Chat or user ID\n */\nexport async function unpinAllMessages(\n client: ITelegramClient,\n chatId: InputPeerLike,\n params?: {\n /**\n * For forums - unpin only messages from the given topic\n */\n topicId?: number\n },\n): Promise<void> {\n const { topicId } = params ?? {}\n\n const peer = await resolvePeer(client, chatId)\n\n const res = await client.call({\n _: 'messages.unpinAllMessages',\n peer,\n topMsgId: topicId,\n })\n\n if (isInputPeerChannel(peer)) {\n client.handleClientUpdate(createDummyUpdate(res.pts, res.ptsCount, peer.channelId))\n } else {\n client.handleClientUpdate(createDummyUpdate(res.pts, res.ptsCount))\n }\n}\n"]}
1
+ {"version":3,"file":"unpin-all-messages.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/messages/unpin-all-messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAClC,MAAuB,EACvB,MAAqB,EACrB,MAWC;IAED,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAEhD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE9C,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;QAC1B,CAAC,EAAE,2BAA2B;QAC9B,IAAI;QACJ,QAAQ,EAAE,OAAO;KACpB,CAAC,CAAA;IAEF,IAAI,CAAC,cAAc,EAAE,CAAC;QAClB,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;QACvF,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;QACvE,CAAC;IACL,CAAC;AACL,CAAC","sourcesContent":["import { ITelegramClient } from '../../client.types.js'\nimport { InputPeerLike } from '../../types/index.js'\nimport { createDummyUpdate } from '../../updates/utils.js'\nimport { isInputPeerChannel } from '../../utils/peer-utils.js'\nimport { resolvePeer } from '../users/resolve-peer.js'\n\n/**\n * Unpin all pinned messages in a chat.\n *\n * @param chatId Chat or user ID\n */\nexport async function unpinAllMessages(\n client: ITelegramClient,\n chatId: InputPeerLike,\n params?: {\n /**\n * For forums - unpin only messages from the given topic\n */\n topicId?: number\n\n /**\n * Whether to dispatch updates that will be generated by this call.\n * Doesn't follow `disableNoDispatch`\n */\n shouldDispatch?: true\n },\n): Promise<void> {\n const { topicId, shouldDispatch } = params ?? {}\n\n const peer = await resolvePeer(client, chatId)\n\n const res = await client.call({\n _: 'messages.unpinAllMessages',\n peer,\n topMsgId: topicId,\n })\n\n if (!shouldDispatch) {\n if (isInputPeerChannel(peer)) {\n client.handleClientUpdate(createDummyUpdate(res.pts, res.ptsCount, peer.channelId))\n } else {\n client.handleClientUpdate(createDummyUpdate(res.pts, res.ptsCount))\n }\n }\n}\n"]}
@@ -43,4 +43,5 @@ export declare class Video extends RawDocument {
43
43
  get hasSpoiler(): boolean;
44
44
  /** For self-destructing videos, TTL in seconds */
45
45
  get ttlSeconds(): number | null;
46
+ get videoStartTs(): number | null;
46
47
  }
@@ -71,6 +71,9 @@ class Video extends RawDocument {
71
71
  get ttlSeconds() {
72
72
  return this.media?.ttlSeconds ?? null;
73
73
  }
74
+ get videoStartTs() {
75
+ return this.attr._ === 'documentAttributeVideo' ? this.attr.videoStartTs ?? null : null;
76
+ }
74
77
  }
75
78
  const Video$1 = /*#__PURE__*/memoizeGetters(Video, ['fileName', 'thumbnails', 'fileId', 'uniqueFileId', 'isAnimation']);
76
79
  const Video$2 = /*#__PURE__*/makeInspectable(Video$1, ['fileSize', 'dcId'], ['inputMedia', 'inputDocument']);
@@ -1 +1 @@
1
- {"version":3,"file":"video.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/media/video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;GAIG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IAYrB;IACA;IAZJ,IAAI,GAAG,OAAgB,CAAA;IAEtB,WAAW;QACjB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAA;QACpD,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAA;QAExD,OAAO,QAAQ,CAAC,QAAQ,CAAC,KA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C;CACJ;AAED,cAAc,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC,CAAA;AAC1F,eAAe,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAA","sourcesContent":["import { tdFileId } from '@mtcute/file-id'\nimport { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { RawDocument } from './document.js'\n\n/**\n * A video, round video message or GIF animation.\n *\n * **Note:** Legacy GIF animations are also wrapped with this class.\n */\nexport class Video extends RawDocument {\n readonly type = 'video' as const\n\n protected _fileIdType(): tdFileId.FileType {\n if (this.isRound) return tdFileId.FileType.VideoNote\n if (this.isAnimation) return tdFileId.FileType.Animation\n\n return tdFileId.FileType.Video\n }\n\n constructor(\n doc: tl.RawDocument,\n readonly attr: tl.RawDocumentAttributeVideo | tl.RawDocumentAttributeImageSize,\n readonly media?: tl.RawMessageMediaDocument,\n ) {\n super(doc)\n }\n\n /**\n * Video width in pixels\n */\n get width(): number {\n return this.attr.w\n }\n\n /**\n * Video height in pixels\n */\n get height(): number {\n return this.attr.h\n }\n\n /**\n * Video duration in seconds.\n *\n * `0` for legacy GIFs\n */\n get duration(): number {\n return this.attr._ === 'documentAttributeVideo' ? this.attr.duration : 0\n }\n\n /**\n * Whether this video is an animated GIF\n * (represented either by actual GIF or a silent MP4 video)\n */\n get isAnimation(): boolean {\n return (\n this.attr._ === 'documentAttributeImageSize' ||\n this.raw.attributes.some((it) => it._ === 'documentAttributeAnimated')\n )\n }\n\n /**\n * Whether this video is a round video message (aka video note)\n */\n get isRound(): boolean {\n return this.attr._ === 'documentAttributeVideo' && Boolean(this.attr.roundMessage)\n }\n\n /**\n * Whether this video is a legacy GIF (i.e. its MIME is `image/gif`)\n */\n get isLegacyGif(): boolean {\n return this.attr._ === 'documentAttributeImageSize'\n }\n\n /** Whether this video is hidden with a spoiler */\n get hasSpoiler(): boolean {\n return this.media?.spoiler ?? false\n }\n\n /** For self-destructing videos, TTL in seconds */\n get ttlSeconds(): number | null {\n return this.media?.ttlSeconds ?? null\n }\n}\n\nmemoizeGetters(Video, ['fileName', 'thumbnails', 'fileId', 'uniqueFileId', 'isAnimation'])\nmakeInspectable(Video, ['fileSize', 'dcId'], ['inputMedia', 'inputDocument'])\n"]}
1
+ {"version":3,"file":"video.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/media/video.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;GAIG;AACH,MAAM,OAAO,KAAM,SAAQ,WAAW;IAYrB;IACA;IAZJ,IAAI,GAAG,OAAgB,CAAA;IAEtB,WAAW;QACjB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAA;QACpD,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAA;QAExD,OAAO,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAA;IAClC,CAAC;IAED,YACI,GAAmB,EACV,IAAqE,EACrE,KAAkC;QAE3C,KAAK,CAAC,GAAG,CAAC,CAAA;QAHD,SAAI,GAAJ,IAAI,CAAiE;QACrE,UAAK,GAAL,KAAK,CAA6B;IAG/C,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtB,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,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAA","sourcesContent":["import { tdFileId } from '@mtcute/file-id'\nimport { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { RawDocument } from './document.js'\n\n/**\n * A video, round video message or GIF animation.\n *\n * **Note:** Legacy GIF animations are also wrapped with this class.\n */\nexport class Video extends RawDocument {\n readonly type = 'video' as const\n\n protected _fileIdType(): tdFileId.FileType {\n if (this.isRound) return tdFileId.FileType.VideoNote\n if (this.isAnimation) return tdFileId.FileType.Animation\n\n return tdFileId.FileType.Video\n }\n\n constructor(\n doc: tl.RawDocument,\n readonly attr: tl.RawDocumentAttributeVideo | tl.RawDocumentAttributeImageSize,\n readonly media?: tl.RawMessageMediaDocument,\n ) {\n super(doc)\n }\n\n /**\n * Video width in pixels\n */\n get width(): number {\n return this.attr.w\n }\n\n /**\n * Video height in pixels\n */\n get height(): number {\n return this.attr.h\n }\n\n /**\n * Video duration in seconds.\n *\n * `0` for legacy GIFs\n */\n get duration(): number {\n return this.attr._ === 'documentAttributeVideo' ? this.attr.duration : 0\n }\n\n /**\n * Whether this video is an animated GIF\n * (represented either by actual GIF or a silent MP4 video)\n */\n get isAnimation(): boolean {\n return (\n this.attr._ === 'documentAttributeImageSize' ||\n this.raw.attributes.some((it) => it._ === 'documentAttributeAnimated')\n )\n }\n\n /**\n * Whether this video is a round video message (aka video note)\n */\n get isRound(): boolean {\n return this.attr._ === 'documentAttributeVideo' && Boolean(this.attr.roundMessage)\n }\n\n /**\n * Whether this video is a legacy GIF (i.e. its MIME is `image/gif`)\n */\n get isLegacyGif(): boolean {\n return this.attr._ === 'documentAttributeImageSize'\n }\n\n /** Whether this video is hidden with a spoiler */\n get hasSpoiler(): boolean {\n return this.media?.spoiler ?? false\n }\n\n /** For self-destructing videos, TTL in seconds */\n get ttlSeconds(): number | null {\n return this.media?.ttlSeconds ?? null\n }\n\n get videoStartTs(): number | null {\n return this.attr._ === 'documentAttributeVideo' ? this.attr.videoStartTs ?? null : null\n }\n}\n\nmemoizeGetters(Video, ['fileName', 'thumbnails', 'fileId', 'uniqueFileId', 'isAnimation'])\nmakeInspectable(Video, ['fileSize', 'dcId'], ['inputMedia', 'inputDocument'])\n"]}
@@ -358,6 +358,20 @@ export interface ActionPaymentRefunded {
358
358
  /** Information about the charge */
359
359
  charge: tl.TypePaymentCharge;
360
360
  }
361
- export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | null;
361
+ /** Telegram Stars were gifted by the other chat participant */
362
+ export interface ActionStarsGifted {
363
+ readonly type: 'stars_gifted';
364
+ /** Whether `currency` is a cryptocurrency */
365
+ isCrypto: boolean;
366
+ /** Currency in which the stars were paid for */
367
+ currency: string;
368
+ /** Amount of `currency` that was paid */
369
+ amount: tl.Long;
370
+ /** Amount of Telegram Stars that were gifted */
371
+ stars: tl.Long;
372
+ /** Transaction ID, if available */
373
+ transactionId?: string;
374
+ }
375
+ export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | ActionStarsGifted | null;
362
376
  /** @internal */
363
377
  export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
@@ -260,6 +260,15 @@ export function _messageActionFromTl(act) {
260
260
  payload: act.payload,
261
261
  charge: act.charge,
262
262
  };
263
+ case 'messageActionGiftStars':
264
+ return {
265
+ type: 'stars_gifted',
266
+ isCrypto: Boolean(act.cryptoCurrency),
267
+ currency: act.cryptoCurrency ?? act.currency,
268
+ amount: act.cryptoAmount ?? act.amount,
269
+ stars: act.stars,
270
+ transactionId: act.transactionId,
271
+ };
263
272
  default:
264
273
  return null;
265
274
  }
@@ -1 +1 @@
1
- {"version":3,"file":"message-action.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message-action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAqB,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAQ,MAAM,kBAAkB,CAAA;AAqgBlD,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAgB,GAAyB;IACzE,kBAAkB;I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AyB;YAC1B,OAAO;gBACH,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,GAAG,CAAC,MAAM;aACpB,CAAA;QACL,KAAK,8BAA8B;YAC/B,OAAO;gBACH,IAAI,EAAE,kBAAkB;gBACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;gBACjC,MAAM,EAAE,GAAG,CAAC,WAAW;gBACvB,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,MAAM,EAAE,GAAG,CAAC,MAAM;aACrB,CAAA;QACL;YACI,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { getMarkedPeerId } from '../../../utils/peer-utils.js'\nimport { _callDiscardReasonFromTl, CallDiscardReason } from '../calls/index.js'\nimport { Photo } from '../media/photo.js'\nimport { parsePeer, Peer } from '../peers/peer.js'\nimport type { Message } from './message.js'\n\n/** Group was created */\nexport interface ActionChatCreated {\n readonly type: 'chat_created'\n\n /** Group name */\n readonly title: string\n\n /** IDs of the users in the group */\n readonly users: number[]\n}\n\n/** Channel/supergroup was created */\nexport interface ActionChannelCreated {\n readonly type: 'channel_created'\n\n /** Original channel/supergroup title */\n readonly title: string\n}\n\n/** Chat was migrated to a supergroup with a given ID */\nexport interface ActionChatMigrateTo {\n readonly type: 'chat_migrate_to'\n\n /** Marked ID of the supergroup chat was migrated to */\n readonly id: number\n}\n\n/** Supergroup was migrated from a chat with a given ID */\nexport interface ActionChannelMigrateFrom {\n readonly type: 'channel_migrate_from'\n\n /** Marked ID of the chat this channel was migrated from */\n readonly id: number\n\n /** Old chat's title */\n readonly title: string\n}\n\n/**\n * A message has been pinned.\n *\n * To get the message itself, use {@link Message.getReplyTo}\n */\nexport interface ActionMessagePinned {\n readonly type: 'message_pinned'\n}\n\n/** History was cleared in a private chat. */\nexport interface ActionHistoryCleared {\n readonly type: 'history_cleared'\n}\n\n/** Someone scored in a game (usually only used for newly set high scores) */\nexport interface ActionGameScore {\n readonly type: 'game_score'\n\n /** Game ID */\n readonly gameId: tl.Long\n\n /** Score */\n readonly score: number\n}\n\n/** Contact has joined Telegram */\nexport interface ActionContactJoined {\n readonly type: 'contact_joined'\n}\n\n/** Group title was changed */\nexport interface ActionTitleChanged {\n readonly type: 'title_changed'\n\n /** New group name */\n readonly title: string\n}\n\n/** Group photo was changed */\nexport interface ActionPhotoChanged {\n readonly type: 'photo_changed'\n\n /** New group photo */\n readonly photo: Photo\n}\n\n/** Group photo was deleted */\nexport interface ActionPhotoDeleted {\n readonly type: 'photo_deleted'\n}\n\n/** Users were added to the chat */\nexport interface ActionUsersAdded {\n readonly type: 'users_added'\n\n /** IDs of the users that were added */\n readonly users: number[]\n}\n\n/** User has left the group */\nexport interface ActionUserLeft {\n readonly type: 'user_left'\n}\n\n/** User was removed from the group */\nexport interface ActionUserRemoved {\n readonly type: 'user_removed'\n\n /** ID of the user that was removed from the group */\n readonly user: number\n}\n\n/** User has joined the group via an invite link */\nexport interface ActionUserJoinedLink {\n readonly type: 'user_joined_link'\n\n /** ID of the user who created the link */\n readonly inviter: number\n}\n\n/**\n * User has joined the group via an invite link\n * and was approved by an administrator\n */\nexport interface ActionUserJoinedApproved {\n readonly type: 'user_joined_approved'\n}\n\n/** A payment was received from a user (bot) */\nexport interface ActionPaymentReceived {\n readonly type: 'payment_received'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n\n /** Bot specified invoice payload */\n readonly payload: Uint8Array\n\n /** Order information provided by the user */\n readonly info?: tl.TypePaymentRequestedInfo\n\n /** ID of the shipping option chosen by the user */\n readonly shippingOptionId?: string\n\n /** Payment provider ID */\n readonly charge?: tl.TypePaymentCharge\n}\n\n/** A payment was sent to a user */\nexport interface ActionPaymentSent {\n readonly type: 'payment_sent'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n}\n\n/** A phone call */\nexport interface ActionCall {\n readonly type: 'call'\n\n /** Call ID */\n readonly id: tl.Long\n\n /** Whether this is a video call */\n readonly isVideo: boolean\n\n /** Duration if the call in seconds (0 if not available) */\n readonly duration: number\n\n /** Call discard reason, if available */\n readonly reason?: CallDiscardReason\n}\n\n/** A screenshot was taken */\nexport interface ActionScreenshotTaken {\n readonly type: 'screenshot_taken'\n}\n\n/** User has authorized via the bot */\nexport interface ActionBotAllowed {\n readonly type: 'bot_allowed'\n\n /** Domain where the user has logged in */\n readonly domain?: string\n}\n\n/**\n * A user is in proximity of another user\n * (see [Proximity alerts](https://core.telegram.org/api/live-location#proximity-alert))\n */\nexport interface ActionGeoProximity {\n readonly type: 'geo_proximity'\n\n /** ID of the user who sent the geolocation with proximity alerts */\n readonly targetId: number\n\n /** ID of the user who has approached `targetId` */\n readonly userId: number\n\n /** Distance between them in meters */\n readonly distance: number\n}\n\n/** Group call has started */\nexport interface ActionGroupCallStarted {\n readonly type: 'group_call_started'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n}\n\n/** Group call has ended */\nexport interface ActionGroupCallEnded {\n readonly type: 'group_call_ended'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Duration of the call */\n readonly duration: number\n}\n\n/** Group call has been scheduled */\nexport interface ActionGroupCallScheduled {\n readonly type: 'group_call_scheduled'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Date when the call will start */\n readonly date: Date\n}\n\n/** Group call has ended */\nexport interface ActionGroupInvite {\n readonly type: 'group_call_invite'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** IDs of the users invited to the call */\n readonly userIds: number[]\n}\n\n/** Messages TTL changed */\nexport interface ActionTtlChanged {\n readonly type: 'ttl_changed'\n\n /** New TTL period */\n readonly period: number\n}\n\n/** Forum topic was created */\nexport interface ActionTopicCreated {\n readonly type: 'topic_created'\n\n /** Title of the topic */\n title: string\n\n /** Icon color of the topic */\n iconColor: number\n\n /** Icon emoji of the topic */\n iconCustomEmoji?: tl.Long\n}\n\n/** Forum topic was modified */\nexport interface ActionTopicEdited {\n readonly type: 'topic_edited'\n\n /** New title of the topic */\n title?: string\n\n /** New icon emoji of the topic (may be empty) */\n iconCustomEmoji?: tl.Long\n\n /** Whether the topic was opened/closed */\n closed?: boolean\n\n /** Whether the topic was (un-)hidden - only for \"General\" topic (`id=1`) */\n hidden?: boolean\n}\n\n/** A non-standard action has happened in the chat */\nexport interface ActionCustom {\n readonly type: 'custom'\n\n /** Text to be shown in the interface */\n action: string\n}\n\n/** Chat theme was changed */\nexport interface ActionThemeChanged {\n readonly type: 'theme_changed'\n\n /** Emoji representing the new theme */\n emoji: string\n}\n\n/** Data was sent from a WebView (user-side action) */\nexport interface ActionWebviewDataSent {\n readonly type: 'webview_sent'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n}\n\n/** Data was received from a WebView (bot-side action) */\nexport interface ActionWebviewDataReceived {\n readonly type: 'webview_received'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n\n /** Data received from the WebView */\n data: string\n}\n\n/** Premium subscription was gifted */\nexport interface ActionPremiumGifted {\n readonly type: 'premium_gifted'\n\n /**\n * Currency in which it was paid for.\n * Three-letter ISO 4217 currency code)\n */\n currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n amount: number\n\n /** Duration of the gifted subscription in months */\n months: number\n\n /** If the subscription was bought with crypto, information about it */\n crypto?: {\n /** Crypto currency name */\n currency: string\n /** Price in the smallest units */\n amount: number\n }\n}\n\n/** A photo has been suggested as a profile photo */\nexport interface ActionPhotoSuggested {\n readonly type: 'photo_suggested'\n\n /** Photo that was suggested */\n photo: Photo\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button.\n * The user-side version of {@link ActionPeerChosen}\n */\nexport interface ActionPeerSent {\n readonly type: 'peer_sent'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Brief information about the chosen peers */\n peers: tl.TypeRequestedPeer[]\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button\n * The bot-side version of {@link ActionPeerSent}\n */\nexport interface ActionPeerChosen {\n readonly type: 'peer_chosen'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Chosen peers */\n peers: Peer[]\n}\n\n/** A wallpaper of the chathas been changed */\nexport interface ActionWallpaperChanged {\n readonly type: 'wallpaper_changed'\n\n /**\n * Whether the user has applied the same wallpaper\n * as the other party previously set in the chat\n */\n same: boolean\n\n /**\n * Whether the wallpaper was forcefully applied for\n * both sides, without explicit confirmation from the other\n * side.\n */\n forBoth: boolean\n\n /** TL object representing the new wallpaper */\n wallpaper: tl.TypeWallPaper\n}\n\n/** A Telergam Premium gift code was received */\nexport interface ActionGiftCode {\n readonly type: 'gift_code'\n\n /** Information about the gift code */\n raw: tl.RawMessageActionGiftCode\n}\n\n/** A Telergam Premium giveaway was started */\nexport interface ActionGiveawayStarted {\n readonly type: 'giveaway_started'\n}\n\n/** A Telergam Premium giveaway was ended and results are available */\nexport interface ActionGiveawayEnded {\n readonly type: 'giveaway_ended'\n\n /** Number of winners in the giveaway */\n winners: number\n\n /** Number of undistributed prizes */\n undistributed: number\n}\n\n/** Boosts were applied to the group */\nexport interface ActionBoostApply {\n readonly type: 'boost_apply'\n\n /** Number of boosts applied */\n count: number\n}\n\n/** A payment was refunded */\nexport interface ActionPaymentRefunded {\n readonly type: 'payment_refunded'\n\n /** Three-letter ISO 4217 currency code */\n currency: string\n\n /** Marked ID of the peer where the stars were refunded (?) */\n peerId: number\n\n /** Number of `currency` refunded, in the smallest unit */\n amount: tl.Long\n\n /** Payload defined by the bot */\n payload?: Uint8Array\n\n /** Information about the charge */\n charge: tl.TypePaymentCharge\n}\n\nexport type MessageAction =\n | ActionChatCreated\n | ActionChannelCreated\n | ActionChatMigrateTo\n | ActionChannelMigrateFrom\n | ActionMessagePinned\n | ActionHistoryCleared\n | ActionGameScore\n | ActionContactJoined\n | ActionTitleChanged\n | ActionPhotoChanged\n | ActionPhotoDeleted\n | ActionUsersAdded\n | ActionUserLeft\n | ActionUserRemoved\n | ActionUserJoinedLink\n | ActionPaymentReceived\n | ActionPaymentSent\n | ActionCall\n | ActionScreenshotTaken\n | ActionBotAllowed\n | ActionGeoProximity\n | ActionGroupCallStarted\n | ActionGroupCallEnded\n | ActionGroupCallScheduled\n | ActionGroupInvite\n | ActionTtlChanged\n | ActionTopicCreated\n | ActionTopicEdited\n | ActionCustom\n | ActionThemeChanged\n | ActionUserJoinedApproved\n | ActionWebviewDataSent\n | ActionWebviewDataReceived\n | ActionPremiumGifted\n | ActionPhotoSuggested\n | ActionPeerSent\n | ActionPeerChosen\n | ActionWallpaperChanged\n | ActionGiftCode\n | ActionGiveawayStarted\n | ActionGiveawayEnded\n | ActionBoostApply\n | ActionPaymentRefunded\n | null\n\n/** @internal */\nexport function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction {\n // todo - passport\n // messageActionSecureValuesSentMe#1b287353 values:Vector<SecureValue> credentials:SecureCredentialsEncrypted\n // messageActionSecureValuesSent#d95c6154 types:Vector<SecureValueType>\n\n switch (act._) {\n case 'messageActionChatCreate':\n return {\n type: 'chat_created',\n title: act.title,\n users: act.users,\n }\n case 'messageActionChannelCreate':\n return {\n type: 'channel_created',\n title: act.title,\n }\n case 'messageActionChatMigrateTo':\n return {\n type: 'chat_migrate_to',\n id: act.channelId,\n }\n case 'messageActionChannelMigrateFrom':\n return {\n type: 'channel_migrate_from',\n id: act.chatId,\n title: act.title,\n }\n case 'messageActionPinMessage':\n return {\n type: 'message_pinned',\n }\n case 'messageActionHistoryClear':\n return {\n type: 'history_cleared',\n }\n case 'messageActionGameScore':\n return {\n type: 'game_score',\n gameId: act.gameId,\n score: act.score,\n }\n case 'messageActionContactSignUp':\n return {\n type: 'contact_joined',\n }\n case 'messageActionChatEditTitle':\n return {\n type: 'title_changed',\n title: act.title,\n }\n case 'messageActionChatEditPhoto':\n return {\n type: 'photo_changed',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionChatDeletePhoto':\n return {\n type: 'photo_deleted',\n }\n case 'messageActionChatAddUser':\n return {\n type: 'users_added',\n users: act.users,\n }\n case 'messageActionChatDeleteUser':\n if (this.raw.fromId?._ === 'peerUser' && act.userId === this.raw.fromId.userId) {\n return {\n type: 'user_left',\n }\n }\n\n return {\n type: 'user_removed',\n user: act.userId,\n }\n\n case 'messageActionChatJoinedByLink':\n return {\n type: 'user_joined_link',\n inviter: act.inviterId,\n }\n case 'messageActionPaymentSentMe':\n return {\n type: 'payment_received',\n currency: act.currency,\n amount: act.totalAmount,\n payload: act.payload,\n info: act.info,\n shippingOptionId: act.shippingOptionId,\n charge: act.charge,\n }\n case 'messageActionPaymentSent':\n return {\n type: 'payment_sent',\n currency: act.currency,\n amount: act.totalAmount,\n }\n case 'messageActionPhoneCall':\n return {\n type: 'call',\n id: act.callId,\n isVideo: Boolean(act.video),\n reason: act.reason ? _callDiscardReasonFromTl(act.reason) : undefined,\n duration: act.duration ?? 0,\n }\n case 'messageActionScreenshotTaken':\n return {\n type: 'screenshot_taken',\n }\n case 'messageActionBotAllowed':\n return {\n type: 'bot_allowed',\n domain: act.domain,\n }\n case 'messageActionGeoProximityReached':\n if (act.fromId._ !== 'peerUser' || act.toId._ !== 'peerUser') {\n return null\n }\n\n return {\n type: 'geo_proximity',\n targetId: act.toId.userId,\n userId: act.fromId.userId,\n distance: act.distance,\n }\n\n case 'messageActionGroupCall':\n if (act.duration) {\n return {\n type: 'group_call_ended',\n call: act.call,\n duration: act.duration,\n }\n }\n\n return {\n type: 'group_call_started',\n call: act.call,\n }\n case 'messageActionGroupCallScheduled':\n return {\n type: 'group_call_scheduled',\n call: act.call,\n date: new Date(act.scheduleDate * 1000),\n }\n case 'messageActionInviteToGroupCall':\n return {\n type: 'group_call_invite',\n call: act.call,\n userIds: act.users,\n }\n case 'messageActionSetMessagesTTL':\n return {\n type: 'ttl_changed',\n period: act.period,\n }\n case 'messageActionTopicCreate':\n return {\n type: 'topic_created',\n title: act.title,\n iconColor: act.iconColor,\n iconCustomEmoji: act.iconEmojiId,\n }\n case 'messageActionTopicEdit':\n return {\n type: 'topic_edited',\n title: act.title,\n iconCustomEmoji: act.iconEmojiId,\n closed: act.closed,\n hidden: act.hidden,\n }\n case 'messageActionCustomAction':\n return {\n type: 'custom',\n action: act.message,\n }\n case 'messageActionSetChatTheme':\n return {\n type: 'theme_changed',\n emoji: act.emoticon,\n }\n case 'messageActionChatJoinedByRequest':\n return {\n type: 'user_joined_approved',\n }\n case 'messageActionWebViewDataSent':\n return {\n type: 'webview_sent',\n text: act.text,\n }\n case 'messageActionWebViewDataSentMe':\n return {\n type: 'webview_received',\n text: act.text,\n data: act.data,\n }\n case 'messageActionGiftPremium':\n return {\n type: 'premium_gifted',\n currency: act.currency,\n amount: act.amount.toNumber(),\n months: act.months,\n crypto: act.cryptoAmount ?\n {\n currency: act.cryptoCurrency!,\n amount: act.cryptoAmount.toNumber(),\n } :\n undefined,\n }\n case 'messageActionSuggestProfilePhoto':\n return {\n type: 'photo_suggested',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionRequestedPeerSentMe':\n return {\n type: 'peer_sent',\n buttonId: act.buttonId,\n peers: act.peers,\n }\n case 'messageActionRequestedPeer':\n return {\n type: 'peer_chosen',\n buttonId: act.buttonId,\n peers: act.peers.map((it) => parsePeer(it, this._peers)),\n }\n case 'messageActionSetChatWallPaper':\n return {\n type: 'wallpaper_changed',\n same: act.same!,\n forBoth: act.forBoth!,\n wallpaper: act.wallpaper,\n }\n case 'messageActionGiftCode':\n return {\n type: 'gift_code',\n raw: act,\n }\n case 'messageActionGiveawayLaunch':\n return {\n type: 'giveaway_started',\n }\n case 'messageActionGiveawayResults':\n return {\n type: 'giveaway_ended',\n winners: act.winnersCount,\n undistributed: act.unclaimedCount,\n }\n case 'messageActionBoostApply':\n return {\n type: 'boost_apply',\n count: act.boosts,\n }\n case 'messageActionPaymentRefunded':\n return {\n type: 'payment_refunded',\n currency: act.currency,\n peerId: getMarkedPeerId(act.peer),\n amount: act.totalAmount,\n payload: act.payload,\n charge: act.charge,\n }\n default:\n return null\n }\n}\n"]}
1
+ {"version":3,"file":"message-action.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message-action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAqB,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAQ,MAAM,kBAAkB,CAAA;AA0hBlD,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAgB,GAAyB;IACzE,kBAAkB;IAClB,6GAA6G;IAC7G,uEAAuE;IAEvE,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,yBAAyB;YAC1B,OAAO;gBACH,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,4BAA4B;YAC7B,OAAO;gBACH,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,4BAA4B;YAC7B,OAAO;gBACH,IAAI,EAAE,iBAAiB;gBACvB,EAAE,EAAE,GAAG,CAAC,SAAS;aACpB,CAAA;QACL,KAAK,iCAAiC;YAClC,OAAO;gBACH,IAAI,EAAE,sBAAsB;gBAC5B,EAAE,EAAE,GAAG,CAAC,MAAM;gBACd,KAAK,EAAE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AC5C,MAAM,EAAE,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,MAAM;gBACtC,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,aAAa,EAAE,GAAG,CAAC,aAAa;aACnC,CAAA;QACL;YACI,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { getMarkedPeerId } from '../../../utils/peer-utils.js'\nimport { _callDiscardReasonFromTl, CallDiscardReason } from '../calls/index.js'\nimport { Photo } from '../media/photo.js'\nimport { parsePeer, Peer } from '../peers/peer.js'\nimport type { Message } from './message.js'\n\n/** Group was created */\nexport interface ActionChatCreated {\n readonly type: 'chat_created'\n\n /** Group name */\n readonly title: string\n\n /** IDs of the users in the group */\n readonly users: number[]\n}\n\n/** Channel/supergroup was created */\nexport interface ActionChannelCreated {\n readonly type: 'channel_created'\n\n /** Original channel/supergroup title */\n readonly title: string\n}\n\n/** Chat was migrated to a supergroup with a given ID */\nexport interface ActionChatMigrateTo {\n readonly type: 'chat_migrate_to'\n\n /** Marked ID of the supergroup chat was migrated to */\n readonly id: number\n}\n\n/** Supergroup was migrated from a chat with a given ID */\nexport interface ActionChannelMigrateFrom {\n readonly type: 'channel_migrate_from'\n\n /** Marked ID of the chat this channel was migrated from */\n readonly id: number\n\n /** Old chat's title */\n readonly title: string\n}\n\n/**\n * A message has been pinned.\n *\n * To get the message itself, use {@link Message.getReplyTo}\n */\nexport interface ActionMessagePinned {\n readonly type: 'message_pinned'\n}\n\n/** History was cleared in a private chat. */\nexport interface ActionHistoryCleared {\n readonly type: 'history_cleared'\n}\n\n/** Someone scored in a game (usually only used for newly set high scores) */\nexport interface ActionGameScore {\n readonly type: 'game_score'\n\n /** Game ID */\n readonly gameId: tl.Long\n\n /** Score */\n readonly score: number\n}\n\n/** Contact has joined Telegram */\nexport interface ActionContactJoined {\n readonly type: 'contact_joined'\n}\n\n/** Group title was changed */\nexport interface ActionTitleChanged {\n readonly type: 'title_changed'\n\n /** New group name */\n readonly title: string\n}\n\n/** Group photo was changed */\nexport interface ActionPhotoChanged {\n readonly type: 'photo_changed'\n\n /** New group photo */\n readonly photo: Photo\n}\n\n/** Group photo was deleted */\nexport interface ActionPhotoDeleted {\n readonly type: 'photo_deleted'\n}\n\n/** Users were added to the chat */\nexport interface ActionUsersAdded {\n readonly type: 'users_added'\n\n /** IDs of the users that were added */\n readonly users: number[]\n}\n\n/** User has left the group */\nexport interface ActionUserLeft {\n readonly type: 'user_left'\n}\n\n/** User was removed from the group */\nexport interface ActionUserRemoved {\n readonly type: 'user_removed'\n\n /** ID of the user that was removed from the group */\n readonly user: number\n}\n\n/** User has joined the group via an invite link */\nexport interface ActionUserJoinedLink {\n readonly type: 'user_joined_link'\n\n /** ID of the user who created the link */\n readonly inviter: number\n}\n\n/**\n * User has joined the group via an invite link\n * and was approved by an administrator\n */\nexport interface ActionUserJoinedApproved {\n readonly type: 'user_joined_approved'\n}\n\n/** A payment was received from a user (bot) */\nexport interface ActionPaymentReceived {\n readonly type: 'payment_received'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n\n /** Bot specified invoice payload */\n readonly payload: Uint8Array\n\n /** Order information provided by the user */\n readonly info?: tl.TypePaymentRequestedInfo\n\n /** ID of the shipping option chosen by the user */\n readonly shippingOptionId?: string\n\n /** Payment provider ID */\n readonly charge?: tl.TypePaymentCharge\n}\n\n/** A payment was sent to a user */\nexport interface ActionPaymentSent {\n readonly type: 'payment_sent'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n}\n\n/** A phone call */\nexport interface ActionCall {\n readonly type: 'call'\n\n /** Call ID */\n readonly id: tl.Long\n\n /** Whether this is a video call */\n readonly isVideo: boolean\n\n /** Duration if the call in seconds (0 if not available) */\n readonly duration: number\n\n /** Call discard reason, if available */\n readonly reason?: CallDiscardReason\n}\n\n/** A screenshot was taken */\nexport interface ActionScreenshotTaken {\n readonly type: 'screenshot_taken'\n}\n\n/** User has authorized via the bot */\nexport interface ActionBotAllowed {\n readonly type: 'bot_allowed'\n\n /** Domain where the user has logged in */\n readonly domain?: string\n}\n\n/**\n * A user is in proximity of another user\n * (see [Proximity alerts](https://core.telegram.org/api/live-location#proximity-alert))\n */\nexport interface ActionGeoProximity {\n readonly type: 'geo_proximity'\n\n /** ID of the user who sent the geolocation with proximity alerts */\n readonly targetId: number\n\n /** ID of the user who has approached `targetId` */\n readonly userId: number\n\n /** Distance between them in meters */\n readonly distance: number\n}\n\n/** Group call has started */\nexport interface ActionGroupCallStarted {\n readonly type: 'group_call_started'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n}\n\n/** Group call has ended */\nexport interface ActionGroupCallEnded {\n readonly type: 'group_call_ended'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Duration of the call */\n readonly duration: number\n}\n\n/** Group call has been scheduled */\nexport interface ActionGroupCallScheduled {\n readonly type: 'group_call_scheduled'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Date when the call will start */\n readonly date: Date\n}\n\n/** Group call has ended */\nexport interface ActionGroupInvite {\n readonly type: 'group_call_invite'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** IDs of the users invited to the call */\n readonly userIds: number[]\n}\n\n/** Messages TTL changed */\nexport interface ActionTtlChanged {\n readonly type: 'ttl_changed'\n\n /** New TTL period */\n readonly period: number\n}\n\n/** Forum topic was created */\nexport interface ActionTopicCreated {\n readonly type: 'topic_created'\n\n /** Title of the topic */\n title: string\n\n /** Icon color of the topic */\n iconColor: number\n\n /** Icon emoji of the topic */\n iconCustomEmoji?: tl.Long\n}\n\n/** Forum topic was modified */\nexport interface ActionTopicEdited {\n readonly type: 'topic_edited'\n\n /** New title of the topic */\n title?: string\n\n /** New icon emoji of the topic (may be empty) */\n iconCustomEmoji?: tl.Long\n\n /** Whether the topic was opened/closed */\n closed?: boolean\n\n /** Whether the topic was (un-)hidden - only for \"General\" topic (`id=1`) */\n hidden?: boolean\n}\n\n/** A non-standard action has happened in the chat */\nexport interface ActionCustom {\n readonly type: 'custom'\n\n /** Text to be shown in the interface */\n action: string\n}\n\n/** Chat theme was changed */\nexport interface ActionThemeChanged {\n readonly type: 'theme_changed'\n\n /** Emoji representing the new theme */\n emoji: string\n}\n\n/** Data was sent from a WebView (user-side action) */\nexport interface ActionWebviewDataSent {\n readonly type: 'webview_sent'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n}\n\n/** Data was received from a WebView (bot-side action) */\nexport interface ActionWebviewDataReceived {\n readonly type: 'webview_received'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n\n /** Data received from the WebView */\n data: string\n}\n\n/** Premium subscription was gifted */\nexport interface ActionPremiumGifted {\n readonly type: 'premium_gifted'\n\n /**\n * Currency in which it was paid for.\n * Three-letter ISO 4217 currency code)\n */\n currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n amount: number\n\n /** Duration of the gifted subscription in months */\n months: number\n\n /** If the subscription was bought with crypto, information about it */\n crypto?: {\n /** Crypto currency name */\n currency: string\n /** Price in the smallest units */\n amount: number\n }\n}\n\n/** A photo has been suggested as a profile photo */\nexport interface ActionPhotoSuggested {\n readonly type: 'photo_suggested'\n\n /** Photo that was suggested */\n photo: Photo\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button.\n * The user-side version of {@link ActionPeerChosen}\n */\nexport interface ActionPeerSent {\n readonly type: 'peer_sent'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Brief information about the chosen peers */\n peers: tl.TypeRequestedPeer[]\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button\n * The bot-side version of {@link ActionPeerSent}\n */\nexport interface ActionPeerChosen {\n readonly type: 'peer_chosen'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Chosen peers */\n peers: Peer[]\n}\n\n/** A wallpaper of the chathas been changed */\nexport interface ActionWallpaperChanged {\n readonly type: 'wallpaper_changed'\n\n /**\n * Whether the user has applied the same wallpaper\n * as the other party previously set in the chat\n */\n same: boolean\n\n /**\n * Whether the wallpaper was forcefully applied for\n * both sides, without explicit confirmation from the other\n * side.\n */\n forBoth: boolean\n\n /** TL object representing the new wallpaper */\n wallpaper: tl.TypeWallPaper\n}\n\n/** A Telergam Premium gift code was received */\nexport interface ActionGiftCode {\n readonly type: 'gift_code'\n\n /** Information about the gift code */\n raw: tl.RawMessageActionGiftCode\n}\n\n/** A Telergam Premium giveaway was started */\nexport interface ActionGiveawayStarted {\n readonly type: 'giveaway_started'\n}\n\n/** A Telergam Premium giveaway was ended and results are available */\nexport interface ActionGiveawayEnded {\n readonly type: 'giveaway_ended'\n\n /** Number of winners in the giveaway */\n winners: number\n\n /** Number of undistributed prizes */\n undistributed: number\n}\n\n/** Boosts were applied to the group */\nexport interface ActionBoostApply {\n readonly type: 'boost_apply'\n\n /** Number of boosts applied */\n count: number\n}\n\n/** A payment was refunded */\nexport interface ActionPaymentRefunded {\n readonly type: 'payment_refunded'\n\n /** Three-letter ISO 4217 currency code */\n currency: string\n\n /** Marked ID of the peer where the stars were refunded (?) */\n peerId: number\n\n /** Number of `currency` refunded, in the smallest unit */\n amount: tl.Long\n\n /** Payload defined by the bot */\n payload?: Uint8Array\n\n /** Information about the charge */\n charge: tl.TypePaymentCharge\n}\n\n/** Telegram Stars were gifted by the other chat participant */\nexport interface ActionStarsGifted {\n readonly type: 'stars_gifted'\n\n /** Whether `currency` is a cryptocurrency */\n isCrypto: boolean\n\n /** Currency in which the stars were paid for */\n currency: string\n\n /** Amount of `currency` that was paid */\n amount: tl.Long\n\n /** Amount of Telegram Stars that were gifted */\n stars: tl.Long\n\n /** Transaction ID, if available */\n transactionId?: string\n}\n\nexport type MessageAction =\n | ActionChatCreated\n | ActionChannelCreated\n | ActionChatMigrateTo\n | ActionChannelMigrateFrom\n | ActionMessagePinned\n | ActionHistoryCleared\n | ActionGameScore\n | ActionContactJoined\n | ActionTitleChanged\n | ActionPhotoChanged\n | ActionPhotoDeleted\n | ActionUsersAdded\n | ActionUserLeft\n | ActionUserRemoved\n | ActionUserJoinedLink\n | ActionPaymentReceived\n | ActionPaymentSent\n | ActionCall\n | ActionScreenshotTaken\n | ActionBotAllowed\n | ActionGeoProximity\n | ActionGroupCallStarted\n | ActionGroupCallEnded\n | ActionGroupCallScheduled\n | ActionGroupInvite\n | ActionTtlChanged\n | ActionTopicCreated\n | ActionTopicEdited\n | ActionCustom\n | ActionThemeChanged\n | ActionUserJoinedApproved\n | ActionWebviewDataSent\n | ActionWebviewDataReceived\n | ActionPremiumGifted\n | ActionPhotoSuggested\n | ActionPeerSent\n | ActionPeerChosen\n | ActionWallpaperChanged\n | ActionGiftCode\n | ActionGiveawayStarted\n | ActionGiveawayEnded\n | ActionBoostApply\n | ActionPaymentRefunded\n | ActionStarsGifted\n | null\n\n/** @internal */\nexport function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction {\n // todo - passport\n // messageActionSecureValuesSentMe#1b287353 values:Vector<SecureValue> credentials:SecureCredentialsEncrypted\n // messageActionSecureValuesSent#d95c6154 types:Vector<SecureValueType>\n\n switch (act._) {\n case 'messageActionChatCreate':\n return {\n type: 'chat_created',\n title: act.title,\n users: act.users,\n }\n case 'messageActionChannelCreate':\n return {\n type: 'channel_created',\n title: act.title,\n }\n case 'messageActionChatMigrateTo':\n return {\n type: 'chat_migrate_to',\n id: act.channelId,\n }\n case 'messageActionChannelMigrateFrom':\n return {\n type: 'channel_migrate_from',\n id: act.chatId,\n title: act.title,\n }\n case 'messageActionPinMessage':\n return {\n type: 'message_pinned',\n }\n case 'messageActionHistoryClear':\n return {\n type: 'history_cleared',\n }\n case 'messageActionGameScore':\n return {\n type: 'game_score',\n gameId: act.gameId,\n score: act.score,\n }\n case 'messageActionContactSignUp':\n return {\n type: 'contact_joined',\n }\n case 'messageActionChatEditTitle':\n return {\n type: 'title_changed',\n title: act.title,\n }\n case 'messageActionChatEditPhoto':\n return {\n type: 'photo_changed',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionChatDeletePhoto':\n return {\n type: 'photo_deleted',\n }\n case 'messageActionChatAddUser':\n return {\n type: 'users_added',\n users: act.users,\n }\n case 'messageActionChatDeleteUser':\n if (this.raw.fromId?._ === 'peerUser' && act.userId === this.raw.fromId.userId) {\n return {\n type: 'user_left',\n }\n }\n\n return {\n type: 'user_removed',\n user: act.userId,\n }\n\n case 'messageActionChatJoinedByLink':\n return {\n type: 'user_joined_link',\n inviter: act.inviterId,\n }\n case 'messageActionPaymentSentMe':\n return {\n type: 'payment_received',\n currency: act.currency,\n amount: act.totalAmount,\n payload: act.payload,\n info: act.info,\n shippingOptionId: act.shippingOptionId,\n charge: act.charge,\n }\n case 'messageActionPaymentSent':\n return {\n type: 'payment_sent',\n currency: act.currency,\n amount: act.totalAmount,\n }\n case 'messageActionPhoneCall':\n return {\n type: 'call',\n id: act.callId,\n isVideo: Boolean(act.video),\n reason: act.reason ? _callDiscardReasonFromTl(act.reason) : undefined,\n duration: act.duration ?? 0,\n }\n case 'messageActionScreenshotTaken':\n return {\n type: 'screenshot_taken',\n }\n case 'messageActionBotAllowed':\n return {\n type: 'bot_allowed',\n domain: act.domain,\n }\n case 'messageActionGeoProximityReached':\n if (act.fromId._ !== 'peerUser' || act.toId._ !== 'peerUser') {\n return null\n }\n\n return {\n type: 'geo_proximity',\n targetId: act.toId.userId,\n userId: act.fromId.userId,\n distance: act.distance,\n }\n\n case 'messageActionGroupCall':\n if (act.duration) {\n return {\n type: 'group_call_ended',\n call: act.call,\n duration: act.duration,\n }\n }\n\n return {\n type: 'group_call_started',\n call: act.call,\n }\n case 'messageActionGroupCallScheduled':\n return {\n type: 'group_call_scheduled',\n call: act.call,\n date: new Date(act.scheduleDate * 1000),\n }\n case 'messageActionInviteToGroupCall':\n return {\n type: 'group_call_invite',\n call: act.call,\n userIds: act.users,\n }\n case 'messageActionSetMessagesTTL':\n return {\n type: 'ttl_changed',\n period: act.period,\n }\n case 'messageActionTopicCreate':\n return {\n type: 'topic_created',\n title: act.title,\n iconColor: act.iconColor,\n iconCustomEmoji: act.iconEmojiId,\n }\n case 'messageActionTopicEdit':\n return {\n type: 'topic_edited',\n title: act.title,\n iconCustomEmoji: act.iconEmojiId,\n closed: act.closed,\n hidden: act.hidden,\n }\n case 'messageActionCustomAction':\n return {\n type: 'custom',\n action: act.message,\n }\n case 'messageActionSetChatTheme':\n return {\n type: 'theme_changed',\n emoji: act.emoticon,\n }\n case 'messageActionChatJoinedByRequest':\n return {\n type: 'user_joined_approved',\n }\n case 'messageActionWebViewDataSent':\n return {\n type: 'webview_sent',\n text: act.text,\n }\n case 'messageActionWebViewDataSentMe':\n return {\n type: 'webview_received',\n text: act.text,\n data: act.data,\n }\n case 'messageActionGiftPremium':\n return {\n type: 'premium_gifted',\n currency: act.currency,\n amount: act.amount.toNumber(),\n months: act.months,\n crypto: act.cryptoAmount ?\n {\n currency: act.cryptoCurrency!,\n amount: act.cryptoAmount.toNumber(),\n } :\n undefined,\n }\n case 'messageActionSuggestProfilePhoto':\n return {\n type: 'photo_suggested',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionRequestedPeerSentMe':\n return {\n type: 'peer_sent',\n buttonId: act.buttonId,\n peers: act.peers,\n }\n case 'messageActionRequestedPeer':\n return {\n type: 'peer_chosen',\n buttonId: act.buttonId,\n peers: act.peers.map((it) => parsePeer(it, this._peers)),\n }\n case 'messageActionSetChatWallPaper':\n return {\n type: 'wallpaper_changed',\n same: act.same!,\n forBoth: act.forBoth!,\n wallpaper: act.wallpaper,\n }\n case 'messageActionGiftCode':\n return {\n type: 'gift_code',\n raw: act,\n }\n case 'messageActionGiveawayLaunch':\n return {\n type: 'giveaway_started',\n }\n case 'messageActionGiveawayResults':\n return {\n type: 'giveaway_ended',\n winners: act.winnersCount,\n undistributed: act.unclaimedCount,\n }\n case 'messageActionBoostApply':\n return {\n type: 'boost_apply',\n count: act.boosts,\n }\n case 'messageActionPaymentRefunded':\n return {\n type: 'payment_refunded',\n currency: act.currency,\n peerId: getMarkedPeerId(act.peer),\n amount: act.totalAmount,\n payload: act.payload,\n charge: act.charge,\n }\n case 'messageActionGiftStars':\n return {\n type: 'stars_gifted',\n isCrypto: Boolean(act.cryptoCurrency),\n currency: act.cryptoCurrency ?? act.currency,\n amount: act.cryptoAmount ?? act.amount,\n stars: act.stars,\n transactionId: act.transactionId,\n }\n default:\n return null\n }\n}\n"]}
@@ -103,6 +103,10 @@ export declare class User {
103
103
  get isPremium(): boolean;
104
104
  /** Whether Premium is required to contact this user */
105
105
  get isPremiumRequired(): boolean;
106
+ /** Number of bot's active users, if available */
107
+ get botActiveUsers(): number | null;
108
+ /** Whether this bot has a main app */
109
+ get hasMainApp(): boolean;
106
110
  /** User's or bot's first name */
107
111
  get firstName(): string;
108
112
  /** User's or bot's last name */
@@ -133,6 +133,14 @@ class User {
133
133
  get isPremiumRequired() {
134
134
  return this.raw.contactRequirePremium;
135
135
  }
136
+ /** Number of bot's active users, if available */
137
+ get botActiveUsers() {
138
+ return this.raw.botActiveUsers ?? null;
139
+ }
140
+ /** Whether this bot has a main app */
141
+ get hasMainApp() {
142
+ return this.raw.botHasMainApp;
143
+ }
136
144
  /** User's or bot's first name */
137
145
  get firstName() {
138
146
  return this.raw.firstName ?? 'Deleted Account';
@@ -1 +1 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/peers/user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAA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/tl'\n\nimport { MtArgumentError } from '../../../types/errors.js'\nimport { assertTypeIs } from '../../../utils/type-assertions.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { MessageEntity } from '../messages/message-entity.js'\nimport { EmojiStatus } from '../reactions/emoji-status.js'\nimport { ChatColors } from './chat-colors.js'\nimport { ChatPhoto } from './chat-photo.js'\n\n/**\n * User's Last Seen & Online status.\n * Can be one of the following:\n * - `online`, user is online right now.\n * - `offline`, user is currently offline.\n * - `recently`, user with hidden last seen time who was online between 1 second and 72 hours ago.\n * - `within_week`, user with hidden last seen time who was online between 72 hours and 7 days ago.\n * - `within_month`, user with hidden last seen time who was online between 7 days and a month ago.\n * - `long_time_ago`, blocked user or user with hidden last seen time who was online more than a month ago.\n * - `bot`, for bots.\n */\nexport type UserStatus = 'online' | 'offline' | 'recently' | 'within_week' | 'within_month' | 'long_time_ago' | 'bot'\n\nexport interface UserParsedStatus {\n status: UserStatus\n lastOnline: Date | null\n nextOffline: Date | null\n byMe: boolean\n}\n\nexport class User {\n readonly type = 'user' as const\n\n /**\n * Underlying raw TL object\n */\n readonly raw: tl.RawUser\n\n constructor(user: tl.TypeUser) {\n assertTypeIs('User#init', user, 'user')\n\n this.raw = user\n }\n\n /** Unique identifier for this user or bot */\n get id(): number {\n return this.raw.id\n }\n\n /**\n * Whether this user's information is incomplete.\n *\n * This usually only happens in large chats, where\n * the server sometimes sends only a part of the user's\n * information. Basic info like name and profile photo\n * are always available, but other fields may be omitted\n * despite being available.\n *\n * It was observed that these fields may be missing:\n * - `username, usernames`\n * - `status, lastOnline, nextOffline`\n * - `storiesMaxId`\n * - `photo` - in some cases when user has some some privacy settings\n * - and probably more\n *\n * This currently only ever happens for non-bot users, so if you are building\n * a normal bot, you can safely ignore this field.\n *\n * To fetch the \"complete\" user information, use one of these methods:\n * - {@link TelegramClient.getUsers}\n * - {@link TelegramClient.getChat}\n * - {@link TelegramClient.getFullChat}.\n *\n * Learn more: [Incomplete peers](https://mtcute.dev/guide/topics/peers.html#incomplete-peers)\n */\n get isMin(): boolean {\n return this.raw.min!\n }\n\n /** Whether this user is you yourself */\n get isSelf(): boolean {\n return this.raw.self!\n }\n\n /** Whether this user is in your contacts */\n get isContact(): boolean {\n return this.raw.contact!\n }\n\n /** Whether you both have each other's contact */\n get isMutualContact(): boolean {\n return this.raw.mutualContact!\n }\n\n /** Whether this user is in yout \"close friends\" list */\n get isCloseFriend(): boolean {\n return this.raw.closeFriend!\n }\n\n /** Whether this user is deleted */\n get isDeleted(): boolean {\n return this.raw.deleted!\n }\n\n /** Whether this user is a bot */\n get isBot(): boolean {\n return this.raw.bot!\n }\n\n /**\n * Whether this user is a bot that can be connected to a\n * Telegram Business account to receive its messages\n */\n get isBusinessBot(): boolean {\n return this.raw.botBusiness!\n }\n\n /** Whether this user is a bot that has access to all messages */\n get isBotWithHistory(): boolean {\n return this.raw.botChatHistory!\n }\n\n /** Whether this user is a bot that can't be added to chats */\n get isBotWithoutChats(): boolean {\n return this.raw.botNochats!\n }\n\n /** Whether this bot offers an attachment menu web app */\n get isBotWithAttachmentMenu(): boolean {\n return this.raw.botAttachMenu!\n }\n\n /** Whether this bot can be edited by the current user */\n get isBotEditable(): boolean {\n return this.raw.botCanEdit!\n }\n\n /** Whether this user has been verified by Telegram */\n get isVerified(): boolean {\n return this.raw.verified!\n }\n\n /**\n * Whether this user has been restricted. Bots only.\n * See {@link restrictionReason} for details\n */\n get isRestricted(): boolean {\n return this.raw.restricted!\n }\n\n /**\n * Reason why this bot was restricted\n */\n get restrictionReason(): tl.TypeRestrictionReason[] {\n return this.raw.restrictionReason ?? []\n }\n\n /** Whether this user has been flagged for scam */\n get isScam(): boolean {\n return this.raw.scam!\n }\n\n /** Whether this user has been flagged for impersonation */\n get isFake(): boolean {\n return this.raw.fake!\n }\n\n /** Whether this user is part of the Telegram support team */\n get isSupport(): boolean {\n return this.raw.support!\n }\n\n /** Whether this user has Premium subscription */\n get isPremium(): boolean {\n return this.raw.premium!\n }\n\n /** Whether Premium is required to contact this user */\n get isPremiumRequired(): boolean {\n return this.raw.contactRequirePremium!\n }\n\n /** User's or bot's first name */\n get firstName(): string {\n return this.raw.firstName ?? 'Deleted Account'\n }\n\n /** User's or bot's last name */\n get lastName(): string | null {\n return this.raw.lastName ?? null\n }\n\n static parseStatus(status?: tl.TypeUserStatus, bot = false): UserParsedStatus {\n let ret: UserStatus\n let date: Date\n let byMe = false\n\n const us = status\n\n if (bot) {\n ret = 'bot'\n } else if (!us) {\n ret = 'long_time_ago'\n } else {\n switch (us._) {\n case 'userStatusOnline':\n ret = 'online'\n date = new Date(us.expires * 1000)\n break\n case 'userStatusOffline':\n ret = 'offline'\n date = new Date(us.wasOnline * 1000)\n break\n case 'userStatusRecently':\n ret = 'recently'\n byMe = us.byMe!\n break\n case 'userStatusLastWeek':\n ret = 'within_week'\n byMe = us.byMe!\n break\n case 'userStatusLastMonth':\n ret = 'within_month'\n byMe = us.byMe!\n break\n default:\n ret = 'long_time_ago'\n break\n }\n }\n\n return {\n status: ret,\n lastOnline: ret === 'offline' ? date! : null,\n nextOffline: ret === 'online' ? date! : null,\n byMe,\n }\n }\n\n private get _parsedStatus() {\n return User.parseStatus(this.raw.status, this.raw.bot)\n }\n\n /** User's Last Seen & Online status */\n get status(): UserStatus {\n return this._parsedStatus.status\n }\n\n /**\n * Whether user's online status is hidden because\n * we have hidden our own online status from them,\n * and we don't have Premium subscription.\n */\n get statusHiddenByMe(): boolean {\n return this._parsedStatus.byMe\n }\n\n /**\n * Last time this user was seen online.\n * Only available if {@link status} is `offline`\n */\n get lastOnline(): Date | null {\n return this._parsedStatus.lastOnline\n }\n\n /**\n * Time when this user will automatically go offline.\n * Only available if {@link status} is `online`\n */\n get nextOffline(): Date | null {\n return this._parsedStatus.nextOffline\n }\n\n /** User's or bot's username */\n get username(): string | null {\n return this.raw.username ?? this.raw.usernames?.[0]?.username ?? null\n }\n\n /** User's or bot's usernames (including collectibles) */\n get usernames(): ReadonlyArray<tl.RawUsername> | null {\n if (this.raw.username) {\n return [{ _: 'username', username: this.raw.username, active: true }]\n }\n\n if (!this.raw.usernames?.length) {\n return null\n }\n\n return this.raw.usernames\n }\n\n /**\n * IETF language tag of the user's language\n *\n * Only available in some contexts\n */\n get language(): string | null {\n return this.raw.langCode ?? null\n }\n\n /**\n * User's or bot's assigned DC (data center).\n * Available only in case the user has set a public profile photo.\n *\n * **Note**: this information is approximate; it is based on where\n * Telegram stores a user profile pictures and does not by any means tell\n * you the user location (i.e. a user might travel far away, but will still connect\n * to its assigned DC).\n * More info at [Pyrogram FAQ](https://docs.pyrogram.org/faq#what-are-the-ip-addresses-of-telegram-data-centers).\n */\n get dcId(): number | null {\n return (this.raw.photo as Exclude<typeof this.raw.photo, tl.RawUserProfilePhotoEmpty>)?.dcId ?? null\n }\n\n /** User's phone number */\n get phoneNumber(): string | null {\n return this.raw.phone ?? null\n }\n\n /**\n * Get this user's input peer for advanced use-cases.\n *\n * > **Note**: for {@link min} users, this method will return\n * > `mtcute.dummyInputPeerMinUser`, which is actually not a valid input peer.\n * > These are used to indicate that the user is incomplete, and a message\n * > reference is needed to resolve the peer.\n * >\n * > Such objects are handled by {@link TelegramClient.resolvePeer} method,\n * > so prefer using it whenever you need an input peer.\n */\n get inputPeer(): tl.TypeInputPeer {\n if (this.raw.min) {\n return {\n _: 'mtcute.dummyInputPeerMinUser',\n userId: this.raw.id,\n }\n }\n\n if (!this.raw.accessHash) {\n throw new MtArgumentError(\"user's access hash is not available!\")\n }\n\n return {\n _: 'inputPeerUser',\n userId: this.raw.id,\n accessHash: this.raw.accessHash,\n }\n }\n\n /**\n * User's or bot's current profile photo, if any.\n * Suitable for downloads only\n */\n get photo(): ChatPhoto | null {\n if (this.raw.photo?._ !== 'userProfilePhoto') return null\n\n return new ChatPhoto(this.inputPeer, this.raw.photo)\n }\n\n /**\n * The list of reasons why this bot might be unavailable to some users.\n * This field is available only in case *isRestricted* is `true`\n */\n get restrictions(): ReadonlyArray<tl.RawRestrictionReason> | null {\n return this.raw.restrictionReason ?? null\n }\n\n /**\n * User's display name.\n *\n * First name and last name if available,\n * only first name otherwise.\n */\n get displayName(): string {\n if (!this.firstName) return 'Deleted Account'\n if (this.lastName) return `${this.firstName} ${this.lastName}`\n\n return this.firstName\n }\n\n /**\n * User's emoji status, if any.\n */\n get emojiStatus(): EmojiStatus | null {\n if (!this.raw.emojiStatus || this.raw.emojiStatus._ === 'emojiStatusEmpty') return null\n\n return new EmojiStatus(this.raw.emojiStatus)\n }\n\n /** Whether you have hidden (arhived) this user's stories */\n get storiesHidden(): boolean {\n return this.raw.storiesHidden!\n }\n\n get storiesUnavailable(): boolean {\n return this.raw.storiesUnavailable!\n }\n\n /**\n * Maximum ID of stories this user has (or 0 if none)\n */\n get storiesMaxId(): number {\n return this.raw.storiesMaxId ?? 0\n }\n\n /**\n * Color that should be used when rendering replies to\n * their messages and web previews sent by them,\n * as well as to render the chat title\n */\n get color(): ChatColors {\n return new ChatColors(this.raw.id, this.raw.color)\n }\n\n /**\n * Color that should be used when rendering the header of\n * the user's profile\n *\n * If `null`, a generic header should be used instead\n */\n get profileColors(): ChatColors | null {\n return this.raw.profileColor ? new ChatColors(this.raw.id, this.raw.profileColor) : null\n }\n\n /**\n * Create a mention for the user.\n *\n * When available and `text` is omitted, this method will return `@username`.\n * Otherwise, text mention is created.\n *\n * Use `null` as `text` (first parameter) to force create a text\n * mention with display name, even if there is a username.\n *\n * > **Note**: This method doesn't format anything on its own.\n * > Instead, it returns a {@link MessageEntity} that can later\n * > be used with `html` or `md` template tags\n *\n * @param text Text of the mention.\n * @example\n * ```typescript\n * msg.replyText(html`Hello, ${msg.sender.mention()`)\n * ```\n */\n mention(text?: string | null): string | MessageEntity {\n if (text === undefined && this.username) {\n return `@${this.username}`\n }\n\n if (!text) text = this.displayName\n\n return new MessageEntity(\n {\n _: 'messageEntityMentionName',\n offset: 0,\n length: text.length,\n userId: this.raw.id,\n },\n text,\n )\n }\n\n /**\n * Create a permanent mention for this user.\n *\n * *Permanent* means that this mention will also\n * contain user's access hash, so even if the user\n * changes their username or the client forgets\n * about that user, it can still be mentioned.\n *\n * Telegram might change access hash in some cases,\n * so it may not exactly be *permanent*. The only way\n * to actually make it permanent is to send it as a message\n * somewhere and load it from there if needed.\n *\n * Note that some users (particularly, users with hidden forwards)\n * may not be mentioned like this outside the chats you have in common.\n *\n * This method is only needed when the result will be\n * stored somewhere outside current mtcute instance (e.g. saved for later use),\n * otherwise {@link mention} will be enough.\n *\n * > **Note**: This method doesn't format anything on its own.\n * > Instead, it returns a {@link MessageEntity} that can later\n * > be used with `html` or `md` template tags\n *\n * > **Note**: the resulting text can only be used by clients\n * > that support mtcute notation of permanent\n * > mention links (`tg://user?id=123&hash=abc`).\n * >\n * > Also note that these permanent mentions are only\n * > valid for current account, since peer access hashes are\n * > account-specific and can't be used on another account.\n * >\n * > Also note that for some users such mentions might not work at all\n * > due to privacy settings.\n *\n * @param text Mention text\n */\n permanentMention(text?: string | null): MessageEntity {\n if (!this.raw.accessHash) {\n throw new MtArgumentError(\"User's access hash is not available!\")\n }\n\n if (!text) text = this.displayName\n\n return new MessageEntity(\n {\n _: 'messageEntityTextUrl',\n offset: 0,\n length: text.length,\n url: `tg://user?id=${this.id}&hash=${this.raw.accessHash.toString(16)}`,\n },\n text,\n )\n }\n}\n\nmemoizeGetters(User, [\n '_parsedStatus' as keyof User,\n 'usernames',\n 'inputPeer',\n 'photo',\n 'emojiStatus',\n 'color',\n 'profileColors',\n])\nmakeInspectable(User, undefined, ['_parsedStatus' as keyof User])\n"]}
1
+ {"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/peers/user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,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;CAClB,CAAC,CAAA;AACF,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,eAA6B,CAAC,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtArgumentError } from '../../../types/errors.js'\nimport { assertTypeIs } from '../../../utils/type-assertions.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { MessageEntity } from '../messages/message-entity.js'\nimport { EmojiStatus } from '../reactions/emoji-status.js'\nimport { ChatColors } from './chat-colors.js'\nimport { ChatPhoto } from './chat-photo.js'\n\n/**\n * User's Last Seen & Online status.\n * Can be one of the following:\n * - `online`, user is online right now.\n * - `offline`, user is currently offline.\n * - `recently`, user with hidden last seen time who was online between 1 second and 72 hours ago.\n * - `within_week`, user with hidden last seen time who was online between 72 hours and 7 days ago.\n * - `within_month`, user with hidden last seen time who was online between 7 days and a month ago.\n * - `long_time_ago`, blocked user or user with hidden last seen time who was online more than a month ago.\n * - `bot`, for bots.\n */\nexport type UserStatus = 'online' | 'offline' | 'recently' | 'within_week' | 'within_month' | 'long_time_ago' | 'bot'\n\nexport interface UserParsedStatus {\n status: UserStatus\n lastOnline: Date | null\n nextOffline: Date | null\n byMe: boolean\n}\n\nexport class User {\n readonly type = 'user' as const\n\n /**\n * Underlying raw TL object\n */\n readonly raw: tl.RawUser\n\n constructor(user: tl.TypeUser) {\n assertTypeIs('User#init', user, 'user')\n\n this.raw = user\n }\n\n /** Unique identifier for this user or bot */\n get id(): number {\n return this.raw.id\n }\n\n /**\n * Whether this user's information is incomplete.\n *\n * This usually only happens in large chats, where\n * the server sometimes sends only a part of the user's\n * information. Basic info like name and profile photo\n * are always available, but other fields may be omitted\n * despite being available.\n *\n * It was observed that these fields may be missing:\n * - `username, usernames`\n * - `status, lastOnline, nextOffline`\n * - `storiesMaxId`\n * - `photo` - in some cases when user has some some privacy settings\n * - and probably more\n *\n * This currently only ever happens for non-bot users, so if you are building\n * a normal bot, you can safely ignore this field.\n *\n * To fetch the \"complete\" user information, use one of these methods:\n * - {@link TelegramClient.getUsers}\n * - {@link TelegramClient.getChat}\n * - {@link TelegramClient.getFullChat}.\n *\n * Learn more: [Incomplete peers](https://mtcute.dev/guide/topics/peers.html#incomplete-peers)\n */\n get isMin(): boolean {\n return this.raw.min!\n }\n\n /** Whether this user is you yourself */\n get isSelf(): boolean {\n return this.raw.self!\n }\n\n /** Whether this user is in your contacts */\n get isContact(): boolean {\n return this.raw.contact!\n }\n\n /** Whether you both have each other's contact */\n get isMutualContact(): boolean {\n return this.raw.mutualContact!\n }\n\n /** Whether this user is in yout \"close friends\" list */\n get isCloseFriend(): boolean {\n return this.raw.closeFriend!\n }\n\n /** Whether this user is deleted */\n get isDeleted(): boolean {\n return this.raw.deleted!\n }\n\n /** Whether this user is a bot */\n get isBot(): boolean {\n return this.raw.bot!\n }\n\n /**\n * Whether this user is a bot that can be connected to a\n * Telegram Business account to receive its messages\n */\n get isBusinessBot(): boolean {\n return this.raw.botBusiness!\n }\n\n /** Whether this user is a bot that has access to all messages */\n get isBotWithHistory(): boolean {\n return this.raw.botChatHistory!\n }\n\n /** Whether this user is a bot that can't be added to chats */\n get isBotWithoutChats(): boolean {\n return this.raw.botNochats!\n }\n\n /** Whether this bot offers an attachment menu web app */\n get isBotWithAttachmentMenu(): boolean {\n return this.raw.botAttachMenu!\n }\n\n /** Whether this bot can be edited by the current user */\n get isBotEditable(): boolean {\n return this.raw.botCanEdit!\n }\n\n /** Whether this user has been verified by Telegram */\n get isVerified(): boolean {\n return this.raw.verified!\n }\n\n /**\n * Whether this user has been restricted. Bots only.\n * See {@link restrictionReason} for details\n */\n get isRestricted(): boolean {\n return this.raw.restricted!\n }\n\n /**\n * Reason why this bot was restricted\n */\n get restrictionReason(): tl.TypeRestrictionReason[] {\n return this.raw.restrictionReason ?? []\n }\n\n /** Whether this user has been flagged for scam */\n get isScam(): boolean {\n return this.raw.scam!\n }\n\n /** Whether this user has been flagged for impersonation */\n get isFake(): boolean {\n return this.raw.fake!\n }\n\n /** Whether this user is part of the Telegram support team */\n get isSupport(): boolean {\n return this.raw.support!\n }\n\n /** Whether this user has Premium subscription */\n get isPremium(): boolean {\n return this.raw.premium!\n }\n\n /** Whether Premium is required to contact this user */\n get isPremiumRequired(): boolean {\n return this.raw.contactRequirePremium!\n }\n\n /** Number of bot's active users, if available */\n get botActiveUsers(): number | null {\n return this.raw.botActiveUsers ?? null\n }\n\n /** Whether this bot has a main app */\n get hasMainApp(): boolean {\n return this.raw.botHasMainApp!\n }\n\n /** User's or bot's first name */\n get firstName(): string {\n return this.raw.firstName ?? 'Deleted Account'\n }\n\n /** User's or bot's last name */\n get lastName(): string | null {\n return this.raw.lastName ?? null\n }\n\n static parseStatus(status?: tl.TypeUserStatus, bot = false): UserParsedStatus {\n let ret: UserStatus\n let date: Date\n let byMe = false\n\n const us = status\n\n if (bot) {\n ret = 'bot'\n } else if (!us) {\n ret = 'long_time_ago'\n } else {\n switch (us._) {\n case 'userStatusOnline':\n ret = 'online'\n date = new Date(us.expires * 1000)\n break\n case 'userStatusOffline':\n ret = 'offline'\n date = new Date(us.wasOnline * 1000)\n break\n case 'userStatusRecently':\n ret = 'recently'\n byMe = us.byMe!\n break\n case 'userStatusLastWeek':\n ret = 'within_week'\n byMe = us.byMe!\n break\n case 'userStatusLastMonth':\n ret = 'within_month'\n byMe = us.byMe!\n break\n default:\n ret = 'long_time_ago'\n break\n }\n }\n\n return {\n status: ret,\n lastOnline: ret === 'offline' ? date! : null,\n nextOffline: ret === 'online' ? date! : null,\n byMe,\n }\n }\n\n private get _parsedStatus() {\n return User.parseStatus(this.raw.status, this.raw.bot)\n }\n\n /** User's Last Seen & Online status */\n get status(): UserStatus {\n return this._parsedStatus.status\n }\n\n /**\n * Whether user's online status is hidden because\n * we have hidden our own online status from them,\n * and we don't have Premium subscription.\n */\n get statusHiddenByMe(): boolean {\n return this._parsedStatus.byMe\n }\n\n /**\n * Last time this user was seen online.\n * Only available if {@link status} is `offline`\n */\n get lastOnline(): Date | null {\n return this._parsedStatus.lastOnline\n }\n\n /**\n * Time when this user will automatically go offline.\n * Only available if {@link status} is `online`\n */\n get nextOffline(): Date | null {\n return this._parsedStatus.nextOffline\n }\n\n /** User's or bot's username */\n get username(): string | null {\n return this.raw.username ?? this.raw.usernames?.[0]?.username ?? null\n }\n\n /** User's or bot's usernames (including collectibles) */\n get usernames(): ReadonlyArray<tl.RawUsername> | null {\n if (this.raw.username) {\n return [{ _: 'username', username: this.raw.username, active: true }]\n }\n\n if (!this.raw.usernames?.length) {\n return null\n }\n\n return this.raw.usernames\n }\n\n /**\n * IETF language tag of the user's language\n *\n * Only available in some contexts\n */\n get language(): string | null {\n return this.raw.langCode ?? null\n }\n\n /**\n * User's or bot's assigned DC (data center).\n * Available only in case the user has set a public profile photo.\n *\n * **Note**: this information is approximate; it is based on where\n * Telegram stores a user profile pictures and does not by any means tell\n * you the user location (i.e. a user might travel far away, but will still connect\n * to its assigned DC).\n * More info at [Pyrogram FAQ](https://docs.pyrogram.org/faq#what-are-the-ip-addresses-of-telegram-data-centers).\n */\n get dcId(): number | null {\n return (this.raw.photo as Exclude<typeof this.raw.photo, tl.RawUserProfilePhotoEmpty>)?.dcId ?? null\n }\n\n /** User's phone number */\n get phoneNumber(): string | null {\n return this.raw.phone ?? null\n }\n\n /**\n * Get this user's input peer for advanced use-cases.\n *\n * > **Note**: for {@link min} users, this method will return\n * > `mtcute.dummyInputPeerMinUser`, which is actually not a valid input peer.\n * > These are used to indicate that the user is incomplete, and a message\n * > reference is needed to resolve the peer.\n * >\n * > Such objects are handled by {@link TelegramClient.resolvePeer} method,\n * > so prefer using it whenever you need an input peer.\n */\n get inputPeer(): tl.TypeInputPeer {\n if (this.raw.min) {\n return {\n _: 'mtcute.dummyInputPeerMinUser',\n userId: this.raw.id,\n }\n }\n\n if (!this.raw.accessHash) {\n throw new MtArgumentError(\"user's access hash is not available!\")\n }\n\n return {\n _: 'inputPeerUser',\n userId: this.raw.id,\n accessHash: this.raw.accessHash,\n }\n }\n\n /**\n * User's or bot's current profile photo, if any.\n * Suitable for downloads only\n */\n get photo(): ChatPhoto | null {\n if (this.raw.photo?._ !== 'userProfilePhoto') return null\n\n return new ChatPhoto(this.inputPeer, this.raw.photo)\n }\n\n /**\n * The list of reasons why this bot might be unavailable to some users.\n * This field is available only in case *isRestricted* is `true`\n */\n get restrictions(): ReadonlyArray<tl.RawRestrictionReason> | null {\n return this.raw.restrictionReason ?? null\n }\n\n /**\n * User's display name.\n *\n * First name and last name if available,\n * only first name otherwise.\n */\n get displayName(): string {\n if (!this.firstName) return 'Deleted Account'\n if (this.lastName) return `${this.firstName} ${this.lastName}`\n\n return this.firstName\n }\n\n /**\n * User's emoji status, if any.\n */\n get emojiStatus(): EmojiStatus | null {\n if (!this.raw.emojiStatus || this.raw.emojiStatus._ === 'emojiStatusEmpty') return null\n\n return new EmojiStatus(this.raw.emojiStatus)\n }\n\n /** Whether you have hidden (arhived) this user's stories */\n get storiesHidden(): boolean {\n return this.raw.storiesHidden!\n }\n\n get storiesUnavailable(): boolean {\n return this.raw.storiesUnavailable!\n }\n\n /**\n * Maximum ID of stories this user has (or 0 if none)\n */\n get storiesMaxId(): number {\n return this.raw.storiesMaxId ?? 0\n }\n\n /**\n * Color that should be used when rendering replies to\n * their messages and web previews sent by them,\n * as well as to render the chat title\n */\n get color(): ChatColors {\n return new ChatColors(this.raw.id, this.raw.color)\n }\n\n /**\n * Color that should be used when rendering the header of\n * the user's profile\n *\n * If `null`, a generic header should be used instead\n */\n get profileColors(): ChatColors | null {\n return this.raw.profileColor ? new ChatColors(this.raw.id, this.raw.profileColor) : null\n }\n\n /**\n * Create a mention for the user.\n *\n * When available and `text` is omitted, this method will return `@username`.\n * Otherwise, text mention is created.\n *\n * Use `null` as `text` (first parameter) to force create a text\n * mention with display name, even if there is a username.\n *\n * > **Note**: This method doesn't format anything on its own.\n * > Instead, it returns a {@link MessageEntity} that can later\n * > be used with `html` or `md` template tags\n *\n * @param text Text of the mention.\n * @example\n * ```typescript\n * msg.replyText(html`Hello, ${msg.sender.mention()`)\n * ```\n */\n mention(text?: string | null): string | MessageEntity {\n if (text === undefined && this.username) {\n return `@${this.username}`\n }\n\n if (!text) text = this.displayName\n\n return new MessageEntity(\n {\n _: 'messageEntityMentionName',\n offset: 0,\n length: text.length,\n userId: this.raw.id,\n },\n text,\n )\n }\n\n /**\n * Create a permanent mention for this user.\n *\n * *Permanent* means that this mention will also\n * contain user's access hash, so even if the user\n * changes their username or the client forgets\n * about that user, it can still be mentioned.\n *\n * Telegram might change access hash in some cases,\n * so it may not exactly be *permanent*. The only way\n * to actually make it permanent is to send it as a message\n * somewhere and load it from there if needed.\n *\n * Note that some users (particularly, users with hidden forwards)\n * may not be mentioned like this outside the chats you have in common.\n *\n * This method is only needed when the result will be\n * stored somewhere outside current mtcute instance (e.g. saved for later use),\n * otherwise {@link mention} will be enough.\n *\n * > **Note**: This method doesn't format anything on its own.\n * > Instead, it returns a {@link MessageEntity} that can later\n * > be used with `html` or `md` template tags\n *\n * > **Note**: the resulting text can only be used by clients\n * > that support mtcute notation of permanent\n * > mention links (`tg://user?id=123&hash=abc`).\n * >\n * > Also note that these permanent mentions are only\n * > valid for current account, since peer access hashes are\n * > account-specific and can't be used on another account.\n * >\n * > Also note that for some users such mentions might not work at all\n * > due to privacy settings.\n *\n * @param text Mention text\n */\n permanentMention(text?: string | null): MessageEntity {\n if (!this.raw.accessHash) {\n throw new MtArgumentError(\"User's access hash is not available!\")\n }\n\n if (!text) text = this.displayName\n\n return new MessageEntity(\n {\n _: 'messageEntityTextUrl',\n offset: 0,\n length: text.length,\n url: `tg://user?id=${this.id}&hash=${this.raw.accessHash.toString(16)}`,\n },\n text,\n )\n }\n}\n\nmemoizeGetters(User, [\n '_parsedStatus' as keyof User,\n 'usernames',\n 'inputPeer',\n 'photo',\n 'emojiStatus',\n 'color',\n 'profileColors',\n])\nmakeInspectable(User, undefined, ['_parsedStatus' as keyof User])\n"]}
@@ -5,7 +5,8 @@ import { StoryInteractiveLocation } from './location.js';
5
5
  import { StoryInteractiveReaction } from './reaction.js';
6
6
  import { StoryInteractiveUrl } from './url.js';
7
7
  import { StoryInteractiveVenue } from './venue.js';
8
+ import { StoryInteractiveWeather } from './weather.js';
8
9
  export * from './input.js';
9
- export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveUrl, StoryInteractiveVenue, };
10
- export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost | StoryInteractiveUrl;
10
+ export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveUrl, StoryInteractiveVenue, StoryInteractiveWeather, };
11
+ export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost | StoryInteractiveUrl | StoryInteractiveWeather;
11
12
  export declare function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement;
@@ -4,8 +4,9 @@ import { StoryInteractiveLocation } from './location.js';
4
4
  import { StoryInteractiveReaction } from './reaction.js';
5
5
  import { StoryInteractiveUrl } from './url.js';
6
6
  import { StoryInteractiveVenue } from './venue.js';
7
+ import { StoryInteractiveWeather } from './weather.js';
7
8
  export * from './input.js';
8
- export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveUrl, StoryInteractiveVenue, };
9
+ export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveUrl, StoryInteractiveVenue, StoryInteractiveWeather, };
9
10
  export function _storyInteractiveElementFromTl(raw, peers) {
10
11
  switch (raw._) {
11
12
  case 'mediaAreaSuggestedReaction':
@@ -18,6 +19,8 @@ export function _storyInteractiveElementFromTl(raw, peers) {
18
19
  return new StoryInteractiveChannelPost(raw, peers);
19
20
  case 'mediaAreaUrl':
20
21
  return new StoryInteractiveUrl(raw);
22
+ case 'mediaAreaWeather':
23
+ return new StoryInteractiveWeather(raw);
21
24
  case 'inputMediaAreaVenue':
22
25
  case 'inputMediaAreaChannelPost':
23
26
  throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,cAAc,YAAY,CAAA;AAC1B,OAAO,EACH,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACxB,CAAA;AASD,MAAM,UAAU,8BAA8B,CAAC,GAAqB,EAAE,KAAiB;IACnF,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,4BAA4B;YAC7B,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,mBAAmB;YACpB,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,gBAAgB;YACjB,OAAO,IAAI,qBAAqB,CAAC,GAAG,CAAC,CAAA;QACzC,KAAK,sBAAsB;YACvB,OAAO,IAAI,2BAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACtD,KAAK,cAAc;YACf,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,CAAA;QACvC,KAAK,qBAAqB,CAAC;QAC3B,KAAK,2BAA2B;YAC5B,MAAM,IAAI,oBAAoB,CAAC,yBAAyB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACnF,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../../types/errors.js'\nimport { PeersIndex } from '../../peers/index.js'\nimport { StoryInteractiveChannelPost } from './channel-post.js'\nimport { StoryInteractiveLocation } from './location.js'\nimport { StoryInteractiveReaction } from './reaction.js'\nimport { StoryInteractiveUrl } from './url.js'\nimport { StoryInteractiveVenue } from './venue.js'\n\nexport * from './input.js'\nexport {\n StoryInteractiveChannelPost,\n StoryInteractiveLocation,\n StoryInteractiveReaction,\n StoryInteractiveUrl,\n StoryInteractiveVenue,\n}\n\nexport type StoryInteractiveElement =\n | StoryInteractiveReaction\n | StoryInteractiveLocation\n | StoryInteractiveVenue\n | StoryInteractiveChannelPost\n | StoryInteractiveUrl\n\nexport function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement {\n switch (raw._) {\n case 'mediaAreaSuggestedReaction':\n return new StoryInteractiveReaction(raw)\n case 'mediaAreaGeoPoint':\n return new StoryInteractiveLocation(raw)\n case 'mediaAreaVenue':\n return new StoryInteractiveVenue(raw)\n case 'mediaAreaChannelPost':\n return new StoryInteractiveChannelPost(raw, peers)\n case 'mediaAreaUrl':\n return new StoryInteractiveUrl(raw)\n case 'inputMediaAreaVenue':\n case 'inputMediaAreaChannelPost':\n throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._)\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,cAAc,YAAY,CAAA;AAC1B,OAAO,EACH,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,GAC1B,CAAA;AAUD,MAAM,UAAU,8BAA8B,CAAC,GAAqB,EAAE,KAAiB;IACnF,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,4BAA4B;YAC7B,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,mBAAmB;YACpB,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,gBAAgB;YACjB,OAAO,IAAI,qBAAqB,CAAC,GAAG,CAAC,CAAA;QACzC,KAAK,sBAAsB;YACvB,OAAO,IAAI,2BAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACtD,KAAK,cAAc;YACf,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,CAAA;QACvC,KAAK,kBAAkB;YACnB,OAAO,IAAI,uBAAuB,CAAC,GAAG,CAAC,CAAA;QAC3C,KAAK,qBAAqB,CAAC;QAC3B,KAAK,2BAA2B;YAC5B,MAAM,IAAI,oBAAoB,CAAC,yBAAyB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACnF,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../../types/errors.js'\nimport { PeersIndex } from '../../peers/index.js'\nimport { StoryInteractiveChannelPost } from './channel-post.js'\nimport { StoryInteractiveLocation } from './location.js'\nimport { StoryInteractiveReaction } from './reaction.js'\nimport { StoryInteractiveUrl } from './url.js'\nimport { StoryInteractiveVenue } from './venue.js'\nimport { StoryInteractiveWeather } from './weather.js'\n\nexport * from './input.js'\nexport {\n StoryInteractiveChannelPost,\n StoryInteractiveLocation,\n StoryInteractiveReaction,\n StoryInteractiveUrl,\n StoryInteractiveVenue,\n StoryInteractiveWeather,\n}\n\nexport type StoryInteractiveElement =\n | StoryInteractiveReaction\n | StoryInteractiveLocation\n | StoryInteractiveVenue\n | StoryInteractiveChannelPost\n | StoryInteractiveUrl\n | StoryInteractiveWeather\n\nexport function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement {\n switch (raw._) {\n case 'mediaAreaSuggestedReaction':\n return new StoryInteractiveReaction(raw)\n case 'mediaAreaGeoPoint':\n return new StoryInteractiveLocation(raw)\n case 'mediaAreaVenue':\n return new StoryInteractiveVenue(raw)\n case 'mediaAreaChannelPost':\n return new StoryInteractiveChannelPost(raw, peers)\n case 'mediaAreaUrl':\n return new StoryInteractiveUrl(raw)\n case 'mediaAreaWeather':\n return new StoryInteractiveWeather(raw)\n case 'inputMediaAreaVenue':\n case 'inputMediaAreaChannelPost':\n throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._)\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { StoryInteractiveArea } from './base.js';
3
+ /**
4
+ * Interactive element containing a weather info
5
+ */
6
+ export declare class StoryInteractiveWeather extends StoryInteractiveArea {
7
+ readonly raw: tl.RawMediaAreaWeather;
8
+ readonly type: "weather";
9
+ constructor(raw: tl.RawMediaAreaWeather);
10
+ /** Emoji representing the weather */
11
+ get emoji(): string;
12
+ /** Temperature in Celsius */
13
+ get temperature(): number;
14
+ get color(): number;
15
+ }
@@ -0,0 +1,27 @@
1
+ import { makeInspectable } from '../../../utils/index.js';
2
+ import { StoryInteractiveArea } from './base.js';
3
+ /**
4
+ * Interactive element containing a weather info
5
+ */
6
+ class StoryInteractiveWeather extends StoryInteractiveArea {
7
+ raw;
8
+ type = 'weather';
9
+ constructor(raw) {
10
+ super(raw);
11
+ this.raw = raw;
12
+ }
13
+ /** Emoji representing the weather */
14
+ get emoji() {
15
+ return this.raw.emoji;
16
+ }
17
+ /** Temperature in Celsius */
18
+ get temperature() {
19
+ return this.raw.temperatureC;
20
+ }
21
+ get color() {
22
+ return this.raw.color;
23
+ }
24
+ }
25
+ const StoryInteractiveWeather$1 = /*#__PURE__*/makeInspectable(StoryInteractiveWeather, );
26
+ //# sourceMappingURL=weather.js.map
27
+ export { StoryInteractiveWeather$1 as StoryInteractiveWeather }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weather.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/weather.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,oBAAoB;IAGxC;IAFZ,IAAI,GAAG,SAAkB,CAAA;IAElC,YAAqB,GAA2B;QAC5C,KAAK,CAAC,GAAG,CAAC,CAAA;QADO,QAAG,GAAH,GAAG,CAAwB;IAEhD,CAAC;IAED,qCAAqC;IACrC,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;IACzB,CAAC;IAED,6BAA6B;IAC7B,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAA;IAChC,CAAC;IAED,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;IACzB,CAAC;CACJ;AAED,eAAe,CAAC,uBAAuB,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../../utils/index.js'\nimport { StoryInteractiveArea } from './base.js'\n\n/**\n * Interactive element containing a weather info\n */\nexport class StoryInteractiveWeather extends StoryInteractiveArea {\n readonly type = 'weather' as const\n\n constructor(readonly raw: tl.RawMediaAreaWeather) {\n super(raw)\n }\n\n /** Emoji representing the weather */\n get emoji(): string {\n return this.raw.emoji\n }\n\n /** Temperature in Celsius */\n get temperature(): number {\n return this.raw.temperatureC\n }\n\n get color(): number {\n return this.raw.color\n }\n}\n\nmakeInspectable(StoryInteractiveWeather)\n"]}
@@ -36,6 +36,8 @@ export interface UpdatesManagerParams {
36
36
  *
37
37
  * > **Note**: you can disable this on per-request basis by passing
38
38
  * > `shouldDispatch: true` to the method call that accepts it.
39
+ * > For some methods you need to always pass `shouldDispatch: true` explicitly.
40
+ * > This is noted in the corresponding method's documentation by "Doesn't follow `disableNoDispatch`"
39
41
  *
40
42
  * @default false
41
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/highlevel/updates/types.ts"],"names":[],"mappings":"","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { AsyncLock, ConditionVariable, Deque, EarlyTimer, Logger, SortedLinkedList } from '../../utils/index.js'\nimport { CurrentUserInfo } from '../storage/service/current-user.js'\nimport { PeersIndex } from '../types/peers/peers-index.js'\n\n/**\n * Function to be called for each update.\n *\n * @param upd The update\n * @param peers Peers that are present in the update\n */\nexport type RawUpdateHandler = (upd: tl.TypeUpdate, peers: PeersIndex) => void\n\n/**\n * Parameters for the updates manager\n */\nexport interface UpdatesManagerParams {\n /**\n * **ADVANCED**\n *\n * Whether to globally disable no-dispatch mechanism.\n *\n * No-dispatch is a mechanism that allows you to call methods\n * that return updates and correctly handle them, without\n * actually dispatching them to the event handlers.\n *\n * In other words, the following code will work differently:\n * ```ts\n * dp.onNewMessage(console.log)\n * console.log(await tg.sendText('me', 'hello'))\n * ```\n * - if `disableNoDispatch` is `true`, the sent message will be\n * dispatched to the event handler, thus it will be printed twice\n * - if `disableNoDispatch` is `false`, the sent message will not be\n * dispatched to the event handler, thus it will onlt be printed once\n *\n * Disabling it may also improve performance, but it's not guaranteed.\n *\n * > **Note**: you can disable this on per-request basis by passing\n * > `shouldDispatch: true` to the method call that accepts it.\n *\n * @default false\n */\n disableNoDispatch?: boolean\n\n /**\n * **ADVANCED**\n *\n * PTS limit for `getChannelDifference` requests (max. 100000).\n * When there are more updates than this limit, the library will\n * skip some of them.\n * According to the [official docs](https://core.telegram.org/method/updates.getChannelDifference),\n * \"Ordinary (non-bot) users are supposed to pass `10-100`\", so passing >100\n * for users may lead to issues.\n *\n * @default 100 for users, 100000 for bots\n */\n channelPtsLimit?: number | ((channelId: number) => number)\n\n /**\n * **ADVANCED**\n *\n * Whenever an `updates.channelDifferenceTooLong` is received,\n * the library isn't able to efficiently handle it on its own,\n * and will call this function for you to handle it instead.\n *\n * [See docs](https://core.telegram.org/constructor/updates.channelDifferenceTooLong)\n */\n onChannelTooLong?: (channelId: number, update: tl.updates.RawChannelDifferenceTooLong) => void\n\n /**\n * **ADVANCED**\n *\n * When `openChat` method is used on a client, the library will\n * set up a timer to periodically fetch the new updates.\n * By default, it will respect the value provided by the server,\n * but it some cases you may want to override it (e.g. decrease it to\n * poll more often and potentially get updates faster).\n *\n * The returned value is treated as seconds.\n */\n overrideOpenChatTimeout?: (upd: tl.updates.TypeChannelDifference) => number\n\n /**\n * Whether to catch up with missed updates when starting updates loop.\n *\n * > **Note**: In case the storage was not properly closed the last time,\n * > \"catching up\" might result in duplicate updates.\n */\n catchUp?: boolean\n}\n\n/** @internal */\nexport interface PendingUpdateContainer {\n upd: tl.TypeUpdates\n seqStart: number\n seqEnd: number\n}\n\n/** @internal */\nexport interface PendingUpdate {\n update: tl.TypeUpdate\n channelId?: number\n pts?: number\n ptsBefore?: number\n qts?: number\n qtsBefore?: number\n timeout?: number\n peers: PeersIndex\n fromDifference: boolean\n}\n\n/** @internal */\nexport interface UpdatesState {\n updatesLoopActive: boolean\n updatesLoopCv: ConditionVariable\n\n postponedTimer: EarlyTimer\n hasTimedoutPostponed: boolean\n\n pendingUpdateContainers: SortedLinkedList<PendingUpdateContainer>\n pendingPtsUpdates: SortedLinkedList<PendingUpdate>\n pendingPtsUpdatesPostponed: SortedLinkedList<PendingUpdate>\n pendingQtsUpdates: SortedLinkedList<PendingUpdate>\n pendingQtsUpdatesPostponed: SortedLinkedList<PendingUpdate>\n pendingUnorderedUpdates: Deque<PendingUpdate>\n\n noDispatchEnabled: boolean\n // channel id or 0 => msg id\n noDispatchMsg: Map<number, Set<number>>\n // channel id or 0 => pts\n noDispatchPts: Map<number, Set<number>>\n noDispatchQts: Set<number>\n\n lock: AsyncLock\n // rpsIncoming?: RpsMeter\n // rpsProcessing?: RpsMeter\n\n // accessing storage every time might be expensive,\n // so store everything here, and load & save\n // every time session is loaded & saved.\n pts?: number\n qts?: number\n date?: number\n seq?: number\n\n // old values of the updates state (i.e. as in DB)\n // used to avoid redundant storage calls\n oldPts?: number\n oldQts?: number\n oldDate?: number\n oldSeq?: number\n selfChanged: boolean\n\n // whether to catch up channels from the locally stored pts\n catchUpChannels: boolean\n catchUpOnStart: boolean\n\n cpts: Map<number, number>\n cptsMod: Map<number, number>\n channelDiffTimeouts: Map<number, NodeJS.Timeout>\n channelsOpened: Map<number, number>\n\n log: Logger\n stop: () => void\n handler: RawUpdateHandler\n auth: CurrentUserInfo | null\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/highlevel/updates/types.ts"],"names":[],"mappings":"","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { AsyncLock, ConditionVariable, Deque, EarlyTimer, Logger, SortedLinkedList } from '../../utils/index.js'\nimport { CurrentUserInfo } from '../storage/service/current-user.js'\nimport { PeersIndex } from '../types/peers/peers-index.js'\n\n/**\n * Function to be called for each update.\n *\n * @param upd The update\n * @param peers Peers that are present in the update\n */\nexport type RawUpdateHandler = (upd: tl.TypeUpdate, peers: PeersIndex) => void\n\n/**\n * Parameters for the updates manager\n */\nexport interface UpdatesManagerParams {\n /**\n * **ADVANCED**\n *\n * Whether to globally disable no-dispatch mechanism.\n *\n * No-dispatch is a mechanism that allows you to call methods\n * that return updates and correctly handle them, without\n * actually dispatching them to the event handlers.\n *\n * In other words, the following code will work differently:\n * ```ts\n * dp.onNewMessage(console.log)\n * console.log(await tg.sendText('me', 'hello'))\n * ```\n * - if `disableNoDispatch` is `true`, the sent message will be\n * dispatched to the event handler, thus it will be printed twice\n * - if `disableNoDispatch` is `false`, the sent message will not be\n * dispatched to the event handler, thus it will onlt be printed once\n *\n * Disabling it may also improve performance, but it's not guaranteed.\n *\n * > **Note**: you can disable this on per-request basis by passing\n * > `shouldDispatch: true` to the method call that accepts it.\n * > For some methods you need to always pass `shouldDispatch: true` explicitly.\n * > This is noted in the corresponding method's documentation by \"Doesn't follow `disableNoDispatch`\"\n *\n * @default false\n */\n disableNoDispatch?: boolean\n\n /**\n * **ADVANCED**\n *\n * PTS limit for `getChannelDifference` requests (max. 100000).\n * When there are more updates than this limit, the library will\n * skip some of them.\n * According to the [official docs](https://core.telegram.org/method/updates.getChannelDifference),\n * \"Ordinary (non-bot) users are supposed to pass `10-100`\", so passing >100\n * for users may lead to issues.\n *\n * @default 100 for users, 100000 for bots\n */\n channelPtsLimit?: number | ((channelId: number) => number)\n\n /**\n * **ADVANCED**\n *\n * Whenever an `updates.channelDifferenceTooLong` is received,\n * the library isn't able to efficiently handle it on its own,\n * and will call this function for you to handle it instead.\n *\n * [See docs](https://core.telegram.org/constructor/updates.channelDifferenceTooLong)\n */\n onChannelTooLong?: (channelId: number, update: tl.updates.RawChannelDifferenceTooLong) => void\n\n /**\n * **ADVANCED**\n *\n * When `openChat` method is used on a client, the library will\n * set up a timer to periodically fetch the new updates.\n * By default, it will respect the value provided by the server,\n * but it some cases you may want to override it (e.g. decrease it to\n * poll more often and potentially get updates faster).\n *\n * The returned value is treated as seconds.\n */\n overrideOpenChatTimeout?: (upd: tl.updates.TypeChannelDifference) => number\n\n /**\n * Whether to catch up with missed updates when starting updates loop.\n *\n * > **Note**: In case the storage was not properly closed the last time,\n * > \"catching up\" might result in duplicate updates.\n */\n catchUp?: boolean\n}\n\n/** @internal */\nexport interface PendingUpdateContainer {\n upd: tl.TypeUpdates\n seqStart: number\n seqEnd: number\n}\n\n/** @internal */\nexport interface PendingUpdate {\n update: tl.TypeUpdate\n channelId?: number\n pts?: number\n ptsBefore?: number\n qts?: number\n qtsBefore?: number\n timeout?: number\n peers: PeersIndex\n fromDifference: boolean\n}\n\n/** @internal */\nexport interface UpdatesState {\n updatesLoopActive: boolean\n updatesLoopCv: ConditionVariable\n\n postponedTimer: EarlyTimer\n hasTimedoutPostponed: boolean\n\n pendingUpdateContainers: SortedLinkedList<PendingUpdateContainer>\n pendingPtsUpdates: SortedLinkedList<PendingUpdate>\n pendingPtsUpdatesPostponed: SortedLinkedList<PendingUpdate>\n pendingQtsUpdates: SortedLinkedList<PendingUpdate>\n pendingQtsUpdatesPostponed: SortedLinkedList<PendingUpdate>\n pendingUnorderedUpdates: Deque<PendingUpdate>\n\n noDispatchEnabled: boolean\n // channel id or 0 => msg id\n noDispatchMsg: Map<number, Set<number>>\n // channel id or 0 => pts\n noDispatchPts: Map<number, Set<number>>\n noDispatchQts: Set<number>\n\n lock: AsyncLock\n // rpsIncoming?: RpsMeter\n // rpsProcessing?: RpsMeter\n\n // accessing storage every time might be expensive,\n // so store everything here, and load & save\n // every time session is loaded & saved.\n pts?: number\n qts?: number\n date?: number\n seq?: number\n\n // old values of the updates state (i.e. as in DB)\n // used to avoid redundant storage calls\n oldPts?: number\n oldQts?: number\n oldDate?: number\n oldSeq?: number\n selfChanged: boolean\n\n // whether to catch up channels from the locally stored pts\n catchUpChannels: boolean\n catchUpOnStart: boolean\n\n cpts: Map<number, number>\n cptsMod: Map<number, number>\n channelDiffTimeouts: Map<number, NodeJS.Timeout>\n channelsOpened: Map<number, number>\n\n log: Logger\n stop: () => void\n handler: RawUpdateHandler\n auth: CurrentUserInfo | null\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { createControllablePromise } from '../../utils/controllable-promise.js';
2
2
  import { deserializeError } from './errors.js';
3
- import { deserializeResult } from './protocol.js';
3
+ import { deserializeResult, serializeResult } from './protocol.js';
4
4
  export class WorkerInvoker {
5
5
  send;
6
6
  constructor(send) {
@@ -15,7 +15,7 @@ export class WorkerInvoker {
15
15
  id,
16
16
  target,
17
17
  method,
18
- args,
18
+ args: serializeResult(args),
19
19
  void: isVoid,
20
20
  withAbort: Boolean(abortSignal),
21
21
  });
@@ -1 +1 @@
1
- {"version":3,"file":"invoker.js","sourceRoot":"","sources":["../../../../src/highlevel/worker/invoker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AACpG,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAuD,MAAM,eAAe,CAAA;AAItG,MAAM,OAAO,aAAa;IACF;IAApB,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE5B,OAAO,GAAG,CAAC,CAAA;IACX,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAA;IAEjD,OAAO,CAAC,MAAoB,EAAE,MAAc,EAAE,IAAe,EAAE,MAAe,EAAE,WAAyB;QAC7G,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAEzB,IAAI,CAAC,IAAI,CAAC;YACN,IAAI,EAAE,QAAQ;YACd,EAAE;YACF,MAAM;YACN,MAAM;YACN,IAAI;YACJ,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;SAClC,CAAC,CAAA;QAEF,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC;gBACN,IAAI,EAAE,OAAO;gBACb,EAAE;aACL,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,OAAO,GAAG,yBAAyB,EAAE,CAAA;YAE3C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,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G,IAAe,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAgB,EAAE,IAAI,CAAC,CAAA;YAChF,CAAC;iBAAM,CAAC;gBACJ,EAAE,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAgB,EAAE,IAAI,CAAC,CAAA;YAC5E,CAAC;YAED,OAAO,EAAU,CAAA;QACrB,CAAC,CAAA;IACL,CAAC;CACJ","sourcesContent":["import { ControllablePromise, createControllablePromise } from '../../utils/controllable-promise.js'\nimport { deserializeError } from './errors.js'\nimport { deserializeResult, SendFn, WorkerInboundMessage, WorkerOutboundMessage } from './protocol.js'\n\nexport type InvokeTarget = Extract<WorkerInboundMessage, { type: 'invoke' }>['target']\n\nexport class WorkerInvoker {\n constructor(private send: SendFn) {}\n\n private _nextId = 0\n private _pending = new Map<number, ControllablePromise>()\n\n private _invoke(target: InvokeTarget, method: string, args: unknown[], isVoid: boolean, abortSignal?: AbortSignal) {\n const id = this._nextId++\n\n this.send({\n type: 'invoke',\n id,\n target,\n method,\n args,\n void: isVoid,\n withAbort: Boolean(abortSignal),\n })\n\n abortSignal?.addEventListener('abort', () => {\n this.send({\n type: 'abort',\n id,\n })\n })\n\n if (!isVoid) {\n const promise = createControllablePromise()\n\n this._pending.set(id, promise)\n\n return promise\n }\n }\n\n invoke(target: InvokeTarget, method: string, args: unknown[]): Promise<unknown> {\n return this._invoke(target, method, args, false) as Promise<unknown>\n }\n\n invokeVoid(target: InvokeTarget, method: string, args: unknown[]): void {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._invoke(target, method, args, true)\n }\n\n invokeWithAbort(target: InvokeTarget, method: string, args: unknown[], abortSignal: AbortSignal): Promise<unknown> {\n if (abortSignal.aborted) return Promise.reject(abortSignal.reason)\n\n return this._invoke(target, method, args, false, abortSignal) as Promise<unknown>\n }\n\n handleResult(msg: Extract<WorkerOutboundMessage, { type: 'result' }>) {\n const promise = this._pending.get(msg.id)\n if (!promise) return\n\n if (msg.error) {\n promise.reject(deserializeError(msg.error))\n } else {\n promise.resolve(deserializeResult(msg.result!))\n }\n }\n\n makeBinder<T>(target: InvokeTarget) {\n return <K extends keyof T>(method: K, isVoid = false) => {\n let fn\n\n if (isVoid) {\n fn = (...args: unknown[]) => this.invokeVoid(target, method as string, args)\n } else {\n fn = (...args: unknown[]) => this.invoke(target, method as string, args)\n }\n\n return fn as T[K]\n }\n }\n}\n"]}
1
+ {"version":3,"file":"invoker.js","sourceRoot":"","sources":["../../../../src/highlevel/worker/invoker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AACpG,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAU,eAAe,EAA+C,MAAM,eAAe,CAAA;AAIvH,MAAM,OAAO,aAAa;IACF;IAApB,YAAoB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE5B,OAAO,GAAG,CAAC,CAAA;IACX,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAA;IAEjD,OAAO,CAAC,MAAoB,EAAE,MAAc,EAAE,IAAe,EAAE,MAAe,EAAE,WAAyB;QAC7G,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAEzB,IAAI,CAAC,IAAI,CAAC;YACN,IAAI,EAAE,QAAQ;YACd,EAAE;YACF,MAAM;YACN,MAAM;YACN,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;YAC3B,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;SAClC,CAAC,CAAA;QAEF,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACxC,IAAI,CAAC,IAAI,CAAC;gBACN,IAAI,EAAE,OAAO;gBACb,EAAE;aACL,CAAC,CAAA;QACN,CAAC,CAAC,C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AO,CAAoB,MAAS,EAAE,MAAM,GAAG,KAAK,EAAE,EAAE;YACpD,IAAI,EAAE,CAAA;YAEN,IAAI,MAAM,EAAE,CAAC;gBACT,EAAE,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAgB,EAAE,IAAI,CAAC,CAAA;YAChF,CAAC;iBAAM,CAAC;gBACJ,EAAE,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAgB,EAAE,IAAI,CAAC,CAAA;YAC5E,CAAC;YAED,OAAO,EAAU,CAAA;QACrB,CAAC,CAAA;IACL,CAAC;CACJ","sourcesContent":["import { ControllablePromise, createControllablePromise } from '../../utils/controllable-promise.js'\nimport { deserializeError } from './errors.js'\nimport { deserializeResult, SendFn, serializeResult, WorkerInboundMessage, WorkerOutboundMessage } from './protocol.js'\n\nexport type InvokeTarget = Extract<WorkerInboundMessage, { type: 'invoke' }>['target']\n\nexport class WorkerInvoker {\n constructor(private send: SendFn) {}\n\n private _nextId = 0\n private _pending = new Map<number, ControllablePromise>()\n\n private _invoke(target: InvokeTarget, method: string, args: unknown[], isVoid: boolean, abortSignal?: AbortSignal) {\n const id = this._nextId++\n\n this.send({\n type: 'invoke',\n id,\n target,\n method,\n args: serializeResult(args),\n void: isVoid,\n withAbort: Boolean(abortSignal),\n })\n\n abortSignal?.addEventListener('abort', () => {\n this.send({\n type: 'abort',\n id,\n })\n })\n\n if (!isVoid) {\n const promise = createControllablePromise()\n\n this._pending.set(id, promise)\n\n return promise\n }\n }\n\n invoke(target: InvokeTarget, method: string, args: unknown[]): Promise<unknown> {\n return this._invoke(target, method, args, false) as Promise<unknown>\n }\n\n invokeVoid(target: InvokeTarget, method: string, args: unknown[]): void {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this._invoke(target, method, args, true)\n }\n\n invokeWithAbort(target: InvokeTarget, method: string, args: unknown[], abortSignal: AbortSignal): Promise<unknown> {\n if (abortSignal.aborted) return Promise.reject(abortSignal.reason)\n\n return this._invoke(target, method, args, false, abortSignal) as Promise<unknown>\n }\n\n handleResult(msg: Extract<WorkerOutboundMessage, { type: 'result' }>) {\n const promise = this._pending.get(msg.id)\n if (!promise) return\n\n if (msg.error) {\n promise.reject(deserializeError(msg.error))\n } else {\n promise.resolve(deserializeResult(msg.result!))\n }\n }\n\n makeBinder<T>(target: InvokeTarget) {\n return <K extends keyof T>(method: K, isVoid = false) => {\n let fn\n\n if (isVoid) {\n fn = (...args: unknown[]) => this.invokeVoid(target, method as string, args)\n } else {\n fn = (...args: unknown[]) => this.invoke(target, method as string, args)\n }\n\n return fn as T[K]\n }\n }\n}\n"]}