2022-04-26 00:02:51 +08:00
|
|
|
package bot
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-05-06 17:47:43 +08:00
|
|
|
"sync"
|
2022-04-26 00:02:51 +08:00
|
|
|
)
|
|
|
|
|
2024-04-02 22:23:32 +08:00
|
|
|
// waitUpdates listen Updates channel and run ProcessUpdate
|
2022-05-06 17:47:43 +08:00
|
|
|
func (b *Bot) waitUpdates(ctx context.Context, wg *sync.WaitGroup) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
2022-04-26 00:02:51 +08:00
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-ctx.Done():
|
2024-04-03 19:44:57 +08:00
|
|
|
return
|
2022-05-03 00:39:04 +08:00
|
|
|
case upd := <-b.updates:
|
2024-04-02 22:23:32 +08:00
|
|
|
b.ProcessUpdate(ctx, upd)
|
2022-04-26 00:02:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|