From c84438af83ccb17d24b56fc56865273fb1fd224b Mon Sep 17 00:00:00 2001 From: Kepka Ludovic Date: Sun, 17 Aug 2025 13:12:03 +0200 Subject: [PATCH] Legere correctif sur le bot pour proton db --- discordbot/__init__.py | 3 +-- protondb/__init__.py | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/discordbot/__init__.py b/discordbot/__init__.py index 8c73881..54f67d3 100644 --- a/discordbot/__init__.py +++ b/discordbot/__init__.py @@ -81,8 +81,7 @@ async def on_message(message: Message): else : msg = f'{mention} J\'ai trouvé {len(games)} jeux :\n' ite = iter(games) - while (game := next(ite, None)) is not None and len(msg) < 1900 : - print(game) + while (game := next(ite, None)) is not None and len(msg) < 1850 : msg += f'- [{game.get('name')}](https://www.protondb.com/app/{game.get('id')}) classé **{game.get('tier')}**\n' rest = sum(1 for _ in ite) if (rest > 0): diff --git a/protondb/__init__.py b/protondb/__init__.py index a7fcced..e66f35e 100644 --- a/protondb/__init__.py +++ b/protondb/__init__.py @@ -1,6 +1,7 @@ import logging import requests +import re from algoliasearch.search.client import SearchClientSync, SearchConfig from database.helpers import ConfigurationHelper @@ -24,8 +25,10 @@ def _call_summary(id): logging.error(f'{response.status_code} on {id}') return None -def _is_name_match(name:str, search_name:str) -> bool: - return name.lower().find(search_name.lower()) >= 0 +def _is_name_match(name:str, search_name:str) -> bool: + normalized_game_name = re.sub("[^a-z0-9]", "", name.lower()) + normalized_search_name = re.sub("[^a-z0-9]", "", search_name.lower()) + return normalized_game_name.find(normalized_search_name.lower()) >= 0 def searhProtonDb(search_name:str): results = []