From bfc0f1e59a498721cec0972acc3e64429a392aa1 Mon Sep 17 00:00:00 2001 From: Lucid Date: Mon, 20 Oct 2025 23:53:37 -0400 Subject: [PATCH] Created a timeout for starting webhook mode to allow traefik to expose the webhook server and assign an SSL cert. --- src/main.ts | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main.ts b/src/main.ts index 0487521..5aad83b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -65,28 +65,31 @@ async function startWebhook(config: WebhookConfig) { await bot.init(); // start server - const info = await serverManager.start(); - logger.info({ - msg: "Server started", - url: info.url - }); + const info = await serverManager.start().then(async info => { + logger.info({ + msg: "Server started", + url: info.url + }); - // set webhook - await bot.api.setWebhook(config.botWebhook, { - allowed_updates: config.botAllowedUpdates, - secret_token: config.botWebhookSecret - }); - logger.info({ - msg: "Webhook was set", - url: config.botWebhook + setTimeout(async () => { + // set webhook + await bot.api + .setWebhook(config.botWebhook, { + allowed_updates: config.botAllowedUpdates, + secret_token: config.botWebhookSecret + }) + .then(() => { + logger.info({ + msg: "Webhook was set", + url: config.botWebhook + }); + }); + }, 25000); }); } try { - if (config.isWebhookMode) - await setTimeout(() => { - if (config.isWebhookMode) startWebhook(config); - }, 20000); + if (config.isWebhookMode) await startWebhook(config); else if (config.isPollingMode) await startPolling(config); } catch (error) { logger.error(error);