From e8e33c46f04b944f108f5887136c157102505cf1 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Fri, 19 Aug 2016 18:52:38 -0500 Subject: [PATCH] Added a check for if a close match to the provided game is not found --- cogs/steam.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cogs/steam.py b/cogs/steam.py index 6910015..70033cf 100644 --- a/cogs/steam.py +++ b/cogs/steam.py @@ -55,8 +55,11 @@ app_id_map = {"portal 2": 620, "fallout new vegas": 22490 } def get_app_id(game: str): - best_match = process.extractOne(game, app_id_map.keys())[0] - return app_id_map.get(best_match) + best_match = process.extractOne(game, app_id_map.keys()) + if best_match[1] > 80: + return app_id_map.get(best_match[0]) + else: + return None class Steam: def __init__(self, bot): @@ -116,6 +119,9 @@ class Steam: app_id = int(option[1]) except ValueError: app_id = get_app_id(game.lower()) + if app_id is None: + await self.bot.say("Sorry, I couldn't find a close match for the game {}".format(game)) + return url = "{}/ISteamUserStats/GetPlayerAchievements/v0001/?key={}&steamid={}&appid={}".format(base_url, self.key, steam_id, app_id) elif option[0] == "games":