mention dans protondb

This commit is contained in:
Kepka Ludovic
2025-08-15 23:22:49 +02:00
committed by skylanix
parent 488c49e42e
commit 9aed719889
3 changed files with 17 additions and 10 deletions

View File

@@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 KiB

View File

@@ -31,6 +31,10 @@
<label for="proton_db_api_key">Api KEY</label>
<input name="proton_db_api_key" type="text" value="{{ configuration.getValue('proton_db_api_key') }}" />
<input type="Submit" value="Définir">
<p>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,
<a href="/static/img/algolia-key.jpg" target="_blank">comme le montre cet exemple</a>
</p>
</form>
<h2>Api</h2>