Files
blog/write-server/src/lib/bot/index.ts
T

23 lines
619 B
TypeScript
Raw Normal View History

2026-06-21 20:42:44 +08:00
import { startPolling } from "./poll";
2026-06-22 14:10:10 +08:00
import { startCommentNotifier } from "./notify";
2026-06-21 20:42:44 +08:00
import { TG_TOKEN } from "./config";
const g = globalThis as Record<string, unknown>;
export async function startBot(): Promise<void> {
if (g.__botStarted) return;
g.__botStarted = true;
if (!TG_TOKEN) {
console.log("[bot] TG_BOT_TOKEN not configured, bot disabled");
return;
}
console.log("[bot] initializing...");
await startPolling();
2026-06-22 14:10:10 +08:00
startCommentNotifier();
2026-06-21 20:42:44 +08:00
}
export { TG_TOKEN } from "./config";
export { sendMessage } from "./tg";
export { getSession, hasSession, clearSession } from "./sessions";