feat: bot assembly, scheduler, and entry point

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 17:54:29 +02:00
parent c49b10e11d
commit 0efe63792e
4 changed files with 134 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import type { Telegraf } from 'telegraf';
import type { Database } from 'better-sqlite3';
import { todayString } from '../utils/date';
import { getScheduleByDate } from '../db/schedule';
import { getSessionByDate } from '../db/sessions';
import { formatDuration } from '../utils/duration';
export async function sendMorningReminder(bot: Telegraf, db: Database, chatId: string): Promise<void> {
const today = todayString();
const scheduled = getScheduleByDate(db, today);
if (!scheduled || scheduled.status !== 'pending') return;
const session = getSessionByDate(db, today);
if (session) return;
await bot.telegram.sendMessage(
chatId,
`Good morning! You have a ${formatDuration(scheduled.planned_min)} session planned today.\n\nUse /log when done, /skip if you can't make it, or /snooze to remind you later.`
);
}
export async function sendEveningNudge(bot: Telegraf, db: Database, chatId: string): Promise<void> {
const today = todayString();
const scheduled = getScheduleByDate(db, today);
if (!scheduled || scheduled.status !== 'pending') return;
const session = getSessionByDate(db, today);
if (session) return;
await bot.telegram.sendMessage(
chatId,
`Still time for today's session (${formatDuration(scheduled.planned_min)})!\n\nUse /log to record it, or /skip to mark it as skipped.`
);
}