Skip to content

Commit

Permalink
better js
Browse files Browse the repository at this point in the history
  • Loading branch information
catdevnull committed Oct 5, 2024
1 parent 325c672 commit 34192dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ COPY --from=prerelease /usr/src/app/package.json .

# run the app
USER bun
ENTRYPOINT [ "bun", "run", "index.ts" ]
ENTRYPOINT [ "bun", "--smol", "run", "index.ts" ]
13 changes: 8 additions & 5 deletions js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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);

0 comments on commit 34192dd

Please sign in to comment.