@mtcute/dispatcher 0.16.7 → 0.16.13

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 (237) hide show
  1. package/{cjs/callback-data-builder.d.ts → callback-data-builder.d.ts} +2 -2
  2. package/callback-data-builder.test.d.ts +1 -0
  3. package/{esm/context → context}/base.d.ts +2 -2
  4. package/{esm/context → context}/business-message.d.ts +5 -6
  5. package/{esm/context → context}/callback-query.d.ts +6 -7
  6. package/{cjs/context → context}/chat-join-request.d.ts +3 -3
  7. package/{esm/context → context}/chosen-inline-result.d.ts +3 -3
  8. package/{esm/context → context}/inline-query.d.ts +4 -5
  9. package/{cjs/context → context}/message.d.ts +11 -6
  10. package/{cjs/context → context}/parse.d.ts +3 -3
  11. package/{esm/context → context}/pre-checkout-query.d.ts +3 -3
  12. package/{esm/context → context}/scene-transition.d.ts +1 -1
  13. package/{cjs/dispatcher.d.ts → dispatcher.d.ts} +9 -10
  14. package/{cjs/filters → filters}/bots.d.ts +4 -4
  15. package/filters/bots.test.d.ts +1 -0
  16. package/{cjs/filters → filters}/chat.d.ts +3 -3
  17. package/{esm/filters → filters}/group.d.ts +4 -4
  18. package/{cjs/filters → filters}/logic.d.ts +1 -1
  19. package/filters/logic.test.d.ts +1 -0
  20. package/{esm/filters → filters}/message.d.ts +9 -5
  21. package/{cjs/filters → filters}/state.d.ts +2 -2
  22. package/{esm/filters → filters}/text.d.ts +3 -3
  23. package/{cjs/filters → filters}/types.d.ts +2 -2
  24. package/{cjs/filters → filters}/updates.d.ts +2 -2
  25. package/{cjs/filters → filters}/user.d.ts +3 -4
  26. package/{cjs/handler.d.ts → handler.d.ts} +5 -5
  27. package/index.cjs +2534 -0
  28. package/index.d.ts +8 -1
  29. package/index.js +2529 -1
  30. package/package.json +28 -24
  31. package/{cjs/state → state}/key.d.ts +3 -3
  32. package/state/provider.d.ts +5 -0
  33. package/{cjs/state → state}/providers/memory.d.ts +3 -4
  34. package/{esm/state → state}/providers/sqlite.d.ts +3 -3
  35. package/{cjs/state → state}/repository.d.ts +1 -1
  36. package/{esm/state → state}/service.d.ts +2 -2
  37. package/{cjs/state → state}/update-state.d.ts +2 -2
  38. package/{esm/wizard.d.ts → wizard.d.ts} +5 -6
  39. package/cjs/callback-data-builder.js +0 -141
  40. package/cjs/callback-data-builder.js.map +0 -1
  41. package/cjs/context/base.d.ts +0 -9
  42. package/cjs/context/base.js +0 -3
  43. package/cjs/context/base.js.map +0 -1
  44. package/cjs/context/business-message.d.ts +0 -61
  45. package/cjs/context/business-message.js +0 -146
  46. package/cjs/context/business-message.js.map +0 -1
  47. package/cjs/context/callback-query.d.ts +0 -63
  48. package/cjs/context/callback-query.js +0 -109
  49. package/cjs/context/callback-query.js.map +0 -1
  50. package/cjs/context/chat-join-request.js +0 -35
  51. package/cjs/context/chat-join-request.js.map +0 -1
  52. package/cjs/context/chosen-inline-result.d.ts +0 -22
  53. package/cjs/context/chosen-inline-result.js +0 -36
  54. package/cjs/context/chosen-inline-result.js.map +0 -1
  55. package/cjs/context/index.js +0 -25
  56. package/cjs/context/index.js.map +0 -1
  57. package/cjs/context/inline-query.d.ts +0 -16
  58. package/cjs/context/inline-query.js +0 -23
  59. package/cjs/context/inline-query.js.map +0 -1
  60. package/cjs/context/message.js +0 -171
  61. package/cjs/context/message.js.map +0 -1
  62. package/cjs/context/parse.js +0 -42
  63. package/cjs/context/parse.js.map +0 -1
  64. package/cjs/context/pre-checkout-query.d.ts +0 -17
  65. package/cjs/context/pre-checkout-query.js +0 -27
  66. package/cjs/context/pre-checkout-query.js.map +0 -1
  67. package/cjs/context/scene-transition.d.ts +0 -24
  68. package/cjs/context/scene-transition.js +0 -52
  69. package/cjs/context/scene-transition.js.map +0 -1
  70. package/cjs/dispatcher.js +0 -908
  71. package/cjs/dispatcher.js.map +0 -1
  72. package/cjs/filters/bots.js +0 -135
  73. package/cjs/filters/bots.js.map +0 -1
  74. package/cjs/filters/bundle.js +0 -27
  75. package/cjs/filters/bundle.js.map +0 -1
  76. package/cjs/filters/chat.js +0 -56
  77. package/cjs/filters/chat.js.map +0 -1
  78. package/cjs/filters/group.d.ts +0 -26
  79. package/cjs/filters/group.js +0 -69
  80. package/cjs/filters/group.js.map +0 -1
  81. package/cjs/filters/index.js +0 -29
  82. package/cjs/filters/index.js.map +0 -1
  83. package/cjs/filters/logic.js +0 -112
  84. package/cjs/filters/logic.js.map +0 -1
  85. package/cjs/filters/message.d.ts +0 -215
  86. package/cjs/filters/message.js +0 -191
  87. package/cjs/filters/message.js.map +0 -1
  88. package/cjs/filters/state.js +0 -33
  89. package/cjs/filters/state.js.map +0 -1
  90. package/cjs/filters/text.d.ts +0 -64
  91. package/cjs/filters/text.js +0 -136
  92. package/cjs/filters/text.js.map +0 -1
  93. package/cjs/filters/types.js +0 -3
  94. package/cjs/filters/types.js.map +0 -1
  95. package/cjs/filters/updates.js +0 -40
  96. package/cjs/filters/updates.js.map +0 -1
  97. package/cjs/filters/user.js +0 -77
  98. package/cjs/filters/user.js.map +0 -1
  99. package/cjs/handler.js +0 -4
  100. package/cjs/handler.js.map +0 -1
  101. package/cjs/index.js +0 -31
  102. package/cjs/index.js.map +0 -1
  103. package/cjs/package.json +0 -3
  104. package/cjs/propagation.js +0 -27
  105. package/cjs/propagation.js.map +0 -1
  106. package/cjs/state/index.js +0 -22
  107. package/cjs/state/index.js.map +0 -1
  108. package/cjs/state/key.js +0 -43
  109. package/cjs/state/key.js.map +0 -1
  110. package/cjs/state/provider.d.ts +0 -5
  111. package/cjs/state/provider.js +0 -3
  112. package/cjs/state/provider.js.map +0 -1
  113. package/cjs/state/providers/index.js +0 -19
  114. package/cjs/state/providers/index.js.map +0 -1
  115. package/cjs/state/providers/memory.js +0 -81
  116. package/cjs/state/providers/memory.js.map +0 -1
  117. package/cjs/state/providers/sqlite.d.ts +0 -28
  118. package/cjs/state/providers/sqlite.js +0 -100
  119. package/cjs/state/providers/sqlite.js.map +0 -1
  120. package/cjs/state/repository.js +0 -3
  121. package/cjs/state/repository.js.map +0 -1
  122. package/cjs/state/service.d.ts +0 -20
  123. package/cjs/state/service.js +0 -70
  124. package/cjs/state/service.js.map +0 -1
  125. package/cjs/state/update-state.js +0 -219
  126. package/cjs/state/update-state.js.map +0 -1
  127. package/cjs/wizard.d.ts +0 -65
  128. package/cjs/wizard.js +0 -105
  129. package/cjs/wizard.js.map +0 -1
  130. package/esm/callback-data-builder.d.ts +0 -49
  131. package/esm/callback-data-builder.js +0 -137
  132. package/esm/callback-data-builder.js.map +0 -1
  133. package/esm/context/base.js +0 -2
  134. package/esm/context/base.js.map +0 -1
  135. package/esm/context/business-message.js +0 -142
  136. package/esm/context/business-message.js.map +0 -1
  137. package/esm/context/callback-query.js +0 -103
  138. package/esm/context/callback-query.js.map +0 -1
  139. package/esm/context/chat-join-request.d.ts +0 -17
  140. package/esm/context/chat-join-request.js +0 -31
  141. package/esm/context/chat-join-request.js.map +0 -1
  142. package/esm/context/chosen-inline-result.js +0 -32
  143. package/esm/context/chosen-inline-result.js.map +0 -1
  144. package/esm/context/index.d.ts +0 -9
  145. package/esm/context/index.js +0 -9
  146. package/esm/context/index.js.map +0 -1
  147. package/esm/context/inline-query.js +0 -19
  148. package/esm/context/inline-query.js.map +0 -1
  149. package/esm/context/message.d.ts +0 -77
  150. package/esm/context/message.js +0 -167
  151. package/esm/context/message.js.map +0 -1
  152. package/esm/context/parse.d.ts +0 -13
  153. package/esm/context/parse.js +0 -39
  154. package/esm/context/parse.js.map +0 -1
  155. package/esm/context/pre-checkout-query.js +0 -23
  156. package/esm/context/pre-checkout-query.js.map +0 -1
  157. package/esm/context/scene-transition.js +0 -48
  158. package/esm/context/scene-transition.js.map +0 -1
  159. package/esm/dispatcher.d.ts +0 -881
  160. package/esm/dispatcher.js +0 -904
  161. package/esm/dispatcher.js.map +0 -1
  162. package/esm/filters/bots.d.ts +0 -64
  163. package/esm/filters/bots.js +0 -131
  164. package/esm/filters/bots.js.map +0 -1
  165. package/esm/filters/bundle.d.ts +0 -10
  166. package/esm/filters/bundle.js +0 -11
  167. package/esm/filters/bundle.js.map +0 -1
  168. package/esm/filters/chat.d.ts +0 -27
  169. package/esm/filters/chat.js +0 -51
  170. package/esm/filters/chat.js.map +0 -1
  171. package/esm/filters/group.js +0 -65
  172. package/esm/filters/group.js.map +0 -1
  173. package/esm/filters/index.d.ts +0 -4
  174. package/esm/filters/index.js +0 -3
  175. package/esm/filters/index.js.map +0 -1
  176. package/esm/filters/logic.d.ts +0 -29
  177. package/esm/filters/logic.js +0 -105
  178. package/esm/filters/logic.js.map +0 -1
  179. package/esm/filters/message.js +0 -168
  180. package/esm/filters/message.js.map +0 -1
  181. package/esm/filters/state.d.ts +0 -15
  182. package/esm/filters/state.js +0 -28
  183. package/esm/filters/state.js.map +0 -1
  184. package/esm/filters/text.js +0 -129
  185. package/esm/filters/text.js.map +0 -1
  186. package/esm/filters/types.d.ts +0 -91
  187. package/esm/filters/types.js +0 -2
  188. package/esm/filters/types.js.map +0 -1
  189. package/esm/filters/updates.d.ts +0 -39
  190. package/esm/filters/updates.js +0 -34
  191. package/esm/filters/updates.js.map +0 -1
  192. package/esm/filters/user.d.ts +0 -25
  193. package/esm/filters/user.js +0 -71
  194. package/esm/filters/user.js.map +0 -1
  195. package/esm/handler.d.ts +0 -41
  196. package/esm/handler.js +0 -3
  197. package/esm/handler.js.map +0 -1
  198. package/esm/index.d.ts +0 -8
  199. package/esm/index.js +0 -9
  200. package/esm/index.js.map +0 -1
  201. package/esm/propagation.d.ts +0 -22
  202. package/esm/propagation.js +0 -24
  203. package/esm/propagation.js.map +0 -1
  204. package/esm/state/index.d.ts +0 -5
  205. package/esm/state/index.js +0 -6
  206. package/esm/state/index.js.map +0 -1
  207. package/esm/state/key.d.ts +0 -24
  208. package/esm/state/key.js +0 -39
  209. package/esm/state/key.js.map +0 -1
  210. package/esm/state/provider.d.ts +0 -5
  211. package/esm/state/provider.js +0 -2
  212. package/esm/state/provider.js.map +0 -1
  213. package/esm/state/providers/index.d.ts +0 -2
  214. package/esm/state/providers/index.js +0 -3
  215. package/esm/state/providers/index.js.map +0 -1
  216. package/esm/state/providers/memory.d.ts +0 -30
  217. package/esm/state/providers/memory.js +0 -77
  218. package/esm/state/providers/memory.js.map +0 -1
  219. package/esm/state/providers/sqlite.js +0 -96
  220. package/esm/state/providers/sqlite.js.map +0 -1
  221. package/esm/state/repository.d.ts +0 -62
  222. package/esm/state/repository.js +0 -2
  223. package/esm/state/repository.js.map +0 -1
  224. package/esm/state/service.js +0 -66
  225. package/esm/state/service.js.map +0 -1
  226. package/esm/state/update-state.d.ts +0 -151
  227. package/esm/state/update-state.js +0 -214
  228. package/esm/state/update-state.js.map +0 -1
  229. package/esm/wizard.js +0 -101
  230. package/esm/wizard.js.map +0 -1
  231. /package/{cjs/context → context}/index.d.ts +0 -0
  232. /package/{cjs/filters → filters}/bundle.d.ts +0 -0
  233. /package/{cjs/filters → filters}/index.d.ts +0 -0
  234. /package/{cjs/index.d.ts → index.d.cts} +0 -0
  235. /package/{cjs/propagation.d.ts → propagation.d.ts} +0 -0
  236. /package/{cjs/state → state}/index.d.ts +0 -0
  237. /package/{cjs/state → state}/providers/index.d.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/dispatcher.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,0CAA0C;AAC1C,4CAA4C;AAC5C,mCAAmC;AAuBnC,OAAO,EACH,eAAe,GAClB,MAAM,cAAc,CAAA;AAgBrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAsCtE,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AA2BjD;;GAEG;AACH,MAAM,OAAO,UAAU;IACX,OAAO,GAA6D,IAAI,GA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^ will be looked into in MTQ-29\n\nimport type {\n BotReactionCountUpdate,\n BotReactionUpdate,\n BotStoppedUpdate,\n BusinessConnection,\n ChatJoinRequestUpdate,\n ChatMemberUpdate,\n DeleteBusinessMessageUpdate,\n DeleteMessageUpdate,\n DeleteStoryUpdate,\n HistoryReadUpdate,\n MaybePromise,\n ParsedUpdate,\n PeersIndex,\n PollUpdate,\n PollVoteUpdate,\n StoryUpdate,\n UserStatusUpdate,\n UserTypingUpdate,\n tl,\n} from '@mtcute/core'\nimport {\n MtArgumentError,\n} from '@mtcute/core'\nimport type { TelegramClient } from '@mtcute/core/client.js'\n\nimport type { UpdateContext } from './context/base.js'\nimport type { BusinessMessageContext } from './context/business-message.js'\nimport type {\n BusinessCallbackQueryContext,\n CallbackQueryContext,\n ChatJoinRequestUpdateContext,\n ChosenInlineResultContext,\n InlineCallbackQueryContext,\n InlineQueryContext,\n MessageContext,\n PreCheckoutQueryContext,\n} from './context/index.js'\nimport type { UpdateContextType } from './context/parse.js'\nimport { _parsedUpdateToContext } from './context/parse.js'\nimport { SceneTransitionContext } from './context/scene-transition.js'\nimport type { UpdateFilter, filters } from './filters/index.js'\n// begin-codegen-imports\nimport type {\n BotChatJoinRequestHandler,\n BotReactionCountUpdateHandler,\n BotReactionUpdateHandler,\n BotStoppedHandler,\n BusinessCallbackQueryHandler,\n BusinessConnectionUpdateHandler,\n BusinessMessageGroupHandler,\n CallbackQueryHandler,\n ChatJoinRequestHandler,\n ChatMemberUpdateHandler,\n ChosenInlineResultHandler,\n DeleteBusinessMessageHandler,\n DeleteMessageHandler,\n DeleteStoryHandler,\n EditBusinessMessageHandler,\n EditMessageHandler,\n HistoryReadHandler,\n InlineCallbackQueryHandler,\n InlineQueryHandler,\n MessageGroupHandler,\n NewBusinessMessageHandler,\n NewMessageHandler,\n PollUpdateHandler,\n PollVoteHandler,\n PreCheckoutQueryHandler,\n RawUpdateHandler,\n StoryUpdateHandler,\n UpdateHandler,\n UserStatusUpdateHandler,\n UserTypingHandler,\n} from './handler.js'\n// end-codegen-imports\nimport type { PropagationAction } from './propagation.js'\nimport type { IStateStorageProvider, StateKeyDelegate } from './state/index.js'\nimport { UpdateState, defaultStateKeyDelegate } from './state/index.js'\nimport { StateService } from './state/service.js'\n\nexport interface DispatcherParams {\n /**\n * If this dispatcher can be used as a scene, its unique name.\n *\n * Should not be set manually, use {@link Dispatcher.scene} instead\n */\n sceneName?: string\n\n /**\n * Custom storage for this dispatcher and its children.\n *\n * @default Client's storage\n */\n storage?: IStateStorageProvider\n\n /**\n * Custom key delegate for the dispatcher.\n */\n key?: StateKeyDelegate\n}\n\nexport interface DispatcherDependencies {\n // intentionally empty, to be extended by consumers\n}\n\n/**\n * Updates dispatcher\n */\nexport class Dispatcher<State extends object = never> {\n private _groups: Map<number, Map<UpdateHandler['name'], UpdateHandler[]>> = new Map()\n private _groupsOrder: number[] = []\n\n private _client?: TelegramClient\n\n private _parent?: Dispatcher<any>\n private _children: Dispatcher<any>[] = []\n\n private _scenes?: Map<string, Dispatcher<any>>\n private _scene?: string\n private _sceneScoped?: boolean\n\n private _storage?: StateService\n private _stateKeyDelegate?: StateKeyDelegate\n\n private _customStateKeyDelegate?: StateKeyDelegate\n private _customStorage?: StateService\n\n private _deps: DispatcherDependencies = {}\n\n private _errorHandler?: <T = {}>(\n err: Error,\n update: ParsedUpdate & T,\n state?: UpdateState<State>,\n ) => MaybePromise<boolean>\n\n private _preUpdateHandler?: <T = {}>(\n update: ParsedUpdate & T,\n state?: UpdateState<State>,\n ) => MaybePromise<PropagationAction | void>\n\n private _postUpdateHandler?: <T = {}>(\n handled: boolean,\n update: ParsedUpdate & T,\n state?: UpdateState<State>,\n ) => MaybePromise<void>\n\n private _sceneTransitionHandler?: (\n update: SceneTransitionContext,\n state: UpdateState<State>,\n ) => MaybePromise<PropagationAction | void>\n\n protected constructor(client?: TelegramClient, params?: DispatcherParams) {\n this.dispatchRawUpdate = this.dispatchRawUpdate.bind(this)\n this.dispatchUpdate = this.dispatchUpdate.bind(this)\n\n // eslint-disable-next-line prefer-const\n let { storage, key, sceneName } = params ?? {}\n\n if (client) {\n this.bindToClient(client)\n\n if (storage) {\n this._storage = new StateService(storage)\n this._stateKeyDelegate = key ?? defaultStateKeyDelegate\n }\n } else {\n // child dispatcher without client\n\n if (storage) {\n this._customStorage = new StateService(storage)\n }\n\n if (key) {\n this._customStateKeyDelegate = key\n }\n\n if (sceneName) {\n if (sceneName[0] === '$') {\n throw new MtArgumentError('Scene name cannot start with $')\n }\n\n this._scene = sceneName\n }\n }\n }\n\n /**\n * Create a new dispatcher and bind it to the client.\n */\n static for<State extends object = never>(\n client: TelegramClient,\n ...args: [State] extends [never]\n ? [params?: DispatcherParams]\n : [params: DispatcherParams & { storage: IStateStorageProvider }]\n ): Dispatcher<State>\n\n static for<State extends object = never>(client: TelegramClient, params?: DispatcherParams): Dispatcher<State> {\n return new Dispatcher<State>(client, params)\n }\n\n /**\n * Create a new child dispatcher.\n */\n static child<State extends object = never>(params?: DispatcherParams): Dispatcher<State> {\n return new Dispatcher<State>(undefined, params)\n }\n\n /**\n * Create a new scene dispatcher\n */\n static scene<State extends object = Record<never, never>>(\n name: string,\n params?: Omit<DispatcherParams, 'sceneName'>,\n ): Dispatcher<State> {\n return new Dispatcher<State>(undefined, { sceneName: name, ...params })\n }\n\n /** For scene dispatchers, name of the scene */\n get sceneName(): string | undefined {\n return this._scene\n }\n\n /**\n * Inject a dependency to be available in this dispatcher and all its children.\n *\n * **Note**: This is only available for the root dispatcher.\n */\n inject<Name extends keyof DispatcherDependencies>(name: Name, value: DispatcherDependencies[Name]): void\n /**\n * Inject dependencies to be available in this dispatcher and all its children.\n *\n * **Note**: This is only available for the root dispatcher.\n */\n inject(deps: Partial<DispatcherDependencies>): void\n inject<Name extends keyof DispatcherDependencies>(\n name: Name | Partial<DispatcherDependencies>,\n value?: DispatcherDependencies[Name],\n ): void {\n if (this._parent) {\n throw new MtArgumentError('Cannot inject dependencies to child dispatchers')\n }\n\n if (typeof name === 'object') {\n for (const [k, v] of Object.entries(name)) {\n (this._deps as any)[k] = v\n }\n } else {\n this._deps[name] = value!\n }\n }\n\n /**\n * Get the dependencies injected into this dispatcher.\n */\n get deps(): DispatcherDependencies {\n return this._deps\n }\n\n /**\n * Bind the dispatcher to the client.\n * Called by the constructor automatically if\n * `client` was passed.\n *\n * Dispatcher also uses bound client to throw errors\n */\n bindToClient(client: TelegramClient): void {\n client.on('update', this.dispatchUpdate)\n client.on('raw_update', this.dispatchRawUpdate)\n\n this._client = client\n }\n\n /**\n * Unbind a dispatcher from the client.\n */\n unbind(): void {\n if (this._client) {\n this._client.off('update', this.dispatchUpdate)\n this._client.off('raw_update', this.dispatchRawUpdate)\n\n this._client = undefined\n }\n }\n\n /**\n * Destroy the dispatcher and all its children.\n *\n * When destroying, all the registered handlers are removed,\n * and the underlying storage is freed.\n */\n async destroy(): Promise<void> {\n if (this._parent && this._customStorage) {\n await this._customStorage.destroy()\n } else if (!this._parent && this._storage) {\n await this._storage.destroy()\n }\n\n this.removeUpdateHandler('all')\n\n for (const child of this._children) {\n await child.destroy()\n }\n\n for (const scene of this._scenes?.values() ?? []) {\n await scene.destroy()\n }\n }\n\n /**\n * Process a raw update with this dispatcher.\n * Calling this method without bound client will not work.\n *\n * Under the hood asynchronously calls {@link dispatchRawUpdateNow}\n * with error handler set to client's one.\n *\n * @param update Update to process\n * @param peers Peers index\n */\n dispatchRawUpdate(update: tl.TypeUpdate | tl.TypeMessage, peers: PeersIndex): void {\n if (!this._client) return\n\n // order does not matter in the dispatcher,\n // so we can handle each update in its own task\n this.dispatchRawUpdateNow(update, peers).catch(err => this._client!.emitError(err))\n }\n\n /**\n * Process a raw update right now in the current stack.\n *\n * Unlike {@link dispatchRawUpdate}, this does not schedule\n * the update to be dispatched, but dispatches it immediately,\n * and after `await`ing this method you can be certain that the update\n * was fully processed by all the registered handlers, including children.\n *\n * @param update Update to process\n * @param peers Peers map\n * @returns Whether the update was handled\n */\n async dispatchRawUpdateNow(update: tl.TypeUpdate | tl.TypeMessage, peers: PeersIndex): Promise<boolean> {\n if (!this._client) return false\n\n let handled = false\n\n outer: for (const grp of this._groupsOrder) {\n const group = this._groups.get(grp)!\n\n if (group.has('raw')) {\n const handlers = group.get('raw')! as RawUpdateHandler[]\n\n for (const h of handlers) {\n let result: void | PropagationAction\n\n if (!h.check || (await h.check(this._client, update, peers))) {\n result = await h.callback(this._client, update, peers)\n handled = true\n } else {\n continue\n }\n\n switch (result) {\n case 'continue':\n continue\n case 'stop':\n break outer\n case 'stop-children':\n return handled\n }\n\n break\n }\n }\n }\n\n for (const child of this._children) {\n const childHandled = await child.dispatchRawUpdateNow(update, peers)\n handled ||= childHandled\n }\n\n return handled\n }\n\n /**\n * Process an update with this dispatcher.\n * Calling this method without bound client will not work.\n *\n * Under the hood asynchronously calls {@link dispatchUpdateNow}\n * with error handler set to client's one.\n *\n * @param update Update to process\n */\n dispatchUpdate(update: ParsedUpdate): void {\n if (!this._client) return\n\n // order does not matter in the dispatcher,\n // so we can handle each update in its own task\n this.dispatchUpdateNow(update).catch(err => this._client!.emitError(err))\n }\n\n /**\n * Process an update right now in the current stack.\n *\n * Unlike {@link dispatchUpdate}, this does not schedule\n * the update to be dispatched, but dispatches it immediately,\n * and after `await`ing this method you can be certain that the update\n * was fully processed by all the registered handlers, including children.\n *\n * @param update Update to process\n * @returns Whether the update was handled\n */\n async dispatchUpdateNow(update: ParsedUpdate): Promise<boolean> {\n return this._dispatchUpdateNowImpl(update)\n }\n\n private async _dispatchUpdateNowImpl(\n update: ParsedUpdate,\n // this is getting a bit crazy lol\n parsedState?: UpdateState<State> | null,\n parsedScene?: string | null,\n forceScene?: true,\n parsedContext?: UpdateContextType,\n ): Promise<boolean> {\n if (!this._client) return false\n\n if (parsedScene === undefined) {\n if (\n this._storage\n && this._scenes\n && (update.name === 'new_message'\n || update.name === 'edit_message'\n || update.name === 'callback_query'\n || update.name === 'message_group'\n || update.name === 'new_business_message'\n || update.name === 'edit_business_message'\n || update.name === 'business_message_group')\n ) {\n // no need to fetch scene if there are no registered scenes\n\n if (!parsedContext) parsedContext = _parsedUpdateToContext(this._client, update)\n const key = await this._stateKeyDelegate!(parsedContext as any)\n\n if (key) {\n parsedScene = await this._storage.getCurrentScene(key)\n } else {\n parsedScene = null\n }\n } else {\n parsedScene = null\n }\n }\n\n if (!forceScene && parsedScene !== null) {\n if (this._scene) {\n if (this._scene !== parsedScene) {\n // should not happen, but just in case\n return false\n }\n } else {\n if (!this._scenes || !this._scenes.has(parsedScene)) {\n // not registered scene\n return false\n }\n\n return this._scenes.get(parsedScene)!._dispatchUpdateNowImpl(update, parsedState, parsedScene, true)\n }\n }\n\n if (parsedState === undefined) {\n if (\n this._storage\n && (update.name === 'new_message'\n || update.name === 'edit_message'\n || update.name === 'callback_query'\n || update.name === 'message_group'\n || update.name === 'new_business_message'\n || update.name === 'edit_business_message'\n || update.name === 'business_message_group')\n ) {\n if (!parsedContext) parsedContext = _parsedUpdateToContext(this._client, update)\n const key = await this._stateKeyDelegate!(parsedContext as any)\n\n if (key) {\n let customKey\n\n if (\n !this._customStateKeyDelegate\n || (customKey = await this._customStateKeyDelegate(parsedContext as any))\n ) {\n parsedState = new UpdateState(\n this._storage,\n key,\n this._scene ?? null,\n this._sceneScoped,\n this._customStorage,\n customKey,\n )\n }\n } else {\n parsedState = null\n }\n } else {\n parsedState = null\n }\n }\n\n let shouldDispatch = true\n let shouldDispatchChildren = true\n let handled = false\n\n switch (await this._preUpdateHandler?.(update, parsedState as any)) {\n case 'stop':\n shouldDispatch = false\n break\n case 'stop-children':\n return false\n }\n\n if (shouldDispatch) {\n outer: for (const grp of this._groupsOrder) {\n const group = this._groups.get(grp)!\n\n if (group.has(update.name)) {\n // raw is not handled here, so we can safely assume this\n const handlers = group.get(update.name)! as Exclude<UpdateHandler, RawUpdateHandler>[]\n\n try {\n for (const h of handlers) {\n let result: void | PropagationAction\n\n if (!parsedContext) parsedContext = _parsedUpdateToContext(this._client, update)\n if (!h.check || (await h.check(parsedContext as any, parsedState as never))) {\n result = await h.callback(parsedContext as any, parsedState as never)\n handled = true\n } else {\n continue\n }\n\n if (parsedState && this._scenes) {\n // check if scene transition was made\n const newScene = parsedState.scene\n\n if (parsedScene !== newScene) {\n const nextDp = newScene ? this._scenes.get(newScene) : this._parent\n\n if (!nextDp) {\n throw new MtArgumentError(`Scene ${newScene} not found`)\n }\n\n if (nextDp._sceneTransitionHandler) {\n const transition = new SceneTransitionContext(parsedScene, parsedContext)\n const transitionResult = await nextDp._sceneTransitionHandler?.(\n transition,\n parsedState,\n )\n\n switch (transitionResult) {\n case 'stop':\n return true\n case 'continue':\n continue\n case 'scene': {\n const scene = parsedState.scene\n const dp = scene ? nextDp._scenes!.get(scene)! : nextDp._parent!\n\n // eslint-disable-next-line ts/return-await\n return dp._dispatchUpdateNowImpl(update, undefined, scene, true)\n }\n }\n }\n }\n }\n\n switch (result) {\n case 'continue':\n continue\n case 'stop':\n break outer\n case 'stop-children':\n shouldDispatchChildren = false\n break outer\n\n case 'scene': {\n if (!parsedState) {\n throw new MtArgumentError('Cannot use ToScene without state')\n }\n\n const scene = parsedState.scene\n const dp = scene ? this._scenes!.get(scene)! : this._parent!\n\n // eslint-disable-next-line ts/return-await\n return dp._dispatchUpdateNowImpl(update, undefined, scene, true)\n }\n }\n\n break\n }\n } catch (e: any) {\n if (this._errorHandler) {\n const handled = await this._errorHandler(e, update, parsedState as never)\n if (!handled) throw e\n } else {\n throw e\n }\n }\n }\n }\n }\n\n if (shouldDispatchChildren) {\n for (const child of this._children) {\n const childHandled = await child._dispatchUpdateNowImpl(update)\n handled ||= childHandled\n }\n }\n\n await this._postUpdateHandler?.(handled, update, parsedState as any)\n\n return handled\n }\n\n /**\n * Add an update handler to a given handlers group\n *\n * @param handler Update handler\n * @param group Handler group index\n */\n addUpdateHandler(handler: UpdateHandler, group = 0): void {\n if (!this._groups.has(group)) {\n this._groups.set(group, new Map())\n this._groupsOrder.push(group)\n this._groupsOrder.sort((a, b) => a - b)\n }\n\n if (!this._groups.get(group)!.has(handler.name)) {\n this._groups.get(group)!.set(handler.name, [])\n }\n\n this._groups.get(group)!.get(handler.name)!.push(handler)\n }\n\n /**\n * Remove an update handler (or handlers) from a given\n * handler group.\n *\n * @param handler Update handler to remove, its name or `'all'` to remove all\n * @param group Handler group index (null to affect all groups)\n */\n removeUpdateHandler(handler: UpdateHandler | UpdateHandler['name'] | 'all', group: number | null = 0): void {\n if (group !== null && !this._groups.has(group)) {\n return\n }\n\n if (typeof handler === 'string') {\n if (handler === 'all') {\n if (group === null) {\n this._groups = new Map()\n } else {\n this._groups.delete(group)\n }\n } else if (group !== null) {\n this._groups.get(group)!.delete(handler)\n }\n\n return\n }\n\n if (group === null) return\n\n if (!this._groups.get(group)!.has(handler.name)) {\n return\n }\n\n const idx = this._groups.get(group)!.get(handler.name)!.indexOf(handler)\n\n if (idx > -1) {\n this._groups.get(group)!.get(handler.name)!.splice(idx, 1)\n }\n }\n\n /**\n * Register an error handler.\n *\n * This is used locally within this dispatcher\n * (does not affect children/parent) whenever\n * an error is thrown inside an update handler.\n * Not used for raw update handlers\n *\n * When an error is thrown, but there is no error\n * handler, it is propagated to `TelegramClient`.\n *\n * There can be at most one error handler.\n * Pass `null` to remove it.\n *\n * @param handler Error handler\n */\n onError<T = {}>(\n handler: ((err: Error, update: ParsedUpdate & T, state?: UpdateState<State>) => MaybePromise<boolean>) | null,\n ): void {\n if (handler) this._errorHandler = handler\n else this._errorHandler = undefined\n }\n\n /**\n * Register pre-update middleware.\n *\n * This is used locally within this dispatcher\n * (does not affect children/parent) before processing\n * an update, and can be used to skip this update.\n *\n * There can be at most one pre-update middleware.\n * Pass `null` to remove it.\n *\n * @param handler Pre-update middleware\n */\n onPreUpdate<T = {}>(\n handler:\n | ((update: ParsedUpdate & T, state?: UpdateState<State>) => MaybePromise<PropagationAction | void>)\n | null,\n ): void {\n if (handler) this._preUpdateHandler = handler\n else this._preUpdateHandler = undefined\n }\n\n /**\n * Register post-update middleware.\n *\n * This is used locally within this dispatcher\n * (does not affect children/parent) after successfully\n * processing an update, and can be used for stats.\n *\n * There can be at most one post-update middleware.\n * Pass `null` to remove it.\n *\n * @param handler Pre-update middleware\n */\n onPostUpdate<T = {}>(\n handler:\n | ((handled: boolean, update: ParsedUpdate & T, state?: UpdateState<State>) => MaybePromise<void>)\n | null,\n ): void {\n if (handler) this._postUpdateHandler = handler\n else this._postUpdateHandler = undefined\n }\n\n /**\n * Set error handler that will propagate\n * the error to the parent dispatcher\n */\n propagateErrorToParent(err: Error, update: ParsedUpdate, state?: UpdateState<State>): MaybePromise<boolean> {\n if (!this.parent) {\n throw new MtArgumentError('This dispatcher is not a child')\n }\n\n if (this.parent._errorHandler) {\n return this.parent._errorHandler(err, update, state as any)\n }\n throw err\n }\n\n // children //\n\n /**\n * Get parent dispatcher if current dispatcher is a child.\n * Otherwise, return `null`\n */\n get parent(): Dispatcher<any> | null {\n return this._parent ?? null\n }\n\n private _prepareChild(child: Dispatcher<any>): void {\n if (child._client) {\n throw new MtArgumentError(\n `Provided dispatcher is ${\n child._parent\n ? 'already a child. Use parent.removeChild() before calling addChild()'\n : 'already bound to a client. Use unbind() before calling addChild()'}`,\n )\n }\n\n child._parent = this as any\n child._client = this._client\n child._storage = this._storage\n child._deps = this._deps\n child._scenes = this._scenes\n child._stateKeyDelegate = this._stateKeyDelegate\n child._customStorage ??= this._customStorage\n child._customStateKeyDelegate ??= this._customStateKeyDelegate\n }\n\n /**\n * Add a child dispatcher.\n *\n * Child dispatchers are called when dispatching updates\n * just like normal, except they can be controlled\n * externally. Additionally, child dispatcher have their own\n * independent handler grouping that does not interfere with parent's,\n * including `StopPropagation` (i.e. returning `StopPropagation` will\n * still call children. To entirely stop, use `StopChildrenPropagation`)\n *\n * Note that child dispatchers share the same TelegramClient and\n * storage binding as the parent, don't bind them manually.\n *\n * @param child Other dispatcher\n */\n addChild(child: Dispatcher<State>): void {\n if (this._children.includes(child)) return\n\n this._prepareChild(child)\n this._children.push(child)\n }\n\n /**\n * Add a dispatcher as a scene with a non-scoped state.\n *\n * Scoped storage for a scene means that the scene will\n * have its own storage, that is only available within\n * the scene and does not interfere with global state.\n * Non-scoped, on the other hand, is the same state as\n * the one used for the root dispatcher\n *\n * @param uid UID of the scene\n * @param scene Dispatcher representing the scene\n * @param scoped Whether to use scoped FSM storage for the scene\n */\n addScene(scene: Dispatcher<State>, scoped: false): void\n /**\n * Add a dispatcher as a scene with a scoped state\n *\n * Scoped storage for a scene means that the scene will\n * have its own storage, that is only available within\n * the scene and does not interfere with global state.\n * Non-scoped, on the other hand, is the same state as\n * the one used for the root dispatcher\n *\n * @param uid UID of the scene\n * @param scene Dispatcher representing the scene\n * @param scoped Whether to use scoped FSM storage for the scene (defaults to `true`)\n */\n addScene(scene: Dispatcher<any>, scoped?: true): void\n addScene(scene: Dispatcher<any>, scoped = true): void {\n if (!this._scenes) this._scenes = new Map()\n\n if (!scene._scene) {\n throw new MtArgumentError(\n 'Non-scene dispatcher passed to addScene. Use `Dispatcher.scene()` to create one.',\n )\n }\n\n if (this._scenes.has(scene._scene)) {\n throw new MtArgumentError(`Scene with name ${scene._scene} is already registered!`)\n }\n\n this._prepareChild(scene)\n scene._sceneScoped = scoped\n this._scenes.set(scene._scene, scene)\n }\n\n /**\n * Remove a child dispatcher.\n *\n * Removing child dispatcher will also remove\n * child dispatcher's client binding.\n *\n * If the provided dispatcher is not a child of current,\n * this function will silently fail.\n *\n * @param child Other dispatcher\n */\n removeChild(child: Dispatcher<any>): void {\n const idx = this._children.indexOf(child)\n\n if (idx > -1) {\n child._unparent()\n this._children.splice(idx, 1)\n }\n }\n\n private _unparent(): void {\n this._parent = this._client = undefined\n this._deps = {} // to avoid dangling references\n this._stateKeyDelegate = undefined\n this._storage = undefined\n }\n\n /**\n * Extend current dispatcher by copying other dispatcher's\n * handlers and children to the current.\n *\n * This might be more efficient for simple cases, but do note that the handler\n * groups, children and scenes will get merged (unlike {@link addChild},\n * where they are independent). Also note that unlike with children,\n * when adding handlers to `other` *after* you extended\n * the current dispatcher, changes will not be applied.\n *\n * @param other Other dispatcher\n */\n extend(other: Dispatcher<State>): void {\n if (other._customStorage || other._customStateKeyDelegate) {\n throw new MtArgumentError('Provided dispatcher has custom storage and cannot be extended from.')\n }\n\n other._groupsOrder.forEach((group) => {\n if (!this._groups.has(group)) {\n this._groups.set(group, other._groups.get(group)!)\n this._groupsOrder.push(group)\n } else {\n const otherGrp = other._groups.get(group)!\n const selfGrp = this._groups.get(group)!\n\n for (const typ of otherGrp.keys()) {\n if (!selfGrp.has(typ)) {\n selfGrp.set(typ, otherGrp.get(typ)!)\n } else {\n // selfGrp[typ].push(...otherGrp[typ])\n selfGrp.get(typ)!.push(...otherGrp.get(typ)!)\n }\n }\n }\n })\n\n other._children.forEach((it) => {\n it._unparent()\n this.addChild(it as any)\n })\n\n if (other._scenes) {\n const otherScenes = other._scenes\n if (!this._scenes) this._scenes = new Map()\n const myScenes = this._scenes\n\n for (const key of otherScenes.keys()) {\n otherScenes.get(key)!._unparent()\n\n if (myScenes.has(key)) {\n // will be overwritten\n myScenes.delete(key)\n }\n\n this.addScene(otherScenes.get(key) as any, otherScenes.get(key)!._sceneScoped as any)\n }\n }\n\n this._groupsOrder.sort((a, b) => a - b)\n }\n\n /**\n * Create a clone of this dispatcher, that has the same handlers,\n * but is not bound to a client or to a parent dispatcher.\n *\n * Custom Storage and key delegate are copied too.\n *\n * By default, child dispatchers (and scenes) are ignored, since\n * that requires cloning every single one of them recursively\n * and then binding them back.\n *\n * @param children Whether to also clone children and scenes\n */\n clone(children = false): Dispatcher<State> {\n const dp = new Dispatcher<State>()\n\n // copy handlers.\n for (const key of this._groups.keys()) {\n const idx = key as any as number\n\n dp._groups.set(idx, new Map())\n\n for (const type of this._groups.get(idx)!.keys()) {\n // dp._groups.get(idx)!.set(type, [...this._groups.get(idx)!].get(type)!])\n dp._groups.get(idx)!.set(type, [...this._groups.get(idx)!.get(type)!])\n }\n }\n\n dp._groupsOrder = [...this._groupsOrder]\n dp._errorHandler = this._errorHandler\n dp._customStateKeyDelegate = this._customStateKeyDelegate\n dp._customStorage = this._customStorage\n\n if (children) {\n this._children.forEach((it) => {\n const child = it.clone(true)\n dp.addChild(child as any)\n })\n\n if (this._scenes) {\n for (const key of this._scenes.keys()) {\n const scene = this._scenes.get(key)!.clone(true)\n dp.addScene(scene as any, this._scenes.get(key)!._sceneScoped as any)\n }\n }\n }\n\n return dp\n }\n\n /**\n * Get update state object for the given key.\n *\n * For custom keys, use prefix starting with `$` to avoid\n * clashing with other keys (scene name can't start with `$`)\n *\n * @param key State storage key\n * @template S State type, defaults to dispatcher's state type. Only checked at compile-time\n */\n getState<S extends object = State>(key: string): UpdateState<S>\n\n /**\n * Get update state object for the given object.\n *\n * Equivalent to `getState(string)`, but derives\n * the key with the registered {@link StateKeyDelegate},\n * and since it could be async, this method is async too.\n *\n * @param object Object for which the state should be fetched\n * @template S State type, defaults to dispatcher's state type. Only checked at compile-time\n */\n getState<S extends object = State>(object: Parameters<StateKeyDelegate>[0]): Promise<UpdateState<S>>\n getState<S extends object = State>(object: string | Parameters<StateKeyDelegate>[0]): MaybePromise<UpdateState<S>> {\n if (!this._storage) {\n throw new MtArgumentError('Cannot use getUpdateState() filter without state storage')\n }\n\n if (typeof object === 'string') {\n return new UpdateState(this._storage, object, this._scene ?? null, this._sceneScoped, this._customStorage)\n }\n\n return Promise.resolve(this._stateKeyDelegate!(object)).then((key) => {\n if (!key) {\n throw new MtArgumentError('Cannot derive key from given object')\n }\n\n if (!this._customStateKeyDelegate) {\n return new UpdateState(this._storage!, key, this._scene ?? null, this._sceneScoped, this._customStorage)\n }\n\n return Promise.resolve(this._customStateKeyDelegate(object)).then((customKey) => {\n if (!customKey) {\n throw new MtArgumentError('Cannot derive custom key from given object')\n }\n\n return new UpdateState(\n this._storage!,\n key,\n this._scene ?? null,\n this._sceneScoped,\n this._customStorage,\n customKey,\n )\n })\n })\n }\n\n /**\n * Get global state.\n *\n * This will load the state for the given object\n * ignoring local custom storage, key delegate and scene scope.\n */\n getGlobalState<T extends object>(object: Parameters<StateKeyDelegate>[0]): Promise<UpdateState<T>> {\n if (!this._parent) {\n throw new MtArgumentError('This dispatcher does not have a parent')\n }\n\n return Promise.resolve(this._stateKeyDelegate!(object)).then((key) => {\n if (!key) {\n throw new MtArgumentError('Cannot derive key from given object')\n }\n\n return new UpdateState(this._storage!, key, this._scene ?? null, false)\n })\n }\n\n // addUpdateHandler convenience wrappers //\n\n private _addKnownHandler(name: UpdateHandler['name'], filter: any, handler?: any, group?: number): void {\n if (typeof handler === 'number' || typeof handler === 'undefined') {\n this.addUpdateHandler(\n {\n name,\n callback: filter,\n } as UpdateHandler,\n handler,\n )\n } else {\n this.addUpdateHandler(\n {\n name,\n callback: handler,\n check: filter,\n } as UpdateHandler,\n group,\n )\n }\n }\n\n /**\n * Register a raw update handler without any filters\n *\n * @param handler Raw update handler\n * @param group Handler group index\n */\n onRawUpdate(handler: RawUpdateHandler['callback'], group?: number): void\n\n /**\n * Register a raw update handler without any filters\n *\n * @param filter Update filter\n * @param handler Raw update handler\n * @param group Handler group index\n */\n onRawUpdate(filter: RawUpdateHandler['check'], handler: RawUpdateHandler['callback'], group?: number): void\n\n /** @internal */\n onRawUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('raw', filter, handler, group)\n }\n\n /**\n * Register a scene transition handler\n *\n * This handler is called whenever a scene transition occurs\n * in the context of the scene that is being entered,\n * and before any of the its own handlers are called,\n * and can be used to customize the transition behavior:\n * - `Stop` to prevent dispatching the update any further **even if ToScene/ToRoot was used**\n * - `Continue` same as Stop, but still dispatch the update to children\n * - `ToScene` to prevent the transition and dispatch the update to the scene entered in the transition handler\n *\n * > **Note**: if multiple `state.enter()` calls were made within the same update,\n * > this handler will only be called for the last one.\n *\n * @param handler Raw update handler\n * @param group Handler group index\n */\n onSceneTransition(\n handler:\n | ((ctx: SceneTransitionContext, state: UpdateState<State>) => MaybePromise<PropagationAction | void>)\n | null,\n ): void {\n if (handler) this._sceneTransitionHandler = handler\n else this._sceneTransitionHandler = undefined\n }\n\n /**\n * Register a callback query (both inline and non-inline) handler without any filters\n *\n * @param handler Callback query handler\n * @param group Handler group index\n */\n onAnyCallbackQuery(\n handler: CallbackQueryHandler<\n CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a callback query (both inline and non-inline) handler with a filter\n *\n * @param filter Update filter\n * @param handler Callback query handler\n * @param group Handler group index\n */\n onAnyCallbackQuery<Mod>(\n filter: UpdateFilter<\n CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext,\n Mod,\n State\n >,\n handler: CallbackQueryHandler<\n filters.Modify<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a callback query (both inline and non-inline) handler with a filter\n *\n * @param filter Update filter\n * @param handler Callback query handler\n * @param group Handler group index\n */\n onAnyCallbackQuery<Mod>(\n filter: UpdateFilter<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, Mod>,\n handler: CallbackQueryHandler<\n filters.Modify<CallbackQueryContext | InlineCallbackQueryContext | BusinessCallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onAnyCallbackQuery(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('callback_query', filter, handler, group)\n this._addKnownHandler('inline_callback_query', filter, handler, group)\n this._addKnownHandler('business_callback_query', filter, handler, group)\n }\n\n // begin-codegen\n\n /**\n * Register a new message handler without any filters\n *\n * @param handler New message handler\n * @param group Handler group index\n */\n onNewMessage(\n handler: NewMessageHandler<MessageContext, State extends never ? never : UpdateState<State>>['callback'],\n group?: number,\n ): void\n\n /**\n * Register a new message handler with a filter\n *\n * @param filter Update filter\n * @param handler New message handler\n * @param group Handler group index\n */\n onNewMessage<Mod>(\n filter: UpdateFilter<MessageContext, Mod, State>,\n handler: NewMessageHandler<\n filters.Modify<MessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a new message handler with a filter\n *\n * @param filter Update filter\n * @param handler New message handler\n * @param group Handler group index\n */\n onNewMessage<Mod>(\n filter: UpdateFilter<MessageContext, Mod>,\n handler: NewMessageHandler<\n filters.Modify<MessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onNewMessage(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('new_message', filter, handler, group)\n }\n\n /**\n * Register an edit message handler without any filters\n *\n * @param handler Edit message handler\n * @param group Handler group index\n */\n onEditMessage(\n handler: EditMessageHandler<MessageContext, State extends never ? never : UpdateState<State>>['callback'],\n group?: number,\n ): void\n\n /**\n * Register an edit message handler with a filter\n *\n * @param filter Update filter\n * @param handler Edit message handler\n * @param group Handler group index\n */\n onEditMessage<Mod>(\n filter: UpdateFilter<MessageContext, Mod, State>,\n handler: EditMessageHandler<\n filters.Modify<MessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register an edit message handler with a filter\n *\n * @param filter Update filter\n * @param handler Edit message handler\n * @param group Handler group index\n */\n onEditMessage<Mod>(\n filter: UpdateFilter<MessageContext, Mod>,\n handler: EditMessageHandler<\n filters.Modify<MessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onEditMessage(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('edit_message', filter, handler, group)\n }\n\n /**\n * Register a message group handler without any filters\n *\n * @param handler Message group handler\n * @param group Handler group index\n */\n onMessageGroup(\n handler: MessageGroupHandler<MessageContext, State extends never ? never : UpdateState<State>>['callback'],\n group?: number,\n ): void\n\n /**\n * Register a message group handler with a filter\n *\n * @param filter Update filter\n * @param handler Message group handler\n * @param group Handler group index\n */\n onMessageGroup<Mod>(\n filter: UpdateFilter<MessageContext, Mod, State>,\n handler: MessageGroupHandler<\n filters.Modify<MessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a message group handler with a filter\n *\n * @param filter Update filter\n * @param handler Message group handler\n * @param group Handler group index\n */\n onMessageGroup<Mod>(\n filter: UpdateFilter<MessageContext, Mod>,\n handler: MessageGroupHandler<\n filters.Modify<MessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onMessageGroup(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('message_group', filter, handler, group)\n }\n\n /**\n * Register a delete message handler without any filters\n *\n * @param handler Delete message handler\n * @param group Handler group index\n */\n onDeleteMessage(handler: DeleteMessageHandler['callback'], group?: number): void\n\n /**\n * Register a delete message handler with a filter\n *\n * @param filter Update filter\n * @param handler Delete message handler\n * @param group Handler group index\n */\n onDeleteMessage<Mod>(\n filter: UpdateFilter<UpdateContext<DeleteMessageUpdate>, Mod>,\n handler: DeleteMessageHandler<filters.Modify<UpdateContext<DeleteMessageUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onDeleteMessage(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('delete_message', filter, handler, group)\n }\n\n /**\n * Register a chat member update handler without any filters\n *\n * @param handler Chat member update handler\n * @param group Handler group index\n */\n onChatMemberUpdate(handler: ChatMemberUpdateHandler['callback'], group?: number): void\n\n /**\n * Register a chat member update handler with a filter\n *\n * @param filter Update filter\n * @param handler Chat member update handler\n * @param group Handler group index\n */\n onChatMemberUpdate<Mod>(\n filter: UpdateFilter<UpdateContext<ChatMemberUpdate>, Mod>,\n handler: ChatMemberUpdateHandler<filters.Modify<UpdateContext<ChatMemberUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onChatMemberUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('chat_member', filter, handler, group)\n }\n\n /**\n * Register an inline query handler without any filters\n *\n * @param handler Inline query handler\n * @param group Handler group index\n */\n onInlineQuery(handler: InlineQueryHandler['callback'], group?: number): void\n\n /**\n * Register an inline query handler with a filter\n *\n * @param filter Update filter\n * @param handler Inline query handler\n * @param group Handler group index\n */\n onInlineQuery<Mod>(\n filter: UpdateFilter<InlineQueryContext, Mod>,\n handler: InlineQueryHandler<filters.Modify<InlineQueryContext, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onInlineQuery(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('inline_query', filter, handler, group)\n }\n\n /**\n * Register a chosen inline result handler without any filters\n *\n * @param handler Chosen inline result handler\n * @param group Handler group index\n */\n onChosenInlineResult(handler: ChosenInlineResultHandler['callback'], group?: number): void\n\n /**\n * Register a chosen inline result handler with a filter\n *\n * @param filter Update filter\n * @param handler Chosen inline result handler\n * @param group Handler group index\n */\n onChosenInlineResult<Mod>(\n filter: UpdateFilter<ChosenInlineResultContext, Mod>,\n handler: ChosenInlineResultHandler<filters.Modify<ChosenInlineResultContext, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onChosenInlineResult(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('chosen_inline_result', filter, handler, group)\n }\n\n /**\n * Register a callback query handler without any filters\n *\n * @param handler Callback query handler\n * @param group Handler group index\n */\n onCallbackQuery(\n handler: CallbackQueryHandler<\n CallbackQueryContext,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a callback query handler with a filter\n *\n * @param filter Update filter\n * @param handler Callback query handler\n * @param group Handler group index\n */\n onCallbackQuery<Mod>(\n filter: UpdateFilter<CallbackQueryContext, Mod, State>,\n handler: CallbackQueryHandler<\n filters.Modify<CallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a callback query handler with a filter\n *\n * @param filter Update filter\n * @param handler Callback query handler\n * @param group Handler group index\n */\n onCallbackQuery<Mod>(\n filter: UpdateFilter<CallbackQueryContext, Mod>,\n handler: CallbackQueryHandler<\n filters.Modify<CallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onCallbackQuery(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('callback_query', filter, handler, group)\n }\n\n /**\n * Register an inline callback query handler without any filters\n *\n * @param handler Inline callback query handler\n * @param group Handler group index\n */\n onInlineCallbackQuery(\n handler: InlineCallbackQueryHandler<\n InlineCallbackQueryContext,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register an inline callback query handler with a filter\n *\n * @param filter Update filter\n * @param handler Inline callback query handler\n * @param group Handler group index\n */\n onInlineCallbackQuery<Mod>(\n filter: UpdateFilter<InlineCallbackQueryContext, Mod, State>,\n handler: InlineCallbackQueryHandler<\n filters.Modify<InlineCallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register an inline callback query handler with a filter\n *\n * @param filter Update filter\n * @param handler Inline callback query handler\n * @param group Handler group index\n */\n onInlineCallbackQuery<Mod>(\n filter: UpdateFilter<InlineCallbackQueryContext, Mod>,\n handler: InlineCallbackQueryHandler<\n filters.Modify<InlineCallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onInlineCallbackQuery(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('inline_callback_query', filter, handler, group)\n }\n\n /**\n * Register a business callback query handler without any filters\n *\n * @param handler Business callback query handler\n * @param group Handler group index\n */\n onBusinessCallbackQuery(\n handler: BusinessCallbackQueryHandler<\n BusinessCallbackQueryContext,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a business callback query handler with a filter\n *\n * @param filter Update filter\n * @param handler Business callback query handler\n * @param group Handler group index\n */\n onBusinessCallbackQuery<Mod>(\n filter: UpdateFilter<BusinessCallbackQueryContext, Mod, State>,\n handler: BusinessCallbackQueryHandler<\n filters.Modify<BusinessCallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a business callback query handler with a filter\n *\n * @param filter Update filter\n * @param handler Business callback query handler\n * @param group Handler group index\n */\n onBusinessCallbackQuery<Mod>(\n filter: UpdateFilter<BusinessCallbackQueryContext, Mod>,\n handler: BusinessCallbackQueryHandler<\n filters.Modify<BusinessCallbackQueryContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onBusinessCallbackQuery(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('business_callback_query', filter, handler, group)\n }\n\n /**\n * Register a poll update handler without any filters\n *\n * @param handler Poll update handler\n * @param group Handler group index\n */\n onPollUpdate(handler: PollUpdateHandler['callback'], group?: number): void\n\n /**\n * Register a poll update handler with a filter\n *\n * @param filter Update filter\n * @param handler Poll update handler\n * @param group Handler group index\n */\n onPollUpdate<Mod>(\n filter: UpdateFilter<UpdateContext<PollUpdate>, Mod>,\n handler: PollUpdateHandler<filters.Modify<UpdateContext<PollUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onPollUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('poll', filter, handler, group)\n }\n\n /**\n * Register a poll vote handler without any filters\n *\n * @param handler Poll vote handler\n * @param group Handler group index\n */\n onPollVote(handler: PollVoteHandler['callback'], group?: number): void\n\n /**\n * Register a poll vote handler with a filter\n *\n * @param filter Update filter\n * @param handler Poll vote handler\n * @param group Handler group index\n */\n onPollVote<Mod>(\n filter: UpdateFilter<UpdateContext<PollVoteUpdate>, Mod>,\n handler: PollVoteHandler<filters.Modify<UpdateContext<PollVoteUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onPollVote(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('poll_vote', filter, handler, group)\n }\n\n /**\n * Register an user status update handler without any filters\n *\n * @param handler User status update handler\n * @param group Handler group index\n */\n onUserStatusUpdate(handler: UserStatusUpdateHandler['callback'], group?: number): void\n\n /**\n * Register an user status update handler with a filter\n *\n * @param filter Update filter\n * @param handler User status update handler\n * @param group Handler group index\n */\n onUserStatusUpdate<Mod>(\n filter: UpdateFilter<UpdateContext<UserStatusUpdate>, Mod>,\n handler: UserStatusUpdateHandler<filters.Modify<UpdateContext<UserStatusUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onUserStatusUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('user_status', filter, handler, group)\n }\n\n /**\n * Register an user typing handler without any filters\n *\n * @param handler User typing handler\n * @param group Handler group index\n */\n onUserTyping(handler: UserTypingHandler['callback'], group?: number): void\n\n /**\n * Register an user typing handler with a filter\n *\n * @param filter Update filter\n * @param handler User typing handler\n * @param group Handler group index\n */\n onUserTyping<Mod>(\n filter: UpdateFilter<UpdateContext<UserTypingUpdate>, Mod>,\n handler: UserTypingHandler<filters.Modify<UpdateContext<UserTypingUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onUserTyping(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('user_typing', filter, handler, group)\n }\n\n /**\n * Register a history read handler without any filters\n *\n * @param handler History read handler\n * @param group Handler group index\n */\n onHistoryRead(handler: HistoryReadHandler['callback'], group?: number): void\n\n /**\n * Register a history read handler with a filter\n *\n * @param filter Update filter\n * @param handler History read handler\n * @param group Handler group index\n */\n onHistoryRead<Mod>(\n filter: UpdateFilter<UpdateContext<HistoryReadUpdate>, Mod>,\n handler: HistoryReadHandler<filters.Modify<UpdateContext<HistoryReadUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onHistoryRead(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('history_read', filter, handler, group)\n }\n\n /**\n * Register a bot stopped handler without any filters\n *\n * @param handler Bot stopped handler\n * @param group Handler group index\n */\n onBotStopped(handler: BotStoppedHandler['callback'], group?: number): void\n\n /**\n * Register a bot stopped handler with a filter\n *\n * @param filter Update filter\n * @param handler Bot stopped handler\n * @param group Handler group index\n */\n onBotStopped<Mod>(\n filter: UpdateFilter<UpdateContext<BotStoppedUpdate>, Mod>,\n handler: BotStoppedHandler<filters.Modify<UpdateContext<BotStoppedUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onBotStopped(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('bot_stopped', filter, handler, group)\n }\n\n /**\n * Register a bot chat join request handler without any filters\n *\n * @param handler Bot chat join request handler\n * @param group Handler group index\n */\n onBotChatJoinRequest(handler: BotChatJoinRequestHandler['callback'], group?: number): void\n\n /**\n * Register a bot chat join request handler with a filter\n *\n * @param filter Update filter\n * @param handler Bot chat join request handler\n * @param group Handler group index\n */\n onBotChatJoinRequest<Mod>(\n filter: UpdateFilter<ChatJoinRequestUpdateContext, Mod>,\n handler: BotChatJoinRequestHandler<filters.Modify<ChatJoinRequestUpdateContext, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onBotChatJoinRequest(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('bot_chat_join_request', filter, handler, group)\n }\n\n /**\n * Register a chat join request handler without any filters\n *\n * @param handler Chat join request handler\n * @param group Handler group index\n */\n onChatJoinRequest(handler: ChatJoinRequestHandler['callback'], group?: number): void\n\n /**\n * Register a chat join request handler with a filter\n *\n * @param filter Update filter\n * @param handler Chat join request handler\n * @param group Handler group index\n */\n onChatJoinRequest<Mod>(\n filter: UpdateFilter<UpdateContext<ChatJoinRequestUpdate>, Mod>,\n handler: ChatJoinRequestHandler<filters.Modify<UpdateContext<ChatJoinRequestUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onChatJoinRequest(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('chat_join_request', filter, handler, group)\n }\n\n /**\n * Register a pre checkout query handler without any filters\n *\n * @param handler Pre checkout query handler\n * @param group Handler group index\n */\n onPreCheckoutQuery(handler: PreCheckoutQueryHandler['callback'], group?: number): void\n\n /**\n * Register a pre checkout query handler with a filter\n *\n * @param filter Update filter\n * @param handler Pre checkout query handler\n * @param group Handler group index\n */\n onPreCheckoutQuery<Mod>(\n filter: UpdateFilter<PreCheckoutQueryContext, Mod>,\n handler: PreCheckoutQueryHandler<filters.Modify<PreCheckoutQueryContext, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onPreCheckoutQuery(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('pre_checkout_query', filter, handler, group)\n }\n\n /**\n * Register a story update handler without any filters\n *\n * @param handler Story update handler\n * @param group Handler group index\n */\n onStoryUpdate(handler: StoryUpdateHandler['callback'], group?: number): void\n\n /**\n * Register a story update handler with a filter\n *\n * @param filter Update filter\n * @param handler Story update handler\n * @param group Handler group index\n */\n onStoryUpdate<Mod>(\n filter: UpdateFilter<UpdateContext<StoryUpdate>, Mod>,\n handler: StoryUpdateHandler<filters.Modify<UpdateContext<StoryUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onStoryUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('story', filter, handler, group)\n }\n\n /**\n * Register a delete story handler without any filters\n *\n * @param handler Delete story handler\n * @param group Handler group index\n */\n onDeleteStory(handler: DeleteStoryHandler['callback'], group?: number): void\n\n /**\n * Register a delete story handler with a filter\n *\n * @param filter Update filter\n * @param handler Delete story handler\n * @param group Handler group index\n */\n onDeleteStory<Mod>(\n filter: UpdateFilter<UpdateContext<DeleteStoryUpdate>, Mod>,\n handler: DeleteStoryHandler<filters.Modify<UpdateContext<DeleteStoryUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onDeleteStory(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('delete_story', filter, handler, group)\n }\n\n /**\n * Register a bot reaction update handler without any filters\n *\n * @param handler Bot reaction update handler\n * @param group Handler group index\n */\n onBotReactionUpdate(handler: BotReactionUpdateHandler['callback'], group?: number): void\n\n /**\n * Register a bot reaction update handler with a filter\n *\n * @param filter Update filter\n * @param handler Bot reaction update handler\n * @param group Handler group index\n */\n onBotReactionUpdate<Mod>(\n filter: UpdateFilter<UpdateContext<BotReactionUpdate>, Mod>,\n handler: BotReactionUpdateHandler<filters.Modify<UpdateContext<BotReactionUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onBotReactionUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('bot_reaction', filter, handler, group)\n }\n\n /**\n * Register a bot reaction count update handler without any filters\n *\n * @param handler Bot reaction count update handler\n * @param group Handler group index\n */\n onBotReactionCountUpdate(handler: BotReactionCountUpdateHandler['callback'], group?: number): void\n\n /**\n * Register a bot reaction count update handler with a filter\n *\n * @param filter Update filter\n * @param handler Bot reaction count update handler\n * @param group Handler group index\n */\n onBotReactionCountUpdate<Mod>(\n filter: UpdateFilter<UpdateContext<BotReactionCountUpdate>, Mod>,\n handler: BotReactionCountUpdateHandler<filters.Modify<UpdateContext<BotReactionCountUpdate>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onBotReactionCountUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('bot_reaction_count', filter, handler, group)\n }\n\n /**\n * Register a business connection update handler without any filters\n *\n * @param handler Business connection update handler\n * @param group Handler group index\n */\n onBusinessConnectionUpdate(handler: BusinessConnectionUpdateHandler['callback'], group?: number): void\n\n /**\n * Register a business connection update handler with a filter\n *\n * @param filter Update filter\n * @param handler Business connection update handler\n * @param group Handler group index\n */\n onBusinessConnectionUpdate<Mod>(\n filter: UpdateFilter<UpdateContext<BusinessConnection>, Mod>,\n handler: BusinessConnectionUpdateHandler<filters.Modify<UpdateContext<BusinessConnection>, Mod>>['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onBusinessConnectionUpdate(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('business_connection', filter, handler, group)\n }\n\n /**\n * Register a new business message handler without any filters\n *\n * @param handler New business message handler\n * @param group Handler group index\n */\n onNewBusinessMessage(\n handler: NewBusinessMessageHandler<\n BusinessMessageContext,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a new business message handler with a filter\n *\n * @param filter Update filter\n * @param handler New business message handler\n * @param group Handler group index\n */\n onNewBusinessMessage<Mod>(\n filter: UpdateFilter<BusinessMessageContext, Mod, State>,\n handler: NewBusinessMessageHandler<\n filters.Modify<BusinessMessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a new business message handler with a filter\n *\n * @param filter Update filter\n * @param handler New business message handler\n * @param group Handler group index\n */\n onNewBusinessMessage<Mod>(\n filter: UpdateFilter<BusinessMessageContext, Mod>,\n handler: NewBusinessMessageHandler<\n filters.Modify<BusinessMessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onNewBusinessMessage(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('new_business_message', filter, handler, group)\n }\n\n /**\n * Register an edit business message handler without any filters\n *\n * @param handler Edit business message handler\n * @param group Handler group index\n */\n onEditBusinessMessage(\n handler: EditBusinessMessageHandler<\n BusinessMessageContext,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register an edit business message handler with a filter\n *\n * @param filter Update filter\n * @param handler Edit business message handler\n * @param group Handler group index\n */\n onEditBusinessMessage<Mod>(\n filter: UpdateFilter<BusinessMessageContext, Mod, State>,\n handler: EditBusinessMessageHandler<\n filters.Modify<BusinessMessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register an edit business message handler with a filter\n *\n * @param filter Update filter\n * @param handler Edit business message handler\n * @param group Handler group index\n */\n onEditBusinessMessage<Mod>(\n filter: UpdateFilter<BusinessMessageContext, Mod>,\n handler: EditBusinessMessageHandler<\n filters.Modify<BusinessMessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onEditBusinessMessage(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('edit_business_message', filter, handler, group)\n }\n\n /**\n * Register a business message group handler without any filters\n *\n * @param handler Business message group handler\n * @param group Handler group index\n */\n onBusinessMessageGroup(\n handler: BusinessMessageGroupHandler<\n BusinessMessageContext,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a business message group handler with a filter\n *\n * @param filter Update filter\n * @param handler Business message group handler\n * @param group Handler group index\n */\n onBusinessMessageGroup<Mod>(\n filter: UpdateFilter<BusinessMessageContext, Mod, State>,\n handler: BusinessMessageGroupHandler<\n filters.Modify<BusinessMessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /**\n * Register a business message group handler with a filter\n *\n * @param filter Update filter\n * @param handler Business message group handler\n * @param group Handler group index\n */\n onBusinessMessageGroup<Mod>(\n filter: UpdateFilter<BusinessMessageContext, Mod>,\n handler: BusinessMessageGroupHandler<\n filters.Modify<BusinessMessageContext, Mod>,\n State extends never ? never : UpdateState<State>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onBusinessMessageGroup(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('business_message_group', filter, handler, group)\n }\n\n /**\n * Register a delete business message handler without any filters\n *\n * @param handler Delete business message handler\n * @param group Handler group index\n */\n onDeleteBusinessMessage(handler: DeleteBusinessMessageHandler['callback'], group?: number): void\n\n /**\n * Register a delete business message handler with a filter\n *\n * @param filter Update filter\n * @param handler Delete business message handler\n * @param group Handler group index\n */\n onDeleteBusinessMessage<Mod>(\n filter: UpdateFilter<UpdateContext<DeleteBusinessMessageUpdate>, Mod>,\n handler: DeleteBusinessMessageHandler<\n filters.Modify<UpdateContext<DeleteBusinessMessageUpdate>, Mod>\n >['callback'],\n group?: number,\n ): void\n\n /** @internal */\n onDeleteBusinessMessage(filter: any, handler?: any, group?: number): void {\n this._addKnownHandler('delete_business_message', filter, handler, group)\n }\n\n // end-codegen\n}\n"]}
@@ -1,64 +0,0 @@
1
- import type { Chat, MaybeArray } from '@mtcute/core';
2
- import type { BusinessMessageContext } from '../context/business-message.js';
3
- import type { MessageContext } from '../context/message.js';
4
- import type { Modify, UpdateFilter } from './types.js';
5
- /**
6
- * Filter messages that call the given command(s)..
7
- *
8
- * When a command matches, the match array is stored in a
9
- * type-safe extension field `.commmand` of the {@link Message} object.
10
- * First element is the command itself, then the arguments.
11
- *
12
- * If the matched command was a RegExp, the first element is the
13
- * command, then the groups from the command regex, then the arguments.
14
- *
15
- * @param commands Command(s) the filter should look for (w/out prefix)
16
- * @param prefixes
17
- * Prefix(es) the filter should look for (default: `/`).
18
- * Can be `null` to disable prefixes altogether
19
- * @param caseSensitive
20
- */
21
- export declare function command(commands: MaybeArray<string | RegExp>, { prefixes, caseSensitive, }?: {
22
- prefixes?: MaybeArray<string> | null;
23
- caseSensitive?: boolean;
24
- }): UpdateFilter<MessageContext | BusinessMessageContext, {
25
- command: string[];
26
- }>;
27
- /**
28
- * Shorthand filter that matches /start commands sent to bot's
29
- * private messages.
30
- */
31
- export declare const start: UpdateFilter<MessageContext | BusinessMessageContext, {
32
- chat: Modify<Chat, {
33
- chatType: 'private';
34
- }>;
35
- command: string[];
36
- }>;
37
- /**
38
- * Shorthand filter that matches /start commands
39
- * sent in groups (i.e. using `?startgroup` parameter).
40
- */
41
- export declare const startGroup: UpdateFilter<MessageContext | BusinessMessageContext, {
42
- chat: Modify<Chat, {
43
- chatType: 'group' | 'supergroup';
44
- }>;
45
- command: string[];
46
- }, never>;
47
- /**
48
- * Filter for deep links (i.e. `/start <deeplink_parameter>`).
49
- *
50
- * If the parameter is a regex, groups are added to `msg.command`,
51
- * meaning that the first group is available in `msg.command[2]`.
52
- */
53
- export declare const deeplink: (params: MaybeArray<string | RegExp>) => UpdateFilter<MessageContext | BusinessMessageContext, {
54
- command: string[];
55
- }>;
56
- /**
57
- * Filter for group deep links (i.e. `/start <deeplink_parameter>`).
58
- *
59
- * If the parameter is a regex, groups are added to `msg.command`,
60
- * meaning that the first group is available in `msg.command[2]`.
61
- */
62
- export declare const deeplinkGroup: (params: MaybeArray<string | RegExp>) => UpdateFilter<MessageContext | BusinessMessageContext, {
63
- command: string[];
64
- }>;
@@ -1,131 +0,0 @@
1
- import { chat } from './chat.js';
2
- import { and, or } from './logic.js';
3
- /**
4
- * Filter messages that call the given command(s)..
5
- *
6
- * When a command matches, the match array is stored in a
7
- * type-safe extension field `.commmand` of the {@link Message} object.
8
- * First element is the command itself, then the arguments.
9
- *
10
- * If the matched command was a RegExp, the first element is the
11
- * command, then the groups from the command regex, then the arguments.
12
- *
13
- * @param commands Command(s) the filter should look for (w/out prefix)
14
- * @param prefixes
15
- * Prefix(es) the filter should look for (default: `/`).
16
- * Can be `null` to disable prefixes altogether
17
- * @param caseSensitive
18
- */
19
- export function command(commands, { prefixes = '/', caseSensitive = false, } = {}) {
20
- if (!Array.isArray(commands))
21
- commands = [commands];
22
- if (!caseSensitive) {
23
- commands = commands.map(i => (typeof i === 'string' ? i.toLowerCase() : i));
24
- }
25
- const argumentsRe = /(["'])(.*?)(?<!\\)\1|(\S+)/g;
26
- const unescapeRe = /\\(['"])/;
27
- const commandsRe = [];
28
- commands.forEach((cmd) => {
29
- if (typeof cmd !== 'string')
30
- cmd = cmd.source;
31
- commandsRe.push(new RegExp(`^(${cmd})(?:\\s|$|@([a-zA-Z0-9_]+?bot)(?:\\s|$))`, caseSensitive ? '' : 'i'));
32
- });
33
- if (prefixes === null)
34
- prefixes = [];
35
- if (typeof prefixes === 'string')
36
- prefixes = [prefixes];
37
- const _prefixes = prefixes;
38
- const check = (msg) => {
39
- if (msg.isMessageGroup)
40
- return check(msg.messages[0]);
41
- for (const pref of _prefixes) {
42
- if (!msg.text.startsWith(pref))
43
- continue;
44
- const withoutPrefix = msg.text.slice(pref.length);
45
- for (const regex of commandsRe) {
46
- const m = withoutPrefix.match(regex);
47
- if (!m)
48
- continue;
49
- const lastGroup = m[m.length - 1];
50
- if (lastGroup) {
51
- const self = msg.client.storage.self.getCached();
52
- if (self && self.isBot && !self.usernames.includes(lastGroup)) {
53
- return false;
54
- }
55
- }
56
- const match = m.slice(1, -1);
57
- if (!caseSensitive)
58
- match[0] = match[0].toLowerCase();
59
- // we use .replace to iterate over global regex, not to replace the text
60
- withoutPrefix.slice(m[0].length).replace(argumentsRe, ($0, $1, $2, $3) => {
61
- match.push(($2 || $3 || '').replace(unescapeRe, '$1'));
62
- return '';
63
- });
64
- msg.command = match;
65
- return true;
66
- }
67
- }
68
- return false;
69
- };
70
- return check;
71
- }
72
- /**
73
- * Shorthand filter that matches /start commands sent to bot's
74
- * private messages.
75
- */
76
- export const start = and(chat('private'), command('start'));
77
- /**
78
- * Shorthand filter that matches /start commands
79
- * sent in groups (i.e. using `?startgroup` parameter).
80
- */
81
- export const startGroup = and(or(chat('supergroup'), chat('group')), command('start'));
82
- function deeplinkBase(base) {
83
- return (params) => {
84
- if (!Array.isArray(params)) {
85
- return and(start, (_msg) => {
86
- const msg = _msg;
87
- if (msg.command.length !== 2)
88
- return false;
89
- const p = msg.command[1];
90
- if (typeof params === 'string' && p === params)
91
- return true;
92
- const m = p.match(params);
93
- if (!m)
94
- return false;
95
- msg.command.push(...m.slice(1));
96
- return true;
97
- });
98
- }
99
- return and(base, (_msg) => {
100
- const msg = _msg;
101
- if (msg.command.length !== 2)
102
- return false;
103
- const p = msg.command[1];
104
- for (const param of params) {
105
- if (typeof param === 'string' && p === param)
106
- return true;
107
- const m = p.match(param);
108
- if (!m)
109
- continue;
110
- msg.command.push(...m.slice(1));
111
- return true;
112
- }
113
- return false;
114
- });
115
- };
116
- }
117
- /**
118
- * Filter for deep links (i.e. `/start <deeplink_parameter>`).
119
- *
120
- * If the parameter is a regex, groups are added to `msg.command`,
121
- * meaning that the first group is available in `msg.command[2]`.
122
- */
123
- export const deeplink = deeplinkBase(start);
124
- /**
125
- * Filter for group deep links (i.e. `/start <deeplink_parameter>`).
126
- *
127
- * If the parameter is a regex, groups are added to `msg.command`,
128
- * meaning that the first group is available in `msg.command[2]`.
129
- */
130
- export const deeplinkGroup = deeplinkBase(startGroup);
131
- //# sourceMappingURL=bots.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bots.js","sourceRoot":"","sources":["../../../src/filters/bots.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,YAAY,CAAA;AAGpC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,OAAO,CAAC,QAAqC,EAAE,EAC3D,QAAQ,GAAG,GAAG,EACd,aAAa,GAAG,KAAK,MAIrB,EAAE;IACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,QAAQ,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEnD,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/E,CAAC;IAED,MAAM,WAAW,GAAG,6BAA6B,CAAA;IACjD,MAAM,UAAU,GAAG,UAAU,CAAA;IAC7B,MAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACrB,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,GAAG,GAAG,GAAG,CAAC,MAAM,CAAA;QAE7C,UAAU,CAAC,IAAI,CAAC,IA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ACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,YAAY,CAAC,KAAK,CAAC,CAAA;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAGtB,YAAY,CAAC,UAAU,CAAC,CAAA","sourcesContent":["import type { Chat, MaybeArray, MaybePromise, Message } from '@mtcute/core'\n\nimport type { BusinessMessageContext } from '../context/business-message.js'\nimport type { MessageContext } from '../context/message.js'\n\nimport { chat } from './chat.js'\nimport { and, or } from './logic.js'\nimport type { Modify, UpdateFilter } from './types.js'\n\n/**\n * Filter messages that call the given command(s)..\n *\n * When a command matches, the match array is stored in a\n * type-safe extension field `.commmand` of the {@link Message} object.\n * First element is the command itself, then the arguments.\n *\n * If the matched command was a RegExp, the first element is the\n * command, then the groups from the command regex, then the arguments.\n *\n * @param commands Command(s) the filter should look for (w/out prefix)\n * @param prefixes\n * Prefix(es) the filter should look for (default: `/`).\n * Can be `null` to disable prefixes altogether\n * @param caseSensitive\n */\nexport function command(commands: MaybeArray<string | RegExp>, {\n prefixes = '/',\n caseSensitive = false,\n}: {\n prefixes?: MaybeArray<string> | null\n caseSensitive?: boolean\n} = {}): UpdateFilter<MessageContext | BusinessMessageContext, { command: string[] }> {\n if (!Array.isArray(commands)) commands = [commands]\n\n if (!caseSensitive) {\n commands = commands.map(i => (typeof i === 'string' ? i.toLowerCase() : i))\n }\n\n const argumentsRe = /([\"'])(.*?)(?<!\\\\)\\1|(\\S+)/g\n const unescapeRe = /\\\\(['\"])/\n const commandsRe: RegExp[] = []\n commands.forEach((cmd) => {\n if (typeof cmd !== 'string') cmd = cmd.source\n\n commandsRe.push(new RegExp(`^(${cmd})(?:\\\\s|$|@([a-zA-Z0-9_]+?bot)(?:\\\\s|$))`, caseSensitive ? '' : 'i'))\n })\n\n if (prefixes === null) prefixes = []\n if (typeof prefixes === 'string') prefixes = [prefixes]\n\n const _prefixes = prefixes\n\n const check = (msg: MessageContext | BusinessMessageContext): MaybePromise<boolean> => {\n if (msg.isMessageGroup) return check(msg.messages[0])\n\n for (const pref of _prefixes) {\n if (!msg.text.startsWith(pref)) continue\n\n const withoutPrefix = msg.text.slice(pref.length)\n\n for (const regex of commandsRe) {\n const m = withoutPrefix.match(regex)\n if (!m) continue\n\n const lastGroup = m[m.length - 1]\n\n if (lastGroup) {\n const self = msg.client.storage.self.getCached()\n\n if (self && self.isBot && !self.usernames.includes(lastGroup)) {\n return false\n }\n }\n\n const match = m.slice(1, -1)\n if (!caseSensitive) match[0] = match[0].toLowerCase()\n\n // we use .replace to iterate over global regex, not to replace the text\n withoutPrefix.slice(m[0].length).replace(argumentsRe, ($0, $1, $2: string, $3: string) => {\n match.push(($2 || $3 || '').replace(unescapeRe, '$1'))\n\n return ''\n })\n ;(msg as MessageContext & { command: string[] }).command = match\n\n return true\n }\n }\n\n return false\n }\n\n return check\n}\n\n/**\n * Shorthand filter that matches /start commands sent to bot's\n * private messages.\n */\nexport const start: UpdateFilter<\n MessageContext | BusinessMessageContext,\n {\n chat: Modify<Chat, {\n chatType: 'private'\n }>\n command: string[]\n }\n> = and(chat('private'), command('start'))\n\n/**\n * Shorthand filter that matches /start commands\n * sent in groups (i.e. using `?startgroup` parameter).\n */\nexport const startGroup: UpdateFilter<\n MessageContext | BusinessMessageContext,\n {\n chat: Modify<Chat, {\n chatType: 'group' | 'supergroup'\n }>\n command: string[]\n },\n never\n> = and(or(chat('supergroup'), chat('group')), command('start'))\n\nfunction deeplinkBase(base: UpdateFilter<MessageContext | BusinessMessageContext, { command: string[] }>) {\n return (\n params: MaybeArray<string | RegExp>,\n ): UpdateFilter<MessageContext | BusinessMessageContext, { command: string[] }> => {\n if (!Array.isArray(params)) {\n return and(start, (_msg: Message) => {\n const msg = _msg as Message & { command: string[] }\n\n if (msg.command.length !== 2) return false\n\n const p = msg.command[1]\n if (typeof params === 'string' && p === params) return true\n\n const m = p.match(params)\n if (!m) return false\n\n msg.command.push(...m.slice(1))\n\n return true\n })\n }\n\n return and(base, (_msg: Message) => {\n const msg = _msg as Message & { command: string[] }\n\n if (msg.command.length !== 2) return false\n\n const p = msg.command[1]\n\n for (const param of params) {\n if (typeof param === 'string' && p === param) return true\n\n const m = p.match(param)\n if (!m) continue\n\n msg.command.push(...m.slice(1))\n\n return true\n }\n\n return false\n })\n }\n}\n\n/**\n * Filter for deep links (i.e. `/start <deeplink_parameter>`).\n *\n * If the parameter is a regex, groups are added to `msg.command`,\n * meaning that the first group is available in `msg.command[2]`.\n */\nexport const deeplink: (params: MaybeArray<string | RegExp>) => UpdateFilter<\n MessageContext | BusinessMessageContext,\n { command: string[] }\n> = deeplinkBase(start)\n\n/**\n * Filter for group deep links (i.e. `/start <deeplink_parameter>`).\n *\n * If the parameter is a regex, groups are added to `msg.command`,\n * meaning that the first group is available in `msg.command[2]`.\n */\nexport const deeplinkGroup: (params: MaybeArray<string | RegExp>) => UpdateFilter<\n MessageContext | BusinessMessageContext,\n { command: string[] }\n> = deeplinkBase(startGroup)\n"]}
@@ -1,10 +0,0 @@
1
- export * from './bots.js';
2
- export * from './chat.js';
3
- export * from './group.js';
4
- export * from './logic.js';
5
- export * from './message.js';
6
- export * from './state.js';
7
- export * from './text.js';
8
- export * from './types.js';
9
- export * from './updates.js';
10
- export * from './user.js';
@@ -1,11 +0,0 @@
1
- export * from './bots.js';
2
- export * from './chat.js';
3
- export * from './group.js';
4
- export * from './logic.js';
5
- export * from './message.js';
6
- export * from './state.js';
7
- export * from './text.js';
8
- export * from './types.js';
9
- export * from './updates.js';
10
- export * from './user.js';
11
- //# sourceMappingURL=bundle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../src/filters/bundle.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA","sourcesContent":["export * from './bots.js'\nexport * from './chat.js'\nexport * from './group.js'\nexport * from './logic.js'\nexport * from './message.js'\nexport * from './state.js'\nexport * from './text.js'\nexport * from './types.js'\nexport * from './updates.js'\nexport * from './user.js'\n"]}
@@ -1,27 +0,0 @@
1
- import type { BotChatJoinRequestUpdate, BusinessMessage, Chat, ChatMemberUpdate, ChatType, DeleteBusinessMessageUpdate, HistoryReadUpdate, MaybeArray, Message, PollVoteUpdate, User, UserTypingUpdate } from '@mtcute/core';
2
- import type { UpdateContextDistributed } from '../context/base.js';
3
- import type { EmptyObject, Modify, UpdateFilter } from './types.js';
4
- /**
5
- * Filter updates by type of the chat where they happened
6
- */
7
- export declare function chat<T extends ChatType, Obj extends {
8
- chat: Chat;
9
- }>(type: T): UpdateFilter<Obj, {
10
- chat: Modify<Chat, {
11
- chatType: T;
12
- }>;
13
- } & (Obj extends Message ? T extends 'private' | 'bot' | 'group' ? {
14
- sender: User;
15
- } : EmptyObject : EmptyObject)>;
16
- /**
17
- * Filter updates by marked chat ID(s) or username(s)
18
- *
19
- * Note that only some updates support filtering by username.
20
- *
21
- * For messages, this filter checks for chat where the message
22
- * was sent to, NOT the chat sender.
23
- */
24
- export declare const chatId: {
25
- (id: MaybeArray<number>): UpdateFilter<UpdateContextDistributed<Message | BusinessMessage | ChatMemberUpdate | PollVoteUpdate | BotChatJoinRequestUpdate>>;
26
- (id: MaybeArray<number | string>): UpdateFilter<UpdateContextDistributed<Message | BusinessMessage | ChatMemberUpdate | UserTypingUpdate | HistoryReadUpdate | PollVoteUpdate | BotChatJoinRequestUpdate | DeleteBusinessMessageUpdate>>;
27
- };
@@ -1,51 +0,0 @@
1
- /**
2
- * Filter updates by type of the chat where they happened
3
- */
4
- export function chat(type) {
5
- return msg => msg.chat.chatType === type;
6
- }
7
- /**
8
- * Filter updates by marked chat ID(s) or username(s)
9
- *
10
- * Note that only some updates support filtering by username.
11
- *
12
- * For messages, this filter checks for chat where the message
13
- * was sent to, NOT the chat sender.
14
- */
15
- export const chatId = (id) => {
16
- const indexId = new Set();
17
- const indexUsername = new Set();
18
- let matchSelf = false;
19
- if (!Array.isArray(id))
20
- id = [id];
21
- id.forEach((id) => {
22
- if (id === 'me' || id === 'self') {
23
- matchSelf = true;
24
- }
25
- else if (typeof id === 'number') {
26
- indexId.add(id);
27
- }
28
- else {
29
- indexUsername.add(id);
30
- }
31
- });
32
- return (upd) => {
33
- switch (upd._name) {
34
- case 'poll_vote': {
35
- const peer = upd.peer;
36
- return peer.type === 'chat' && (indexId.has(peer.id)
37
- || Boolean(peer.usernames?.some(u => indexUsername.has(u.username))));
38
- }
39
- case 'history_read':
40
- case 'user_typing': {
41
- const id = upd.chatId;
42
- return (matchSelf && id === upd.client.storage.self.getCached()?.userId) || indexId.has(id);
43
- }
44
- }
45
- const chat = upd.chat;
46
- return (matchSelf && chat.isSelf)
47
- || indexId.has(chat.id)
48
- || Boolean(chat.usernames?.some(u => indexUsername.has(u.username)));
49
- };
50
- };
51
- //# sourceMappingURL=chat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../src/filters/chat.ts"],"names":[],"mappings":"AAmBA;;GAEG;AACH,MAAM,UAAU,IAAI,CAAiD,IAAO;IAYxE,OAAO,GAAG,CAAC,EAAE,CACT,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAA;AAClC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAkBf,CAAC,EAAE,EAAE,EAAE;IACP,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;IACjC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAA;IACvC,IAAI,SAAS,GAAG,KAAK,CAAA;IAErB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAAE,EAAE,GAA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B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;eACpB,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC1E,CAAC,CAAA;AACL,CAAC,CAAA","sourcesContent":["import type {\n BotChatJoinRequestUpdate,\n BusinessMessage,\n Chat,\n ChatMemberUpdate,\n ChatType,\n DeleteBusinessMessageUpdate,\n HistoryReadUpdate,\n MaybeArray,\n Message,\n PollVoteUpdate,\n User,\n UserTypingUpdate,\n} from '@mtcute/core'\n\nimport type { UpdateContextDistributed } from '../context/base.js'\n\nimport type { EmptyObject, Modify, UpdateFilter } from './types.js'\n\n/**\n * Filter updates by type of the chat where they happened\n */\nexport function chat<T extends ChatType, Obj extends { chat: Chat }>(type: T): UpdateFilter<\n Obj,\n {\n chat: Modify<Chat, { chatType: T }>\n } & (Obj extends Message\n ? T extends 'private' | 'bot' | 'group'\n ? {\n sender: User\n }\n : EmptyObject\n : EmptyObject)\n> {\n return msg =>\n msg.chat.chatType === type\n}\n\n/**\n * Filter updates by marked chat ID(s) or username(s)\n *\n * Note that only some updates support filtering by username.\n *\n * For messages, this filter checks for chat where the message\n * was sent to, NOT the chat sender.\n */\nexport const chatId: {\n (id: MaybeArray<number>): UpdateFilter<UpdateContextDistributed<\n | Message\n | BusinessMessage\n | ChatMemberUpdate\n | PollVoteUpdate\n | BotChatJoinRequestUpdate\n >>\n (id: MaybeArray<number | string>): UpdateFilter<UpdateContextDistributed<\n | Message\n | BusinessMessage\n | ChatMemberUpdate\n | UserTypingUpdate\n | HistoryReadUpdate\n | PollVoteUpdate\n | BotChatJoinRequestUpdate\n | DeleteBusinessMessageUpdate\n >>\n} = (id) => {\n const indexId = new Set<number>()\n const indexUsername = new Set<string>()\n let matchSelf = false\n\n if (!Array.isArray(id)) id = [id]\n id.forEach((id) => {\n if (id === 'me' || id === 'self') {\n matchSelf = true\n } else if (typeof id === 'number') {\n indexId.add(id)\n } else {\n indexUsername.add(id)\n }\n })\n\n return (upd) => {\n switch (upd._name) {\n case 'poll_vote': {\n const peer = upd.peer\n\n return peer.type === 'chat' && (\n indexId.has(peer.id)\n || Boolean(peer.usernames?.some(u => indexUsername.has(u.username)))\n )\n }\n case 'history_read':\n case 'user_typing': {\n const id = upd.chatId\n\n return (matchSelf && id === upd.client.storage.self.getCached()?.userId) || indexId.has(id)\n }\n }\n\n const chat = upd.chat\n\n return (matchSelf && chat.isSelf)\n || indexId.has(chat.id)\n || Boolean(chat.usernames?.some(u => indexUsername.has(u.username)))\n }\n}\n"]}