feat: bot assembly, scheduler, and entry point
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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.`
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user