From 2b8ff5b4accee9191535f823858e9411dc3a9743 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 27 Jul 2022 16:10:34 +0800 Subject: [PATCH] =?UTF-8?q?vctools=20=E5=BC=80=E5=90=AF=E6=88=96=E8=80=85?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=BE=A4=E7=BB=84=E7=9B=B4=E6=92=AD=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vctools/main.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 vctools/main.py diff --git a/vctools/main.py b/vctools/main.py new file mode 100644 index 0000000..e9c4c25 --- /dev/null +++ b/vctools/main.py @@ -0,0 +1,37 @@ +from pyrogram.errors import ChatAdminRequired +from pyrogram.raw.functions.channels import GetFullChannel +from pyrogram.raw.functions.phone import CreateGroupCall, DiscardGroupCall + +from pagermaid.listener import listener +from pagermaid.enums import Client, Message + + +@listener(command="vctools", + admins_only=True, + groups_only=True, + parameters="<开启/关闭>", + description="开启/关闭群组直播间") +async def vctools(bot: Client, message: Message): + if not message.arguments: + return await message.reply("请输入 `开启/关闭`") + if message.arguments == "开启": + try: + await bot.invoke( + CreateGroupCall( + peer=await bot.resolve_peer(message.chat.id), + random_id=bot.rnd_id() // 9000000000, + ) + ) + return await message.edit("已开启群组直播间") + except ChatAdminRequired: + return await message.reply("需要管理员权限") + elif message.arguments == "关闭": + try: + full_chat = (await bot.invoke(GetFullChannel(channel=await bot.resolve_peer(message.chat.id)))).full_chat + if full_chat.call: + await bot.invoke(DiscardGroupCall(call=full_chat.call)) + return await message.edit("已关闭群组直播间") + except ChatAdminRequired: + return await message.reply("需要管理员权限") + else: + return await message.reply("请输入开启/关闭")