Skip to content

Commit

Permalink
feat: add check timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
totanvix committed Jun 28, 2023
1 parent 8f61fe4 commit 246f1de
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions utils/bot/bot.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package bot

import (
"errors"
"fmt"
"log"
"strings"
"time"

"zeril-bot/utils/bitcoin"
"zeril-bot/utils/kqxs"
Expand Down Expand Up @@ -42,13 +44,17 @@ func (b Bot) ResolveHook() error {
go b.resolveCallbackCommand()
}

for r := range b.rCh {
if r.err != nil {
for {
select {
case r, ok := <-b.rCh:
if !ok {
return nil
}
return r.err
case <-time.After(10 * time.Second):
return errors.New("Timeout")
}
}

return nil
}

func (b Bot) setTypingAction() {
Expand Down

0 comments on commit 246f1de

Please sign in to comment.