From fa2b2f8d27dbe9fafa295ec74d4ccea6e3b972b3 Mon Sep 17 00:00:00 2001 From: Tobias Leuschner Date: Fri, 20 Feb 2026 17:38:44 +0100 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20Mute-Cooldown-Logik=20hinzu:=20Impl?= =?UTF-8?q?ementiere=20Datenstruktur=20f=C3=BCr=20Mute-Cooldowns=20zur=20V?= =?UTF-8?q?ermeidung=20von=20Spam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bot.py b/bot.py index 34e878e..3cc32bc 100644 --- a/bot.py +++ b/bot.py @@ -12,6 +12,7 @@ load_dotenv() TOKEN = os.getenv("DISCORD_TOKEN") MILESTONE_CHANNEL_ID = int(os.getenv("MILESTONE_CHANNEL_ID", 0)) DATA_FILE = "data.json" +MUTE_COOLDOWN = 5.0 # Sekunden zwischen zwei zählbaren Mutes pro Nutzer # --------------------------------------------------------------------------- # Konfiguration @@ -355,6 +356,7 @@ intents.members = True bot = commands.Bot(command_prefix="!", intents=intents) mute_data = load_data() voice_sessions: dict[tuple[int, int], float] = {} +mute_cooldowns: dict[tuple[int, int], float] = {} # (guild_id, user_id) → letzter Mute-Timestamp @tasks.loop(hours=1) @@ -428,6 +430,14 @@ async def on_voice_state_update(member: discord.Member, if not just_deafened and not just_mic_muted: return + # Spam-Schutz: Mute innerhalb des Cooldowns wird nicht gezählt + key = (guild.id, member.id) + now = time.time() + if now - mute_cooldowns.get(key, 0.0) < MUTE_COOLDOWN: + print(f"[SKIP ] {member.display_name} — Cooldown aktiv [{guild.name}]") + return + mute_cooldowns[key] = now + kind = "deaf" if just_deafened else "mic" old_lb = get_sorted_lb(mute_data, guild.id)