From 2cbe8c9a7a5ed1a8e530e404df36dbd39ec6c86e Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Tue, 26 Oct 2021 15:52:09 +0700 Subject: [PATCH] moved --- driver/queues.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 driver/queues.py diff --git a/driver/queues.py b/driver/queues.py new file mode 100644 index 0000000..bdd6074 --- /dev/null +++ b/driver/queues.py @@ -0,0 +1,31 @@ +QUEUE = {} + +def add_to_queue(chat_id, songname, link, ref, type, quality): + if chat_id in QUEUE: + chat_queue = QUEUE[chat_id] + chat_queue.append([songname, link, ref, type, quality]) + return int(len(chat_queue)-1) + else: + QUEUE[chat_id] = [[songname, link, ref, type, quality]] + +def get_queue(chat_id): + if chat_id in QUEUE: + chat_queue = QUEUE[chat_id] + return chat_queue + else: + return 0 + +def pop_an_item(chat_id): + if chat_id in QUEUE: + chat_queue = QUEUE[chat_id] + chat_queue.pop(0) + return 1 + else: + return 0 + +def clear_queue(chat_id): + if chat_id in QUEUE: + QUEUE.pop(chat_id) + return 1 + else: + return 0