process updates using goroutines
This commit is contained in:
parent
3b7d3ed3b8
commit
5e23b05631
@ -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")
|
||||||
@ -330,7 +336,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func DownloadFile(filepath string, url string) error {
|
func DownloadFile(filepath string, url string) error {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user