mirror of
https://github.com/Luzifer/twitch-bot.git
synced 2024-11-09 16:50:01 +00:00
24 lines
461 B
Go
24 lines
461 B
Go
package main
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
|
|
"github.com/go-irc/irc"
|
|
)
|
|
|
|
func init() {
|
|
registerAction(func(c *irc.Client, m *irc.Message, ruleDef *rule, r *ruleAction) error {
|
|
if r.Delay == 0 && r.DelayJitter == 0 {
|
|
return nil
|
|
}
|
|
|
|
totalDelay := r.Delay
|
|
if r.DelayJitter > 0 {
|
|
totalDelay += time.Duration(rand.Int63n(int64(r.DelayJitter))) // #nosec: G404 // It's just time, no need for crypto/rand
|
|
}
|
|
|
|
time.Sleep(totalDelay)
|
|
return nil
|
|
})
|
|
}
|