From 8f0b398843049d7a11e864a90de07f021ca6c052 Mon Sep 17 00:00:00 2001 From: Marcin Macierzanka Date: Sat, 4 Jul 2026 16:14:40 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20deduplikacja=20wpis=C3=B3w=20w=20histor?= =?UTF-8?q?ii=20odtwarzania=20(ka=C5=BCde=20nagranie=20widoczne=20tylko=20?= =?UTF-8?q?raz)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index d9da571..83b425b 100644 --- a/bot.py +++ b/bot.py @@ -34,7 +34,15 @@ class MusicBot(commands.Cog): import json with open(config_path, "r") as f: data = json.load(f) - self.history[guild_id] = data.get(str(guild_id), []) + raw_history = data.get(str(guild_id), []) + unique_history = [] + seen = set() + for item in raw_history: + key = (item.get("title", ""), item.get("url", "")) + if key not in seen: + seen.add(key) + unique_history.append(item) + self.history[guild_id] = unique_history except Exception as e: print(f"Error loading history: {e}") self.history[guild_id] = [] @@ -69,6 +77,7 @@ class MusicBot(commands.Cog): "is_local": player.data.get("is_local", False), "filepath": player.data.get("filepath") } + history = [h for h in history if h.get("title") != entry["title"] and (not entry.get("url") or h.get("url") != entry["url"])] history.insert(0, entry) self.history[guild_id] = history[:50] self.save_history(guild_id)