From 781e80626959cbc8ef50e7c904db58223aaffdf2 Mon Sep 17 00:00:00 2001 From: Antoine Dufils Date: Mon, 18 Aug 2025 14:58:37 +0200 Subject: [PATCH 1/2] Fix: make user sync messages ephemeral and suppress SSL warnings --- integration_bot/commands.py | 6 ++++-- integration_bot/utils/login.py | 4 ++++ integration_bot/utils/teams.py | 3 +++ integration_bot/utils/users.py | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/integration_bot/commands.py b/integration_bot/commands.py index 6fbf43f..ebc93a1 100644 --- a/integration_bot/commands.py +++ b/integration_bot/commands.py @@ -58,9 +58,11 @@ async def usersync_self(self, interaction: discord.Interaction) -> None: token = login() teams = get_teams_with_users(token) await assign_roles_to_member(interaction.user, teams, True) - await interaction.followup.send("✅ User sync for yourself completed successfully.") + await interaction.followup.send("✅ User sync for yourself completed successfully.", ephemeral = True) + except AttributeError: + await interaction.followup.send(f"❌ Error during user sync: You must execute this command in a server channel.", ephemeral = True) except Exception as e: - await interaction.followup.send(f"❌ Error during user sync for yourself: {str(e)}") + await interaction.followup.send(f"❌ Error during user sync for yourself: {str(e)}", ephemeral = True) @app_commands.command(name='cleanupteams', description="Nettoie les rôles, salons et retire le rôle 'Nouveau'") async def cleanupteams(self, interaction: discord.Interaction) -> None: diff --git a/integration_bot/utils/login.py b/integration_bot/utils/login.py index ed161a4..44fa752 100644 --- a/integration_bot/utils/login.py +++ b/integration_bot/utils/login.py @@ -1,5 +1,9 @@ import os import requests +import urllib3 + +# Disable SSL warnings when verify=False is used +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) def login() -> str: api_url:str = os.getenv("API_URL") + "/auth/login" diff --git a/integration_bot/utils/teams.py b/integration_bot/utils/teams.py index 44e64c1..43c327f 100644 --- a/integration_bot/utils/teams.py +++ b/integration_bot/utils/teams.py @@ -1,6 +1,9 @@ import os import requests +# Disable SSL warnings when verify=False is used +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + def get_teams_with_factions(token: str) -> list: url = os.getenv("API_URL") + "/team/admin/teamswithfactions" headers = {"Authorization": f"Bearer {token}"} diff --git a/integration_bot/utils/users.py b/integration_bot/utils/users.py index 170863a..6cbd536 100644 --- a/integration_bot/utils/users.py +++ b/integration_bot/utils/users.py @@ -1,6 +1,9 @@ import os import requests +# Disable SSL warnings when verify=False is used +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + def get_teams_with_users(token: str) -> list: url = os.getenv("API_URL") + "/team/admin/teamswithusers" headers = {"Authorization": f"Bearer {token}"} From 48976685f4ed39a38af63fa45a07057444396cdd Mon Sep 17 00:00:00 2001 From: Antoine Dufils Date: Mon, 18 Aug 2025 15:17:48 +0200 Subject: [PATCH 2/2] add logging for fetch teams --- integration_bot/utils/users.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration_bot/utils/users.py b/integration_bot/utils/users.py index 6cbd536..165151f 100644 --- a/integration_bot/utils/users.py +++ b/integration_bot/utils/users.py @@ -1,4 +1,5 @@ import os +import logging import requests # Disable SSL warnings when verify=False is used @@ -7,11 +8,11 @@ def get_teams_with_users(token: str) -> list: url = os.getenv("API_URL") + "/team/admin/teamswithusers" headers = {"Authorization": f"Bearer {token}"} - print(f"[FETCH] Fetching teams with users...") + logging.info(f"[FETCH] Fetching teams with users...") response = requests.get(url, headers=headers, verify=False) if response.status_code == 200: data = response.json().get('data', []) - print(f"[FETCH] Retrieved {len(data)} teams.") + logging.info(f"[FETCH] Retrieved {len(data)} teams.") return data else: print(f"[FETCH] Failed to fetch teams. Status: {response.status_code}, Response: {response.text}")