diff --git a/pkg/channels/utils.go b/pkg/channels/utils.go index b5e5d71..677c8d1 100644 --- a/pkg/channels/utils.go +++ b/pkg/channels/utils.go @@ -4,6 +4,7 @@ import ( "context" "errors" "sync" + "time" "github.com/YspCoder/clawgo/pkg/logger" ) @@ -59,3 +60,14 @@ func runChannelTask(name, taskName string, task func() error, onFailure func(err } }() } + +func sleepWithContext(ctx context.Context, d time.Duration) bool { + timer := time.NewTimer(d) + defer timer.Stop() + select { + case <-ctx.Done(): + return false + case <-timer.C: + return true + } +} diff --git a/pkg/channels/whatsapp.go b/pkg/channels/whatsapp.go index 88884be..f8b54d4 100644 --- a/pkg/channels/whatsapp.go +++ b/pkg/channels/whatsapp.go @@ -287,14 +287,3 @@ func nextBackoff(current, max time.Duration) time.Duration { } return next } - -func sleepWithContext(ctx context.Context, d time.Duration) bool { - timer := time.NewTimer(d) - defer timer.Stop() - select { - case <-ctx.Done(): - return false - case <-timer.C: - return true - } -}