1
bot/wait_updates.go
sattellite cea80ccf6e
exit from waitUpdates function when context is terminated (#75)
After the new changes return from the waitUpdates function was lost when the passed context was terminated.
2024-04-03 14:44:57 +03:00

21 lines
305 B
Go

package bot
import (
"context"
"sync"
)
// waitUpdates listen Updates channel and run ProcessUpdate
func (b *Bot) waitUpdates(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()
for {
select {
case <-ctx.Done():
return
case upd := <-b.updates:
b.ProcessUpdate(ctx, upd)
}
}
}