370 lines
14 KiB
HTML
370 lines
14 KiB
HTML
{% extends "template.html" %}
|
|
|
|
{% block content %}
|
|
<h1>Configuration de Mamie</h1>
|
|
<p>Configurez les tokens Discord, les notifications Humble Bundle et l'API Twitch.</p>
|
|
|
|
<h2>Discord</h2>
|
|
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ category }}" style="padding: 10px; margin: 10px 0; border-radius: 5px; {% if category == 'error' %}background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb;{% else %}background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb;{% endif %}">
|
|
{{ message }}
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<form action="{{ url_for('updateConfiguration') }}" method="POST">
|
|
<fieldset>
|
|
<legend>API Discord</legend>
|
|
<label for="discord_token">Token Discord (caché)</label>
|
|
<input name="discord_token" type="password" placeholder="Votre token Discord" />
|
|
<small>Nécessite un redémarrage après modification</small>
|
|
</fieldset>
|
|
|
|
<fieldset>
|
|
<legend>Messages de bienvenue</legend>
|
|
<label for="welcome_enable">
|
|
<input type="checkbox" name="welcome_enable" {% if configuration.getValue('welcome_enable') %}checked="checked"{% endif %}>
|
|
Activer le message de bienvenue pour les nouveaux membres
|
|
</label>
|
|
|
|
<label for="welcome_channel_id">Canal de bienvenue</label>
|
|
<select name="welcome_channel_id">
|
|
{% for channel in channels %}
|
|
<option value="{{channel.id}}" {% if configuration.getIntValue('welcome_channel_id')==channel.id %}selected="selected"{% endif %}>
|
|
{{channel.name}}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
|
|
<label for="welcome_message">Message personnalisé de bienvenue</label>
|
|
<textarea name="welcome_message" rows="3" placeholder="Bienvenue {member.mention} sur le serveur !">{{ configuration.getValue('welcome_message') }}</textarea>
|
|
<small>
|
|
<strong>Syntaxes disponibles :</strong><br>
|
|
• <code>{member.mention}</code> - Mentionne l'utilisateur (@NomUtilisateur)<br>
|
|
• <code>{member.name}</code> - Nom d'utilisateur (sans mention)<br>
|
|
• <code>{member.display_name}</code> - Surnom sur le serveur<br>
|
|
• <code>{member.id}</code> - ID de l'utilisateur<br>
|
|
• <code>{server.name}</code> - Nom du serveur<br>
|
|
• <code>{server.member_count}</code> - Nombre total de membres<br>
|
|
• <code><#ID_DU_CHANNEL></code> - Mentionne un salon (ex: <#123456789012345678>)
|
|
</small>
|
|
</fieldset>
|
|
|
|
<fieldset>
|
|
<legend>Auto-Role</legend>
|
|
<label for="autorole_enable">
|
|
<input type="checkbox" name="autorole_enable" {% if configuration.getValue('autorole_enable') %}checked="checked"{% endif %}>
|
|
Attribuer automatiquement un rôle aux nouveaux membres
|
|
</label>
|
|
|
|
<label for="autorole_role_id">Rôle à attribuer</label>
|
|
{% if roles|length > 1 %}
|
|
<div class="tabs tabs-autorole">
|
|
{% for guild_data in roles %}
|
|
<button type="button" class="tab-button-autorole" onclick="openTabAutorole(event, 'autorole-guild-{{guild_data.guild_id}}')" {% if loop.first %}id="defaultOpenAutorole"{% endif %}>
|
|
{{ guild_data.guild_name }}
|
|
</button>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% for guild_data in roles %}
|
|
<div id="autorole-guild-{{guild_data.guild_id}}" class="tab-content-autorole" {% if not loop.first %}style="display: none;"{% endif %}>
|
|
<select name="autorole_role_id">
|
|
<option value="">-- Aucun rôle --</option>
|
|
{% for role in guild_data.roles %}
|
|
<option value="{{role.id}}" {% if configuration.getIntValue('autorole_role_id')==role.id %}selected="selected"{% endif %}>
|
|
{% if role.color.value != 0 %}⬤{% else %}○{% endif %} {{role.name}}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<small>
|
|
<strong>Note :</strong> Le bot doit avoir la permission "Gérer les rôles" et son rôle doit être positionné plus haut que le rôle à attribuer dans la hiérarchie des rôles.
|
|
</small>
|
|
|
|
<script>
|
|
function openTabAutorole(evt, tabName) {
|
|
var i, tabcontent, tabbuttons;
|
|
tabcontent = document.getElementsByClassName("tab-content-autorole");
|
|
for (i = 0; i < tabcontent.length; i++) {
|
|
tabcontent[i].style.display = "none";
|
|
}
|
|
tabbuttons = document.getElementsByClassName("tab-button-autorole");
|
|
for (i = 0; i < tabbuttons.length; i++) {
|
|
tabbuttons[i].className = tabbuttons[i].className.replace(" active", "");
|
|
}
|
|
document.getElementById(tabName).style.display = "block";
|
|
evt.currentTarget.className += " active";
|
|
}
|
|
document.getElementById("defaultOpenAutorole")?.click();
|
|
</script>
|
|
|
|
<style>
|
|
.tabs-autorole {
|
|
overflow: hidden;
|
|
border-bottom: 2px solid #ccc;
|
|
margin-bottom: 10px;
|
|
}
|
|
.tab-button-autorole {
|
|
background-color: #f1f1f1;
|
|
border: none;
|
|
outline: none;
|
|
cursor: pointer;
|
|
padding: 10px 20px;
|
|
transition: 0.3s;
|
|
font-size: 14px;
|
|
margin-right: 2px;
|
|
}
|
|
.tab-button-autorole:hover {
|
|
background-color: #ddd;
|
|
}
|
|
.tab-button-autorole.active {
|
|
background-color: #ccc;
|
|
font-weight: bold;
|
|
}
|
|
.tab-content-autorole {
|
|
animation: fadeEffect 0.3s;
|
|
}
|
|
</style>
|
|
</fieldset>
|
|
|
|
<fieldset>
|
|
<legend>Messages de départ</legend>
|
|
<label for="leave_enable">
|
|
<input type="checkbox" name="leave_enable" {% if configuration.getValue('leave_enable') %}checked="checked"{% endif %}>
|
|
Activer le message de départ quand un membre quitte le serveur
|
|
</label>
|
|
|
|
<label for="leave_channel_id">Canal de départ</label>
|
|
<select name="leave_channel_id">
|
|
{% for channel in channels %}
|
|
<option value="{{channel.id}}" {% if configuration.getIntValue('leave_channel_id')==channel.id %}selected="selected"{% endif %}>
|
|
{{channel.name}}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
|
|
<label for="leave_message">Message personnalisé de départ</label>
|
|
<textarea name="leave_message" rows="3" placeholder="{member.mention} a quitté le serveur.">{{ configuration.getValue('leave_message') }}</textarea>
|
|
<small>
|
|
<strong>Syntaxes disponibles :</strong><br>
|
|
• <code>{member.mention}</code> - Mentionne l'utilisateur (@NomUtilisateur)<br>
|
|
• <code>{member.name}</code> - Nom d'utilisateur (sans mention)<br>
|
|
• <code>{member.display_name}</code> - Surnom sur le serveur<br>
|
|
• <code>{member.id}</code> - ID de l'utilisateur<br>
|
|
• <code>{server.name}</code> - Nom du serveur<br>
|
|
• <code>{server.member_count}</code> - Nombre total de membres<br>
|
|
• <code><#ID_DU_CHANNEL></code> - Mentionne un salon (ex: <#123456789012345678>)
|
|
</small>
|
|
</fieldset>
|
|
|
|
<fieldset>
|
|
<legend>Modération</legend>
|
|
<label for="moderation_enable">
|
|
<input type="checkbox" name="moderation_enable" {% if configuration.getValue('moderation_enable') %}checked="checked"{% endif %}>
|
|
Activer les commandes d'avertissement (!warn, !unwarn, !inspect)
|
|
</label>
|
|
|
|
<label for="moderation_ban_enable">
|
|
<input type="checkbox" name="moderation_ban_enable" {% if configuration.getValue('moderation_ban_enable') %}checked="checked"{% endif %}>
|
|
Activer les commandes de bannissement (!ban, !unban)
|
|
</label>
|
|
|
|
<label for="moderation_kick_enable">
|
|
<input type="checkbox" name="moderation_kick_enable" {% if configuration.getValue('moderation_kick_enable') %}checked="checked"{% endif %}>
|
|
Activer la commande d'expulsion (!kick)
|
|
</label>
|
|
|
|
<label for="moderation_log_channel_id">Canal de logs de modération</label>
|
|
<select name="moderation_log_channel_id">
|
|
{% for channel in channels %}
|
|
<option value="{{channel.id}}" {% if configuration.getIntValue('moderation_log_channel_id')==channel.id %}selected="selected"{% endif %}>
|
|
{{channel.name}}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
<small>Toutes les actions de modération seront notifiées dans ce canal</small>
|
|
|
|
<label>Rôles Staff autorisés</label>
|
|
{% set selected_roles = (configuration.getValue('moderation_staff_role_ids') or '').split(',') %}
|
|
|
|
{% if roles|length > 1 %}
|
|
<div class="tabs">
|
|
{% for guild_data in roles %}
|
|
<button type="button" class="tab-button" onclick="openTab(event, 'guild-{{guild_data.guild_id}}')" {% if loop.first %}id="defaultOpen"{% endif %}>
|
|
{{ guild_data.guild_name }}
|
|
</button>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% for guild_data in roles %}
|
|
<div id="guild-{{guild_data.guild_id}}" class="tab-content" {% if not loop.first %}style="display: none;"{% endif %}>
|
|
<div style="max-height: 300px; overflow-y: auto; border: 1px solid #ccc; padding: 10px; border-radius: 5px;">
|
|
{% for role in guild_data.roles %}
|
|
<label style="display: block; margin: 5px 0;">
|
|
<input type="checkbox" name="moderation_staff_role_ids" value="{{role.id}}" {% if role.id|string in selected_roles %}checked="checked"{% endif %}>
|
|
{% if role.color.value != 0 %}
|
|
<span style="color:#{{ '%06x' % role.color.value }}">●</span>
|
|
{% else %}
|
|
<span>○</span>
|
|
{% endif %}
|
|
{{role.name}}
|
|
</label>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<small>Sélectionnez un ou plusieurs rôles qui peuvent utiliser les commandes de modération</small>
|
|
|
|
<script>
|
|
function openTab(evt, tabName) {
|
|
var i, tabcontent, tabbuttons;
|
|
tabcontent = document.getElementsByClassName("tab-content");
|
|
for (i = 0; i < tabcontent.length; i++) {
|
|
tabcontent[i].style.display = "none";
|
|
}
|
|
tabbuttons = document.getElementsByClassName("tab-button");
|
|
for (i = 0; i < tabbuttons.length; i++) {
|
|
tabbuttons[i].className = tabbuttons[i].className.replace(" active", "");
|
|
}
|
|
document.getElementById(tabName).style.display = "block";
|
|
evt.currentTarget.className += " active";
|
|
}
|
|
document.getElementById("defaultOpen")?.click();
|
|
</script>
|
|
|
|
<style>
|
|
.tabs {
|
|
overflow: hidden;
|
|
border-bottom: 2px solid #ccc;
|
|
margin-bottom: 10px;
|
|
}
|
|
.tab-button {
|
|
background-color: #f1f1f1;
|
|
border: none;
|
|
outline: none;
|
|
cursor: pointer;
|
|
padding: 10px 20px;
|
|
transition: 0.3s;
|
|
font-size: 14px;
|
|
margin-right: 2px;
|
|
}
|
|
.tab-button:hover {
|
|
background-color: #ddd;
|
|
}
|
|
.tab-button.active {
|
|
background-color: #ccc;
|
|
font-weight: bold;
|
|
}
|
|
.tab-content {
|
|
animation: fadeEffect 0.3s;
|
|
}
|
|
@keyframes fadeEffect {
|
|
from {opacity: 0;}
|
|
to {opacity: 1;}
|
|
}
|
|
</style>
|
|
|
|
<label for="moderation_embed_delete_delay">Délai de suppression des embeds (en secondes)</label>
|
|
<input name="moderation_embed_delete_delay" type="number" value="{{ configuration.getValue('moderation_embed_delete_delay') or '0' }}" placeholder="0" min="0" />
|
|
<small>Mettre 0 pour ne pas supprimer automatiquement</small>
|
|
</fieldset>
|
|
|
|
<input type="Submit" value="Enregistrer la configuration Discord">
|
|
</form>
|
|
|
|
<h2>API Twitch</h2>
|
|
<form action="{{ url_for('updateConfiguration') }}" method="POST">
|
|
<label for="twitch_client_id">Client ID</label>
|
|
<input name="twitch_client_id" type="text" value="{{ configuration.getValue('twitch_client_id') }}" />
|
|
<label for="twitch_client_secret">Client Secret</label>
|
|
<input name="twitch_client_secret" type="text" value="{{ configuration.getValue('twitch_client_secret') }}" />
|
|
<label for="twitch_channel">Chaîne à rejoindre</label>
|
|
<input name="twitch_channel" type="text" value="{{ configuration.getValue('twitch_channel') }}"
|
|
placeholder="#machinTruc" />
|
|
<input type="Submit" value="Enregistrer la configuration Twitch">
|
|
<p>
|
|
<a href="{{ url_for('twitchConfigurationHelp') }}">Aide</a>
|
|
</p>
|
|
{% if configuration.getValue('twitch_client_secret') and configuration.getValue('twitch_client_id') %}
|
|
<p>
|
|
<a href="{{ url_for('twitchRequestToken') }}">Obtenir token et refresh token</a>
|
|
</p>
|
|
<label for="twitch_access_token">Access Token</label>
|
|
<input name="twitch_access_token" type="text" value="{{ configuration.getValue('twitch_access_token') }}"
|
|
readonly="readonly" />
|
|
<label for="twitch_refresh_token">Refresh Token</label>
|
|
<input name="twitch_refresh_token" type="text" value="{{ configuration.getValue('twitch_refresh_token') }}"
|
|
readonly="readonly" />
|
|
<p>Nécessite un redémarrage après l'obtention des Tokens.</p>
|
|
{% endif %}
|
|
</form>
|
|
|
|
<h2>Humble Bundle</h2>
|
|
<form action="{{ url_for('updateConfiguration') }}" method="POST">
|
|
<p>Humble Bundle propose régulièrement des bundles de jeux vidéo à des prix réduits. Activez les notifications pour recevoir automatiquement les nouveaux packs disponibles sur votre serveur Discord.</p>
|
|
|
|
<label for="humble_bundle_enable">
|
|
<input type="checkbox" name="humble_bundle_enable" {% if configuration.getValue('humble_bundle_enable') %}checked="checked"{% endif %}>
|
|
Activer les notifications Humble Bundle
|
|
</label>
|
|
|
|
<label for="humble_bundle_channel">Canal de notification</label>
|
|
<select name="humble_bundle_channel">
|
|
{% for channel in channels %}
|
|
<option value="{{channel.id}}" {% if configuration.getIntValue('humble_bundle_channel')==channel.id %}selected="selected"{% endif %}>
|
|
{{channel.name}}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
|
|
<input type="Submit" value="Enregistrer la configuration Humble Bundle">
|
|
</form>
|
|
|
|
<h2>⚠️ Gestion des serveurs</h2>
|
|
<form action="{{ url_for('leaveGuild') }}" method="POST" onsubmit="return confirmLeave();">
|
|
<fieldset>
|
|
<legend>Quitter un serveur Discord</legend>
|
|
<p style="color: #856404; background-color: #fff3cd; border: 1px solid #ffeeba; padding: 10px; border-radius: 5px;">
|
|
<strong>⚠️ Attention :</strong> Cette action est irréversible ! Le bot quittera définitivement le serveur sélectionné.
|
|
Pour rejoindre à nouveau, vous devrez ré-inviter le bot.
|
|
</p>
|
|
|
|
{% if guilds and guilds|length > 0 %}
|
|
<label for="guild_id">Sélectionner un serveur à quitter</label>
|
|
<select name="guild_id" id="guild_id" required>
|
|
<option value="">-- Choisir un serveur --</option>
|
|
{% for guild in guilds %}
|
|
<option value="{{ guild.id }}">{{ guild.name }} ({{ guild.member_count }} membres)</option>
|
|
{% endfor %}
|
|
</select>
|
|
|
|
<label for="confirm_leave" style="margin-top: 15px;">
|
|
<input type="checkbox" name="confirm_leave" id="confirm_leave" value="1" required>
|
|
Je confirme vouloir faire quitter le bot de ce serveur
|
|
</label>
|
|
|
|
<input type="submit" value="🚪 Quitter le serveur" style="background-color: #dc3545; border-color: #dc3545;" />
|
|
{% else %}
|
|
<p>Aucun serveur Discord connecté ou le bot n'est pas encore démarré.</p>
|
|
{% endif %}
|
|
</fieldset>
|
|
</form>
|
|
|
|
<script>
|
|
function confirmLeave() {
|
|
var select = document.getElementById('guild_id');
|
|
var serverName = select.options[select.selectedIndex].text;
|
|
return confirm('Êtes-vous VRAIMENT sûr de vouloir quitter le serveur "' + serverName + '" ?\n\nCette action est IRRÉVERSIBLE !');
|
|
}
|
|
</script>
|
|
{% endblock %} |