mic-bot/main.ts

25 lines
678 B
TypeScript
Raw Normal View History

2024-10-19 10:00:35 +00:00
import { runBot } from "./bot/bot.ts";
import { init as initNormalMode } from "./bot/normal_mode/init.ts"
2024-10-23 16:09:10 +00:00
import { init as initSetupMode } from "./bot/setup_mode/init.ts"
2024-10-19 10:00:35 +00:00
import { setupDB } from "./repo/exports.ts";
2024-10-19 10:47:33 +00:00
import { loadConfig } from "./config.ts";
2024-10-24 08:35:13 +00:00
import { BotMode } from "./cfg/config.ts";
2024-10-19 10:00:35 +00:00
const main = async () => {
2024-10-19 10:47:33 +00:00
const cfg = loadConfig()
2024-10-19 10:00:35 +00:00
const { botCfg } = cfg
const { db } = await setupDB(cfg)
2024-10-24 08:35:13 +00:00
await runBot(botCfg, (bot) => {
2024-10-19 10:00:35 +00:00
switch (botCfg.mode) {
2024-10-19 10:47:33 +00:00
case BotMode.normal:
2024-10-19 10:00:35 +00:00
initNormalMode(bot, db, cfg)
break;
2024-10-19 10:47:33 +00:00
case BotMode.setup:
2024-10-23 16:09:10 +00:00
initSetupMode(bot, cfg)
2024-10-19 10:00:35 +00:00
break;
}
})
}
if (import.meta.main) { main() }