process updates using goroutines

This commit is contained in:
UserA 2024-08-13 01:26:08 +03:00
parent 8db55b7554
commit 36db6b9385

View File

@ -95,6 +95,12 @@ func main() {
var bc = GetBotController() var bc = GetBotController()
for update := range bc.updates { for update := range bc.updates {
go ProcessUpdate(bc, update)
}
}
func ProcessUpdate(bc BotController, update tgbotapi.Update) {
if update.Message != nil { if update.Message != nil {
var UserID = update.Message.From.ID var UserID = update.Message.From.ID
@ -241,7 +247,7 @@ func main() {
if err != nil { if err != nil {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Something went wrong, try again...") msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Something went wrong, try again...")
bc.bot.Send(msg) bc.bot.Send(msg)
continue return
} }
bc.db.Model(&user).Update("state", "start") bc.db.Model(&user).Update("state", "start")
@ -331,7 +337,6 @@ func main() {
} }
} }
} }
}
func DownloadFile(filepath string, url string) error { func DownloadFile(filepath string, url string) error {