Stringify booleans discordrest redis

This commit is contained in:
Jeremy "EndenDragon" Zhang 2019-01-14 15:21:02 -08:00 committed by GitHub
parent 790dca1766
commit bb10944052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,7 +22,7 @@ class DiscordREST:
def init_discordrest(self): def init_discordrest(self):
if not self._bucket_contains("global_limited"): if not self._bucket_contains("global_limited"):
self._set_bucket("global_limited", False) self._set_bucket("global_limited", "False")
self._set_bucket("global_limit_expire", 0) self._set_bucket("global_limit_expire", 0)
def _get_bucket(self, key): def _get_bucket(self, key):
@ -76,7 +76,7 @@ class DiscordREST:
self._set_bucket(url, int(req.headers['X-RateLimit-Reset'])) self._set_bucket(url, int(req.headers['X-RateLimit-Reset']))
if 300 > req.status_code >= 200: if 300 > req.status_code >= 200:
self._set_bucket("global_limited", False) self._set_bucket("global_limited", "False")
return { return {
'success': True, 'success': True,
'content': json_or_text(req), 'content': json_or_text(req),
@ -87,7 +87,7 @@ class DiscordREST:
if 'X-RateLimit-Global' not in req.headers: if 'X-RateLimit-Global' not in req.headers:
self._set_bucket(url, int(req.headers['X-RateLimit-Reset'])) self._set_bucket(url, int(req.headers['X-RateLimit-Reset']))
else: else:
self._set_bucket("global_limited", True) self._set_bucket("global_limited", "True")
self._set_bucket("global_limit_expire", time.time() + int(req.headers['Retry-After'])) self._set_bucket("global_limit_expire", time.time() + int(req.headers['Retry-After']))
if req.status_code == 502 and tries <= 5: if req.status_code == 502 and tries <= 5:
@ -189,4 +189,4 @@ class DiscordREST:
def delete_webhook(self, webhook_id, webhook_token): def delete_webhook(self, webhook_id, webhook_token):
_endpoint = "/webhooks/{id}/{token}".format(id=webhook_id, token=webhook_token) _endpoint = "/webhooks/{id}/{token}".format(id=webhook_id, token=webhook_token)
r = self.request("DELETE", _endpoint) r = self.request("DELETE", _endpoint)
return r return r