feat(bot): 🎨 Make message queues a hash.

This commit is contained in:
Nyeki.py
2024-10-19 22:26:10 -03:00
parent 0787240ce7
commit 98e1e50831
2 changed files with 25 additions and 20 deletions
+5 -5
View File
@@ -5,11 +5,11 @@ T = TypeVar("T")
U = TypeVar("U")
def deduplicate(iter: Iterable[T], key: Callable[[T], U] = lambda i: i) -> list[T]:
def deduplicate(i: Iterable[T], key: Callable[[T], U] = lambda i: i) -> list[T]:
"""Deduplicates an Iterable.
Args:
iter (Iterable[T]): The iterable with items to deduplicate.
i (Iterable[T]): The iterable with items to deduplicate.
key (Callable[[T], U], optional): The key by which to deduplicate. Defaults to `lambda i: i`.
Returns:
@@ -20,8 +20,8 @@ def deduplicate(iter: Iterable[T], key: Callable[[T], U] = lambda i: i) -> list[
result = []
for i in iter:
if key(i) not in found_keys:
result.append(i)
for item in i:
if key(item) not in found_keys:
result.append(item)
return result