Nag
A named nag created by Sponsorkit.nag().
Class in sponsorkit.nag.
from sponsorkit import NagAlso importable from sponsorkit.nag.
class Nag:
...A named nag created by sponsorkit.Sponsorkit.nag().
The run counter goes up by one per process per id, on the first due() call. due() returns predicate(result) and (runs >= every or time since last shown >= or_every). shown() resets the counter and records the time.
due() is always False when SPONSORKIT_DISABLE is set, and (unless force=True) when SPONSORKIT_NO_NAG or CI is set or the session is not interactive (stdout/stderr not a TTY, or the interactive=False option). It never signs in.
Don't construct a Nag yourself: call sponsorkit.Sponsorkit.nag(), which validates the arguments and binds the nag to the client's storage.
Attributes#
id#
id: strThe name of the counter, as passed to Sponsorkit.nag().
every#
every: intDue once this many runs have counted since the nag was last shown.
or_every#
or_every: timedelta | NoneAlso due once this much time passed since it was last shown, or None.
Methods#
due()#
def due(self, predicate: Predicate | None = None, *, force: bool = False) -> boolWhether to show the nag now. predicate receives the current ContributionResult.
shown()#
def shown(self) -> NoneRecord that the nag was shown: resets the run counter and sets lastShown to now.
adue()#
async def adue(self, predicate: Predicate | None = None, *, force: bool = False) -> boolAsync variant of due() (runs in a worker thread).
ashown()#
async def ashown(self) -> NoneAsync variant of shown().