summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-01-02 20:05:15 -0800
committerFuwn <[email protected]>2023-01-02 20:05:15 -0800
commitb66bf0d63af0f5973c9cd96567c2aa99d9e13de3 (patch)
tree55fd46ccf90e5e5246dd6e7844264019237338db
parentfix(api.py): flask port... (diff)
downloadrubys_song_skipper-b66bf0d63af0f5973c9cd96567c2aa99d9e13de3.tar.xz
rubys_song_skipper-b66bf0d63af0f5973c9cd96567c2aa99d9e13de3.zip
fix: save code to file
-rw-r--r--rubys_song_skipper/api.py5
-rw-r--r--rubys_song_skipper/bot.py33
2 files changed, 22 insertions, 16 deletions
diff --git a/rubys_song_skipper/api.py b/rubys_song_skipper/api.py
index f31aa69..63f50b8 100644
--- a/rubys_song_skipper/api.py
+++ b/rubys_song_skipper/api.py
@@ -4,7 +4,6 @@ import threading
app = Flask(__name__)
-code = ""
@app.route("/")
@@ -23,7 +22,9 @@ def login():
@app.route("/callback")
def callback():
- code = request.args.get("code")
+ with open("code.txt", "w") as file:
+ file.write(request.args.get("code"))
+ file.close()
return (
"thanks"
diff --git a/rubys_song_skipper/bot.py b/rubys_song_skipper/bot.py
index b25ac9c..a0650b6 100644
--- a/rubys_song_skipper/bot.py
+++ b/rubys_song_skipper/bot.py
@@ -21,17 +21,22 @@ class Bot(commands.Bot):
@commands.command(name="skip")
async def skip(self, ctx):
- if api.code == "":
- await ctx.send("no code, sign in")
- else:
- print(
- requests.post(
- "https://api.spotify.com/v1/me/player/next",
- headers={
- "Authorization": "Bearer " + api.code,
- "Content-Type": "application/json",
- },
- ).text
- )
-
- await ctx.send("skipped lol")
+ with open("code.txt", "r") as file:
+ code = file.read()
+
+ file.close()
+
+ if code == "":
+ await ctx.send("no code, sign in")
+ else:
+ print(
+ requests.post(
+ "https://api.spotify.com/v1/me/player/next",
+ headers={
+ "Authorization": "Bearer " + api.code,
+ "Content-Type": "application/json",
+ },
+ ).text
+ )
+
+ await ctx.send("skipped lol")