Skip to content

Commit

Permalink
Update __init__.py and requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 8, 2023
1 parent b370b9b commit 9c7f152
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
48 changes: 24 additions & 24 deletions bot/models/redis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from bot import r
from typing import Tuple, Union

# ------------------------------------------------------------------------


def add_to_queue(
group_id: str,
from_user: str,
Expand Down Expand Up @@ -42,7 +39,7 @@ def next_in_queue(group_id: str) -> Union[Tuple, None]:
value = queue[group_id]
if group_id not in queue:
return None
for i, v in range(len(value)):
for i in range(len(value)):
if value[i].get("is_playing"):
next = value[i + 1]
values = (
Expand All @@ -62,7 +59,7 @@ def previous_in_queue(group_id: str) -> Union[Tuple, None]:
value = queue[group_id]
if group_id not in queue:
return None
for i, v in range(len(value)):
for i in range(len(value)):
if value[i].get("is_playing"):
next = value[i - 1]
values = (
Expand All @@ -80,32 +77,35 @@ def previous_in_queue(group_id: str) -> Union[Tuple, None]:
def remove_queue(group_id: str) -> None:
r.hdel("queues", group_id)

def get_current_position_in_queue(group_id: str) -> Union[int, None]:
queue = r.hgetall("queues")
if group_id not in queue:
return None
value = queue[group_id].values()[-1]
for i in range(len(values)):
if values[i].get("is_playing"):
return value["position"]

def get_last_queue_position(group_id: str) -> Union[int, None]:
def get_last_position_in_queue(group_id: str) -> Union[int, None]:
queue = r.hgetall("queues")
if group_id not in queue:
return None
value = list(queue.values())[-1]
value = queue[group_id].values()[-1]
return value["position"]

def update_is_played():
def next_in_queue(group_id: str) -> Union[Tuple, None]:
values = ()
def update_is_played_in_queue(action: str) -> None:
queue = r.hgetall("queues")
value = queue[group_id]
values = 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
for i in range(len(values)):
if values[i].get("is_playing"):
if action == "previous":
values[i]["is_playing"] = False
values[i - 1]["is_playing"] = True
return r.hset("queues", group_id, values)
elif action == "next":
values[i]["is_playing"] = False
values[i + 1]["is_playing"] = True
return r.hset("queues", group_id, values)
return None
# ------------------------------------------------------------------------
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ numpy==1.24.4
opencv-python-headless==4.8.0.74
pillow==10.0.0
piper-tts==1.2.0
psycopg2_binary==2.9.9
pyrogram==2.0.106
python-dotenv==1.0.0
PyPDF2==3.0.1
Expand All @@ -16,6 +17,7 @@ requests==2.31.0
selenium==4.11.2
shutup==0.2.0
speedtest-cli==2.1.3
SQLAlchemy==2.0.21
termcolor==1.1
tgcrypto==1.2.5
translate==3.6.1
Expand Down

0 comments on commit 9c7f152

Please sign in to comment.