import type { Context } from "hono";
import { generateCode, getTelegramStatus } from "./telegram.service";

export async function generateCodeHandler(c: Context) {
  try {
    const result = await generateCode();
    return c.json(result);
  } catch (error) {
    return c.json({ error: "Failed to generate code" }, 500);
  }
}

export async function telegramStatusHandler(c: Context) {
  try {
    const status = await getTelegramStatus();
    return c.json(status);
  } catch (error) {
    return c.json({ connected: false, botUsername: null }, 500);
  }
}
