mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-06 06:40:35 +01:00
Ajout fonctionnalité des commandes Discord
This commit is contained in:
@@ -1,6 +1,49 @@
|
||||
from flask import render_template
|
||||
from flask import render_template, request, redirect, url_for, flash
|
||||
from webapp import webapp
|
||||
from database import db
|
||||
from database.models import Commande
|
||||
|
||||
@webapp.route("/commandes")
|
||||
def commandes():
|
||||
return render_template("commandes.html")
|
||||
commandes_list = Commande.query.all()
|
||||
return render_template("commandes.html", commandes=commandes_list)
|
||||
|
||||
@webapp.route("/commandes/add", methods=['POST'])
|
||||
def add_commande():
|
||||
trigger = request.form.get('trigger')
|
||||
response = request.form.get('response')
|
||||
discord_enable = request.form.get('discord_enable') == 'on'
|
||||
twitch_enable = request.form.get('twitch_enable') == 'on'
|
||||
|
||||
if trigger and response:
|
||||
if not trigger.startswith('!'):
|
||||
trigger = '!' + trigger
|
||||
|
||||
existing = Commande.query.filter_by(trigger=trigger).first()
|
||||
if not existing:
|
||||
commande = Commande(trigger=trigger, response=response, discord_enable=discord_enable, twitch_enable=twitch_enable)
|
||||
db.session.add(commande)
|
||||
db.session.commit()
|
||||
|
||||
return redirect(url_for('commandes'))
|
||||
|
||||
@webapp.route("/commandes/delete/<int:commande_id>")
|
||||
def delete_commande(commande_id):
|
||||
commande = Commande.query.get_or_404(commande_id)
|
||||
db.session.delete(commande)
|
||||
db.session.commit()
|
||||
return redirect(url_for('commandes'))
|
||||
|
||||
@webapp.route("/commandes/toggle-discord/<int:commande_id>")
|
||||
def toggle_discord_commande(commande_id):
|
||||
commande = Commande.query.get_or_404(commande_id)
|
||||
commande.discord_enable = not commande.discord_enable
|
||||
db.session.commit()
|
||||
return redirect(url_for('commandes'))
|
||||
|
||||
@webapp.route("/commandes/toggle-twitch/<int:commande_id>")
|
||||
def toggle_twitch_commande(commande_id):
|
||||
commande = Commande.query.get_or_404(commande_id)
|
||||
commande.twitch_enable = not commande.twitch_enable
|
||||
db.session.commit()
|
||||
return redirect(url_for('commandes'))
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
header nav img {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.table_td {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: normal;
|
||||
max-width: 250px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
@@ -1,6 +1,55 @@
|
||||
{% extends "template.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Configuration des Commandes.</h1>
|
||||
<p>TODO</p>
|
||||
<h1>Commandes de Mamie</h1>
|
||||
<p>Gérez les commandes personnalisées du bot. Ces commandes peuvent être activées sur Discord et/ou Twitch selon vos besoins.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="table_td">Commande</th>
|
||||
<th class="table_td">Réponse</th>
|
||||
<th class="table_td">Discord</th>
|
||||
<th class="table_td">Twitch</th>
|
||||
<th class="table_td">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for commande in commandes %}
|
||||
<tr>
|
||||
<td class="table_td">{{ commande.trigger }}</td>
|
||||
<td class="table_td">{{ commande.response }}</td>
|
||||
<td class="table_td">
|
||||
<a href="{{ url_for('toggle_discord_commande', commande_id = commande.id) }}" style="text-decoration: none; font-size: 1.2em;">
|
||||
{{ '✅' if commande.discord_enable else '❌' }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="table_td">
|
||||
<a href="{{ url_for('toggle_twitch_commande', commande_id = commande.id) }}" style="text-decoration: none; font-size: 1.2em;">
|
||||
{{ '✅' if commande.twitch_enable else '❌' }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="table_td">
|
||||
<a href="{{ url_for('delete_commande', commande_id = commande.id) }}" onclick="return confirm('Êtes-vous sûr de vouloir supprimer cette commande ?')">Supprimer</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2>Ajouter une commande</h2>
|
||||
<form action="{{ url_for('add_commande') }}" method="POST">
|
||||
<label for="trigger">Commande</label>
|
||||
<input name="trigger" type="text" />
|
||||
<label for="response">Réponse</label>
|
||||
<textarea name="response" rows="5" cols="50"></textarea>
|
||||
<div>
|
||||
<label for="discord_enable">Discord</label>
|
||||
<input name="discord_enable" type="checkbox" checked />
|
||||
</div>
|
||||
<div>
|
||||
<label for="twitch_enable">Twitch</label>
|
||||
<input name="twitch_enable" type="checkbox" unchecked />
|
||||
</div>
|
||||
<input type="Submit" value="Ajouter">
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -1,7 +1,8 @@
|
||||
{% extends "template.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Configuration de Mamie.</h1>
|
||||
<h1>Configuration de Mamie</h1>
|
||||
<p>Configurez les tokens Discord, les notifications Humble Bundle et l'API ProtonDB pour la commande !protondb.</p>
|
||||
|
||||
<h2>Humble Bundle</h2>
|
||||
<form action="{{ url_for('updateConfiguration') }}" method="POST">
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
{% extends "template.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Humeurs de Mamie.</h1>
|
||||
<h1>Humeurs de Mamie</h1>
|
||||
<p>Définissez les statuts Discord qui changeront automatiquement toutes les 10 minutes pour donner de la personnalité à votre bot.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Text</th>
|
||||
<th>Action</th>
|
||||
<th class="table_td">Text</th>
|
||||
<th class="table_td">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for humeur in humeurs %}
|
||||
<tr>
|
||||
<td>{{humeur.text}}</td>
|
||||
<td><a href="{{ url_for('delHumeur', id = humeur.id) }}">Supprimer</a></td>
|
||||
<td class="table_td">{{humeur.text}}</td>
|
||||
<td class="table_td"><a href="{{ url_for('delHumeur', id = humeur.id) }}" onclick="return confirm('Êtes-vous sûr de vouloir supprimer cette humeur ?')">Supprimer</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "template.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Configuration des Messages.</h1>
|
||||
<h1>Messages de Mamie</h1>
|
||||
<p>TODO</p>
|
||||
{% endblock %}
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "template.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Modération.</h1>
|
||||
<p>TODO</p>
|
||||
<h1>Modération</h1>
|
||||
<p>Outils de modération communautaire pour gérer votre serveur Discord (fonctionnalité en développement).</p>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user