mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 10:16:57 +00:00
vctools 开启或者关闭群组直播间
This commit is contained in:
parent
29ff69c21d
commit
2b8ff5b4ac
37
vctools/main.py
Normal file
37
vctools/main.py
Normal file
@ -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("请输入开启/关闭")
|
Loading…
Reference in New Issue
Block a user