V1.3 du système de gestions des rapports d'utilisateur
This commit is contained in:
parent
22b3c2a3c4
commit
813ddeb802
2 changed files with 13 additions and 6 deletions
8
bot.py
8
bot.py
|
|
@ -54,15 +54,17 @@ class MyBot(commands.Bot):
|
|||
try:
|
||||
flask_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "serveur_flask.py")
|
||||
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(
|
||||
[sys.executable, flask_path],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
cwd=os.path.dirname(flask_path)
|
||||
)
|
||||
kuby_logger.info(f"✅ Serveur Flask démarré (PID: {self.flask_process.pid})")
|
||||
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:
|
||||
kuby_logger.error(f"❌ Impossible de démarrer le serveur Flask: {e}")
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ app = Flask(__name__)
|
|||
|
||||
# --- CONFIGURATION ---
|
||||
PROJECT_PATH = "/home/discord/Bot/Kuby_V2"
|
||||
WEBHOOK_SECRET = "Nois1"
|
||||
WEBHOOK_SECRET = "Nois2"
|
||||
PROCESS_NAME = "kuby-bot"
|
||||
DISCORD_LOG_URL = "https://discord.com/api/webhooks/1482148910888652910/IA9CcOWtjGswbuxMaOu_6uaclv5zojZo4ttxtV6RYyZzJ9gW7BF7xp_Zv3oPIjYEuh8o"
|
||||
|
||||
|
|
@ -78,8 +78,13 @@ def deploy():
|
|||
@app.route('/gitlab_webhook', methods=['POST'])
|
||||
def gitlab_webhook():
|
||||
# Protection par Token uniquement (anti-crawler géré par le secret)
|
||||
if request.headers.get('X-Gitlab-Token') != WEBHOOK_SECRET:
|
||||
abort(404)
|
||||
received_token = request.headers.get('X-Gitlab-Token')
|
||||
|
||||
# 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
|
||||
payload = request.json
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue