Merge branch 'dev' into 'main'
V1.3 du système de gestions des rapports d'utilisateur See merge request Omega_Kube/kuby!7
This commit is contained in:
commit
a41a6f35fd
2 changed files with 13 additions and 6 deletions
8
bot.py
8
bot.py
|
|
@ -54,15 +54,17 @@ class MyBot(commands.Bot):
|
||||||
try:
|
try:
|
||||||
flask_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "serveur_flask.py")
|
flask_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "serveur_flask.py")
|
||||||
if os.path.exists(flask_path):
|
if os.path.exists(flask_path):
|
||||||
|
# On utilise DEVNULL car PM2 ou Nohup gèrent déjà les logs globaux
|
||||||
|
# et ça évite que le pipe se remplisse et bloque le serveur Flask
|
||||||
self.flask_process = subprocess.Popen(
|
self.flask_process = subprocess.Popen(
|
||||||
[sys.executable, flask_path],
|
[sys.executable, flask_path],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.DEVNULL,
|
||||||
cwd=os.path.dirname(flask_path)
|
cwd=os.path.dirname(flask_path)
|
||||||
)
|
)
|
||||||
kuby_logger.info(f"✅ Serveur Flask démarré (PID: {self.flask_process.pid})")
|
kuby_logger.info(f"✅ Serveur Flask démarré (PID: {self.flask_process.pid})")
|
||||||
else:
|
else:
|
||||||
kuby_logger.warning(f"⚠️ Fichier serveur_flask.py introuvable à {flask_path}")
|
kuby_logger.warning(f"⚠️ Fichier serveur_flask.py introuvable")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
kuby_logger.error(f"❌ Impossible de démarrer le serveur Flask: {e}")
|
kuby_logger.error(f"❌ Impossible de démarrer le serveur Flask: {e}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ app = Flask(__name__)
|
||||||
|
|
||||||
# --- CONFIGURATION ---
|
# --- CONFIGURATION ---
|
||||||
PROJECT_PATH = "/home/discord/Bot/Kuby_V2"
|
PROJECT_PATH = "/home/discord/Bot/Kuby_V2"
|
||||||
WEBHOOK_SECRET = "Nois1"
|
WEBHOOK_SECRET = "Nois2"
|
||||||
PROCESS_NAME = "kuby-bot"
|
PROCESS_NAME = "kuby-bot"
|
||||||
DISCORD_LOG_URL = "https://discord.com/api/webhooks/1482148910888652910/IA9CcOWtjGswbuxMaOu_6uaclv5zojZo4ttxtV6RYyZzJ9gW7BF7xp_Zv3oPIjYEuh8o"
|
DISCORD_LOG_URL = "https://discord.com/api/webhooks/1482148910888652910/IA9CcOWtjGswbuxMaOu_6uaclv5zojZo4ttxtV6RYyZzJ9gW7BF7xp_Zv3oPIjYEuh8o"
|
||||||
|
|
||||||
|
|
@ -78,8 +78,13 @@ def deploy():
|
||||||
@app.route('/gitlab_webhook', methods=['POST'])
|
@app.route('/gitlab_webhook', methods=['POST'])
|
||||||
def gitlab_webhook():
|
def gitlab_webhook():
|
||||||
# Protection par Token uniquement (anti-crawler géré par le secret)
|
# Protection par Token uniquement (anti-crawler géré par le secret)
|
||||||
if request.headers.get('X-Gitlab-Token') != WEBHOOK_SECRET:
|
received_token = request.headers.get('X-Gitlab-Token')
|
||||||
abort(404)
|
|
||||||
|
# Log de debug pour voir ce que GitLab envoie vs ce qu'on attend
|
||||||
|
print(f"[DEBUG] Webhook reçu. Token attendu: '{WEBHOOK_SECRET}', Token reçu: '{received_token}'")
|
||||||
|
|
||||||
|
if received_token != WEBHOOK_SECRET:
|
||||||
|
abort(403) # Changé en 403 pour différencier une route non trouvée d'un accès refusé
|
||||||
|
|
||||||
# Transférer la payload au bot Discord localement sur le port 5001
|
# Transférer la payload au bot Discord localement sur le port 5001
|
||||||
payload = request.json
|
payload = request.json
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue