Merge branch 'main' into ProtonDbGameAlias

This commit is contained in:
skylanix
2025-08-22 15:46:23 +02:00
committed by GitHub
4 changed files with 19 additions and 16 deletions

View File

@@ -41,7 +41,7 @@ class DiscordBot(discord.Client):
if token : if token :
self.run(token.value) self.run(token.value)
else : else :
logging.error('Pas de token, on ne lance pas Discord') logging.error('Aucun token Discord configuré. Le bot ne peut pas être démarré')
intents = discord.Intents.default() intents = discord.Intents.default()
intents.message_content = True intents.message_content = True
@@ -61,7 +61,7 @@ async def on_message(message: Message):
await message.channel.send(commande.response, suppress_embeds=True) await message.channel.send(commande.response, suppress_embeds=True)
return return
except Exception as e: except Exception as e:
logging.error(e) logging.error(f'Échec de l\'exécution de la commande Discord : {e}')
if(ConfigurationHelper().getValue('proton_db_enable_enable') and message.content.find('!protondb')==0) : if(ConfigurationHelper().getValue('proton_db_enable_enable') and message.content.find('!protondb')==0) :
if (message.content.find('<@')>0) : if (message.content.find('<@')>0) :
@@ -83,5 +83,5 @@ async def on_message(message: Message):
try : try :
await message.channel.send(msg, suppress_embeds=True) await message.channel.send(msg, suppress_embeds=True)
except Exception as e: except Exception as e:
logging.error(e) logging.error(f'Échec de l\'envoi du message ProtonDB : {e}')

View File

@@ -16,7 +16,7 @@ def _callHexas():
response = requests.get("http://hexas.shionn.org/humble-bundle/json", headers={ "Content-Type": "application/json" }) response = requests.get("http://hexas.shionn.org/humble-bundle/json", headers={ "Content-Type": "application/json" })
if response.status_code == 200: if response.status_code == 200:
return response.json() return response.json()
logging.error(f"Erreur de connexion {response.status_code}") logging.error(f"Échec de la connexion à l'API Humble Bundle. Code de statut HTTP : {response.status_code}")
return None return None
def _isNotAlreadyNotified(bundle): def _isNotAlreadyNotified(bundle):
@@ -41,7 +41,7 @@ async def checkHumbleBundleAndNotify(bot: Client):
db.session.add(GameBundle(id=bundle['id'], name=bundle['name'], json = json.dumps(bundle))) db.session.add(GameBundle(id=bundle['id'], name=bundle['name'], json = json.dumps(bundle)))
db.session.commit() db.session.commit()
except Exception as e: except Exception as e:
logging.error(f"Erreur de connexion {e}") logging.error(f"Échec de la vérification des offres Humble Bundle : {e}")
else: else:
logging.info('Humble Bundle est désactivé') logging.info('Humble Bundle est désactivé')

View File

@@ -24,7 +24,7 @@ def _call_summary(id):
response = requests.get(f'http://jazzy-starlight-aeea19.netlify.app/api/v1/reports/summaries/{id}.json') response = requests.get(f'http://jazzy-starlight-aeea19.netlify.app/api/v1/reports/summaries/{id}.json')
if (response.status_code == 200) : if (response.status_code == 200) :
return response.json() return response.json()
logging.error(f'{response.status_code} on {id}') logging.error(f'Échec de la récupération des données ProtonDB pour le jeu {id}. Code de statut HTTP : {response.status_code}')
return None return None
def _is_name_match(name:str, search_name:str) -> bool: def _is_name_match(name:str, search_name:str) -> bool:
@@ -56,7 +56,7 @@ def searhProtonDb(search_name:str):
}) })
logging.info(f'Trouvé {name}({id}) : {tier}') logging.info(f'Trouvé {name}({id}) : {tier}')
except Exception as e: except Exception as e:
logging.error(f'error on {name}({id}): {e}') logging.error(f'Erreur lors du traitement du jeu {name} (ID: {id}) : {e}')
else: else:
logging.info(f'{name}({id}) ne contient pas {search_name}') logging.info(f'{name}({id}) ne contient pas {search_name}')
return results return results

View File

@@ -33,15 +33,18 @@ class TwitchBot() :
async def _connect(self): async def _connect(self):
with webapp.app_context(): with webapp.app_context():
if _isConfigured() : if _isConfigured() :
helper = ConfigurationHelper() try :
self.twitch = await Twitch(helper.getValue('twitch_client_id'), helper.getValue('twitch_client_secret')) helper = ConfigurationHelper()
await self.twitch.set_user_authentication(helper.getValue('twitch_access_token'), USER_SCOPE, helper.getValue('twitch_refresh_token')) self.twitch = await Twitch(helper.getValue('twitch_client_id'), helper.getValue('twitch_client_secret'))
self.chat = await Chat(self.twitch) await self.twitch.set_user_authentication(helper.getValue('twitch_access_token'), USER_SCOPE, helper.getValue('twitch_refresh_token'))
self.chat.register_event(ChatEvent.READY, _onReady) self.chat = await Chat(self.twitch)
self.chat.register_event(ChatEvent.MESSAGE, _onMessage) self.chat.register_event(ChatEvent.READY, _onReady)
# chat.register_event(ChatEvent.SUB, on_sub) self.chat.register_event(ChatEvent.MESSAGE, _onMessage)
self.chat.register_command('hello', _helloCommand) # chat.register_event(ChatEvent.SUB, on_sub)
self.chat.start() self.chat.register_command('hello', _helloCommand)
self.chat.start()
except Exception as e:
logging.error(f'Échec de l\'authentification Twitch. Vérifiez vos identifiants et redémarrez après correction : {e}')
else: else:
logging.info("Twitch n'est pas configuré") logging.info("Twitch n'est pas configuré")