From c5c74c24ecebb2c3aedb6dbbca30503df15f9244 Mon Sep 17 00:00:00 2001 From: bifidokk Date: Tue, 23 Apr 2024 18:55:35 +0300 Subject: [PATCH] Change bot initialisation --- internal/tgbot/tgbot.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/tgbot/tgbot.go b/internal/tgbot/tgbot.go index 025183c..708b9be 100644 --- a/internal/tgbot/tgbot.go +++ b/internal/tgbot/tgbot.go @@ -15,6 +15,13 @@ func Create() *tgbotapi.BotAPI { webhookPath = config.GetEnv("webhook_path") baseUrl := config.GetEnv("base_url") + go func() { + err := http.ListenAndServe(baseUrl, nil) + if err != nil { + panic(err) + } + }() + bot, err := tgbotapi.NewBotAPI(botToken) if err != nil { panic(err) @@ -36,13 +43,6 @@ func Create() *tgbotapi.BotAPI { log.Printf("Telegram callback failed: %s", info.LastErrorMessage) } - go func() { - err := http.ListenAndServe(baseUrl, nil) - if err != nil { - panic(err) - } - }() - return bot }