from typing import Optional from driver.core import user from pyrogram.raw.functions.channels import GetFullChannel from pyrogram.raw.functions.messages import GetFullChat from pyrogram.types import Message from pyrogram.raw.types import ( InputGroupCall, InputPeerChannel, InputPeerChat, ) async def get_calls(m: Message, err_msg: str = "") -> Optional[InputGroupCall]: chat_peer = await user.resolve_peer(m.chat.id) if isinstance(chat_peer, (InputPeerChannel, InputPeerChat)): if isinstance(chat_peer, InputPeerChannel): full_chat = (await user.send(GetFullChannel(channel=chat_peer))).full_chat elif isinstance(chat_peer, InputPeerChat): full_chat = ( await user.send(GetFullChat(chat_id=chat_peer.chat_id)) ).full_chat if full_chat is not None: return full_chat.call await message.err(f"❌ no group calls found\n\n» `{err_msg}`") return False def bytes(size: float) -> str: if not size: return "" power = 1024 t_n = 0 power_dict = {0: " ", 1: "Ki", 2: "Mi", 3: "Gi", 4: "Ti"} while size > power: size /= power t_n += 1 return "{:.2f} {}B".format(size, power_dict[t_n])