fix(dispatcher): support text filters inside filters.replyTo

This commit is contained in:
alina 🌸 2024-12-03 02:40:31 +03:00
parent a0ed269b5e
commit 9e218e3457
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI

View file

@ -1,10 +1,12 @@
import type {
BusinessCallbackQuery,
BusinessMessage,
CallbackQuery,
ChosenInlineResult,
InlineCallbackQuery,
InlineQuery,
} from '@mtcute/core'
import {
BusinessMessage,
Message,
} from '@mtcute/core'
@ -12,21 +14,23 @@ import type { UpdateContextDistributed } from '../context/base.js'
import type { UpdateFilter } from './types.js'
type UpdatesWithText = UpdateContextDistributed<
type UpdatesWithText =
| Message
| BusinessMessage
| UpdateContextDistributed<
| InlineQuery
| ChosenInlineResult
| CallbackQuery
| InlineCallbackQuery
| BusinessCallbackQuery
>
>
function extractText(obj: UpdatesWithText): string | null {
switch (obj._name) {
case 'new_message':
case 'new_business_message':
if (obj instanceof Message || obj instanceof BusinessMessage) {
return obj.text
}
switch (obj._name) {
case 'inline_query':
return obj.query
case 'chosen_inline_result':