From b370b9bb9a55ae613cd2417467a19bcae6939eeb Mon Sep 17 00:00:00 2001 From: Santiago Ramirez <94815926+SantiiRepair@users.noreply.github.com> Date: Sun, 8 Oct 2023 18:45:03 +0000 Subject: [PATCH] Update __init__.py --- bot/models/redis/__init__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/bot/models/redis/__init__.py b/bot/models/redis/__init__.py index 393eca4..8ea4959 100644 --- a/bot/models/redis/__init__.py +++ b/bot/models/redis/__init__.py @@ -88,5 +88,24 @@ def get_last_queue_position(group_id: str) -> Union[int, None]: value = list(queue.values())[-1] return value["position"] - +def update_is_played(): +def next_in_queue(group_id: str) -> Union[Tuple, None]: + values = () + queue = r.hgetall("queues") + value = queue[group_id] + if group_id not in queue: + return None + for i in range(len(value)): + if value[i].get("is_playing"): + next = value[i + 1] + values = ( + next["from_user"], + next["is_playing"], + next["position"], + next["date"], + next["file"], + next["type"], + ) + return values + return None # ------------------------------------------------------------------------