Skip to content

Commit

Permalink
Apply time-fix, json is not able to decode 2s but 2 which is ns
Browse files Browse the repository at this point in the history
instead of s

Signed-off-by: Knut Ahlers <[email protected]>
  • Loading branch information
Luzifer committed Jun 17, 2021
1 parent edd8a12 commit 6d358b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion action_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (a ActorTimeout) Execute(c *irc.Client, m *irc.Message, r *Rule) error {
Command: "PRIVMSG",
Params: []string{
m.Params[0],
fmt.Sprintf("/timeout %s %d", m.User, *a.Timeout/time.Second),
fmt.Sprintf("/timeout %s %d", m.User, fixDurationValue(*a.Timeout)/time.Second),
},
}),
"sending timeout",
Expand Down
11 changes: 11 additions & 0 deletions helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import "time"

func fixDurationValue(d time.Duration) time.Duration {
if d >= time.Second {
return d
}

return d * time.Second
}

0 comments on commit 6d358b3

Please sign in to comment.