From 20abea5a63f83d6464596579318449e2b369c547 Mon Sep 17 00:00:00 2001 From: levina <82658782+levina-lab@users.noreply.github.com> Date: Wed, 9 Feb 2022 09:59:38 +0700 Subject: [PATCH] improvements --- driver/utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/driver/utils.py b/driver/utils.py index 6a53e68..b7b1e2e 100644 --- a/driver/utils.py +++ b/driver/utils.py @@ -1,7 +1,9 @@ import asyncio -from driver.queues import QUEUE, clear_queue, get_queue, pop_an_item from driver.core import bot, calls +from driver.database.dbqueue import remove_active_chat, music_off +from driver.queues import QUEUE, clear_queue, get_queue, pop_an_item + from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from pytgcalls.types import Update from pytgcalls.types.input_stream import AudioPiped, AudioVideoPiped @@ -29,6 +31,8 @@ async def skip_current_song(chat_id): chat_queue = get_queue(chat_id) if len(chat_queue) == 1: await calls.leave_group_call(chat_id) + await remove_active_chat(chat_id) + await music_off(chat_id) clear_queue(chat_id) return 1 else: @@ -65,6 +69,8 @@ async def skip_current_song(chat_id): return [songname, link, type] except: await calls.leave_group_call(chat_id) + await remove_active_chat(chat_id) + await music_off(chat_id) clear_queue(chat_id) return 2 else: @@ -89,18 +95,24 @@ async def skip_item(chat_id, h): @calls.on_kicked() async def kicked_handler(_, chat_id: int): if chat_id in QUEUE: + await music_off(chat_id) + await remove_active_chat(chat_id) clear_queue(chat_id) @calls.on_closed_voice_chat() async def closed_voice_chat_handler(_, chat_id: int): if chat_id in QUEUE: + await music_off(chat_id) + await remove_active_chat(chat_id) clear_queue(chat_id) @calls.on_left() async def left_handler(_, chat_id: int): if chat_id in QUEUE: + await music_off(chat_id) + await remove_active_chat(chat_id) clear_queue(chat_id)