Apply time-fix, json is not able to decode 2s but 2 which is ns

instead of s

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-06-17 18:08:52 +02:00
parent edd8a12af1
commit 6d358b307f
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 12 additions and 1 deletions

View file

@ -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",

11
helpers.go Normal file
View file

@ -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
}