Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 8, 2023
1 parent debe244 commit 65e28c6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bot/models/redis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from bot import r
from typing import Tuple, Union


# ------------------------------------------------------------------------
def add_to_queue(group_id, from_user, date):
def add_to_queue(group_id, from_user, date) -> bool:
values = {"from_user": from_user, "date": date}
hset = r.hset("queues", group_id, values)
return hset


def next_in_queue():
def next_in_queue() -> Union[Tuple, None]:
queue = r.hgetall("queues").popitem()
group_id = queue[0]
value = queue[1]
if not value:
return None
return value["from_user"], value["date"], value[""]


def remove_queue():
queue = r.hgetall("queues").popitem()
group_id = queue[0]
hdel = r.hdel("queues", group_id)
return hdel

Expand Down

0 comments on commit 65e28c6

Please sign in to comment.