22 lines
544 B
TypeScript
22 lines
544 B
TypeScript
import { startPolling } from "./poll";
|
|
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();
|
|
}
|
|
|
|
export { TG_TOKEN } from "./config";
|
|
export { sendMessage } from "./tg";
|
|
export { getSession, hasSession, clearSession } from "./sessions";
|