diff --git a/discordbot/__init__.py b/discordbot/__init__.py index 27acb92..df6c671 100644 --- a/discordbot/__init__.py +++ b/discordbot/__init__.py @@ -10,6 +10,7 @@ from database import db from database.helpers import ConfigurationHelper from database.models import Configuration, GameBundle, Humeur from protondb import searhProtonDb +from discord import Message class DiscordBot(discord.Client): @@ -67,16 +68,18 @@ intents.message_content = True bot = DiscordBot(intents=intents) @bot.event -async def on_message(message): - content: str = message.content; - if(ConfigurationHelper().getValue('proton_db_enable_enable') and content.find('!protondb')==0) : - if (content.find('@')>0) : - user = content[content.find('@'):] +async def on_message(message: Message): + if(ConfigurationHelper().getValue('proton_db_enable_enable') and message.content.find('!protondb')==0) : + if (message.content.find('<@')>0) : + mention = message.content[message.content.find('<@'):] else : - user = f'@{message.author.name}' - name = message.content.replace('!protondb', '').replace(f'{user}', '').strip(); + mention = message.author.mention + name = message.content.replace('!protondb', '').replace(f'{mention}', '').strip(); games = searhProtonDb(name) - msg = f'{user} J\'ai trouvé {len(games)} jeux :\n' - for game in games: - msg += f'- [{game.get('name')}](https://www.protondb.com/app/{game.get('id')}) classé **{game.get('tier')}**\n' + if (len(games)==0) : + msg = f'{mention} Je n\'ai pas trouvé de jeux correspondant à **{name}**' + else : + msg = f'{mention} J\'ai trouvé {len(games)} jeux :\n' + for game in games: + msg += f'- [{game.get('name')}](https://www.protondb.com/app/{game.get('id')}) classé **{game.get('tier')}**\n' await message.channel.send(msg) diff --git a/webapp/static/img/algolia-key.jpg b/webapp/static/img/algolia-key.jpg new file mode 100644 index 0000000..b5a8331 Binary files /dev/null and b/webapp/static/img/algolia-key.jpg differ diff --git a/webapp/templates/configurations.html b/webapp/templates/configurations.html index 5c65d6f..baa597c 100644 --- a/webapp/templates/configurations.html +++ b/webapp/templates/configurations.html @@ -31,6 +31,10 @@ +

Pour trouver les clefs, dans votre navigateur avec la console ouverte faites une recherche de jeux sur protondb, + puis chercher les clef dans les requetes, + comme le montre cet exemple +

Api