process updates using goroutines

This commit is contained in:
akulij 2024-08-13 01:26:08 +03:00
parent 3b7d3ed3b8
commit 5e23b05631

View File

@ -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")
@ -331,7 +337,6 @@ func main() {
}
}
}
}
func DownloadFile(filepath string, url string) error {