/* eslint-disable no-eval */
const path = eval('require("path")') as typeof import("path");

const BOTS_ROOT = "/var/www/html/bots/bot_hills";

const VALID_BOT_NAMES = [
  "bot_moderacao",
  "bot_comunidade",
  "bot_utilidades",
] as const;

export type BotName = (typeof VALID_BOT_NAMES)[number];

export function isValidBotName(name: string): name is BotName {
  return VALID_BOT_NAMES.includes(name as BotName);
}

export function getBotDir(botName: BotName): string {
  return path.join(BOTS_ROOT, botName);
}

export function getBotPidFile(botName: BotName): string {
  return path.join(getBotDir(botName), ".pid");
}

export function getBotLogDir(botName: BotName): string {
  return path.join(getBotDir(botName), "logs");
}

export function getBotLogFile(botName: BotName): string {
  return path.join(getBotLogDir(botName), "bot.log");
}

export function getBotEnvFile(botName: BotName): string {
  return path.join(getBotDir(botName), ".env");
}

export function getBotDataDir(botName: BotName): string {
  return path.join(getBotDir(botName), "data");
}

export function getBotModulesDir(botName: BotName): string {
  return path.join(getBotDir(botName), "modules");
}

export function getBotModulesConfigFile(botName: BotName): string {
  return path.join(getBotDataDir(botName), "modules-config.json");
}

export function getAllBotNames(): BotName[] {
  return [...VALID_BOT_NAMES];
}
