# Ultroid - UserBot # Copyright (C) 2021 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # . """ ✘ Commands Available - • `{i}startvc` Start Group Call in a group. • `{i}stopvc` Stop Group Call in a group. • `{i}vcinvite` Invite all members of group in Group Call. (You must be joined) """ from telethon.tl.functions.channels import GetFullChannelRequest as getchat from telethon.tl.functions.phone import CreateGroupCallRequest as startvc from telethon.tl.functions.phone import DiscardGroupCallRequest as stopvc from telethon.tl.functions.phone import GetGroupCallRequest as getvc from telethon.tl.functions.phone import InviteToGroupCallRequest as invitetovc from . import eor, ultroid_cmd async def get_call(event): mm = await event.client(getchat(event.chat_id)) xx = await event.client(getvc(mm.full_chat.call)) return xx.call def user_list(l, n): for i in range(0, len(l), n): yield l[i : i + n] @ultroid_cmd( pattern="stopvc$", admins_only=True, groups_only=True, ) async def _(e): try: await e.client(stopvc(await get_call(e))) await eor(e, "`Voice Chat Stopped...`") except Exception as ex: await eor(e, f"`{ex}`") @ultroid_cmd( pattern="vcinvite$", groups_only=True, ) async def _(e): ok = await eor(e, "`Inviting Members to Voice Chat...`") users = [] z = 0 async for x in e.client.iter_participants(e.chat_id): if not x.bot: users.append(x.id) hmm = list(user_list(users, 6)) for p in hmm: try: await e.client(invitetovc(call=await get_call(e), users=p)) z += 6 except BaseException: pass await ok.edit(f"`Invited {z} users`") @ultroid_cmd( pattern="startvc$", admins_only=True, groups_only=True, ) async def _(e): try: await e.client(startvc(e.chat_id)) await eor(e, "`Voice Chat Started...`") except Exception as ex: await eor(e, f"`{ex}`")