refactor(modmail): centralize config into single /modmail config panel
- Remove 5 redundant commands (setup, addcategory, removecategory, enable, disable) - Single /modmail config opens interactive Components V2 panel - Channel select for ticket category, role select for staff, channel select for logs - Toggle enable/disable button - Categories sub-panel: add via modal, remove via select - Fix lint (unused imports/vars, contextlib.suppress) + ruff format
This commit is contained in:
parent
f505b6c552
commit
b736f4cc8b
6 changed files with 251 additions and 157 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from config import DATA_DIR
|
||||
|
||||
|
|
@ -32,6 +31,12 @@ def get_config() -> dict:
|
|||
return _load()
|
||||
|
||||
|
||||
def set_guild_id(guild_id: int):
|
||||
data = _load()
|
||||
data["guild_id"] = guild_id
|
||||
_save(data)
|
||||
|
||||
|
||||
def set_enabled(guild_id: int, enabled: bool):
|
||||
data = _load()
|
||||
data["enabled"] = enabled
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import html
|
||||
import os
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
|
|
@ -35,12 +34,16 @@ def generate_transcript(messages: list[dict], ticket_info: dict) -> str:
|
|||
attachments_html = ""
|
||||
for att in msg.get("attachments", []):
|
||||
if att.url.lower().endswith((".png", ".jpg", ".jpeg", ".gif", ".webp")):
|
||||
attachments_html += f'<div class="attachment"><img src="{html.escape(att.url)}" alt="attachment" /></div>'
|
||||
attachments_html += (
|
||||
f'<div class="attachment"><img src="{html.escape(att.url)}" alt="attachment" /></div>'
|
||||
)
|
||||
else:
|
||||
attachments_html += f'<div class="attachment"><a href="{html.escape(att.url)}">{html.escape(att.filename)}</a></div>'
|
||||
attachments_html += (
|
||||
f'<div class="attachment"><a href="{html.escape(att.url)}">{html.escape(att.filename)}</a></div>'
|
||||
)
|
||||
|
||||
messages_html += f"""
|
||||
<div class="message {'staff' if is_staff else 'user'}">
|
||||
<div class="message {"staff" if is_staff else "user"}">
|
||||
<div class="msg-header">
|
||||
<img class="avatar" src="{avatar}" alt="{html.escape(str(author))}" />
|
||||
<span class="author">{html.escape(str(author))}</span>
|
||||
|
|
@ -60,7 +63,7 @@ def generate_transcript(messages: list[dict], ticket_info: dict) -> str:
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Transcript — Ticket #{ticket_info.get('channel_id', 0)}</title>
|
||||
<title>Transcript — Ticket #{ticket_info.get("channel_id", 0)}</title>
|
||||
<style>
|
||||
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
||||
body {{
|
||||
|
|
@ -184,10 +187,10 @@ def generate_transcript(messages: list[dict], ticket_info: dict) -> str:
|
|||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Transcript — Ticket #{ticket_info.get('channel_id', 0)}</h1>
|
||||
<h1>Transcript — Ticket #{ticket_info.get("channel_id", 0)}</h1>
|
||||
<div class="meta">
|
||||
<span>Catégorie: {html.escape(ticket_info.get('category', 'N/A'))}</span>
|
||||
<span>Utilisateur: {ticket_info.get('user_id', 'N/A')}</span>
|
||||
<span>Catégorie: {html.escape(ticket_info.get("category", "N/A"))}</span>
|
||||
<span>Utilisateur: {ticket_info.get("user_id", "N/A")}</span>
|
||||
<span>Généré le: {date_str}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue