🥅 Caught error from in socket_server

This commit is contained in:
Mawoka
2022-05-06 22:12:43 +02:00
parent cbe6ab99b4
commit 61eb56f756
+16 -13
View File
@@ -14,20 +14,23 @@ settings = settings()
async def join_game(sid, data): async def join_game(sid, data):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
redis_res = await redis.get(f"game:{data['game_pin']}") redis_res = await redis.get(f"game:{data['game_pin']}")
if json.loads(redis_res)["captcha_enabled"]: try:
try: if json.loads(redis_res)["captcha_enabled"]:
async with session.post( try:
"https://hcaptcha.com/siteverify", async with session.post(
data={"response": data["captcha"], "secret": settings.hcaptcha_key}, "https://hcaptcha.com/siteverify",
) as resp: data={"response": data["captcha"], "secret": settings.hcaptcha_key},
resp_data = await resp.json() ) as resp:
if not resp_data["success"]: resp_data = await resp.json()
print("CAPTCHA FAILED") if not resp_data["success"]:
return print("CAPTCHA FAILED")
except KeyError: return
print("CAPTCHA FAILED") except KeyError:
print("CAPTCHA FAILED")
return return
except TypeError:
pass
if redis_res is None: if redis_res is None:
await sio.emit("game_not_found", room=sid) await sio.emit("game_not_found", room=sid)
else: else: