Skip to content

Commit a08d96d

Browse files
authored
Merge pull request #4 from ungdev/some-fix
Fix: make user sync messages ephemeral and suppress SSL warnings
2 parents 0ea406f + 4897668 commit a08d96d

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

integration_bot/commands.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ async def usersync_self(self, interaction: discord.Interaction) -> None:
5858
token = login()
5959
teams = get_teams_with_users(token)
6060
await assign_roles_to_member(interaction.user, teams, True)
61-
await interaction.followup.send("✅ User sync for yourself completed successfully.")
61+
await interaction.followup.send("✅ User sync for yourself completed successfully.", ephemeral = True)
62+
except AttributeError:
63+
await interaction.followup.send(f"❌ Error during user sync: You must execute this command in a server channel.", ephemeral = True)
6264
except Exception as e:
63-
await interaction.followup.send(f"❌ Error during user sync for yourself: {str(e)}")
65+
await interaction.followup.send(f"❌ Error during user sync for yourself: {str(e)}", ephemeral = True)
6466

6567
@app_commands.command(name='cleanupteams', description="Nettoie les rôles, salons et retire le rôle 'Nouveau'")
6668
async def cleanupteams(self, interaction: discord.Interaction) -> None:

integration_bot/utils/login.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import os
22
import requests
3+
import urllib3
4+
5+
# Disable SSL warnings when verify=False is used
6+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
37

48
def login() -> str:
59
api_url:str = os.getenv("API_URL") + "/auth/login"

integration_bot/utils/teams.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import os
22
import requests
33

4+
# Disable SSL warnings when verify=False is used
5+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
6+
47
def get_teams_with_factions(token: str) -> list:
58
url = os.getenv("API_URL") + "/team/admin/teamswithfactions"
69
headers = {"Authorization": f"Bearer {token}"}

integration_bot/utils/users.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import os
2+
import logging
23
import requests
34

5+
# Disable SSL warnings when verify=False is used
6+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
7+
48
def get_teams_with_users(token: str) -> list:
59
url = os.getenv("API_URL") + "/team/admin/teamswithusers"
610
headers = {"Authorization": f"Bearer {token}"}
7-
print(f"[FETCH] Fetching teams with users...")
11+
logging.info(f"[FETCH] Fetching teams with users...")
812
response = requests.get(url, headers=headers, verify=False)
913
if response.status_code == 200:
1014
data = response.json().get('data', [])
11-
print(f"[FETCH] Retrieved {len(data)} teams.")
15+
logging.info(f"[FETCH] Retrieved {len(data)} teams.")
1216
return data
1317
else:
1418
print(f"[FETCH] Failed to fetch teams. Status: {response.status_code}, Response: {response.text}")

0 commit comments

Comments
 (0)