Created a timeout for starting webhook mode to allow traefik to expose the webhook server and assign an SSL cert.
All checks were successful
Main / build-and-push-docker-image (20.x) (push) Successful in 3m11s
All checks were successful
Main / build-and-push-docker-image (20.x) (push) Successful in 3m11s
This commit is contained in:
37
src/main.ts
37
src/main.ts
@@ -65,28 +65,31 @@ async function startWebhook(config: WebhookConfig) {
|
|||||||
await bot.init();
|
await bot.init();
|
||||||
|
|
||||||
// start server
|
// start server
|
||||||
const info = await serverManager.start();
|
const info = await serverManager.start().then(async info => {
|
||||||
logger.info({
|
logger.info({
|
||||||
msg: "Server started",
|
msg: "Server started",
|
||||||
url: info.url
|
url: info.url
|
||||||
});
|
});
|
||||||
|
|
||||||
// set webhook
|
setTimeout(async () => {
|
||||||
await bot.api.setWebhook(config.botWebhook, {
|
// set webhook
|
||||||
allowed_updates: config.botAllowedUpdates,
|
await bot.api
|
||||||
secret_token: config.botWebhookSecret
|
.setWebhook(config.botWebhook, {
|
||||||
});
|
allowed_updates: config.botAllowedUpdates,
|
||||||
logger.info({
|
secret_token: config.botWebhookSecret
|
||||||
msg: "Webhook was set",
|
})
|
||||||
url: config.botWebhook
|
.then(() => {
|
||||||
|
logger.info({
|
||||||
|
msg: "Webhook was set",
|
||||||
|
url: config.botWebhook
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 25000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (config.isWebhookMode)
|
if (config.isWebhookMode) await startWebhook(config);
|
||||||
await setTimeout(() => {
|
|
||||||
if (config.isWebhookMode) startWebhook(config);
|
|
||||||
}, 20000);
|
|
||||||
else if (config.isPollingMode) await startPolling(config);
|
else if (config.isPollingMode) await startPolling(config);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user