@mtcute/core 0.13.3 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/cjs/highlevel/base.d.ts +1 -0
  2. package/cjs/highlevel/base.js +3 -0
  3. package/cjs/highlevel/base.js.map +1 -1
  4. package/cjs/highlevel/client.d.ts +2 -4
  5. package/cjs/highlevel/client.js +3 -0
  6. package/cjs/highlevel/client.js.map +1 -1
  7. package/cjs/highlevel/client.types.d.ts +1 -0
  8. package/cjs/highlevel/client.types.js.map +1 -1
  9. package/cjs/highlevel/methods/_init.js +3 -0
  10. package/cjs/highlevel/methods/_init.js.map +1 -1
  11. package/cjs/highlevel/methods/chats/delete-history.d.ts +2 -4
  12. package/cjs/highlevel/methods/chats/delete-history.js.map +1 -1
  13. package/cjs/highlevel/methods/chats/kick-chat-member.js +1 -1
  14. package/cjs/highlevel/methods/chats/kick-chat-member.js.map +1 -1
  15. package/cjs/highlevel/methods/messages/find-in-update.js +4 -2
  16. package/cjs/highlevel/methods/messages/find-in-update.js.map +1 -1
  17. package/cjs/highlevel/types/stories/interactive/index.d.ts +3 -2
  18. package/cjs/highlevel/types/stories/interactive/index.js +5 -1
  19. package/cjs/highlevel/types/stories/interactive/index.js.map +1 -1
  20. package/cjs/highlevel/types/stories/interactive/input.d.ts +1 -0
  21. package/cjs/highlevel/types/stories/interactive/input.js +7 -0
  22. package/cjs/highlevel/types/stories/interactive/input.js.map +1 -1
  23. package/cjs/highlevel/types/stories/interactive/url.d.ts +11 -0
  24. package/cjs/highlevel/types/stories/interactive/url.js +20 -0
  25. package/cjs/highlevel/types/stories/interactive/url.js.map +1 -0
  26. package/cjs/highlevel/types/updates/callback-query.d.ts +16 -2
  27. package/cjs/highlevel/types/updates/callback-query.js +31 -1
  28. package/cjs/highlevel/types/updates/callback-query.js.map +1 -1
  29. package/cjs/highlevel/types/updates/index.d.ts +5 -2
  30. package/cjs/highlevel/types/updates/index.js +2 -1
  31. package/cjs/highlevel/types/updates/index.js.map +1 -1
  32. package/cjs/highlevel/types/updates/parse-update.js +2 -0
  33. package/cjs/highlevel/types/updates/parse-update.js.map +1 -1
  34. package/cjs/highlevel/worker/port.d.ts +2 -0
  35. package/cjs/highlevel/worker/port.js +5 -0
  36. package/cjs/highlevel/worker/port.js.map +1 -1
  37. package/cjs/highlevel/worker/protocol.d.ts +2 -0
  38. package/cjs/highlevel/worker/protocol.js.map +1 -1
  39. package/cjs/highlevel/worker/worker.js +1 -0
  40. package/cjs/highlevel/worker/worker.js.map +1 -1
  41. package/cjs/network/client.d.ts +2 -0
  42. package/cjs/network/client.js +8 -0
  43. package/cjs/network/client.js.map +1 -1
  44. package/cjs/network/mtproto-session.js +2 -0
  45. package/cjs/network/mtproto-session.js.map +1 -1
  46. package/cjs/network/network-manager.d.ts +9 -2
  47. package/cjs/network/network-manager.js +26 -13
  48. package/cjs/network/network-manager.js.map +1 -1
  49. package/cjs/network/session-connection.js +12 -3
  50. package/cjs/network/session-connection.js.map +1 -1
  51. package/cjs/storage/sqlite/repository/peers.d.ts +2 -0
  52. package/cjs/storage/sqlite/repository/peers.js +14 -0
  53. package/cjs/storage/sqlite/repository/peers.js.map +1 -1
  54. package/cjs/utils/misc-utils.d.ts +1 -0
  55. package/cjs/utils/misc-utils.js +17 -1
  56. package/cjs/utils/misc-utils.js.map +1 -1
  57. package/esm/highlevel/base.d.ts +1 -0
  58. package/esm/highlevel/base.js +3 -0
  59. package/esm/highlevel/base.js.map +1 -1
  60. package/esm/highlevel/client.d.ts +2 -4
  61. package/esm/highlevel/client.js +3 -0
  62. package/esm/highlevel/client.js.map +1 -1
  63. package/esm/highlevel/client.types.d.ts +1 -0
  64. package/esm/highlevel/client.types.js.map +1 -1
  65. package/esm/highlevel/methods/_init.js +3 -0
  66. package/esm/highlevel/methods/_init.js.map +1 -1
  67. package/esm/highlevel/methods/chats/delete-history.d.ts +2 -4
  68. package/esm/highlevel/methods/chats/delete-history.js.map +1 -1
  69. package/esm/highlevel/methods/chats/kick-chat-member.js +2 -2
  70. package/esm/highlevel/methods/chats/kick-chat-member.js.map +1 -1
  71. package/esm/highlevel/methods/messages/find-in-update.js +4 -2
  72. package/esm/highlevel/methods/messages/find-in-update.js.map +1 -1
  73. package/esm/highlevel/types/stories/interactive/index.d.ts +3 -2
  74. package/esm/highlevel/types/stories/interactive/index.js +4 -1
  75. package/esm/highlevel/types/stories/interactive/index.js.map +1 -1
  76. package/esm/highlevel/types/stories/interactive/input.d.ts +1 -0
  77. package/esm/highlevel/types/stories/interactive/input.js +7 -0
  78. package/esm/highlevel/types/stories/interactive/input.js.map +1 -1
  79. package/esm/highlevel/types/stories/interactive/url.d.ts +11 -0
  80. package/esm/highlevel/types/stories/interactive/url.js +16 -0
  81. package/esm/highlevel/types/stories/interactive/url.js.map +1 -0
  82. package/esm/highlevel/types/updates/callback-query.d.ts +16 -2
  83. package/esm/highlevel/types/updates/callback-query.js +30 -0
  84. package/esm/highlevel/types/updates/callback-query.js.map +1 -1
  85. package/esm/highlevel/types/updates/index.d.ts +5 -2
  86. package/esm/highlevel/types/updates/index.js +2 -2
  87. package/esm/highlevel/types/updates/index.js.map +1 -1
  88. package/esm/highlevel/types/updates/parse-update.js +3 -1
  89. package/esm/highlevel/types/updates/parse-update.js.map +1 -1
  90. package/esm/highlevel/worker/port.d.ts +2 -0
  91. package/esm/highlevel/worker/port.js +5 -0
  92. package/esm/highlevel/worker/port.js.map +1 -1
  93. package/esm/highlevel/worker/protocol.d.ts +2 -0
  94. package/esm/highlevel/worker/protocol.js.map +1 -1
  95. package/esm/highlevel/worker/worker.js +1 -0
  96. package/esm/highlevel/worker/worker.js.map +1 -1
  97. package/esm/network/client.d.ts +2 -0
  98. package/esm/network/client.js +8 -0
  99. package/esm/network/client.js.map +1 -1
  100. package/esm/network/mtproto-session.js +2 -0
  101. package/esm/network/mtproto-session.js.map +1 -1
  102. package/esm/network/network-manager.d.ts +9 -2
  103. package/esm/network/network-manager.js +27 -14
  104. package/esm/network/network-manager.js.map +1 -1
  105. package/esm/network/session-connection.js +12 -3
  106. package/esm/network/session-connection.js.map +1 -1
  107. package/esm/storage/sqlite/repository/peers.d.ts +2 -0
  108. package/esm/storage/sqlite/repository/peers.js +14 -0
  109. package/esm/storage/sqlite/repository/peers.js.map +1 -1
  110. package/esm/utils/misc-utils.d.ts +1 -0
  111. package/esm/utils/misc-utils.js +15 -0
  112. package/esm/utils/misc-utils.js.map +1 -1
  113. package/package.json +4 -4
@@ -23,6 +23,7 @@ export interface ITelegramClient {
23
23
  readonly log: Logger;
24
24
  readonly storage: PublicPart<TelegramStorageManager>;
25
25
  readonly appConfig: PublicPart<AppConfigManager>;
26
+ readonly stopSignal: AbortSignal;
26
27
  prepare(): Promise<void>;
27
28
  connect(): Promise<void>;
28
29
  close(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"client.types.js","sourceRoot":"","sources":["../../../src/highlevel/client.types.ts"],"names":[],"mappings":"","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport type { ConnectionKind, RpcCallOptions } from '../network/index.js'\nimport type { MustEqual, PublicPart } from '../types/utils.js'\nimport type { Logger } from '../utils/logger.js'\nimport type { AppConfigManager } from './managers/app-config-manager.js'\nimport type { TelegramStorageManager } from './storage/storage.js'\nimport type { RawUpdateHandler } from './updates/types.js'\nimport type { StringSessionData } from './utils/string-session.js'\n\n/**\n * Connection state of the client\n *\n * - `offline` - not connected (only emitted when {@link ICorePlatform.onNetworkChanged} callback\n * is called with `false`)\n * - `connecting` - currently connecting. All requests will be queued until the connection is established\n * - `updating` - connected and is currently updating the state (i.e. downloading missing updates).\n * At this point client is already fully operational, but some updates may be missing.\n * Is only emitted when updates manager is enabled.\n * - `connected` - connected and ready to send requests. When updates manager is enabled, this state\n * may be emitted before `updating` state\n */\nexport type ConnectionState = 'offline' | 'connecting' | 'updating' | 'connected'\n\n// NB: when adding new methods, don't forget to add them to:\n// - worker/port.ts\n// - generate-client script\n\nexport interface ITelegramClient {\n readonly log: Logger\n readonly storage: PublicPart<TelegramStorageManager>\n readonly appConfig: PublicPart<AppConfigManager>\n\n prepare(): Promise<void>\n connect(): Promise<void>\n close(): Promise<void>\n notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>\n notifyLoggedOut(): Promise<void>\n notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>\n notifyChannelClosed(channelId: number): Promise<boolean>\n startUpdatesLoop(): Promise<void>\n stopUpdatesLoop(): Promise<void>\n call<T extends tl.RpcMethod>(\n message: MustEqual<T, tl.RpcMethod>,\n params?: RpcCallOptions,\n ): Promise<tl.RpcCallReturn[T['_']]>\n importSession(session: string | StringSessionData, force?: boolean): Promise<void>\n exportSession(): Promise<string>\n onError(handler: (err: unknown) => void): void\n emitError(err: unknown): void\n handleClientUpdate(updates: tl.TypeUpdates, noDispatch?: boolean): void\n\n onServerUpdate(handler: (update: tl.TypeUpdates) => void): void\n onUpdate(handler: RawUpdateHandler): void\n onConnectionState(handler: (state: ConnectionState) => void): void\n\n getApiCrenetials(): Promise<{ id: number; hash: string }>\n // todo - this is only used for file dl/ul, which should probably be moved\n // to the client to allow moving the thing to worker\n // or at least load this once at startup (and then these methods can be made sync)\n getPoolSize(kind: ConnectionKind, dcId?: number): Promise<number>\n getPrimaryDcId(): Promise<number>\n\n computeSrpParams(request: tl.account.RawPassword, password: string): Promise<tl.RawInputCheckPasswordSRP>\n computeNewPasswordHash(algo: tl.TypePasswordKdfAlgo, password: string): Promise<Uint8Array>\n}\n"]}
1
+ {"version":3,"file":"client.types.js","sourceRoot":"","sources":["../../../src/highlevel/client.types.ts"],"names":[],"mappings":"","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport type { ConnectionKind, RpcCallOptions } from '../network/index.js'\nimport type { MustEqual, PublicPart } from '../types/utils.js'\nimport type { Logger } from '../utils/logger.js'\nimport type { AppConfigManager } from './managers/app-config-manager.js'\nimport type { TelegramStorageManager } from './storage/storage.js'\nimport type { RawUpdateHandler } from './updates/types.js'\nimport type { StringSessionData } from './utils/string-session.js'\n\n/**\n * Connection state of the client\n *\n * - `offline` - not connected (only emitted when {@link ICorePlatform.onNetworkChanged} callback\n * is called with `false`)\n * - `connecting` - currently connecting. All requests will be queued until the connection is established\n * - `updating` - connected and is currently updating the state (i.e. downloading missing updates).\n * At this point client is already fully operational, but some updates may be missing.\n * Is only emitted when updates manager is enabled.\n * - `connected` - connected and ready to send requests. When updates manager is enabled, this state\n * may be emitted before `updating` state\n */\nexport type ConnectionState = 'offline' | 'connecting' | 'updating' | 'connected'\n\n// NB: when adding new methods, don't forget to add them to:\n// - worker/port.ts\n// - generate-client script\n\nexport interface ITelegramClient {\n readonly log: Logger\n readonly storage: PublicPart<TelegramStorageManager>\n readonly appConfig: PublicPart<AppConfigManager>\n readonly stopSignal: AbortSignal\n\n prepare(): Promise<void>\n connect(): Promise<void>\n close(): Promise<void>\n notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>\n notifyLoggedOut(): Promise<void>\n notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>\n notifyChannelClosed(channelId: number): Promise<boolean>\n startUpdatesLoop(): Promise<void>\n stopUpdatesLoop(): Promise<void>\n call<T extends tl.RpcMethod>(\n message: MustEqual<T, tl.RpcMethod>,\n params?: RpcCallOptions,\n ): Promise<tl.RpcCallReturn[T['_']]>\n importSession(session: string | StringSessionData, force?: boolean): Promise<void>\n exportSession(): Promise<string>\n onError(handler: (err: unknown) => void): void\n emitError(err: unknown): void\n handleClientUpdate(updates: tl.TypeUpdates, noDispatch?: boolean): void\n\n onServerUpdate(handler: (update: tl.TypeUpdates) => void): void\n onUpdate(handler: RawUpdateHandler): void\n onConnectionState(handler: (state: ConnectionState) => void): void\n\n getApiCrenetials(): Promise<{ id: number; hash: string }>\n // todo - this is only used for file dl/ul, which should probably be moved\n // to the client to allow moving the thing to worker\n // or at least load this once at startup (and then these methods can be made sync)\n getPoolSize(kind: ConnectionKind, dcId?: number): Promise<number>\n getPrimaryDcId(): Promise<number>\n\n computeSrpParams(request: tl.account.RawPassword, password: string): Promise<tl.RawInputCheckPasswordSRP>\n computeNewPasswordHash(algo: tl.TypePasswordKdfAlgo, password: string): Promise<Uint8Array>\n}\n"]}
@@ -24,6 +24,9 @@ function _initializeClient(opts) {
24
24
  this.log = this._client.log;
25
25
  // @ts-expect-error codegen
26
26
  this.storage = this._client.storage;
27
+ Object.defineProperty(this, 'stopSignal', {
28
+ get: () => this._client.stopSignal,
29
+ });
27
30
  if (!opts.disableUpdates) {
28
31
  const skipConversationUpdates = opts.skipConversationUpdates ?? true;
29
32
  const { messageGroupingInterval } = opts.updates ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"_init.js","sourceRoot":"","sources":["../../../../src/highlevel/methods/_init.ts"],"names":[],"mappings":";AAAA,sDAAsD;;AAEtD,QAAQ;AACR,mDAAsE;AACtE,wCAA0E;AAK1E,QAAQ;AACR,8DAAuD;AACvD,QAAQ;AACR,oDAAyF;AAmCzF,cAAc;AACd,gBAAgB;AAChB,SAAS,iBAAiB,CAAuB,IAA2B;IACxE,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAA;IAC9B,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACvF,MAAM,IAAI,6BAAkB,CACxB,+EAA+E,CAClF,CAAA;QACL,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,4BAAkB,CAAC,IAAiC,CAAC,CAAA;IAC5E,CAAC;IAED,2BAA2B;IAC3B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAA;IAC3B,2BAA2B;IAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA;IAEnC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QACvB,MAAM,uBAAuB,GAAG,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAA;QACpE,MAAM,EAAE,uBAAuB,EAAE,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;QAEtD,IAAI,CAAC,OAAO,CAAC,QAAQ,CACjB,IAAA,mCAAuB,EAAC;YACpB,uBAAuB;YACvB,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;gBACjB,IAAI,8BAAY,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,uBAAuB;oBAAE,OAAM;gBAE9E,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;gBAC3B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;YACvC,CAAC;YACD,WAAW,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;YAC1C,CAAC;SACJ,CAAC,CACL,CAAA;IACL,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// @copy\nimport { MtUnsupportedError, PartialOnly } from '../../types/index.js'\nimport { BaseTelegramClient, BaseTelegramClientOptions } from '../base.js'\nimport { TelegramClient } from '../client.js'\nimport { ITelegramClient } from '../client.types.js'\n// @copy\nimport { ITelegramStorageProvider } from '../storage/provider.js'\n// @copy\nimport { Conversation } from '../types/conversation.js'\n// @copy\nimport { makeParsedUpdateHandler, ParsedUpdateHandlerParams } from '../updates/parsed.js'\n\n// @copy\ntype TelegramClientOptions = (\n | (PartialOnly<Omit<BaseTelegramClientOptions, 'storage'>, 'transport' | 'crypto'> & {\n /**\n * Storage to use for this client.\n *\n * If a string is passed, it will be used as\n * a name for the default platform-specific storage provider to use.\n *\n * @default `\"client.session\"`\n */\n storage?: string | ITelegramStorageProvider\n })\n | { client: ITelegramClient }\n) & {\n /**\n * If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`,\n * effectively disabling the server-sent events for the clients.\n * May be useful in some cases.\n *\n * @default false\n */\n disableUpdates?: boolean\n updates?: Omit<ParsedUpdateHandlerParams, 'onUpdate'>\n /**\n * If `true`, the updates that were handled by some {@link Conversation}\n * will not be dispatched any further.\n *\n * @default true\n */\n skipConversationUpdates?: boolean\n}\n\n// @initialize\n/** @internal */\nfunction _initializeClient(this: TelegramClient, opts: TelegramClientOptions) {\n if ('client' in opts) {\n this._client = opts.client\n } else {\n if (!opts.storage || typeof opts.storage === 'string' || !opts.transport || !opts.crypto) {\n throw new MtUnsupportedError(\n 'You need to explicitly provide storage, transport and crypto for @mtcute/core',\n )\n }\n\n this._client = new BaseTelegramClient(opts as BaseTelegramClientOptions)\n }\n\n // @ts-expect-error codegen\n this.log = this._client.log\n // @ts-expect-error codegen\n this.storage = this._client.storage\n\n if (!opts.disableUpdates) {\n const skipConversationUpdates = opts.skipConversationUpdates ?? true\n const { messageGroupingInterval } = opts.updates ?? {}\n\n this._client.onUpdate(\n makeParsedUpdateHandler({\n messageGroupingInterval,\n onUpdate: (update) => {\n if (Conversation.handleUpdate(this, update) && skipConversationUpdates) return\n\n this.emit('update', update)\n this.emit(update.name, update.data)\n },\n onRawUpdate: (update, peers) => {\n this.emit('raw_update', update, peers)\n },\n }),\n )\n }\n}\n"]}
1
+ {"version":3,"file":"_init.js","sourceRoot":"","sources":["../../../../src/highlevel/methods/_init.ts"],"names":[],"mappings":";AAAA,sDAAsD;;AAEtD,QAAQ;AACR,mDAAsE;AACtE,wCAA0E;AAK1E,QAAQ;AACR,8DAAuD;AACvD,QAAQ;AACR,oDAAyF;AAmCzF,cAAc;AACd,gBAAgB;AAChB,SAAS,iBAAiB,CAAuB,IAA2B;IACxE,IA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E,MAAM,CAAC,IAAI,CAAC,CAAA;YACvC,CAAC;YACD,WAAW,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;gBAC3B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;YAC1C,CAAC;SACJ,CAAC,CACL,CAAA;IACL,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n\n// @copy\nimport { MtUnsupportedError, PartialOnly } from '../../types/index.js'\nimport { BaseTelegramClient, BaseTelegramClientOptions } from '../base.js'\nimport { TelegramClient } from '../client.js'\nimport { ITelegramClient } from '../client.types.js'\n// @copy\nimport { ITelegramStorageProvider } from '../storage/provider.js'\n// @copy\nimport { Conversation } from '../types/conversation.js'\n// @copy\nimport { makeParsedUpdateHandler, ParsedUpdateHandlerParams } from '../updates/parsed.js'\n\n// @copy\ntype TelegramClientOptions = (\n | (PartialOnly<Omit<BaseTelegramClientOptions, 'storage'>, 'transport' | 'crypto'> & {\n /**\n * Storage to use for this client.\n *\n * If a string is passed, it will be used as\n * a name for the default platform-specific storage provider to use.\n *\n * @default `\"client.session\"`\n */\n storage?: string | ITelegramStorageProvider\n })\n | { client: ITelegramClient }\n) & {\n /**\n * If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`,\n * effectively disabling the server-sent events for the clients.\n * May be useful in some cases.\n *\n * @default false\n */\n disableUpdates?: boolean\n updates?: Omit<ParsedUpdateHandlerParams, 'onUpdate'>\n /**\n * If `true`, the updates that were handled by some {@link Conversation}\n * will not be dispatched any further.\n *\n * @default true\n */\n skipConversationUpdates?: boolean\n}\n\n// @initialize\n/** @internal */\nfunction _initializeClient(this: TelegramClient, opts: TelegramClientOptions) {\n if ('client' in opts) {\n this._client = opts.client\n } else {\n if (!opts.storage || typeof opts.storage === 'string' || !opts.transport || !opts.crypto) {\n throw new MtUnsupportedError(\n 'You need to explicitly provide storage, transport and crypto for @mtcute/core',\n )\n }\n\n this._client = new BaseTelegramClient(opts as BaseTelegramClientOptions)\n }\n\n // @ts-expect-error codegen\n this.log = this._client.log\n // @ts-expect-error codegen\n this.storage = this._client.storage\n Object.defineProperty(this, 'stopSignal', {\n get: () => this._client.stopSignal,\n })\n\n if (!opts.disableUpdates) {\n const skipConversationUpdates = opts.skipConversationUpdates ?? true\n const { messageGroupingInterval } = opts.updates ?? {}\n\n this._client.onUpdate(\n makeParsedUpdateHandler({\n messageGroupingInterval,\n onUpdate: (update) => {\n if (Conversation.handleUpdate(this, update) && skipConversationUpdates) return\n\n this.emit('update', update)\n this.emit(update.name, update.data)\n },\n onRawUpdate: (update, peers) => {\n this.emit('raw_update', update, peers)\n },\n }),\n )\n }\n}\n"]}
@@ -6,11 +6,9 @@ import { InputPeerLike } from '../../types/index.js';
6
6
  export declare function deleteHistory(client: ITelegramClient, chat: InputPeerLike, params?: {
7
7
  /**
8
8
  * Deletion mode. Can be:
9
- * - `delete`: delete messages (only for yourself)
10
- * - `clear`: delete messages (only for yourself)
9
+ * - `delete`: delete messages (only for yourself) AND the dialog itself
10
+ * - `clear`: delete messages (only for yourself), but keep the dialog in the list
11
11
  * - `revoke`: delete messages for all users
12
- * - I'm not sure what's the difference between `delete` and `clear`,
13
- * but they are in fact different flags in TL object.
14
12
  *
15
13
  * @default 'delete'
16
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"delete-history.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/chats/delete-history.ts"],"names":[],"mappings":";;;AAEA,qDAA0D;AAC1D,6DAA8D;AAC9D,8DAAsD;AAEtD;;GAEG;AACI,KAAK,UAAU,aAAa,CAC/B,MAAuB,EACvB,IAAmB,EACnB,MAmBC;IAED,MAAM,EAAE,IAAI,GAAG,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAEnD,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAW,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAE5C,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;QAC1B,CAAC,EAAE,wBAAwB;QAC3B,SAAS,EAAE,IAAI,KAAK,OAAO;QAC3B,MAAM,EAAE,IAAI,KAAK,QAAQ;QACzB,IAAI;QACJ,KAAK;KACR,CAAC,CAAA;IAEF,IAAI,IAAA,kCAAkB,EAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,kBAAkB,CAAC,IAAA,4BAAiB,EAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;IACvF,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,kBAAkB,CAAC,IAAA,4BAAiB,EAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACvE,CAAC;AACL,CAAC;AAzCD,sCAyCC","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 * Delete communication history (for private chats and legacy groups)\n */\nexport async function deleteHistory(\n client: ITelegramClient,\n chat: InputPeerLike,\n params?: {\n /**\n * Deletion mode. Can be:\n * - `delete`: delete messages (only for yourself)\n * - `clear`: delete messages (only for yourself)\n * - `revoke`: delete messages for all users\n * - I'm not sure what's the difference between `delete` and `clear`,\n * but they are in fact different flags in TL object.\n *\n * @default 'delete'\n */\n mode: 'delete' | 'clear' | 'revoke'\n\n /**\n * Maximum ID of message to delete.\n *\n * @default 0, i.e. remove all messages\n */\n maxId?: number\n },\n): Promise<void> {\n const { mode = 'delete', maxId = 0 } = params ?? {}\n\n const peer = await resolvePeer(client, chat)\n\n const res = await client.call({\n _: 'messages.deleteHistory',\n justClear: mode === 'clear',\n revoke: mode === 'revoke',\n peer,\n maxId,\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":"delete-history.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/chats/delete-history.ts"],"names":[],"mappings":";;;AAEA,qDAA0D;AAC1D,6DAA8D;AAC9D,8DAAsD;AAEtD;;GAEG;AACI,KAAK,UAAU,aAAa,CAC/B,MAAuB,EACvB,IAAmB,EACnB,MAiBC;IAED,MAAM,EAAE,IAAI,GAAG,QAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAEnD,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAW,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAE5C,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC;QAC1B,CAAC,EAAE,wBAAwB;QAC3B,SAAS,EAAE,IAAI,KAAK,OAAO;QAC3B,MAAM,EAAE,IAAI,KAAK,QAAQ;QACzB,IAAI;QACJ,KAAK;KACR,CAAC,CAAA;IAEF,IAAI,IAAA,kCAAkB,EAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,kBAAkB,CAAC,IAAA,4BAAiB,EAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;IACvF,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,kBAAkB,CAAC,IAAA,4BAAiB,EAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACvE,CAAC;AACL,CAAC;AAvCD,sCAuCC","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 * Delete communication history (for private chats and legacy groups)\n */\nexport async function deleteHistory(\n client: ITelegramClient,\n chat: InputPeerLike,\n params?: {\n /**\n * Deletion mode. Can be:\n * - `delete`: delete messages (only for yourself) AND the dialog itself\n * - `clear`: delete messages (only for yourself), but keep the dialog in the list\n * - `revoke`: delete messages for all users\n *\n * @default 'delete'\n */\n mode: 'delete' | 'clear' | 'revoke'\n\n /**\n * Maximum ID of message to delete.\n *\n * @default 0, i.e. remove all messages\n */\n maxId?: number\n },\n): Promise<void> {\n const { mode = 'delete', maxId = 0 } = params ?? {}\n\n const peer = await resolvePeer(client, chat)\n\n const res = await client.call({\n _: 'messages.deleteHistory',\n justClear: mode === 'clear',\n revoke: mode === 'revoke',\n peer,\n maxId,\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"]}
@@ -21,7 +21,7 @@ async function kickChatMember(client, params) {
21
21
  // not needed in case this is a legacy group
22
22
  if ((0, peer_utils_js_1.isInputPeerChannel)(chat)) {
23
23
  // i fucking love telegram serverside race conditions
24
- await (0, misc_utils_js_1.sleep)(1000);
24
+ await (0, misc_utils_js_1.sleepWithAbort)(1000, client.stopSignal);
25
25
  await (0, unban_chat_member_js_1.unbanChatMember)(client, { chatId: chat, participantId: user });
26
26
  }
27
27
  return msg;
@@ -1 +1 @@
1
- {"version":3,"file":"kick-chat-member.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/chats/kick-chat-member.ts"],"names":[],"mappings":";;;AAAA,gEAAoD;AAGpD,6DAA8D;AAC9D,8DAAsD;AACtD,6DAAoD;AACpD,iEAAwD;AAExD;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAChC,MAAuB,EACvB,MAKC;IAED,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAEjC,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE9C,MAAM,GAAG,GAAG,MAAM,IAAA,kCAAa,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9E,4CAA4C;IAC5C,IAAI,IAAA,kCAAkB,EAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,qDAAqD;QACrD,MAAM,IAAA,qBAAK,EAAC,IAAI,CAAC,CAAA;QACjB,MAAM,IAAA,sCAAe,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACxE,CAAC;IAED,OAAO,GAAG,CAAA;AACd,CAAC;AAxBD,wCAwBC","sourcesContent":["import { sleep } from '../../../utils/misc-utils.js'\nimport { ITelegramClient } from '../../client.types.js'\nimport { InputPeerLike, Message } from '../../types/index.js'\nimport { isInputPeerChannel } from '../../utils/peer-utils.js'\nimport { resolvePeer } from '../users/resolve-peer.js'\nimport { banChatMember } from './ban-chat-member.js'\nimport { unbanChatMember } from './unban-chat-member.js'\n\n/**\n * Kick a user from a chat.\n *\n * This effectively bans a user and immediately unbans them.\n *\n * @returns Service message about removed user, if one was generated.\n */\nexport async function kickChatMember(\n client: ITelegramClient,\n params: {\n /** Chat ID */\n chatId: InputPeerLike\n /** User ID */\n userId: InputPeerLike\n },\n): Promise<Message | null> {\n const { chatId, userId } = params\n\n const chat = await resolvePeer(client, chatId)\n const user = await resolvePeer(client, userId)\n\n const msg = await banChatMember(client, { chatId: chat, participantId: user })\n\n // not needed in case this is a legacy group\n if (isInputPeerChannel(chat)) {\n // i fucking love telegram serverside race conditions\n await sleep(1000)\n await unbanChatMember(client, { chatId: chat, participantId: user })\n }\n\n return msg\n}\n"]}
1
+ {"version":3,"file":"kick-chat-member.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/chats/kick-chat-member.ts"],"names":[],"mappings":";;;AAAA,gEAA6D;AAG7D,6DAA8D;AAC9D,8DAAsD;AACtD,6DAAoD;AACpD,iEAAwD;AAExD;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAChC,MAAuB,EACvB,MAKC;IAED,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAEjC,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE9C,MAAM,GAAG,GAAG,MAAM,IAAA,kCAAa,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9E,4CAA4C;IAC5C,IAAI,IAAA,kCAAkB,EAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,qDAAqD;QACrD,MAAM,IAAA,8BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;QAC7C,MAAM,IAAA,sCAAe,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACxE,CAAC;IAED,OAAO,GAAG,CAAA;AACd,CAAC;AAxBD,wCAwBC","sourcesContent":["import { sleepWithAbort } from '../../../utils/misc-utils.js'\nimport { ITelegramClient } from '../../client.types.js'\nimport { InputPeerLike, Message } from '../../types/index.js'\nimport { isInputPeerChannel } from '../../utils/peer-utils.js'\nimport { resolvePeer } from '../users/resolve-peer.js'\nimport { banChatMember } from './ban-chat-member.js'\nimport { unbanChatMember } from './unban-chat-member.js'\n\n/**\n * Kick a user from a chat.\n *\n * This effectively bans a user and immediately unbans them.\n *\n * @returns Service message about removed user, if one was generated.\n */\nexport async function kickChatMember(\n client: ITelegramClient,\n params: {\n /** Chat ID */\n chatId: InputPeerLike\n /** User ID */\n userId: InputPeerLike\n },\n): Promise<Message | null> {\n const { chatId, userId } = params\n\n const chat = await resolvePeer(client, chatId)\n const user = await resolvePeer(client, userId)\n\n const msg = await banChatMember(client, { chatId: chat, participantId: user })\n\n // not needed in case this is a legacy group\n if (isInputPeerChannel(chat)) {\n // i fucking love telegram serverside race conditions\n await sleepWithAbort(1000, client.stopSignal)\n await unbanChatMember(client, { chatId: chat, participantId: user })\n }\n\n return msg\n}\n"]}
@@ -19,9 +19,11 @@ function _findMessageInUpdate(client, res, isEdit = false, noDispatch = true, al
19
19
  continue;
20
20
  }
21
21
  if (isEdit) {
22
- if (!(u._ === 'updateEditMessage' ||
22
+ if (!((u._ === 'updateEditMessage' ||
23
23
  u._ === 'updateEditChannelMessage' ||
24
- u._ === 'updateBotEditBusinessMessage')) {
24
+ u._ === 'updateBotEditBusinessMessage' ||
25
+ u._ === 'updateBotNewBusinessMessage') // for whatever reason
26
+ )) {
25
27
  continue;
26
28
  }
27
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"find-in-update.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/messages/find-in-update.ts"],"names":[],"mappings":";;;AAGA,wDAA+D;AAE/D,4DAAuD;AACvD,yDAAuD;AACvD,qDAA6D;AA2B7D;;;GAGG;AACH,SAAgB,oBAAoB,CAChC,MAAuB,EACvB,GAAmB,EACnB,MAAM,GAAG,KAAK,EACd,UAAU,GAAG,IAAI,EACjB,SAAS,GAAG,KAAK,EACjB,QAAkB;IAElB,IAAA,+BAAoB,EAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;IAEjD,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAE1C,IAAI,YAAY,GAAG,CAAC,CAAA;IAEpB,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnE,YAAY,GAAG,CAAC,CAAC,EAAE,CAAA;YACnB,SAAQ;QACZ,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACT,IACI,CAAC,CACG,CAAC,CAAC,CAAC,KAAK,mBAAmB;gBAC3B,CAAC,CAAC,CAAC,KAAK,0BAA0B;gBAClC,CAAC,CAAC,CAAC,KAAK,8BAA8B,CACzC,EACH,CAAC;gBACC,SAAQ;YACZ,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IACI,CAAC,CACG,CAAC,CAAC,CAAC,KAAK,kBAAkB;gBAC1B,CAAC,CAAC,CAAC,KAAK,yBAAyB;gBACjC,CAAC,CAAC,CAAC,KAAK,2BAA2B;gBACnC,CAAC,CAAC,CAAC,KAAK,yBAAyB;gBACjC,CAAC,CAAC,CAAC,KAAK,6BAA6B,CACxC,EACH,CAAC;gBACC,SAAQ;YACZ,CAAC;QACL,CAAC;QAED,qEAAqE;QACrE,uDAAuD;QACvD,iEAAiE;QACjE,IAAI,YAAY,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,YAAY;YAAE,SAAQ;QAEjE,MAAM,KAAK,GAAG,qBAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAElC,OAAO,IAAI,kBAAO,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,2BAA2B,CAAC,CAAA;IAC7E,CAAC;IAED,IAAI,SAAS;QAAE,OAAO,IAAI,CAAA;IAE1B,MAAM,IAAI,gCAAoB,CAC1B,+BAA+B,EAC/B,wEAAwE,EACxE,MAAM,CACT,CAAA;AACL,CAAC;AA7DD,oDA6DC","sourcesContent":["/* eslint-disable max-params,no-lonely-if */\nimport { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../types/errors.js'\nimport { ITelegramClient } from '../../client.types.js'\nimport { Message } from '../../types/messages/index.js'\nimport { PeersIndex } from '../../types/peers/index.js'\nimport { assertIsUpdatesGroup } from '../../updates/utils.js'\n\n/**\n * @internal\n * @noemit\n */\nexport function _findMessageInUpdate(\n client: ITelegramClient,\n res: tl.TypeUpdates,\n isEdit?: boolean,\n noDispatch?: boolean,\n allowNull?: false,\n randomId?: tl.Long,\n): Message\n/**\n * @internal\n * @noemit\n */\nexport function _findMessageInUpdate(\n client: ITelegramClient,\n res: tl.TypeUpdates,\n isEdit?: boolean,\n noDispatch?: boolean,\n allowNull?: true,\n randomId?: tl.Long,\n): Message | null\n\n/**\n * @internal\n * @noemit\n */\nexport function _findMessageInUpdate(\n client: ITelegramClient,\n res: tl.TypeUpdates,\n isEdit = false,\n noDispatch = true,\n allowNull = false,\n randomId?: tl.Long,\n): Message | null {\n assertIsUpdatesGroup('_findMessageInUpdate', res)\n\n client.handleClientUpdate(res, noDispatch)\n\n let ourMessageId = 0\n\n for (const u of res.updates) {\n if (randomId && u._ === 'updateMessageID' && u.randomId.eq(randomId)) {\n ourMessageId = u.id\n continue\n }\n\n if (isEdit) {\n if (\n !(\n u._ === 'updateEditMessage' ||\n u._ === 'updateEditChannelMessage' ||\n u._ === 'updateBotEditBusinessMessage'\n )\n ) {\n continue\n }\n } else {\n if (\n !(\n u._ === 'updateNewMessage' ||\n u._ === 'updateNewChannelMessage' ||\n u._ === 'updateNewScheduledMessage' ||\n u._ === 'updateQuickReplyMessage' ||\n u._ === 'updateBotNewBusinessMessage'\n )\n ) {\n continue\n }\n }\n\n // this *may* break if updateMessageID comes after the message update\n // but it's unlikely and is not worth the effort to fix\n // we should eventually move to properly handling updateMessageID\n if (ourMessageId !== 0 && u.message.id !== ourMessageId) continue\n\n const peers = PeersIndex.from(res)\n\n return new Message(u.message, peers, u._ === 'updateNewScheduledMessage')\n }\n\n if (allowNull) return null\n\n throw new MtTypeAssertionError(\n '_findInUpdate (@ .updates[*])',\n 'updateNewMessage | updateNewChannelMessage | updateNewScheduledMessage',\n 'none',\n )\n}\n"]}
1
+ {"version":3,"file":"find-in-update.js","sourceRoot":"","sources":["../../../../../src/highlevel/methods/messages/find-in-update.ts"],"names":[],"mappings":";;;AAGA,wDAA+D;AAE/D,4DAAuD;AACvD,yDAAuD;AACvD,qDAA6D;AA2B7D;;;GAGG;AACH,SAAgB,oBAAoB,CAChC,MAAuB,EACvB,GAAmB,EACnB,MAAM,GAAG,KAAK,EACd,UAAU,GAAG,IAAI,EACjB,SAAS,GAAG,KAAK,EACjB,QAAkB;IAElB,IAAA,+BAAoB,EAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;IAEjD,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAE1C,IAAI,YAAY,GAAG,CAAC,CAAA;IAEpB,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,QAAQ,IAAI,CAAC,CAAC,CAAC,KAAK,iBAAiB,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnE,YAAY,GAAG,CAAC,CAAC,EAAE,CAAA;YACnB,SAAQ;QACZ,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACT,IACI,CAAC,CACG,CACI,CAAC,CAAC,CAAC,KAAK,mBAAmB;gBAC3B,CAAC,CAAC,CAAC,KAAK,0BAA0B;gBAClC,CAAC,CAAC,CAAC,KAAK,8BAA8B;gBACtC,CAAC,CAAC,CAAC,KAAK,6BAA6B,CACxC,CAAC,sBAAsB;aAC3B,EACH,CAAC;gBACC,SAAQ;YACZ,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IACI,CAAC,CACG,CAAC,CAAC,CAAC,KAAK,kBAAkB;gBAC1B,CAAC,CAAC,CAAC,KAAK,yBAAyB;gBACjC,CAAC,CAAC,CAAC,KAAK,2BAA2B;gBACnC,CAAC,CAAC,CAAC,KAAK,yBAAyB;gBACjC,CAAC,CAAC,CAAC,KAAK,6BAA6B,CACxC,EACH,CAAC;gBACC,SAAQ;YACZ,CAAC;QACL,CAAC;QAED,qEAAqE;QACrE,uDAAuD;QACvD,iEAAiE;QACjE,IAAI,YAAY,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,YAAY;YAAE,SAAQ;QAEjE,MAAM,KAAK,GAAG,qBAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAElC,OAAO,IAAI,kBAAO,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,2BAA2B,CAAC,CAAA;IAC7E,CAAC;IAED,IAAI,SAAS;QAAE,OAAO,IAAI,CAAA;IAE1B,MAAM,IAAI,gCAAoB,CAC1B,+BAA+B,EAC/B,wEAAwE,EACxE,MAAM,CACT,CAAA;AACL,CAAC;AAhED,oDAgEC","sourcesContent":["/* eslint-disable max-params,no-lonely-if */\nimport { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../types/errors.js'\nimport { ITelegramClient } from '../../client.types.js'\nimport { Message } from '../../types/messages/index.js'\nimport { PeersIndex } from '../../types/peers/index.js'\nimport { assertIsUpdatesGroup } from '../../updates/utils.js'\n\n/**\n * @internal\n * @noemit\n */\nexport function _findMessageInUpdate(\n client: ITelegramClient,\n res: tl.TypeUpdates,\n isEdit?: boolean,\n noDispatch?: boolean,\n allowNull?: false,\n randomId?: tl.Long,\n): Message\n/**\n * @internal\n * @noemit\n */\nexport function _findMessageInUpdate(\n client: ITelegramClient,\n res: tl.TypeUpdates,\n isEdit?: boolean,\n noDispatch?: boolean,\n allowNull?: true,\n randomId?: tl.Long,\n): Message | null\n\n/**\n * @internal\n * @noemit\n */\nexport function _findMessageInUpdate(\n client: ITelegramClient,\n res: tl.TypeUpdates,\n isEdit = false,\n noDispatch = true,\n allowNull = false,\n randomId?: tl.Long,\n): Message | null {\n assertIsUpdatesGroup('_findMessageInUpdate', res)\n\n client.handleClientUpdate(res, noDispatch)\n\n let ourMessageId = 0\n\n for (const u of res.updates) {\n if (randomId && u._ === 'updateMessageID' && u.randomId.eq(randomId)) {\n ourMessageId = u.id\n continue\n }\n\n if (isEdit) {\n if (\n !(\n (\n u._ === 'updateEditMessage' ||\n u._ === 'updateEditChannelMessage' ||\n u._ === 'updateBotEditBusinessMessage' ||\n u._ === 'updateBotNewBusinessMessage'\n ) // for whatever reason\n )\n ) {\n continue\n }\n } else {\n if (\n !(\n u._ === 'updateNewMessage' ||\n u._ === 'updateNewChannelMessage' ||\n u._ === 'updateNewScheduledMessage' ||\n u._ === 'updateQuickReplyMessage' ||\n u._ === 'updateBotNewBusinessMessage'\n )\n ) {\n continue\n }\n }\n\n // this *may* break if updateMessageID comes after the message update\n // but it's unlikely and is not worth the effort to fix\n // we should eventually move to properly handling updateMessageID\n if (ourMessageId !== 0 && u.message.id !== ourMessageId) continue\n\n const peers = PeersIndex.from(res)\n\n return new Message(u.message, peers, u._ === 'updateNewScheduledMessage')\n }\n\n if (allowNull) return null\n\n throw new MtTypeAssertionError(\n '_findInUpdate (@ .updates[*])',\n 'updateNewMessage | updateNewChannelMessage | updateNewScheduledMessage',\n 'none',\n )\n}\n"]}
@@ -3,8 +3,9 @@ import { PeersIndex } from '../../peers/index.js';
3
3
  import { StoryInteractiveChannelPost } from './channel-post.js';
4
4
  import { StoryInteractiveLocation } from './location.js';
5
5
  import { StoryInteractiveReaction } from './reaction.js';
6
+ import { StoryInteractiveUrl } from './url.js';
6
7
  import { StoryInteractiveVenue } from './venue.js';
7
8
  export * from './input.js';
8
- export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveVenue };
9
- export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost;
9
+ export { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveUrl, StoryInteractiveVenue, };
10
+ export type StoryInteractiveElement = StoryInteractiveReaction | StoryInteractiveLocation | StoryInteractiveVenue | StoryInteractiveChannelPost | StoryInteractiveUrl;
10
11
  export declare function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement;
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports._storyInteractiveElementFromTl = exports.StoryInteractiveVenue = exports.StoryInteractiveReaction = exports.StoryInteractiveLocation = exports.StoryInteractiveChannelPost = void 0;
17
+ exports._storyInteractiveElementFromTl = exports.StoryInteractiveVenue = exports.StoryInteractiveUrl = exports.StoryInteractiveReaction = exports.StoryInteractiveLocation = exports.StoryInteractiveChannelPost = void 0;
18
18
  const errors_js_1 = require("../../../../types/errors.js");
19
19
  const channel_post_js_1 = require("./channel-post.js");
20
20
  Object.defineProperty(exports, "StoryInteractiveChannelPost", { enumerable: true, get: function () { return channel_post_js_1.StoryInteractiveChannelPost; } });
@@ -22,6 +22,8 @@ const location_js_1 = require("./location.js");
22
22
  Object.defineProperty(exports, "StoryInteractiveLocation", { enumerable: true, get: function () { return location_js_1.StoryInteractiveLocation; } });
23
23
  const reaction_js_1 = require("./reaction.js");
24
24
  Object.defineProperty(exports, "StoryInteractiveReaction", { enumerable: true, get: function () { return reaction_js_1.StoryInteractiveReaction; } });
25
+ const url_js_1 = require("./url.js");
26
+ Object.defineProperty(exports, "StoryInteractiveUrl", { enumerable: true, get: function () { return url_js_1.StoryInteractiveUrl; } });
25
27
  const venue_js_1 = require("./venue.js");
26
28
  Object.defineProperty(exports, "StoryInteractiveVenue", { enumerable: true, get: function () { return venue_js_1.StoryInteractiveVenue; } });
27
29
  __exportStar(require("./input.js"), exports);
@@ -35,6 +37,8 @@ function _storyInteractiveElementFromTl(raw, peers) {
35
37
  return new venue_js_1.StoryInteractiveVenue(raw);
36
38
  case 'mediaAreaChannelPost':
37
39
  return new channel_post_js_1.StoryInteractiveChannelPost(raw, peers);
40
+ case 'mediaAreaUrl':
41
+ return new url_js_1.StoryInteractiveUrl(raw);
38
42
  case 'inputMediaAreaVenue':
39
43
  case 'inputMediaAreaChannelPost':
40
44
  throw new errors_js_1.MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,2DAAkE;AAElE,uDAA+D;AAMtD,4GANA,6CAA2B,OAMA;AALpC,+CAAwD;AAKlB,yGAL7B,sCAAwB,OAK6B;AAJ9D,+CAAwD;AAIQ,yGAJvD,sCAAwB,OAIuD;AAHxF,yCAAkD;AAGwC,sGAHjF,gCAAqB,OAGiF;AAD/G,6CAA0B;AAS1B,SAAgB,8BAA8B,CAAC,GAAqB,EAAE,KAAiB;IACnF,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,4BAA4B;YAC7B,OAAO,IAAI,sCAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,mBAAmB;YACpB,OAAO,IAAI,sCAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,gBAAgB;YACjB,OAAO,IAAI,gCAAqB,CAAC,GAAG,CAAC,CAAA;QACzC,KAAK,sBAAsB;YACvB,OAAO,IAAI,6CAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACtD,KAAK,qBAAqB,CAAC;QAC3B,KAAK,2BAA2B;YAC5B,MAAM,IAAI,gCAAoB,CAAC,yBAAyB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACnF,CAAC;AACL,CAAC;AAdD,wEAcC","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 { StoryInteractiveVenue } from './venue.js'\n\nexport * from './input.js'\nexport { StoryInteractiveChannelPost, StoryInteractiveLocation, StoryInteractiveReaction, StoryInteractiveVenue }\n\nexport type StoryInteractiveElement =\n | StoryInteractiveReaction\n | StoryInteractiveLocation\n | StoryInteractiveVenue\n | StoryInteractiveChannelPost\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 '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,2DAAkE;AAElE,uDAA+D;AAQ3D,4GARK,6CAA2B,OAQL;AAP/B,+CAAwD;AAQpD,yGARK,sCAAwB,OAQL;AAP5B,+CAAwD;AAQpD,yGARK,sCAAwB,OAQL;AAP5B,qCAA8C;AAQ1C,oGARK,4BAAmB,OAQL;AAPvB,yCAAkD;AAQ9C,sGARK,gCAAqB,OAQL;AANzB,6CAA0B;AAgB1B,SAAgB,8BAA8B,CAAC,GAAqB,EAAE,KAAiB;IACnF,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,4BAA4B;YAC7B,OAAO,IAAI,sCAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,mBAAmB;YACpB,OAAO,IAAI,sCAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,gBAAgB;YACjB,OAAO,IAAI,gCAAqB,CAAC,GAAG,CAAC,CAAA;QACzC,KAAK,sBAAsB;YACvB,OAAO,IAAI,6CAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACtD,KAAK,cAAc;YACf,OAAO,IAAI,4BAAmB,CAAC,GAAG,CAAC,CAAA;QACvC,KAAK,qBAAqB,CAAC;QAC3B,KAAK,2BAA2B;YAC5B,MAAM,IAAI,gCAAoB,CAAC,yBAAyB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACnF,CAAC;AACL,CAAC;AAhBD,wEAgBC","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"]}
@@ -64,4 +64,5 @@ export declare class StoryElement {
64
64
  */
65
65
  flipped?: boolean;
66
66
  }): tl.RawMediaAreaSuggestedReaction;
67
+ url(url: string): tl.RawMediaAreaUrl;
67
68
  }
@@ -80,6 +80,13 @@ class StoryElement {
80
80
  flipped: params.flipped,
81
81
  };
82
82
  }
83
+ url(url) {
84
+ return {
85
+ _: 'mediaAreaUrl',
86
+ coordinates: this._position,
87
+ url,
88
+ };
89
+ }
83
90
  }
84
91
  exports.StoryElement = StoryElement;
85
92
  //# sourceMappingURL=input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/input.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAKvB,uDAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAa,YAAY;IACO;IAA5B,YAA4B,SAAqC;QAArC,cAAS,GAAT,SAAS,CAA4B;IAAG,CAAC;IAErE,MAAM,CAAC,EAAE,CAAC,MAAkF;QACxF,OAAO,IAAI,YAAY,CAAC;YACpB,CAAC,EAAE,sBAAsB;YACzB,CAAC,EAAE,MAAM,CAAC,CAAC;YACX,CAAC,EAAE,MAAM,CAAC,CAAC;YACX,CAAC,EAAE,MAAM,CAAC,KAAK;YACf,CAAC,EAAE,MAAM,CAAC,MAAM;YAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC;SACjC,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,MAyBL;QACG,OAAO;YACH,CAAC,EAAE,gBAAgB;YACnB,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,GAAG,EAAE;gBACD,CAAC,EAAE,UAAU;gBACb,GAAG,EAAE,MAAM,CAAC,QAAQ;gBACpB,IAAI,EAAE,MAAM,CAAC,SAAS;gBACtB,UAAU,EAAE,cAAI,CAAC,IAAI;aACxB;YACD,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,YAAY;YAChD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;YACzB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;SAChC,CAAA;IACL,CAAC;IAED,eAAe,CAAC,OAAgB,EAAE,QAAgB;QAC9C,OAAO;YACH,CAAC,EAAE,qBAAqB;YACxB,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,OAAO;YACP,QAAQ;SACX,CAAA;IACL,CAAC;IAED,QAAQ,CAAC,MAUR;QACG,OAAO;YACH,CAAC,EAAE,mBAAmB;YACtB,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,GAAG,EAAE;gBACD,CAAC,EAAE,UAAU;gBACb,GAAG,EAAE,MAAM,CAAC,QAAQ;gBACpB,IAAI,EAAE,MAAM,CAAC,SAAS;gBACtB,UAAU,EAAE,cAAI,CAAC,IAAI;aACxB;SACJ,CAAA;IACL,CAAC;IAED,QAAQ,CACJ,QAAuB,EACvB,SAUI,EAAE;QAEN,+EAA+E;QAC/E,qDAAqD;QACrD,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;QAE1B,OAAO;YACH,CAAC,EAAE,4BAA4B;YAC/B,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,QAAQ,EAAE,IAAA,iCAAsB,EAAC,QAAQ,CAAC;YAC1C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;SAC1B,CAAA;IACL,CAAC;CACJ;AAnHD,oCAmHC","sourcesContent":["import Long from 'long'\n\nimport { tl } from '@mtcute/tl'\n\nimport { VenueSource } from '../../media/index.js'\nimport { InputReaction, normalizeInputReaction } from '../../reactions/index.js'\n\n/**\n * Constructor for interactive story elements.\n *\n * @example\n * ```typescript\n * const element = StoryElement\n * .at({ x: 0, y: 0, width: 10, height: 10 })\n * .reaction('👍', { dark: true })\n * ```\n */\nexport class StoryElement {\n private constructor(private _position: tl.RawMediaAreaCoordinates) {}\n\n static at(params: { x: number; y: number; width: number; height: number; rotation?: number }) {\n return new StoryElement({\n _: 'mediaAreaCoordinates',\n x: params.x,\n y: params.y,\n w: params.width,\n h: params.height,\n rotation: params.rotation ?? 0,\n })\n }\n\n venue(params: {\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n\n /**\n * Venue name\n */\n title: string\n\n /**\n * Venue address\n */\n address: string\n\n /**\n * Source where this venue was acquired\n */\n source: VenueSource\n }): tl.RawMediaAreaVenue {\n return {\n _: 'mediaAreaVenue',\n coordinates: this._position,\n geo: {\n _: 'geoPoint',\n lat: params.latitude,\n long: params.longitude,\n accessHash: Long.ZERO,\n },\n title: params.title,\n address: params.address,\n provider: params.source.provider ?? 'foursquare',\n venueId: params.source.id,\n venueType: params.source.type,\n }\n }\n\n venueFromInline(queryId: tl.Long, resultId: string): tl.RawInputMediaAreaVenue {\n return {\n _: 'inputMediaAreaVenue',\n coordinates: this._position,\n queryId,\n resultId,\n }\n }\n\n location(params: {\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n }): tl.RawMediaAreaGeoPoint {\n return {\n _: 'mediaAreaGeoPoint',\n coordinates: this._position,\n geo: {\n _: 'geoPoint',\n lat: params.latitude,\n long: params.longitude,\n accessHash: Long.ZERO,\n },\n }\n }\n\n reaction(\n reaction: InputReaction,\n params: {\n /**\n * Whether this reaction is on a dark background\n */\n dark?: boolean\n\n /**\n * Whether this reaction is flipped (i.e. has tail on the left)\n */\n flipped?: boolean\n } = {},\n ): tl.RawMediaAreaSuggestedReaction {\n // for whatever reason, in MTProto dimensions of these are expected to be 16:9/\n // we adjust them here to make it easier to work with\n this._position.h *= 9 / 16\n\n return {\n _: 'mediaAreaSuggestedReaction',\n coordinates: this._position,\n reaction: normalizeInputReaction(reaction),\n dark: params.dark,\n flipped: params.flipped,\n }\n }\n}\n"]}
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/input.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAKvB,uDAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAa,YAAY;IACO;IAA5B,YAA4B,SAAqC;QAArC,cAAS,GAAT,SAAS,CAA4B;IAAG,CAAC;IAErE,MAAM,CAAC,EAAE,CAAC,MAAkF;QACxF,OAAO,IAAI,YAAY,CAAC;YACpB,CAAC,EAAE,sBAAsB;YACzB,CAAC,EAAE,MAAM,CAAC,CAAC;YACX,CAAC,EAAE,MAAM,CAAC,CAAC;YACX,CAAC,EAAE,MAAM,CAAC,KAAK;YACf,CAAC,EAAE,MAAM,CAAC,MAAM;YAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC;SACjC,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,MAyBL;QACG,OAAO;YACH,CAAC,EAAE,gBAAgB;YACnB,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,GAAG,EAAE;gBACD,CAAC,EAAE,UAAU;gBACb,GAAG,EAAE,MAAM,CAAC,QAAQ;gBACpB,IAAI,EAAE,MAAM,CAAC,SAAS;gBACtB,UAAU,EAAE,cAAI,CAAC,IAAI;aACxB;YACD,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,YAAY;YAChD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE;YACzB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;SAChC,CAAA;IACL,CAAC;IAED,eAAe,CAAC,OAAgB,EAAE,QAAgB;QAC9C,OAAO;YACH,CAAC,EAAE,qBAAqB;YACxB,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,OAAO;YACP,QAAQ;SACX,CAAA;IACL,CAAC;IAED,QAAQ,CAAC,MAUR;QACG,OAAO;YACH,CAAC,EAAE,mBAAmB;YACtB,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,GAAG,EAAE;gBACD,CAAC,EAAE,UAAU;gBACb,GAAG,EAAE,MAAM,CAAC,QAAQ;gBACpB,IAAI,EAAE,MAAM,CAAC,SAAS;gBACtB,UAAU,EAAE,cAAI,CAAC,IAAI;aACxB;SACJ,CAAA;IACL,CAAC;IAED,QAAQ,CACJ,QAAuB,EACvB,SAUI,EAAE;QAEN,+EAA+E;QAC/E,qDAAqD;QACrD,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;QAE1B,OAAO;YACH,CAAC,EAAE,4BAA4B;YAC/B,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,QAAQ,EAAE,IAAA,iCAAsB,EAAC,QAAQ,CAAC;YAC1C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;SAC1B,CAAA;IACL,CAAC;IAED,GAAG,CAAC,GAAW;QACX,OAAO;YACH,CAAC,EAAE,cAAc;YACjB,WAAW,EAAE,IAAI,CAAC,SAAS;YAC3B,GAAG;SACN,CAAA;IACL,CAAC;CACJ;AA3HD,oCA2HC","sourcesContent":["import Long from 'long'\n\nimport { tl } from '@mtcute/tl'\n\nimport { VenueSource } from '../../media/index.js'\nimport { InputReaction, normalizeInputReaction } from '../../reactions/index.js'\n\n/**\n * Constructor for interactive story elements.\n *\n * @example\n * ```typescript\n * const element = StoryElement\n * .at({ x: 0, y: 0, width: 10, height: 10 })\n * .reaction('👍', { dark: true })\n * ```\n */\nexport class StoryElement {\n private constructor(private _position: tl.RawMediaAreaCoordinates) {}\n\n static at(params: { x: number; y: number; width: number; height: number; rotation?: number }) {\n return new StoryElement({\n _: 'mediaAreaCoordinates',\n x: params.x,\n y: params.y,\n w: params.width,\n h: params.height,\n rotation: params.rotation ?? 0,\n })\n }\n\n venue(params: {\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n\n /**\n * Venue name\n */\n title: string\n\n /**\n * Venue address\n */\n address: string\n\n /**\n * Source where this venue was acquired\n */\n source: VenueSource\n }): tl.RawMediaAreaVenue {\n return {\n _: 'mediaAreaVenue',\n coordinates: this._position,\n geo: {\n _: 'geoPoint',\n lat: params.latitude,\n long: params.longitude,\n accessHash: Long.ZERO,\n },\n title: params.title,\n address: params.address,\n provider: params.source.provider ?? 'foursquare',\n venueId: params.source.id,\n venueType: params.source.type,\n }\n }\n\n venueFromInline(queryId: tl.Long, resultId: string): tl.RawInputMediaAreaVenue {\n return {\n _: 'inputMediaAreaVenue',\n coordinates: this._position,\n queryId,\n resultId,\n }\n }\n\n location(params: {\n /**\n * Latitude of the geolocation\n */\n latitude: number\n\n /**\n * Longitude of the geolocation\n */\n longitude: number\n }): tl.RawMediaAreaGeoPoint {\n return {\n _: 'mediaAreaGeoPoint',\n coordinates: this._position,\n geo: {\n _: 'geoPoint',\n lat: params.latitude,\n long: params.longitude,\n accessHash: Long.ZERO,\n },\n }\n }\n\n reaction(\n reaction: InputReaction,\n params: {\n /**\n * Whether this reaction is on a dark background\n */\n dark?: boolean\n\n /**\n * Whether this reaction is flipped (i.e. has tail on the left)\n */\n flipped?: boolean\n } = {},\n ): tl.RawMediaAreaSuggestedReaction {\n // for whatever reason, in MTProto dimensions of these are expected to be 16:9/\n // we adjust them here to make it easier to work with\n this._position.h *= 9 / 16\n\n return {\n _: 'mediaAreaSuggestedReaction',\n coordinates: this._position,\n reaction: normalizeInputReaction(reaction),\n dark: params.dark,\n flipped: params.flipped,\n }\n }\n\n url(url: string): tl.RawMediaAreaUrl {\n return {\n _: 'mediaAreaUrl',\n coordinates: this._position,\n url,\n }\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { StoryInteractiveArea } from './base.js';
3
+ /**
4
+ * Interactive element containing a URL link
5
+ */
6
+ export declare class StoryInteractiveUrl extends StoryInteractiveArea {
7
+ readonly raw: tl.RawMediaAreaUrl;
8
+ readonly type: "url";
9
+ constructor(raw: tl.RawMediaAreaUrl);
10
+ get url(): string;
11
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StoryInteractiveUrl = void 0;
4
+ const base_js_1 = require("./base.js");
5
+ /**
6
+ * Interactive element containing a URL link
7
+ */
8
+ class StoryInteractiveUrl extends base_js_1.StoryInteractiveArea {
9
+ raw;
10
+ type = 'url';
11
+ constructor(raw) {
12
+ super(raw);
13
+ this.raw = raw;
14
+ }
15
+ get url() {
16
+ return this.raw.url;
17
+ }
18
+ }
19
+ exports.StoryInteractiveUrl = StoryInteractiveUrl;
20
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/url.ts"],"names":[],"mappings":";;;AAEA,uCAAgD;AAEhD;;GAEG;AACH,MAAa,mBAAoB,SAAQ,8BAAoB;IAGpC;IAFZ,IAAI,GAAG,KAAc,CAAA;IAE9B,YAAqB,GAAuB;QACxC,KAAK,CAAC,GAAG,CAAC,CAAA;QADO,QAAG,GAAH,GAAG,CAAoB;IAE5C,CAAC;IAED,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;IACvB,CAAC;CACJ;AAVD,kDAUC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { StoryInteractiveArea } from './base.js'\n\n/**\n * Interactive element containing a URL link\n */\nexport class StoryInteractiveUrl extends StoryInteractiveArea {\n readonly type = 'url' as const\n\n constructor(readonly raw: tl.RawMediaAreaUrl) {\n super(raw)\n }\n\n get url(): string {\n return this.raw.url\n }\n}\n"]}
@@ -1,12 +1,13 @@
1
1
  import { tl } from '@mtcute/tl';
2
+ import { Message } from '../messages/message.js';
2
3
  import { Chat } from '../peers/chat.js';
3
4
  import { PeersIndex } from '../peers/peers-index.js';
4
5
  import { User } from '../peers/user.js';
5
6
  /** Base class for callback queries */
6
7
  declare class BaseCallbackQuery {
7
- readonly raw: tl.RawUpdateBotCallbackQuery | tl.RawUpdateInlineBotCallbackQuery;
8
+ readonly raw: tl.RawUpdateBotCallbackQuery | tl.RawUpdateInlineBotCallbackQuery | tl.RawUpdateBusinessBotCallbackQuery;
8
9
  readonly _peers: PeersIndex;
9
- constructor(raw: tl.RawUpdateBotCallbackQuery | tl.RawUpdateInlineBotCallbackQuery, _peers: PeersIndex);
10
+ constructor(raw: tl.RawUpdateBotCallbackQuery | tl.RawUpdateInlineBotCallbackQuery | tl.RawUpdateBusinessBotCallbackQuery, _peers: PeersIndex);
10
11
  /**
11
12
  * ID of this callback query
12
13
  */
@@ -78,4 +79,17 @@ export declare class InlineCallbackQuery extends BaseCallbackQuery {
78
79
  */
79
80
  get inlineMessageIdStr(): string;
80
81
  }
82
+ /**
83
+ * A callback query originating from a message sent by the bot via a business connection
84
+ */
85
+ export declare class BusinessCallbackQuery extends BaseCallbackQuery {
86
+ readonly raw: tl.RawUpdateBusinessBotCallbackQuery;
87
+ constructor(raw: tl.RawUpdateBusinessBotCallbackQuery, _peers: PeersIndex);
88
+ /** ID of the business connection */
89
+ get connectionId(): string;
90
+ /** Message containing the button */
91
+ get message(): Message;
92
+ /** Message that {@link message} is a reply to (if any) */
93
+ get replyToMessage(): Message | null;
94
+ }
81
95
  export {};
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InlineCallbackQuery = exports.CallbackQuery = void 0;
3
+ exports.BusinessCallbackQuery = exports.InlineCallbackQuery = exports.CallbackQuery = void 0;
4
4
  const platform_js_1 = require("../../../platform.js");
5
5
  const errors_js_1 = require("../../../types/errors.js");
6
6
  const index_js_1 = require("../../utils/index.js");
7
7
  const inline_utils_js_1 = require("../../utils/inline-utils.js");
8
8
  const memoize_js_1 = require("../../utils/memoize.js");
9
+ const message_js_1 = require("../messages/message.js");
9
10
  const chat_js_1 = require("../peers/chat.js");
10
11
  const user_js_1 = require("../peers/user.js");
11
12
  /** Base class for callback queries */
@@ -62,6 +63,8 @@ class BaseCallbackQuery {
62
63
  * short name of the game that should be returned.
63
64
  */
64
65
  get game() {
66
+ if (this.raw._ === 'updateBusinessBotCallbackQuery')
67
+ return null;
65
68
  return this.raw.gameShortName ?? null;
66
69
  }
67
70
  }
@@ -124,4 +127,31 @@ class InlineCallbackQuery extends BaseCallbackQuery {
124
127
  exports.InlineCallbackQuery = InlineCallbackQuery;
125
128
  (0, memoize_js_1.memoizeGetters)(InlineCallbackQuery, ['user', 'dataStr', 'inlineMessageIdStr']);
126
129
  (0, index_js_1.makeInspectable)(InlineCallbackQuery);
130
+ /**
131
+ * A callback query originating from a message sent by the bot via a business connection
132
+ */
133
+ class BusinessCallbackQuery extends BaseCallbackQuery {
134
+ raw;
135
+ constructor(raw, _peers) {
136
+ super(raw, _peers);
137
+ this.raw = raw;
138
+ }
139
+ /** ID of the business connection */
140
+ get connectionId() {
141
+ return this.raw.connectionId;
142
+ }
143
+ /** Message containing the button */
144
+ get message() {
145
+ return new message_js_1.Message(this.raw.message, this._peers);
146
+ }
147
+ /** Message that {@link message} is a reply to (if any) */
148
+ get replyToMessage() {
149
+ if (!this.raw.replyToMessage)
150
+ return null;
151
+ return new message_js_1.Message(this.raw.replyToMessage, this._peers);
152
+ }
153
+ }
154
+ exports.BusinessCallbackQuery = BusinessCallbackQuery;
155
+ (0, memoize_js_1.memoizeGetters)(BusinessCallbackQuery, ['user', 'dataStr', 'message', 'replyToMessage']);
156
+ (0, index_js_1.makeInspectable)(BusinessCallbackQuery);
127
157
  //# sourceMappingURL=callback-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"callback-query.js","sourceRoot":"","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AI9C,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACJ,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,wBAAwB,EAAE,CAAC;YAC1C,MAAM,IAAI,2BAAe,CAAC,2CAA2C,CAAC,CAAA;QAC1E,CAAC;QAED,OAAO,IAAI,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;IACnD,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;IACzB,CAAC;CACJ;AAzBD,sCAyBC;AAED,IAAA,2BAAc,EAAC,aAAa,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;AAC1D,IAAA,0BAAe,EAAC,aAAa,CAAC,CAAA;AAE9B;;GAEG;AACH,MAAa,mBAAoB,SAAQ,iBAAiB;IAEzC;IADb,YACa,GAAuC,EAChD,MAAkB;QAElB,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAHT,QAAG,GAAH,GAAG,CAAoC;IAIpD,CAAC;IAED;;;;OAIG;IACH,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;IACzB,CAAC;IAED;;;;;;OAMG;IACH,IAAI,kBAAkB;QAClB,OAAO,IAAA,uCAAqB,EAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAChD,CAAC;CACJ;AA3BD,kDA2BC;AAED,IAAA,2BAAc,EAAC,mBAAmB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAA;AAC9E,IAAA,0BAAe,EAAC,mBAAmB,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { getPlatform } from '../../../platform.js'\nimport { MtArgumentError } from '../../../types/errors.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { encodeInlineMessageId } from '../../utils/inline-utils.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { Chat } from '../peers/chat.js'\nimport { PeersIndex } from '../peers/peers-index.js'\nimport { User } from '../peers/user.js'\n\n/** Base class for callback queries */\nclass BaseCallbackQuery {\n constructor(\n readonly raw: tl.RawUpdateBotCallbackQuery | tl.RawUpdateInlineBotCallbackQuery,\n readonly _peers: PeersIndex,\n ) {}\n\n /**\n * ID of this callback query\n */\n get id(): tl.Long {\n return this.raw.queryId\n }\n\n /**\n * User who has pressed the button\n */\n get user(): User {\n return new User(this._peers.user(this.raw.userId))\n }\n\n /**\n * Unique ID, that represents the chat to which the inline\n * message was sent. Does *not* contain actual chat ID.\n */\n get uniqueChatId(): tl.Long {\n return this.raw.chatInstance\n }\n\n /**\n * Data that was contained in the callback button, if any\n *\n * Note that this field is defined by the client, and a bad\n * client can send arbitrary data in this field.\n */\n get data(): Uint8Array | null {\n return this.raw.data ?? null\n }\n\n /**\n * Data that was contained in the callback button, if any,\n * parsed as a UTF8 string\n *\n * Note that this field is defined by the client, and a bad\n * client can send arbitrary data in this field.\n */\n get dataStr(): string | null {\n if (!this.raw.data) return null\n\n return getPlatform().utf8Decode(this.raw.data)\n }\n\n /**\n * In case this message was from {@link InputInlineResultGame},\n * or the button was {@link BotKeyboard.game},\n * short name of the game that should be returned.\n */\n get game(): string | null {\n return this.raw.gameShortName ?? null\n }\n}\n\n/**\n * A callback query originating from a normal message sent by the bot.\n */\nexport class CallbackQuery extends BaseCallbackQuery {\n constructor(\n readonly raw: tl.RawUpdateBotCallbackQuery,\n _peers: PeersIndex,\n ) {\n super(raw, _peers)\n }\n\n /**\n * Chat where the originating message was sent\n */\n get chat(): Chat {\n if (this.raw._ !== 'updateBotCallbackQuery') {\n throw new MtArgumentError('Cannot get message id for inline callback')\n }\n\n return new Chat(this._peers.get(this.raw.peer))\n }\n\n /**\n * Identifier of the message containing the button which was clicked.\n */\n get messageId(): number {\n return this.raw.msgId\n }\n}\n\nmemoizeGetters(CallbackQuery, ['user', 'dataStr', 'chat'])\nmakeInspectable(CallbackQuery)\n\n/**\n * A callback query originating from an inline message sent by the bot.\n */\nexport class InlineCallbackQuery extends BaseCallbackQuery {\n constructor(\n readonly raw: tl.RawUpdateInlineBotCallbackQuery,\n _peers: PeersIndex,\n ) {\n super(raw, _peers)\n }\n\n /**\n * Identifier of the previously sent inline message,\n * that contained the button which was clicked.\n * This ID can be used in `TelegramClient.editInlineMessage`\n */\n get inlineMessageId(): tl.TypeInputBotInlineMessageID {\n return this.raw.msgId\n }\n\n /**\n * Identifier of the previously sent inline message,\n * that contained the button which was clicked,\n * as a TDLib and Bot API compatible string.\n * Can be used instead of {@link inlineMessageId} in\n * case you want to store it in some storage.\n */\n get inlineMessageIdStr(): string {\n return encodeInlineMessageId(this.raw.msgId)\n }\n}\n\nmemoizeGetters(InlineCallbackQuery, ['user', 'dataStr', 'inlineMessageIdStr'])\nmakeInspectable(InlineCallbackQuery)\n"]}
1
+ {"version":3,"file":"callback-query.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/updates/callback-query.ts"],"names":[],"mappings":";;;AAEA,sDAAkD;AAClD,wDAA0D;AAC1D,mDAAsD;AACtD,iEAAmE;AACnE,uDAAuD;AACvD,uDAAgD;AAChD,8CAAuC;AAEvC,8CAAuC;AAEvC,sCAAsC;AACtC,MAAM,iBAAiB;IAEN;IAIA;IALb,YACa,GAGiC,EACjC,MAAkB;QAJlB,QAAG,GAAH,GAAG,CAG8B;QACjC,WAAM,GAAN,MAAM,CAAY;IAC5B,CAAC;IAEJ;;OAEG;IACH,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACJ,OAAO,IAAI,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACtD,CAAC;IAED;;;OAGG;IACH,IAAI,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;AAxBD,sDAwBC;AAED,IAAA,2BAAc,EAAC,qBAAqB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAA;AACvF,IAAA,0BAAe,EAAC,qBAAqB,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { getPlatform } from '../../../platform.js'\nimport { MtArgumentError } from '../../../types/errors.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { encodeInlineMessageId } from '../../utils/inline-utils.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { Message } from '../messages/message.js'\nimport { Chat } from '../peers/chat.js'\nimport { PeersIndex } from '../peers/peers-index.js'\nimport { User } from '../peers/user.js'\n\n/** Base class for callback queries */\nclass BaseCallbackQuery {\n constructor(\n readonly raw:\n | tl.RawUpdateBotCallbackQuery\n | tl.RawUpdateInlineBotCallbackQuery\n | tl.RawUpdateBusinessBotCallbackQuery,\n readonly _peers: PeersIndex,\n ) {}\n\n /**\n * ID of this callback query\n */\n get id(): tl.Long {\n return this.raw.queryId\n }\n\n /**\n * User who has pressed the button\n */\n get user(): User {\n return new User(this._peers.user(this.raw.userId))\n }\n\n /**\n * Unique ID, that represents the chat to which the inline\n * message was sent. Does *not* contain actual chat ID.\n */\n get uniqueChatId(): tl.Long {\n return this.raw.chatInstance\n }\n\n /**\n * Data that was contained in the callback button, if any\n *\n * Note that this field is defined by the client, and a bad\n * client can send arbitrary data in this field.\n */\n get data(): Uint8Array | null {\n return this.raw.data ?? null\n }\n\n /**\n * Data that was contained in the callback button, if any,\n * parsed as a UTF8 string\n *\n * Note that this field is defined by the client, and a bad\n * client can send arbitrary data in this field.\n */\n get dataStr(): string | null {\n if (!this.raw.data) return null\n\n return getPlatform().utf8Decode(this.raw.data)\n }\n\n /**\n * In case this message was from {@link InputInlineResultGame},\n * or the button was {@link BotKeyboard.game},\n * short name of the game that should be returned.\n */\n get game(): string | null {\n if (this.raw._ === 'updateBusinessBotCallbackQuery') return null\n\n return this.raw.gameShortName ?? null\n }\n}\n\n/**\n * A callback query originating from a normal message sent by the bot.\n */\nexport class CallbackQuery extends BaseCallbackQuery {\n constructor(\n readonly raw: tl.RawUpdateBotCallbackQuery,\n _peers: PeersIndex,\n ) {\n super(raw, _peers)\n }\n\n /**\n * Chat where the originating message was sent\n */\n get chat(): Chat {\n if (this.raw._ !== 'updateBotCallbackQuery') {\n throw new MtArgumentError('Cannot get message id for inline callback')\n }\n\n return new Chat(this._peers.get(this.raw.peer))\n }\n\n /**\n * Identifier of the message containing the button which was clicked.\n */\n get messageId(): number {\n return this.raw.msgId\n }\n}\n\nmemoizeGetters(CallbackQuery, ['user', 'dataStr', 'chat'])\nmakeInspectable(CallbackQuery)\n\n/**\n * A callback query originating from an inline message sent by the bot.\n */\nexport class InlineCallbackQuery extends BaseCallbackQuery {\n constructor(\n readonly raw: tl.RawUpdateInlineBotCallbackQuery,\n _peers: PeersIndex,\n ) {\n super(raw, _peers)\n }\n\n /**\n * Identifier of the previously sent inline message,\n * that contained the button which was clicked.\n * This ID can be used in `TelegramClient.editInlineMessage`\n */\n get inlineMessageId(): tl.TypeInputBotInlineMessageID {\n return this.raw.msgId\n }\n\n /**\n * Identifier of the previously sent inline message,\n * that contained the button which was clicked,\n * as a TDLib and Bot API compatible string.\n * Can be used instead of {@link inlineMessageId} in\n * case you want to store it in some storage.\n */\n get inlineMessageIdStr(): string {\n return encodeInlineMessageId(this.raw.msgId)\n }\n}\n\nmemoizeGetters(InlineCallbackQuery, ['user', 'dataStr', 'inlineMessageIdStr'])\nmakeInspectable(InlineCallbackQuery)\n\n/**\n * A callback query originating from a message sent by the bot via a business connection\n */\nexport class BusinessCallbackQuery extends BaseCallbackQuery {\n constructor(\n readonly raw: tl.RawUpdateBusinessBotCallbackQuery,\n _peers: PeersIndex,\n ) {\n super(raw, _peers)\n }\n\n /** ID of the business connection */\n get connectionId(): string {\n return this.raw.connectionId\n }\n\n /** Message containing the button */\n get message(): Message {\n return new Message(this.raw.message, this._peers)\n }\n\n /** Message that {@link message} is a reply to (if any) */\n get replyToMessage(): Message | null {\n if (!this.raw.replyToMessage) return null\n\n return new Message(this.raw.replyToMessage, this._peers)\n }\n}\n\nmemoizeGetters(BusinessCallbackQuery, ['user', 'dataStr', 'message', 'replyToMessage'])\nmakeInspectable(BusinessCallbackQuery)\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { BusinessConnection, Message } from '../../types/index.js';
2
2
  import { BotChatJoinRequestUpdate } from './bot-chat-join-request.js';
3
3
  import { BotStoppedUpdate } from './bot-stopped.js';
4
- import { CallbackQuery, InlineCallbackQuery } from './callback-query.js';
4
+ import { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery } from './callback-query.js';
5
5
  import { ChatJoinRequestUpdate } from './chat-join-request.js';
6
6
  import { ChatMemberUpdate } from './chat-member-update.js';
7
7
  import { InlineQuery } from './inline-query.js';
@@ -19,7 +19,7 @@ import { PreCheckoutQuery } from './pre-checkout-query.js';
19
19
  import { StoryUpdate } from './story-update.js';
20
20
  import { UserStatusUpdate } from './user-status-update.js';
21
21
  import { UserTypingUpdate } from './user-typing-update.js';
22
- export { BotChatJoinRequestUpdate, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessMessage, CallbackQuery, ChatJoinRequestUpdate, ChatMemberUpdate, ChosenInlineResult, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, PollUpdate, PollVoteUpdate, PreCheckoutQuery, StoryUpdate, UserStatusUpdate, UserTypingUpdate, };
22
+ export { BotChatJoinRequestUpdate, BotReactionCountUpdate, BotReactionUpdate, BotStoppedUpdate, BusinessCallbackQuery, BusinessMessage, CallbackQuery, ChatJoinRequestUpdate, ChatMemberUpdate, ChosenInlineResult, DeleteBusinessMessageUpdate, DeleteMessageUpdate, DeleteStoryUpdate, HistoryReadUpdate, InlineCallbackQuery, InlineQuery, PollUpdate, PollVoteUpdate, PreCheckoutQuery, StoryUpdate, UserStatusUpdate, UserTypingUpdate, };
23
23
  export type ParsedUpdate = {
24
24
  name: 'new_message';
25
25
  data: Message;
@@ -47,6 +47,9 @@ export type ParsedUpdate = {
47
47
  } | {
48
48
  name: 'inline_callback_query';
49
49
  data: InlineCallbackQuery;
50
+ } | {
51
+ name: 'business_callback_query';
52
+ data: BusinessCallbackQuery;
50
53
  } | {
51
54
  name: 'poll';
52
55
  data: PollUpdate;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserTypingUpdate = exports.UserStatusUpdate = exports.StoryUpdate = exports.PreCheckoutQuery = exports.PollVoteUpdate = exports.PollUpdate = exports.InlineQuery = exports.InlineCallbackQuery = exports.HistoryReadUpdate = exports.DeleteStoryUpdate = exports.DeleteMessageUpdate = exports.DeleteBusinessMessageUpdate = exports.ChosenInlineResult = exports.ChatMemberUpdate = exports.ChatJoinRequestUpdate = exports.CallbackQuery = exports.BusinessMessage = exports.BotStoppedUpdate = exports.BotReactionUpdate = exports.BotReactionCountUpdate = exports.BotChatJoinRequestUpdate = void 0;
3
+ exports.UserTypingUpdate = exports.UserStatusUpdate = exports.StoryUpdate = exports.PreCheckoutQuery = exports.PollVoteUpdate = exports.PollUpdate = exports.InlineQuery = exports.InlineCallbackQuery = exports.HistoryReadUpdate = exports.DeleteStoryUpdate = exports.DeleteMessageUpdate = exports.DeleteBusinessMessageUpdate = exports.ChosenInlineResult = exports.ChatMemberUpdate = exports.ChatJoinRequestUpdate = exports.CallbackQuery = exports.BusinessMessage = exports.BusinessCallbackQuery = exports.BotStoppedUpdate = exports.BotReactionUpdate = exports.BotReactionCountUpdate = exports.BotChatJoinRequestUpdate = void 0;
4
4
  const bot_chat_join_request_js_1 = require("./bot-chat-join-request.js");
5
5
  Object.defineProperty(exports, "BotChatJoinRequestUpdate", { enumerable: true, get: function () { return bot_chat_join_request_js_1.BotChatJoinRequestUpdate; } });
6
6
  const bot_stopped_js_1 = require("./bot-stopped.js");
7
7
  Object.defineProperty(exports, "BotStoppedUpdate", { enumerable: true, get: function () { return bot_stopped_js_1.BotStoppedUpdate; } });
8
8
  const callback_query_js_1 = require("./callback-query.js");
9
+ Object.defineProperty(exports, "BusinessCallbackQuery", { enumerable: true, get: function () { return callback_query_js_1.BusinessCallbackQuery; } });
9
10
  Object.defineProperty(exports, "CallbackQuery", { enumerable: true, get: function () { return callback_query_js_1.CallbackQuery; } });
10
11
  Object.defineProperty(exports, "InlineCallbackQuery", { enumerable: true, get: function () { return callback_query_js_1.InlineCallbackQuery; } });
11
12
  const chat_join_request_js_1 = require("./chat-join-request.js");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/updates/index.ts"],"names":[],"mappings":";;;AACA,yEAAqE;AAsBjE,yGAtBK,mDAAwB,OAsBL;AArB5B,qDAAmD;AAwB/C,iGAxBK,iCAAgB,OAwBL;AAvBpB,2DAAwE;AAyBpE,8FAzBK,iCAAa,OAyBL;AAQb,oGAjCoB,uCAAmB,OAiCpB;AAhCvB,iEAA8D;AAyB1D,sGAzBK,4CAAqB,OAyBL;AAxBzB,mEAA0D;AAyBtD,iGAzBK,wCAAgB,OAyBL;AAxBpB,uDAA+C;AA+B3C,4FA/BK,6BAAW,OA+BL;AA7Bf,uDAA6E;AAgBzE,uGAhBK,wCAAsB,OAgBL;AACtB,kGAjB6B,mCAAiB,OAiB7B;AAhBrB,+DAAuD;AAkBnD,gGAlBK,qCAAe,OAkBL;AAjBnB,uEAA8D;AAqB1D,mGArBK,4CAAkB,OAqBL;AApBtB,2FAAiF;AAqB7E,4GArBK,+DAA2B,OAqBL;AApB/B,yEAAgE;AAqB5D,oGArBK,8CAAmB,OAqBL;AApBvB,qEAA4D;AAqBxD,kGArBK,0CAAiB,OAqBL;AApBrB,qEAA4D;AAqBxD,kGArBK,0CAAiB,OAqBL;AApBrB,qDAA6C;AAuBzC,2FAvBK,2BAAU,OAuBL;AAtBd,iDAA+C;AAuB3C,+FAvBK,6BAAc,OAuBL;AAtBlB,mEAA0D;AAuBtD,iGAvBK,wCAAgB,OAuBL;AAtBpB,uDAA+C;AAuB3C,4FAvBK,6BAAW,OAuBL;AAtBf,mEAA0D;AAuBtD,iGAvBK,wCAAgB,OAuBL;AAtBpB,mEAA0D;AAuBtD,iGAvBK,wCAAgB,OAuBL;AAiCpB,cAAc","sourcesContent":["import type { BusinessConnection, Message } from '../../types/index.js'\nimport { BotChatJoinRequestUpdate } from './bot-chat-join-request.js'\nimport { BotStoppedUpdate } from './bot-stopped.js'\nimport { CallbackQuery, InlineCallbackQuery } from './callback-query.js'\nimport { ChatJoinRequestUpdate } from './chat-join-request.js'\nimport { ChatMemberUpdate } from './chat-member-update.js'\nimport { InlineQuery } from './inline-query.js'\nexport type { ChatMemberUpdateType } from './chat-member-update.js'\nimport { BotReactionCountUpdate, BotReactionUpdate } from './bot-reaction.js'\nimport { BusinessMessage } from './business-message.js'\nimport { ChosenInlineResult } from './chosen-inline-result.js'\nimport { DeleteBusinessMessageUpdate } from './delete-business-message-update.js'\nimport { DeleteMessageUpdate } from './delete-message-update.js'\nimport { DeleteStoryUpdate } from './delete-story-update.js'\nimport { HistoryReadUpdate } from './history-read-update.js'\nimport { PollUpdate } from './poll-update.js'\nimport { PollVoteUpdate } from './poll-vote.js'\nimport { PreCheckoutQuery } from './pre-checkout-query.js'\nimport { StoryUpdate } from './story-update.js'\nimport { UserStatusUpdate } from './user-status-update.js'\nimport { UserTypingUpdate } from './user-typing-update.js'\n\nexport {\n BotChatJoinRequestUpdate,\n BotReactionCountUpdate,\n BotReactionUpdate,\n BotStoppedUpdate,\n BusinessMessage,\n CallbackQuery,\n ChatJoinRequestUpdate,\n ChatMemberUpdate,\n ChosenInlineResult,\n DeleteBusinessMessageUpdate,\n DeleteMessageUpdate,\n DeleteStoryUpdate,\n HistoryReadUpdate,\n InlineCallbackQuery,\n InlineQuery,\n PollUpdate,\n PollVoteUpdate,\n PreCheckoutQuery,\n StoryUpdate,\n UserStatusUpdate,\n UserTypingUpdate,\n}\n\n// begin-codegen\nexport type ParsedUpdate =\n | { name: 'new_message'; data: Message }\n | { name: 'edit_message'; data: Message }\n | { name: 'message_group'; data: Message[] }\n | { name: 'delete_message'; data: DeleteMessageUpdate }\n | { name: 'chat_member'; data: ChatMemberUpdate }\n | { name: 'inline_query'; data: InlineQuery }\n | { name: 'chosen_inline_result'; data: ChosenInlineResult }\n | { name: 'callback_query'; data: CallbackQuery }\n | { name: 'inline_callback_query'; data: InlineCallbackQuery }\n | { name: 'poll'; data: PollUpdate }\n | { name: 'poll_vote'; data: PollVoteUpdate }\n | { name: 'user_status'; data: UserStatusUpdate }\n | { name: 'user_typing'; data: UserTypingUpdate }\n | { name: 'history_read'; data: HistoryReadUpdate }\n | { name: 'bot_stopped'; data: BotStoppedUpdate }\n | { name: 'bot_chat_join_request'; data: BotChatJoinRequestUpdate }\n | { name: 'chat_join_request'; data: ChatJoinRequestUpdate }\n | { name: 'pre_checkout_query'; data: PreCheckoutQuery }\n | { name: 'story'; data: StoryUpdate }\n | { name: 'delete_story'; data: DeleteStoryUpdate }\n | { name: 'bot_reaction'; data: BotReactionUpdate }\n | { name: 'bot_reaction_count'; data: BotReactionCountUpdate }\n | { name: 'business_connection'; data: BusinessConnection }\n | { name: 'new_business_message'; data: BusinessMessage }\n | { name: 'edit_business_message'; data: BusinessMessage }\n | { name: 'business_message_group'; data: BusinessMessage[] }\n | { name: 'delete_business_message'; data: DeleteBusinessMessageUpdate }\n\n// end-codegen\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/updates/index.ts"],"names":[],"mappings":";;;AACA,yEAAqE;AAsBjE,yGAtBK,mDAAwB,OAsBL;AArB5B,qDAAmD;AAwB/C,iGAxBK,iCAAgB,OAwBL;AAvBpB,2DAA+F;AAwB3F,sGAxBK,yCAAqB,OAwBL;AAErB,8FA1B4B,iCAAa,OA0B5B;AAQb,oGAlC2C,uCAAmB,OAkC3C;AAjCvB,iEAA8D;AA0B1D,sGA1BK,4CAAqB,OA0BL;AAzBzB,mEAA0D;AA0BtD,iGA1BK,wCAAgB,OA0BL;AAzBpB,uDAA+C;AAgC3C,4FAhCK,6BAAW,OAgCL;AA9Bf,uDAA6E;AAgBzE,uGAhBK,wCAAsB,OAgBL;AACtB,kGAjB6B,mCAAiB,OAiB7B;AAhBrB,+DAAuD;AAmBnD,gGAnBK,qCAAe,OAmBL;AAlBnB,uEAA8D;AAsB1D,mGAtBK,4CAAkB,OAsBL;AArBtB,2FAAiF;AAsB7E,4GAtBK,+DAA2B,OAsBL;AArB/B,yEAAgE;AAsB5D,oGAtBK,8CAAmB,OAsBL;AArBvB,qEAA4D;AAsBxD,kGAtBK,0CAAiB,OAsBL;AArBrB,qEAA4D;AAsBxD,kGAtBK,0CAAiB,OAsBL;AArBrB,qDAA6C;AAwBzC,2FAxBK,2BAAU,OAwBL;AAvBd,iDAA+C;AAwB3C,+FAxBK,6BAAc,OAwBL;AAvBlB,mEAA0D;AAwBtD,iGAxBK,wCAAgB,OAwBL;AAvBpB,uDAA+C;AAwB3C,4FAxBK,6BAAW,OAwBL;AAvBf,mEAA0D;AAwBtD,iGAxBK,wCAAgB,OAwBL;AAvBpB,mEAA0D;AAwBtD,iGAxBK,wCAAgB,OAwBL;AAkCpB,cAAc","sourcesContent":["import type { BusinessConnection, Message } from '../../types/index.js'\nimport { BotChatJoinRequestUpdate } from './bot-chat-join-request.js'\nimport { BotStoppedUpdate } from './bot-stopped.js'\nimport { BusinessCallbackQuery, CallbackQuery, InlineCallbackQuery } from './callback-query.js'\nimport { ChatJoinRequestUpdate } from './chat-join-request.js'\nimport { ChatMemberUpdate } from './chat-member-update.js'\nimport { InlineQuery } from './inline-query.js'\nexport type { ChatMemberUpdateType } from './chat-member-update.js'\nimport { BotReactionCountUpdate, BotReactionUpdate } from './bot-reaction.js'\nimport { BusinessMessage } from './business-message.js'\nimport { ChosenInlineResult } from './chosen-inline-result.js'\nimport { DeleteBusinessMessageUpdate } from './delete-business-message-update.js'\nimport { DeleteMessageUpdate } from './delete-message-update.js'\nimport { DeleteStoryUpdate } from './delete-story-update.js'\nimport { HistoryReadUpdate } from './history-read-update.js'\nimport { PollUpdate } from './poll-update.js'\nimport { PollVoteUpdate } from './poll-vote.js'\nimport { PreCheckoutQuery } from './pre-checkout-query.js'\nimport { StoryUpdate } from './story-update.js'\nimport { UserStatusUpdate } from './user-status-update.js'\nimport { UserTypingUpdate } from './user-typing-update.js'\n\nexport {\n BotChatJoinRequestUpdate,\n BotReactionCountUpdate,\n BotReactionUpdate,\n BotStoppedUpdate,\n BusinessCallbackQuery,\n BusinessMessage,\n CallbackQuery,\n ChatJoinRequestUpdate,\n ChatMemberUpdate,\n ChosenInlineResult,\n DeleteBusinessMessageUpdate,\n DeleteMessageUpdate,\n DeleteStoryUpdate,\n HistoryReadUpdate,\n InlineCallbackQuery,\n InlineQuery,\n PollUpdate,\n PollVoteUpdate,\n PreCheckoutQuery,\n StoryUpdate,\n UserStatusUpdate,\n UserTypingUpdate,\n}\n\n// begin-codegen\nexport type ParsedUpdate =\n | { name: 'new_message'; data: Message }\n | { name: 'edit_message'; data: Message }\n | { name: 'message_group'; data: Message[] }\n | { name: 'delete_message'; data: DeleteMessageUpdate }\n | { name: 'chat_member'; data: ChatMemberUpdate }\n | { name: 'inline_query'; data: InlineQuery }\n | { name: 'chosen_inline_result'; data: ChosenInlineResult }\n | { name: 'callback_query'; data: CallbackQuery }\n | { name: 'inline_callback_query'; data: InlineCallbackQuery }\n | { name: 'business_callback_query'; data: BusinessCallbackQuery }\n | { name: 'poll'; data: PollUpdate }\n | { name: 'poll_vote'; data: PollVoteUpdate }\n | { name: 'user_status'; data: UserStatusUpdate }\n | { name: 'user_typing'; data: UserTypingUpdate }\n | { name: 'history_read'; data: HistoryReadUpdate }\n | { name: 'bot_stopped'; data: BotStoppedUpdate }\n | { name: 'bot_chat_join_request'; data: BotChatJoinRequestUpdate }\n | { name: 'chat_join_request'; data: ChatJoinRequestUpdate }\n | { name: 'pre_checkout_query'; data: PreCheckoutQuery }\n | { name: 'story'; data: StoryUpdate }\n | { name: 'delete_story'; data: DeleteStoryUpdate }\n | { name: 'bot_reaction'; data: BotReactionUpdate }\n | { name: 'bot_reaction_count'; data: BotReactionCountUpdate }\n | { name: 'business_connection'; data: BusinessConnection }\n | { name: 'new_business_message'; data: BusinessMessage }\n | { name: 'edit_business_message'; data: BusinessMessage }\n | { name: 'business_message_group'; data: BusinessMessage[] }\n | { name: 'delete_business_message'; data: DeleteBusinessMessageUpdate }\n\n// end-codegen\n"]}
@@ -76,6 +76,8 @@ function _parseUpdate(update, peers) {
76
76
  return { name: 'edit_business_message', data: new index_js_1.BusinessMessage(update, peers) };
77
77
  case 'updateBotDeleteBusinessMessage':
78
78
  return { name: 'delete_business_message', data: new index_js_1.DeleteBusinessMessageUpdate(update, peers) };
79
+ case 'updateBusinessBotCallbackQuery':
80
+ return { name: 'business_callback_query', data: new index_js_1.BusinessCallbackQuery(update, peers) };
79
81
  default:
80
82
  return null;
81
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-update.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/updates/parse-update.ts"],"names":[],"mappings":";;;AAGA,0CA0BoB;AAEpB,gBAAgB;AAChB,SAAgB,YAAY,CAAC,MAAqB,EAAE,KAAiB;IACjE,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC;QACf,KAAK,kBAAkB,CAAC;QACxB,KAAK,yBAAyB,CAAC;QAC/B,KAAK,2BAA2B;YAC5B,OAAO;gBACH,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,IAAI,kBAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,KAAK,2BAA2B,CAAC;aACrF,CAAA;QACL,KAAK,mBAAmB,CAAC;QACzB,KAAK,0BAA0B;YAC3B,OAAO,EAAE,IAAI,EAAE,cA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E,IAAI,EAAE,IAAI,4BAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;YAC/E,CAAC;YAED,OAAO;gBACH,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,IAAI,sBAAW,CAAC,MAAM,EAAE,KAAK,CAAC;aACvC,CAAA;QACL,CAAC;QACD,KAAK,0BAA0B;YAC3B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,4BAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;QAC/E,KAAK,2BAA2B;YAC5B,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,IAAI,iCAAsB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;QAC1F,KAAK,0BAA0B;YAC3B,OAAO,EAAE,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,6BAAkB,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,CAAA;QAClG,KAAK,6BAA6B;YAC9B,OAAO,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,IAAI,0BAAe,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;QACrF,KAAK,8BAA8B;YAC/B,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,IAAI,0BAAe,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;QACtF,KAAK,gCAAgC;YACjC,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,EAAE,IAAI,sCAA2B,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;QACpG;YACI,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC;AA9ED,oCA8EC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument */\nimport { tl } from '@mtcute/tl'\n\nimport {\n BotChatJoinRequestUpdate,\n BotReactionCountUpdate,\n BotReactionUpdate,\n BotStoppedUpdate,\n BusinessConnection,\n BusinessMessage,\n CallbackQuery,\n ChatJoinRequestUpdate,\n ChatMemberUpdate,\n ChosenInlineResult,\n DeleteBusinessMessageUpdate,\n DeleteMessageUpdate,\n DeleteStoryUpdate,\n HistoryReadUpdate,\n InlineCallbackQuery,\n InlineQuery,\n Message,\n ParsedUpdate,\n PeersIndex,\n PollUpdate,\n PollVoteUpdate,\n PreCheckoutQuery,\n StoryUpdate,\n UserStatusUpdate,\n UserTypingUpdate,\n} from '../index.js'\n\n/** @internal */\nexport function _parseUpdate(update: tl.TypeUpdate, peers: PeersIndex): ParsedUpdate | null {\n switch (update._) {\n case 'updateNewMessage':\n case 'updateNewChannelMessage':\n case 'updateNewScheduledMessage':\n return {\n name: 'new_message',\n data: new Message(update.message, peers, update._ === 'updateNewScheduledMessage'),\n }\n case 'updateEditMessage':\n case 'updateEditChannelMessage':\n return { name: 'edit_message', data: new Message(update.message, peers) }\n case 'updateChatParticipant':\n case 'updateChannelParticipant':\n return { name: 'chat_member', data: new ChatMemberUpdate(update, peers) }\n case 'updateBotInlineQuery':\n return { name: 'inline_query', data: new InlineQuery(update, peers) }\n case 'updateBotInlineSend':\n return { name: 'chosen_inline_result', data: new ChosenInlineResult(update, peers) }\n case 'updateBotCallbackQuery':\n return { name: 'callback_query', data: new CallbackQuery(update, peers) }\n case 'updateInlineBotCallbackQuery':\n return { name: 'inline_callback_query', data: new InlineCallbackQuery(update, peers) }\n case 'updateMessagePoll':\n return { name: 'poll', data: new PollUpdate(update, peers) }\n case 'updateMessagePollVote':\n return { name: 'poll_vote', data: new PollVoteUpdate(update, peers) }\n case 'updateUserStatus':\n return { name: 'user_status', data: new UserStatusUpdate(update) }\n case 'updateChannelUserTyping':\n case 'updateChatUserTyping':\n case 'updateUserTyping':\n return { name: 'user_typing', data: new UserTypingUpdate(update) }\n case 'updateDeleteChannelMessages':\n case 'updateDeleteMessages':\n return { name: 'delete_message', data: new DeleteMessageUpdate(update) }\n case 'updateReadHistoryInbox':\n case 'updateReadHistoryOutbox':\n case 'updateReadChannelInbox':\n case 'updateReadChannelOutbox':\n case 'updateReadChannelDiscussionInbox':\n case 'updateReadChannelDiscussionOutbox':\n return { name: 'history_read', data: new HistoryReadUpdate(update) }\n case 'updateBotStopped':\n return { name: 'bot_stopped', data: new BotStoppedUpdate(update, peers) }\n case 'updateBotChatInviteRequester':\n return { name: 'bot_chat_join_request', data: new BotChatJoinRequestUpdate(update, peers) }\n case 'updatePendingJoinRequests':\n return { name: 'chat_join_request', data: new ChatJoinRequestUpdate(update, peers) }\n case 'updateBotPrecheckoutQuery':\n return { name: 'pre_checkout_query', data: new PreCheckoutQuery(update, peers) }\n case 'updateStory': {\n const story = update.story\n\n if (story._ === 'storyItemDeleted') {\n return { name: 'delete_story', data: new DeleteStoryUpdate(update, peers) }\n }\n\n return {\n name: 'story',\n data: new StoryUpdate(update, peers),\n }\n }\n case 'updateBotMessageReaction':\n return { name: 'bot_reaction', data: new BotReactionUpdate(update, peers) }\n case 'updateBotMessageReactions':\n return { name: 'bot_reaction_count', data: new BotReactionCountUpdate(update, peers) }\n case 'updateBotBusinessConnect':\n return { name: 'business_connection', data: new BusinessConnection(update.connection, peers) }\n case 'updateBotNewBusinessMessage':\n return { name: 'new_business_message', data: new BusinessMessage(update, peers) }\n case 'updateBotEditBusinessMessage':\n return { name: 'edit_business_message', data: new BusinessMessage(update, peers) }\n case 'updateBotDeleteBusinessMessage':\n return { name: 'delete_business_message', data: new DeleteBusinessMessageUpdate(update, peers) }\n default:\n return null\n }\n}\n"]}
1
+ {"version":3,"file":"parse-update.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/updates/parse-update.ts"],"names":[],"mappings":";;;AAGA,0CA2BoB;AAEpB,gBAAgB;AAChB,SAAgB,YAAY,CAAC,MAAqB,EAAE,KAAiB;IACjE,QAAQ,MAAM,CAAC,CAAC,EAAE,CAAC;QACf,KAAK,kBAAkB,CAAC;QACxB,KAAK,yBAAyB,CAAC;QAC/B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B,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;QACpG,KAAK,gCAAgC;YACjC,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,IAAI,EAAE,IAAI,gCAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAA;QAC9F;YACI,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC;AAhFD,oCAgFC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument */\nimport { tl } from '@mtcute/tl'\n\nimport {\n BotChatJoinRequestUpdate,\n BotReactionCountUpdate,\n BotReactionUpdate,\n BotStoppedUpdate,\n BusinessCallbackQuery,\n BusinessConnection,\n BusinessMessage,\n CallbackQuery,\n ChatJoinRequestUpdate,\n ChatMemberUpdate,\n ChosenInlineResult,\n DeleteBusinessMessageUpdate,\n DeleteMessageUpdate,\n DeleteStoryUpdate,\n HistoryReadUpdate,\n InlineCallbackQuery,\n InlineQuery,\n Message,\n ParsedUpdate,\n PeersIndex,\n PollUpdate,\n PollVoteUpdate,\n PreCheckoutQuery,\n StoryUpdate,\n UserStatusUpdate,\n UserTypingUpdate,\n} from '../index.js'\n\n/** @internal */\nexport function _parseUpdate(update: tl.TypeUpdate, peers: PeersIndex): ParsedUpdate | null {\n switch (update._) {\n case 'updateNewMessage':\n case 'updateNewChannelMessage':\n case 'updateNewScheduledMessage':\n return {\n name: 'new_message',\n data: new Message(update.message, peers, update._ === 'updateNewScheduledMessage'),\n }\n case 'updateEditMessage':\n case 'updateEditChannelMessage':\n return { name: 'edit_message', data: new Message(update.message, peers) }\n case 'updateChatParticipant':\n case 'updateChannelParticipant':\n return { name: 'chat_member', data: new ChatMemberUpdate(update, peers) }\n case 'updateBotInlineQuery':\n return { name: 'inline_query', data: new InlineQuery(update, peers) }\n case 'updateBotInlineSend':\n return { name: 'chosen_inline_result', data: new ChosenInlineResult(update, peers) }\n case 'updateBotCallbackQuery':\n return { name: 'callback_query', data: new CallbackQuery(update, peers) }\n case 'updateInlineBotCallbackQuery':\n return { name: 'inline_callback_query', data: new InlineCallbackQuery(update, peers) }\n case 'updateMessagePoll':\n return { name: 'poll', data: new PollUpdate(update, peers) }\n case 'updateMessagePollVote':\n return { name: 'poll_vote', data: new PollVoteUpdate(update, peers) }\n case 'updateUserStatus':\n return { name: 'user_status', data: new UserStatusUpdate(update) }\n case 'updateChannelUserTyping':\n case 'updateChatUserTyping':\n case 'updateUserTyping':\n return { name: 'user_typing', data: new UserTypingUpdate(update) }\n case 'updateDeleteChannelMessages':\n case 'updateDeleteMessages':\n return { name: 'delete_message', data: new DeleteMessageUpdate(update) }\n case 'updateReadHistoryInbox':\n case 'updateReadHistoryOutbox':\n case 'updateReadChannelInbox':\n case 'updateReadChannelOutbox':\n case 'updateReadChannelDiscussionInbox':\n case 'updateReadChannelDiscussionOutbox':\n return { name: 'history_read', data: new HistoryReadUpdate(update) }\n case 'updateBotStopped':\n return { name: 'bot_stopped', data: new BotStoppedUpdate(update, peers) }\n case 'updateBotChatInviteRequester':\n return { name: 'bot_chat_join_request', data: new BotChatJoinRequestUpdate(update, peers) }\n case 'updatePendingJoinRequests':\n return { name: 'chat_join_request', data: new ChatJoinRequestUpdate(update, peers) }\n case 'updateBotPrecheckoutQuery':\n return { name: 'pre_checkout_query', data: new PreCheckoutQuery(update, peers) }\n case 'updateStory': {\n const story = update.story\n\n if (story._ === 'storyItemDeleted') {\n return { name: 'delete_story', data: new DeleteStoryUpdate(update, peers) }\n }\n\n return {\n name: 'story',\n data: new StoryUpdate(update, peers),\n }\n }\n case 'updateBotMessageReaction':\n return { name: 'bot_reaction', data: new BotReactionUpdate(update, peers) }\n case 'updateBotMessageReactions':\n return { name: 'bot_reaction_count', data: new BotReactionCountUpdate(update, peers) }\n case 'updateBotBusinessConnect':\n return { name: 'business_connection', data: new BusinessConnection(update.connection, peers) }\n case 'updateBotNewBusinessMessage':\n return { name: 'new_business_message', data: new BusinessMessage(update, peers) }\n case 'updateBotEditBusinessMessage':\n return { name: 'edit_business_message', data: new BusinessMessage(update, peers) }\n case 'updateBotDeleteBusinessMessage':\n return { name: 'delete_business_message', data: new DeleteBusinessMessageUpdate(update, peers) }\n case 'updateBusinessBotCallbackQuery':\n return { name: 'business_callback_query', data: new BusinessCallbackQuery(update, peers) }\n default:\n return null\n }\n}\n"]}
@@ -36,6 +36,8 @@ export declare abstract class TelegramWorkerPort<Custom extends WorkerCustomMeth
36
36
  readonly computeNewPasswordHash: (algo: tl.TypePasswordKdfAlgo, password: string) => Promise<Uint8Array>;
37
37
  readonly startUpdatesLoop: () => Promise<void>;
38
38
  readonly stopUpdatesLoop: () => Promise<void>;
39
+ private _abortController;
40
+ readonly stopSignal: AbortSignal;
39
41
  constructor(options: TelegramWorkerPortOptions);
40
42
  abstract connectToWorker(worker: SomeWorker, handler: ClientMessageHandler): [SendFn, () => void];
41
43
  private _serverUpdatesHandler;