video-stream/driver/queues.py

35 lines
777 B
Python
Raw Normal View History

2022-01-18 07:47:49 +00:00
""" queue storage """
2021-10-26 08:52:09 +00:00
QUEUE = {}
2022-01-18 07:47:49 +00:00
def add_to_queue(chat_id, songname, link, ref, type, quality, image, duration):
2021-10-26 08:52:09 +00:00
if chat_id in QUEUE:
chat_queue = QUEUE[chat_id]
2022-01-18 07:47:49 +00:00
chat_queue.append([songname, link, ref, type, quality, image, duration])
2021-10-26 08:52:09 +00:00
return int(len(chat_queue)-1)
else:
2022-01-18 07:47:49 +00:00
QUEUE[chat_id] = [[songname, link, ref, type, quality, image, duration]]
2021-10-26 08:52:09 +00:00
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