I'm writing telegram-bot using Go (go-telegram-bot-api). It constantly parses a website and notifies about changes (every minute). Today I added simple keyboard and now can't make them work together.
The problem is that webpage parsing is in the infinite loop and program when it enters the loop ignores updates coming from the "client".
I've tried putting everything in a single loop, changing orders, etc. Maybe there is another or proper way of doing this?
Sample code:
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message != nil {
switch update.Message.Text {
case "Show Keyboard":
Keyboard is sent
case "OptionsForParsing":
options.applied
case "StartParsing":
search bool = true
case "StopParsing":
search bool = false
}
}
if search == true{
for{
time.Sleep(1 * time.Minute)
AreThereChanges?()
if yes{
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "help please")
bot.Send(msg)
}
}}
}