aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-12-11 13:50:03 -0800
committerGravatar MarkKoz <[email protected]>2019-12-11 13:50:03 -0800
commite49d9d5429c8e1aedfde5a5d38750890b3361496 (patch)
treefdd0ee39afcd5a5c783f1f10b85a082131de5761
parentReddit: use expires_in from the response to calculate token expiration (diff)
Reddit: define AccessToken type at the module level
-rw-r--r--bot/cogs/reddit.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/bot/cogs/reddit.py b/bot/cogs/reddit.py
index 083f90573..d9e1f0a39 100644
--- a/bot/cogs/reddit.py
+++ b/bot/cogs/reddit.py
@@ -18,6 +18,8 @@ from bot.pagination import LinePaginator
log = logging.getLogger(__name__)
+AccessToken = namedtuple("AccessToken", ["token", "expires_at"])
+
class Reddit(Cog):
"""Track subreddit posts and show detailed statistics about them."""
@@ -73,7 +75,6 @@ class Reddit(Cog):
if response.status == 200 and response.content_type == "application/json":
content = await response.json()
expiration = int(content["expires_in"]) - 60 # Subtract 1 minute for leeway.
- AccessToken = namedtuple("AccessToken", ["token", "expires_at"])
self.access_token = AccessToken(
token=content["access_token"],
expires_at=datetime.utcnow() + timedelta(seconds=expiration)