File size: 686 Bytes
a8e9b84 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import asyncio
from DragMusic.misc import db
from DragMusic.utils.database import get_active_chats, is_music_playing
async def timer():
while not await asyncio.sleep(1):
active_chats = await get_active_chats()
for chat_id in active_chats:
if not await is_music_playing(chat_id):
continue
playing = db.get(chat_id)
if not playing:
continue
duration = int(playing[0]["seconds"])
if duration == 0:
continue
if db[chat_id][0]["played"] >= duration:
continue
db[chat_id][0]["played"] += 1
asyncio.create_task(timer())
|