This commit is contained in:
Tofik Denianto 2021-11-21 12:32:21 +07:00 committed by GitHub
parent 17f40cff37
commit 8e3666eb52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,6 @@
from driver.veez import call_py
from pytgcalls import PyTgCalls
from pytgcalls.types import Update
from driver.queues import QUEUE, clear_queue, get_queue, pop_an_item from driver.queues import QUEUE, clear_queue, get_queue, pop_an_item
from driver.veez import call_py
from pytgcalls.types import Update
from pytgcalls.types.input_stream import AudioPiped, AudioVideoPiped from pytgcalls.types.input_stream import AudioPiped, AudioVideoPiped
from pytgcalls.types.input_stream.quality import ( from pytgcalls.types.input_stream.quality import (
HighQualityAudio, HighQualityAudio,
@ -20,35 +19,35 @@ async def skip_current_song(chat_id):
clear_queue(chat_id) clear_queue(chat_id)
return 1 return 1
else: else:
try: try:
songname = chat_queue[1][0] songname = chat_queue[1][0]
url = chat_queue[1][1] url = chat_queue[1][1]
link = chat_queue[1][2] link = chat_queue[1][2]
type = chat_queue[1][3] type = chat_queue[1][3]
Q = chat_queue[1][4] Q = chat_queue[1][4]
if type == "Audio": if type == "Audio":
await call_py.change_stream( await call_py.change_stream(
chat_id, chat_id,
AudioPiped( AudioPiped(
url, url,
), ),
) )
elif type == "Video": elif type == "Video":
if Q == 720: if Q == 720:
hm = HighQualityVideo() hm = HighQualityVideo()
elif Q == 480: elif Q == 480:
hm = MediumQualityVideo() hm = MediumQualityVideo()
elif Q == 360: elif Q == 360:
hm = LowQualityVideo() hm = LowQualityVideo()
await call_py.change_stream( await call_py.change_stream(
chat_id, AudioVideoPiped(url, HighQualityAudio(), hm) chat_id, AudioVideoPiped(url, HighQualityAudio(), hm)
) )
pop_an_item(chat_id) pop_an_item(chat_id)
return [songname, link, type] return [songname, link, type]
except: except:
await call_py.leave_group_call(chat_id) await call_py.leave_group_call(chat_id)
clear_queue(chat_id) clear_queue(chat_id)
return 2 return 2
else: else:
return 0 return 0
@ -68,20 +67,27 @@ async def skip_item(chat_id, h):
return 0 return 0
@call_py.on_kicked()
async def kicked_handler(_, chat_id: int):
if chat_id in QUEUE:
clear_queue(chat_id)
@call_py.on_closed_voice_chat()
async def closed_voice_chat_handler(_, chat_id: int):
if chat_id in QUEUE:
clear_queue(chat_id)
@call_py.on_left()
async def left_handler(_, chat_id: int):
if chat_id in QUEUE:
clear_queue(chat_id)
@call_py.on_stream_end() @call_py.on_stream_end()
async def on_end_handler(_, u: Update): async def stream_end_handler(_, u: Update):
if isinstance(u, StreamAudioEnded) or isinstance(u, StreamVideoEnded): if isinstance(u, StreamAudioEnded) or isinstance(u, StreamVideoEnded):
chat_id = u.chat_id chat_id = u.chat_id
print(chat_id) print(chat_id)
await skip_current_song(chat_id) await skip_current_song(chat_id)
@call_py.on_closed_voice_chat()
async def closed_handler(client: PyTgCalls, chat_id: int):
if chat_id in QUEUE:
clear_queue(chat_id)
@call_py.on_kicked()
async def kicked_handler(client: PyTgCalls, chat_id: int) -> None:
if chat_id in QUEUE:
clear_queue(chat_id)