.BANCHO. Switch from mirrorapi to cheesegull for beatmap update requests

This commit is contained in:
Nyo 2017-01-16 21:24:15 +01:00
parent 2407ecc3bf
commit 784c4a11f1
3 changed files with 14 additions and 24 deletions

2
common

@ -1 +1 @@
Subproject commit 751cd5e293bc2da8ca37c574a16c2ad848b0a6f6 Subproject commit 7262d62693691321907476321235014ca62dcec4

View File

@ -17,6 +17,7 @@ from helpers import systemHelper
from objects import fokabot from objects import fokabot
from objects import glob from objects import glob
from helpers import chatHelper as chat from helpers import chatHelper as chat
from common.web import cheesegull
""" """
Commands callbacks Commands callbacks
@ -396,7 +397,7 @@ def getPPMessage(userID, just_data = False):
# Make sure status is 200 # Make sure status is 200
if data["status"] != 200: if data["status"] != 200:
if "message" in data: 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: else:
raise exceptions.apiException raise exceptions.apiException
@ -432,7 +433,7 @@ def getPPMessage(userID, just_data = False):
return "API Timeout. Please try again in a few seconds." return "API Timeout. Please try again in a few seconds."
except exceptions.apiException: except exceptions.apiException:
# API error # API error
return "Unknown error in LETS API call. Please tell this to a dev." return "Unknown error in LETS API call."
#except: #except:
# Unknown exception # Unknown exception
# TODO: print exception # TODO: print exception
@ -681,23 +682,12 @@ def updateBeatmap(fro, chan, message):
if token.tillerino[0] == 0: if token.tillerino[0] == 0:
return "Please give me a beatmap first with /np command." return "Please give me a beatmap first with /np command."
# Send request # Send the request to cheesegull
beatmapData = glob.db.fetch("SELECT beatmapset_id, song_name FROM beatmaps WHERE beatmap_id = %s LIMIT 1", [token.tillerino[0]]) ok, message = cheesegull.updateBeatmap(token.tillerino[0])
if beatmapData is None: if ok:
return "Couldn't find beatmap data in database. Please load the beatmap's leaderboard and try again." return "An update request for that beatmap has been queued. Check back in a few minutes and the beatmap should be updated!"
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."
else: 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: except:
return False return False

View File

@ -48,8 +48,8 @@ class config:
self.config.get("server","gziplevel") self.config.get("server","gziplevel")
self.config.get("server","cikey") self.config.get("server","cikey")
self.config.get("mirror","url") self.config.get("cheesegull", "apiurl")
self.config.get("mirror","apikey") self.config.get("cheesegull", "apikey")
self.config.get("debug","enable") self.config.get("debug","enable")
self.config.get("debug","packets") self.config.get("debug","packets")
@ -107,9 +107,9 @@ class config:
self.config.set("server", "gziplevel", "6") self.config.set("server", "gziplevel", "6")
self.config.set("server", "cikey", "changeme") self.config.set("server", "cikey", "changeme")
self.config.add_section("mirror") self.config.add_section("cheesegull")
self.config.set("mirror", "url", "http://storage.ripple.moe") self.config.set("cheesegull", "apiurl", "http://cheesegu.ll/api")
self.config.set("mirror", "apikey", "anotherkey") self.config.set("cheesegull", "apikey", "")
self.config.add_section("debug") self.config.add_section("debug")
self.config.set("debug", "enable", "0") self.config.set("debug", "enable", "0")