From 784c4a11f17315abb8eb492c6a61637dd50c5d38 Mon Sep 17 00:00:00 2001 From: Nyo Date: Mon, 16 Jan 2017 21:24:15 +0100 Subject: [PATCH] .BANCHO. Switch from mirrorapi to cheesegull for beatmap update requests --- common | 2 +- constants/fokabotCommands.py | 26 ++++++++------------------ helpers/configHelper.py | 10 +++++----- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/common b/common index 751cd5e..7262d62 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 751cd5e293bc2da8ca37c574a16c2ad848b0a6f6 +Subproject commit 7262d62693691321907476321235014ca62dcec4 diff --git a/constants/fokabotCommands.py b/constants/fokabotCommands.py index a667590..b596d1d 100644 --- a/constants/fokabotCommands.py +++ b/constants/fokabotCommands.py @@ -17,6 +17,7 @@ from helpers import systemHelper from objects import fokabot from objects import glob from helpers import chatHelper as chat +from common.web import cheesegull """ Commands callbacks @@ -396,7 +397,7 @@ def getPPMessage(userID, just_data = False): # Make sure status is 200 if data["status"] != 200: if "message" in data: - return "Error in LETS API call ({}). Please tell this to a dev.".format(data["message"]) + return "Error in LETS API call ({}).".format(data["message"]) else: raise exceptions.apiException @@ -432,7 +433,7 @@ def getPPMessage(userID, just_data = False): return "API Timeout. Please try again in a few seconds." except exceptions.apiException: # API error - return "Unknown error in LETS API call. Please tell this to a dev." + return "Unknown error in LETS API call." #except: # Unknown exception # TODO: print exception @@ -681,23 +682,12 @@ def updateBeatmap(fro, chan, message): if token.tillerino[0] == 0: return "Please give me a beatmap first with /np command." - # Send request - beatmapData = glob.db.fetch("SELECT beatmapset_id, song_name FROM beatmaps WHERE beatmap_id = %s LIMIT 1", [token.tillerino[0]]) - if beatmapData is None: - return "Couldn't find beatmap data in database. Please load the beatmap's leaderboard and try again." - - response = requests.post("{}/api/v1/update_beatmap".format(glob.conf.config["mirror"]["url"]), { - "beatmap_set_id": beatmapData["beatmapset_id"], - "beatmap_name": beatmapData["song_name"], - "username": token.username, - "key": glob.conf.config["mirror"]["apikey"] - }) - if response.status_code == 200: - return "An update request for that beatmap has been queued. You'll receive a message once the beatmap has been updated on our mirror!" - elif response.status_code == 429: - return "You are sending too many beatmaps update requests. Wait a bit and retry later." + # Send the request to cheesegull + ok, message = cheesegull.updateBeatmap(token.tillerino[0]) + if ok: + return "An update request for that beatmap has been queued. Check back in a few minutes and the beatmap should be updated!" else: - return "Error in beatmap mirror API request. Tell this to a dev: {}".format(response.text) + return "Error in beatmap mirror API request: {}".format(message) except: return False diff --git a/helpers/configHelper.py b/helpers/configHelper.py index ed5a351..86f0674 100644 --- a/helpers/configHelper.py +++ b/helpers/configHelper.py @@ -48,8 +48,8 @@ class config: self.config.get("server","gziplevel") self.config.get("server","cikey") - self.config.get("mirror","url") - self.config.get("mirror","apikey") + self.config.get("cheesegull", "apiurl") + self.config.get("cheesegull", "apikey") self.config.get("debug","enable") self.config.get("debug","packets") @@ -107,9 +107,9 @@ class config: self.config.set("server", "gziplevel", "6") self.config.set("server", "cikey", "changeme") - self.config.add_section("mirror") - self.config.set("mirror", "url", "http://storage.ripple.moe") - self.config.set("mirror", "apikey", "anotherkey") + self.config.add_section("cheesegull") + self.config.set("cheesegull", "apiurl", "http://cheesegu.ll/api") + self.config.set("cheesegull", "apikey", "") self.config.add_section("debug") self.config.set("debug", "enable", "0")