Documentation ¶
Overview ¶
Package throttler provides implementations for the plugin.Throttler interface.
Index ¶
- func PerChannel(maxInvokes uint, duration time.Duration) plugin.Throttler
- func PerGuild(maxInvokes uint, duration time.Duration) plugin.Throttler
- func PerMember(maxInvokes uint, duration time.Duration) plugin.Throttler
- func PerUser(maxInvokes uint, duration time.Duration) plugin.Throttler
- type Condition
- type Conditional
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PerChannel ¶
PerChannel returns a new plugin.Throttler that works on a per-channel basis. It allows at maximum the passed number of invokes in the passed duration.
func PerGuild ¶
PerGuild returns a new plugin.Throttler that works on a per-guild basis. It allows at maximum the passed number of invokes in the passed duration.
All commands invoked in direct messages will be throttled on a per-user basis.
func PerMember ¶
PerMember returns a new plugin.Throttler that works on a per-member basis. It allows at maximum the passed number of invokes in the passed duration. Effectively, this is the same as PerUser but filtered additionally by guild.
All commands invoked in direct messages will be throttled on a per-user basis.
Types ¶
type Condition ¶
type Condition struct { // Restrictions is the restriction a user must fulfill to use the // throttler in this condition. // // Restrictions is considered fulfilled, if it returns nil. Restrictions plugin.RestrictionFunc // Throttler is the plugin.Throttler used if the Restrictions are // fulfilled. Throttler plugin.Throttler }
Condition is a single conditional throttler.
type Conditional ¶
type Conditional struct { // Conditions contains the conditional throttlers. Conditions []Condition // Default is the fallback throttler. // If it is nil, users encountering this won't be throttled. Default plugin.Throttler }
Conditional is a plugin.Throttler that uses different cooldowns based on restrictions. It will attempt to find the firstmost Condition, where a call to Condition.Restrictions returns nil. If there is no such Condition, the default throttler will be used.
If the throttler of a condition or the default throttler is nil, the encountering user will be regarded as exempt from throttling.