mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 13:29:27 +01:00
parent
9670d96282
commit
2f4431a5fb
@ -90,10 +90,20 @@ func (fl *Fakelag) Touch() {
|
|||||||
if elapsed > fl.config.Cooldown {
|
if elapsed > fl.config.Cooldown {
|
||||||
// let them burst again
|
// let them burst again
|
||||||
fl.state = FakelagBursting
|
fl.state = FakelagBursting
|
||||||
|
fl.burstCount = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// space them out by at least window/messagesperwindow
|
var sleepDuration time.Duration
|
||||||
sleepDuration := time.Duration((int64(fl.config.Window) / int64(fl.config.MessagesPerWindow)) - int64(elapsed))
|
if fl.config.MessagesPerWindow > 0 {
|
||||||
|
// space them out by at least window/messagesperwindow
|
||||||
|
sleepDuration = time.Duration((int64(fl.config.Window) / int64(fl.config.MessagesPerWindow)) - int64(elapsed))
|
||||||
|
} else {
|
||||||
|
// only burst messages are allowed: sleep until cooldown expires,
|
||||||
|
// then count this as a burst message
|
||||||
|
sleepDuration = time.Duration(int64(fl.config.Cooldown) - int64(elapsed))
|
||||||
|
fl.state = FakelagBursting
|
||||||
|
fl.burstCount = 1
|
||||||
|
}
|
||||||
if sleepDuration > 0 {
|
if sleepDuration > 0 {
|
||||||
fl.sleepFunc(sleepDuration)
|
fl.sleepFunc(sleepDuration)
|
||||||
// the touch time should take into account the time we slept
|
// the touch time should take into account the time we slept
|
||||||
|
Loading…
Reference in New Issue
Block a user