diff options
| author | Fuwn <[email protected]> | 2023-01-02 22:49:27 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-01-02 22:49:27 -0800 |
| commit | f0a259e01855f7153a58464999fca4e3f4edaf1b (patch) | |
| tree | 2c306c3a7cbdc490de2a98220a3d1e7d7ee0f5e3 | |
| parent | fix: debug (diff) | |
| download | rubys_song_skipper-f0a259e01855f7153a58464999fca4e3f4edaf1b.tar.xz rubys_song_skipper-f0a259e01855f7153a58464999fca4e3f4edaf1b.zip | |
feat(bot.py): always refresh token
| -rw-r--r-- | rubys_song_skipper/bot.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/rubys_song_skipper/bot.py b/rubys_song_skipper/bot.py index 328e66b..2b2b370 100644 --- a/rubys_song_skipper/bot.py +++ b/rubys_song_skipper/bot.py @@ -30,6 +30,16 @@ class Bot(commands.Bot): refresh = lines[1].strip() expire = lines[2].strip() + refreshed = spotify.refresh_bearer(refresh) + access = refreshed[0] + expire = refreshed[1] + + with open("code.txt", "w") as file: + file.write(f"{access}\n{refresh}\n{expire}") + file.close() + + file.close() + # if time.time() > float(expire): # file.close() @@ -44,16 +54,12 @@ class Bot(commands.Bot): if data == "": await ctx.send("i'm not authorized to do that. sign in.") else: - print( - requests.post( - "https://api.spotify.com/v1/me/player/next", - headers={ - "Authorization": "Bearer " + access, - "Content-Type": "application/json", - }, - ).text + requests.post( + "https://api.spotify.com/v1/me/player/next", + headers={ + "Authorization": "Bearer " + access, + "Content-Type": "application/json", + }, ) await ctx.send("i've skipped that song.") - - file.close() |