modified: app.py
modified: bot.py modified: templates/server_settings.html
This commit is contained in:
65
app.py
65
app.py
@@ -46,6 +46,17 @@ app.config["SESSION_TYPE"] = "filesystem" # Oder 'redis' für Redis-basierte Sp
|
||||
Session(app)
|
||||
print(f"Session Type: {app.config['SESSION_TYPE']}")
|
||||
|
||||
import json as _json
|
||||
|
||||
@app.template_filter("from_json_ids")
|
||||
def from_json_ids(value):
|
||||
"""Converts a JSON list of role ID strings to a space-separated string for display."""
|
||||
try:
|
||||
ids = _json.loads(value)
|
||||
return " ".join(str(i) for i in ids)
|
||||
except Exception:
|
||||
return value or ""
|
||||
|
||||
DB_HOST = os.getenv("DB_HOST")
|
||||
DB_PORT = os.getenv("DB_PORT")
|
||||
DB_USER = os.getenv("DB_USER")
|
||||
@@ -735,7 +746,23 @@ def server_settings(guild_id):
|
||||
auto_mute_duration = request.form.get("auto_mute_duration", "1h")
|
||||
log_channel_id = request.form.get("log_channel_id")
|
||||
mod_log_enabled = bool(request.form.get("mod_log_enabled"))
|
||||
|
||||
|
||||
# Honeypot fields
|
||||
honeypot_enabled = bool(request.form.get("honeypot_enabled"))
|
||||
honeypot_channel_id = request.form.get("honeypot_channel_id")
|
||||
honeypot_preserve_old_accounts = bool(request.form.get("honeypot_preserve_old_accounts"))
|
||||
honeypot_get_role = request.form.get("honeypot_get_role") or None
|
||||
honeypot_log_channel_id = request.form.get("honeypot_log_channel_id")
|
||||
honeypot_ignore_roles_raw = request.form.get("honeypot_ignore_roles", "").strip()
|
||||
honeypot_acc_age_min = int(request.form.get("honeypot_acc_age_min", 30))
|
||||
|
||||
# Build ignore roles JSON
|
||||
import json as _json
|
||||
honeypot_ignore_roles = None
|
||||
if honeypot_ignore_roles_raw:
|
||||
ids = [r.strip() for r in honeypot_ignore_roles_raw.replace(",", " ").split() if r.strip().isdigit()]
|
||||
honeypot_ignore_roles = _json.dumps(ids) if ids else None
|
||||
|
||||
# Validierung
|
||||
if max_warn_threshold < 1 or max_warn_threshold > 10:
|
||||
flash("Warn-Limit muss zwischen 1 und 10 liegen.", "danger")
|
||||
@@ -750,25 +777,38 @@ def server_settings(guild_id):
|
||||
# Konvertiere leere Strings zu NULL
|
||||
mute_role_id = int(mute_role_id) if mute_role_id and mute_role_id.isdigit() else None
|
||||
log_channel_id = int(log_channel_id) if log_channel_id and log_channel_id.isdigit() else None
|
||||
|
||||
honeypot_channel_id = int(honeypot_channel_id) if honeypot_channel_id and honeypot_channel_id.isdigit() else None
|
||||
honeypot_log_channel_id = int(honeypot_log_channel_id) if honeypot_log_channel_id and honeypot_log_channel_id.isdigit() else None
|
||||
|
||||
# Update oder Insert Einstellungen
|
||||
if current_settings:
|
||||
cursor.execute("""
|
||||
UPDATE guild_settings
|
||||
SET mute_role_id = %s, mute_role_name = %s, auto_create_mute_role = %s,
|
||||
max_warn_threshold = %s, auto_mute_on_warns = %s, auto_mute_duration = %s,
|
||||
log_channel_id = %s, mod_log_enabled = %s
|
||||
log_channel_id = %s, mod_log_enabled = %s,
|
||||
honeypot_enabled = %s, honeypot_channel_id = %s,
|
||||
honeypot_preserve_old_accounts = %s, honeypot_get_role = %s,
|
||||
honeypot_log_channel_id = %s, honeypot_ignore_roles = %s,
|
||||
honeypot_acc_age_min = %s
|
||||
WHERE guild_id = %s
|
||||
""", (mute_role_id, mute_role_name, auto_create_mute_role, max_warn_threshold,
|
||||
auto_mute_on_warns, auto_mute_duration, log_channel_id, mod_log_enabled, guild_id))
|
||||
""", (mute_role_id, mute_role_name, auto_create_mute_role, max_warn_threshold,
|
||||
auto_mute_on_warns, auto_mute_duration, log_channel_id, mod_log_enabled,
|
||||
honeypot_enabled, honeypot_channel_id, honeypot_preserve_old_accounts,
|
||||
honeypot_get_role, honeypot_log_channel_id, honeypot_ignore_roles,
|
||||
honeypot_acc_age_min, guild_id))
|
||||
else:
|
||||
cursor.execute("""
|
||||
INSERT INTO guild_settings
|
||||
(guild_id, mute_role_id, mute_role_name, auto_create_mute_role, max_warn_threshold,
|
||||
auto_mute_on_warns, auto_mute_duration, log_channel_id, mod_log_enabled)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
auto_mute_on_warns, auto_mute_duration, log_channel_id, mod_log_enabled,
|
||||
honeypot_enabled, honeypot_channel_id, honeypot_preserve_old_accounts,
|
||||
honeypot_get_role, honeypot_log_channel_id, honeypot_ignore_roles, honeypot_acc_age_min)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
""", (guild_id, mute_role_id, mute_role_name, auto_create_mute_role, max_warn_threshold,
|
||||
auto_mute_on_warns, auto_mute_duration, log_channel_id, mod_log_enabled))
|
||||
auto_mute_on_warns, auto_mute_duration, log_channel_id, mod_log_enabled,
|
||||
honeypot_enabled, honeypot_channel_id, honeypot_preserve_old_accounts,
|
||||
honeypot_get_role, honeypot_log_channel_id, honeypot_ignore_roles, honeypot_acc_age_min))
|
||||
|
||||
connection.commit()
|
||||
flash("Server-Einstellungen erfolgreich gespeichert!", "success")
|
||||
@@ -794,7 +834,14 @@ def server_settings(guild_id):
|
||||
"auto_mute_on_warns": False,
|
||||
"auto_mute_duration": "1h",
|
||||
"log_channel_id": None,
|
||||
"mod_log_enabled": True
|
||||
"mod_log_enabled": True,
|
||||
"honeypot_enabled": False,
|
||||
"honeypot_channel_id": None,
|
||||
"honeypot_preserve_old_accounts": False,
|
||||
"honeypot_get_role": None,
|
||||
"honeypot_log_channel_id": None,
|
||||
"honeypot_ignore_roles": None,
|
||||
"honeypot_acc_age_min": 30
|
||||
}
|
||||
|
||||
# Hole Servername
|
||||
|
||||
Reference in New Issue
Block a user