def get_chat_members_count(
        self,
        chat_id: Union[int, str]
    ) -> int:
        """Use this method to get the number of members in a chat.

        Args:
            chat_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the target chat.

        Returns:
            On success, an integer is returned.

        Raises:
            :class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
            ``ValueError`` if a chat_id belongs to user.
        """
        peer = self.resolve_peer(chat_id)

        if isinstance(peer, types.InputPeerChat):
            return self.send(
                functions.messages.GetChats(
                    id=[peer.chat_id]
                )
            ).chats[0].participants_count
        elif isinstance(peer, types.InputPeerChannel):
            return self.send(
                functions.channels.GetFullChannel(
                    channel=peer
                )
            ).full_chat.participants_count
        else:
            raise ValueError("The chat_id \"{}\" belongs to a user".format(chat_id))
def get_chat_members_count ( self , chat_id : Union [ int , str ] ) -> int : peer = self . resolve_peer ( chat_id ) if isinstance ( peer , types . InputPeerChat ) : return self . send ( functions . messages . GetChats ( id = [ peer . chat_id ] ) ) . chats [ 0 ] . participants_count elif isinstance ( peer , types . InputPeerChannel ) : return self . send ( functions . channels . GetFullChannel ( channel = peer ) ) . full_chat . participants_count else : raise ValueError ( "The chat_id \"{}\" belongs to a user" . format ( chat_id ) )
Use this method to get the number of members in a chat.

        Args:
            chat_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the target chat.

        Returns:
            On success, an integer is returned.

        Raises:
            :class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
            ``ValueError`` if a chat_id belongs to user.