From 70386a79a1b5dfa27fdf2cbbc0c5d74323840731 Mon Sep 17 00:00:00 2001 From: xtao-dada Date: Wed, 2 Mar 2022 22:55:29 +0800 Subject: [PATCH] Fix a bug. --- main.py | 4 ++-- program/assistant_settings.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index fe64802..489fca0 100644 --- a/main.py +++ b/main.py @@ -10,8 +10,8 @@ async def start_bot(): LOGS.info("[INFO]: BOT & USERBOT CLIENT STARTED !!") await calls.start() LOGS.info("[INFO]: PY-TGCALLS CLIENT STARTED !!") - await user.join_chat("VeezSupportGroup") - await user.join_chat("levinachannel") + # await user.join_chat("VeezSupportGroup") + # await user.join_chat("levinachannel") await idle() LOGS.info("[INFO]: BOT & USERBOT STOPPED !!") await bot.stop() diff --git a/program/assistant_settings.py b/program/assistant_settings.py index 00a9e39..1ed201e 100644 --- a/program/assistant_settings.py +++ b/program/assistant_settings.py @@ -118,6 +118,11 @@ async def start_group_call(c: Client, m: Message): chat_id = m.chat.id msg = await c.send_message(chat_id, "`尝试开启视频聊天中...`") try: + group_call = ( + await get_calls(c, m, err_msg="") + ) + if group_call: + raise FileExistsError peer = await user.resolve_peer(chat_id) await user.send( CreateGroupCall( @@ -133,6 +138,8 @@ async def start_group_call(c: Client, m: Message): await msg.edit_text( "❌ 您需要首先赋予 userbot `管理语音聊天` 权限" ) + except FileExistsError: + await msg.edit_text("✅ 视频聊天未关闭") @Client.on_message(command(["stopvc", f"stopvc@{BOT_USERNAME}"]) & other_filters) @@ -141,13 +148,11 @@ async def start_group_call(c: Client, m: Message): async def stop_group_call(c: Client, m: Message): chat_id = m.chat.id msg = await c.send_message(chat_id, "`尝试关闭视频聊天中...`") - if not ( - group_call := ( + group_call = ( await get_calls(c, m, err_msg="group call not active") ) - ): - await msg.edit_text("❌ 未开启视频聊天") - return + if not group_call: + return await msg.edit_text("❌ 未开启视频聊天") await user.send( DiscardGroupCall( call=group_call