diff --git a/js/Dockerfile b/js/Dockerfile index 46d88b7..a3b50a7 100644 --- a/js/Dockerfile +++ b/js/Dockerfile @@ -34,4 +34,4 @@ COPY --from=prerelease /usr/src/app/package.json . # run the app USER bun -ENTRYPOINT [ "bun", "run", "index.ts" ] \ No newline at end of file +ENTRYPOINT [ "bun", "--smol", "run", "index.ts" ] \ No newline at end of file diff --git a/js/index.ts b/js/index.ts index 7d935ab..d35e815 100644 --- a/js/index.ts +++ b/js/index.ts @@ -5,6 +5,11 @@ import { Readable } from "node:stream"; // https://github.com/yagop/node-telegram-bot-api/blob/master/doc/usage.md#file-options-metadata process.env.NTBA_FIX_350 = "false"; +const botParams = { + polling: true, + baseApiUrl: process.env.TELEGRAM_API_URL, +}; + const CobaltResult = z.discriminatedUnion("status", [ z.object({ status: z.literal("error"), @@ -69,7 +74,7 @@ async function askCobalt( class Bot { private bot: TelegramBot; constructor(token: string) { - this.bot = new TelegramBot(token, { polling: true }); + this.bot = new TelegramBot(token, botParams); this.bot.getMe().then((me) => { console.log("Bot initialized as", me.username); }); @@ -230,11 +235,9 @@ if (!token) { } if (process.argv[2] === "logout") { - const bot = new TelegramBot(token, { - polling: true, - baseApiUrl: process.env.TELEGRAM_API_URL, - }); + const bot = new TelegramBot(token, botParams); await bot.logOut(); + process.exit(0); } new Bot(token);