diff --git a/TODO.md b/TODO.md index 18cf720..e69de29 100644 --- a/TODO.md +++ b/TODO.md @@ -1,11 +0,0 @@ -# TODO - Kuby - -- [x] Identifier le cog qui démarre le serveur aiohttp sur 127.0.0.1:5001 (bug_report.py) -- [x] Remplacer l’async hook `cog_load` par un démarrage différé via `__init__` + `bot.loop.create_task` (disnake 2.12.0) -- [x] Renommer la logique serveur en `_start_webhook_server` -- [x] Attendre `await bot.wait_until_ready()` avant d’ouvrir le port -- [x] Conserver le retry bind port 5001 (OSError errno 98) -- [ ] Redémarrer le bot -- [ ] Vérifier dans les logs: "Internal Bot Webhook Server started on 127.0.0.1:5001" - - diff --git a/commandes/ticket/__init__.py b/commandes/ticket/__init__.py index b71b953..eaa4c41 100644 --- a/commandes/ticket/__init__.py +++ b/commandes/ticket/__init__.py @@ -182,7 +182,7 @@ class TicketPanelView(disnake.ui.View): accessory=disnake.ui.Button( label=cat.name, style=disnake.ButtonStyle.primary, - custom_id=f"cat_{cat.id}_{int(disnake.utils.time_snowflake(disnake.utils.utcnow()) / 1000)}" +custom_id=f"cat|{cat.id}|{int(disnake.utils.time_snowflake(disnake.utils.utcnow()) / 1000)}" ) ) ) @@ -3138,17 +3138,17 @@ class TicketCommands(commands.Cog): view = TicketPanelView(self.bot, config, self.storage) await view._analytics_callback(inter) - # ✅ BUGFIX: Sélection de catégorie en V2 => custom_id = cat_{cat.id}_{snowflake} - elif custom_id.startswith("cat_"): + # ✅ BUGFIX: Sélection de catégorie en V2 => custom_id = cat|| + elif str(custom_id).startswith("cat|"): try: - # format: cat__ - parts = custom_id.split("_") - if len(parts) >= 3: - cat_id = "_".join(parts[1:-1]) - else: - cat_id = parts[1] if len(parts) > 1 else None + # format: cat|| + parts = str(custom_id).split("|") + if len(parts) < 3: + await inter.response.send_message("Catégorie non trouvée.", ephemeral=True) + return - category = next((c for c in config.categories if c.id == cat_id), None) + cat_id = parts[1] + category = next((c for c in config.categories if str(c.id) == str(cat_id)), None) if not category: await inter.response.send_message("Catégorie non trouvée.", ephemeral=True) return @@ -3158,6 +3158,29 @@ class TicketCommands(commands.Cog): modal = RecruitmentQuestionsModal(self.bot, config, category) else: modal = TicketPriorityModal(self.bot, config, category) + + await inter.response.send_modal(modal) + except Exception as e: + kuby_logger.error(f"[TicketSystem] cat| routing error: {e}", exc_info=True) + if not inter.response.is_done(): + await inter.response.send_message(f"Erreur interne: {e}", ephemeral=True) + + # backward compatibility (legacy cat__) + elif custom_id.startswith("cat_"): + try: + parts = str(custom_id).split("_") + cat_id = "_".join(parts[1:-1]) if len(parts) >= 3 else (parts[1] if len(parts) > 1 else None) + + category = next((c for c in config.categories if str(c.id) == str(cat_id)), None) + if not category: + await inter.response.send_message("Catégorie non trouvée.", ephemeral=True) + return + + if category.is_recruitment and category.questions: + modal = RecruitmentQuestionsModal(self.bot, config, category) + else: + modal = TicketPriorityModal(self.bot, config, category) + await inter.response.send_modal(modal) except Exception as e: kuby_logger.error(f"[TicketSystem] cat_ routing error: {e}", exc_info=True)