improve
added auto leave from vc after finished streaming video
This commit is contained in:
parent
306d697070
commit
22b076260f
@ -4,6 +4,7 @@ import subprocess
|
||||
from pytgcalls import idle
|
||||
from pytgcalls import PyTgCalls
|
||||
from pytgcalls import StreamType
|
||||
from pytgcalls.types import Update
|
||||
from pytgcalls.types.input_stream import AudioParameters
|
||||
from pytgcalls.types.input_stream import InputAudioStream
|
||||
from pytgcalls.types.input_stream import InputVideoStream
|
||||
@ -32,6 +33,20 @@ def raw_converter(dl, song, video):
|
||||
cwd=None,
|
||||
)
|
||||
|
||||
async def leave_call(chat_id: int):
|
||||
process = FFMPEG_PROCESSES.get(chat_id)
|
||||
if process:
|
||||
try:
|
||||
process.send_signal(SIGINT)
|
||||
await asyncio.sleep(3)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
||||
try:
|
||||
await call_py.leave_group_call(chat_id)
|
||||
except Exception as e:
|
||||
print(f"🚫 error - {e}")
|
||||
|
||||
def youtube(url: str):
|
||||
try:
|
||||
params = {"format": "best[height=?480]/best", "noplaylist": True}
|
||||
@ -151,7 +166,13 @@ async def stopvideo(client, m: Message):
|
||||
await asyncio.sleep(3)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
||||
await call_py.leave_group_call(chat_id)
|
||||
await m.reply("✅ **successfully left vc !**")
|
||||
except Exception as e:
|
||||
await m.reply(f"🚫 **error** | `{e}`")
|
||||
|
||||
@call_py.on_stream_end()
|
||||
async def handler(client: PyTgCalls, update: Update):
|
||||
chat_id = update.chat.id
|
||||
await leave_call(chat_id)
|
||||
|
Loading…
Reference in New Issue
Block a user