Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add delay option #164

Merged
merged 1 commit into from Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/notify/notify.go
Expand Up @@ -55,6 +55,7 @@ func readConfig() {
set.StringSliceVarP(&options.Providers, "provider", "p", []string{}, "provider to send the notification to (optional)", goflags.NormalizedStringSliceOptions)
set.StringSliceVar(&options.IDs, "id", []string{}, "id to send the notification to (optional)", goflags.NormalizedStringSliceOptions)
set.IntVarP(&options.RateLimit, "rate-limit", "rl", 1, "maximum number of HTTP requests to send per second")
set.IntVarP(&options.Delay, "delay", "d", 0, "delay in seconds between each notification")
set.BoolVar(&options.Bulk, "bulk", false, "enable bulk processing")
set.IntVarP(&options.CharLimit, "char-limit", "cl", 4000, "max character limit per message")
set.StringVarP(&options.MessageFormat, "msg-format", "mf", "", "add custom formatting to message")
Expand Down
3 changes: 3 additions & 0 deletions internal/runner/runner.go
Expand Up @@ -128,6 +128,9 @@ func (r *Runner) Run() error {

func (r *Runner) sendMessage(msg string) error {
if len(msg) > 0 {
if r.options.Delay > 0 {
time.Sleep(time.Duration(r.options.Delay) * time.Second)
}
gologger.Silent().Msgf("%s\n", msg)
err := r.providers.Send(msg)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/types/types.go
Expand Up @@ -12,6 +12,7 @@ type Options struct {
IDs goflags.StringSlice `yaml:"ids,omitempty"`
Proxy string `yaml:"proxy,omitempty"`
RateLimit int `yaml:"rate_limit,omitempty"`
Delay int `yaml:"delay,omitempty"`

MessageFormat string `yaml:"message_format,omitempty"`

Expand Down