Change oyoyo tokenbucket to be consistent with !wait TB

In !wait, the delay is how long it takes (in seconds) to add one token,
whereas in oyoyo the delay was the opposite (lower = longer refill).

IMO the !wait one makes more sense, so change oyoyo to match.
This commit is contained in:
Ryan Schmidt 2018-07-13 21:45:25 -07:00
parent 4077bfe398
commit e426c25ddd
No known key found for this signature in database
GPG Key ID: E0F0AE21C1C0CB86

View File

@ -58,7 +58,7 @@ class TokenBucket(object):
def tokens(self):
now = time.time()
if self._tokens < self.capacity:
delta = self.fill_rate * (now - self.timestamp)
delta = (now - self.timestamp) / self.fill_rate
self._tokens = min(self.capacity, self._tokens + delta)
self.timestamp = now
return self._tokens