  Gamma-ray bursts (GRBs) and their early afterglows ionise their circumburst
material. Only high-energy spectroscopy therefore, allows examination of the
matter close to the burst itself. Soft X-ray absorption allows an estimate to
be made of the total column density in metals. The detection of the X-ray
afterglow can also be used to place a limit on the total gas column along the
line of sight based on the Compton scattering opacity. Such a limit would
enable, for the first time, the determination of lower limits on the
metallicity in the circumburst environments of GRBs. In this paper, we
determine the limits that can be placed on the total gas column density in the
vicinities of GRBs based on the Compton scattering. We simulate the effects of
Compton scattering on a collimated beam of high energy photons passing through
a shell of high column density material to determine the expected lightcurves,
luminosities, and spectra. We compare these predictions to observations, and
determine what limits can realistically be placed on the total gas column
density. The smearing out of pulses in the lightcurve from Compton scattering
is not likely to be observable, and its absence does not place strong
constraints on the Compton depth for GRBs. However, the distribution of
observed luminosities of bursts allows us to place statistical, model-dependent
limits that are typically <~1e25 cm^{-2} for less luminous bursts, and as low
as ~1e24 cm$^{-2} for the most luminous. Using the shape of the high-energy
broadband spectrum, however, in some favourable cases, limits as low as ~5e24
cm^{-2} can placed on individual bursts, implying metallicity lower limits from
X- and gamma-rays alone from 0 up to 0.01 Z/Zsun. At extremely high redshifts,
this limit would be at least 0.02 Z/Z_sun, enough to discriminate population
III from non-primordial GRBs.
