From 5e23b05631b2303c2cdd53ae9d0bccb0deaf07c3 Mon Sep 17 00:00:00 2001 From: akulij Date: Tue, 13 Aug 2024 01:26:08 +0300 Subject: [PATCH] process updates using goroutines --- cmd/app/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/app/main.go b/cmd/app/main.go index 7123560..9b1fbd7 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -95,6 +95,12 @@ func main() { var bc = GetBotController() for update := range bc.updates { + go ProcessUpdate(bc, update) + } +} + +func ProcessUpdate(bc BotController, update tgbotapi.Update) { + if update.Message != nil { var UserID = update.Message.From.ID @@ -241,7 +247,7 @@ func main() { if err != nil { msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Something went wrong, try again...") bc.bot.Send(msg) - continue + return } bc.db.Model(&user).Update("state", "start") @@ -330,7 +336,6 @@ func main() { } } } - } } func DownloadFile(filepath string, url string) error {