Name: Rate Limiter
Version: v1.0.7
Edit: 2 Feb 2021
By: ALiwoto and Contributors (C)
import "github.com/AnimeKaizoku/ratelimiter/ratelimiter"
func loadLimiter(d *ext.Dispatcher) {
limiter = ratelimiter.NewLimiter(d, &ratelimiter.LimiterConfig{
ConsiderChannel: false,
ConsiderUser: true,
ConsiderEdits: false,
IgnoreMediaGroup: true,
TextOnly: false,
HandlerGroups: []int{0, 1, 2},
})
// 14 messages per 6 seconds
limiter.SetFloodWaitTime(6 * time.Second)
limiter.SetMaxMessageCount(14)
// add sudo users as exceptions, so they don't get rate-limited by library
limiter.AddExceptionID(sudoUsers...)
limiter.Start()
}