2023-09-10 18:27:48 +00:00
|
|
|
#!/usr/bin/env tsx
|
|
|
|
|
|
|
|
import { onShutdown } from "node-graceful-shutdown";
|
|
|
|
import { createBot } from "#root/bot.js";
|
2023-09-08 19:09:35 +00:00
|
|
|
import { config } from "#root/config.js";
|
2023-09-10 18:27:48 +00:00
|
|
|
import { logger } from "#root/logger.js";
|
2023-09-08 19:09:35 +00:00
|
|
|
|
2023-09-10 18:27:48 +00:00
|
|
|
try {
|
|
|
|
const bot = createBot(config.BOT_TOKEN);
|
2023-09-08 19:09:35 +00:00
|
|
|
|
2023-09-10 18:27:48 +00:00
|
|
|
// Graceful shutdown
|
|
|
|
onShutdown(async () => {
|
|
|
|
logger.info("shutdown");
|
|
|
|
await bot.stop();
|
2023-09-08 19:09:35 +00:00
|
|
|
});
|
|
|
|
|
2023-09-10 18:27:48 +00:00
|
|
|
await bot.start({
|
|
|
|
onStart: ({ username }) =>
|
|
|
|
logger.info({
|
|
|
|
msg: "bot running...",
|
|
|
|
username,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
logger.error(error);
|
|
|
|
process.exit(1);
|
2023-09-08 19:09:35 +00:00
|
|
|
}
|