// Entry point: `peppa-bot` (launchd agent quest.telecom.peppa.bot). import { createDb } from "@peppa/db"; import { loadEnv } from "@peppa/shared"; import { createBot } from "./bot.ts"; import { TelegramApi } from "./telegram.ts"; const env = loadEnv(); if (!env.TELEGRAM_BOT_TOKEN) { console.error("TELEGRAM_BOT_TOKEN is not set"); process.exit(1); } const bot = createBot({ db: createDb(env.PEPPA_DB), api: new TelegramApi(env.TELEGRAM_BOT_TOKEN, process.env.TELEGRAM_API_URL), secret: env.TELEGRAM_BOT_TOKEN, webUrl: env.PEPPA_WEB_URL, log: (m) => console.log(`${new Date().toISOString()} ${m}`), }); await bot.start(); for (const sig of ["SIGINT", "SIGTERM"] as const) { process.on(sig, () => void bot.stop().then(() => process.exit(0))); }