import type { Context } from 'telegraf'; import type { Database } from 'better-sqlite3'; import { todayString } from '../../utils/date'; import { getProgressAnalysis } from '../../ai/coach'; export function handleProgress(db: Database) { return async (ctx: Context) => { await ctx.reply('Analysing your recent history…'); try { const result = await getProgressAnalysis(db, todayString()); await ctx.reply(result); } catch (err) { await ctx.reply(`AI unavailable: ${(err as Error).message}`); } }; }