We present multiwavelength observations of the Type II SN 2020pni. Classified at $sim 1.3$ days after explosion, the object showed narrow (FWHM $<250,textrm{km},textrm{s}^{-1}$) recombination lines of ionized helium, nitrogen, and carbon, as typically seen in flash-spectroscopy events. Using the non-LTE radiative transfer code CMFGEN to model our first high resolution spectrum, we infer a progenitor mass-loss rate of $dot{M}=(3.5-5.3)times10^{-3}$ M$_{odot}$ yr$^{-1}$ (assuming a wind velocity of $v_w=200,textrm{km},textrm{s}^{-1}$), estimated at a radius of $R_{rm in}=2.5times10^{14},rm{cm}$. In addition, we find that the progenitor of SN 2020pni was enriched in helium and nitrogen (relative abundances in mass fractions of 0.30$-$0.40, and $8.2times10^{-3}$, respectively). Radio upper limits are also consistent with a dense CSM, and a mass-loss rate of $dot M>5 times 10^{-4},rm{M_{odot},yr^{-1}}$. During the first 4 days after first light, we also observe an increase in velocity of the hydrogen lines (from $sim 250,textrm{km},textrm{s}^{-1}$ to $sim 1000,textrm{km},textrm{s}^{-1}$), which suggests a complex CSM. The presence of dense and confined CSM, as well as its inhomogeneous structure, suggest a phase of enhanced mass loss of the progenitor of SN 2020pni during the last year before explosion. Finally, we compare SN 2020pni to a sample of other shock-photoionization events. We find no evidence of correlations among the physical parameters of the explosions and the characteristics of the CSM surrounding the progenitors of these events. This favors the idea that the mass-loss experienced by massive stars during their final years could be governed by stochastic phenomena, and that, at the same time, the physical mechanisms responsible for this mass-loss must be common to a variety of different progenitors.