diff --git a/src/bot/index.ts b/src/bot/index.ts index 4f4a03e..1a8c863 100644 --- a/src/bot/index.ts +++ b/src/bot/index.ts @@ -1,4 +1,5 @@ import { Telegraf } from 'telegraf'; +import { message } from 'telegraf/filters'; import type { Database } from 'better-sqlite3'; import { handleLog } from './commands/log'; import { handleSkip } from './commands/skip'; @@ -30,9 +31,8 @@ export function createBot(token: string, chatId: string, db: Database): Telegraf bot.command('setup', handleSetup(db)); const setupReply = handleSetupReply(db); - bot.on('text', async (ctx) => { - const text = (ctx.message as { text?: string })?.text ?? ''; - if (text.startsWith('/')) return; + bot.on(message('text'), async (ctx) => { + if (ctx.message.text.startsWith('/')) return; await setupReply(ctx); });