Skip to content

Tooter

Modules:

Name Description
core

Classes:

Name Description
Tooter

Functions:

Name Description
is_acceptable_email_address

Whether value is an address mail can safely be sent to.

Tooter

Methods:

Name Description
async_relay

Post one notification, and report what apprise said about it.

bark

Push one iOS critical alert, if a device is configured and due.

critical

An alert that means something is down, not something is interesting.

email

Send email

async_relay(channel, body, notifier_type, title, chat_id=None) async

Post one notification, and report what apprise said about it.

The status is returned rather than only printed because 424 is not noise -- it is Telegram saying this recipient has blocked the bot, and the caller is the only one in a position to remember that. Printing it and returning None is what let four blocked chats be sent to for weeks.

bark(message, key=None)

Push one iOS critical alert, if a device is configured and due.

Unset BARK_URL is the ordinary case rather than an error: most of the deployables that embed this component have no reason to page anybody, and they all share one env component. Silence beats an exception, and beats a log line repeated by twenty services.

The cooldown is the difference between this being usable and being switched off within a day. Watchtower checks every 60 seconds, and a replica set can sit without a primary for an hour -- that is sixty pages, each ringing for thirty seconds. Once per condition per CRITICAL_COOLDOWN_SECONDS still nags while something is broken without making the phone unusable.

It is held in memory, so a restart re-pages. That is the right way round: a watchtower that just came up should re-assert what it finds rather than stay quiet about it.

Between BARK_QUIET_START and BARK_QUIET_END nothing is sent at all -- see QuietHours. This is the only place that window can be honoured, because a critical alert exists specifically to override the phone's own silence. Telegram still goes out, so nothing is lost from the log.

critical(message, key=None, chat_id=None)

An alert that means something is down, not something is interesting.

Everything else here goes to Telegram and waits to be read. A Telegram notification cannot wake anyone: it obeys silent mode and Do Not Disturb, which is correct for the hundred informational alerts a day and useless for the replica set losing its primary at 3am.

So this sends twice. Telegram keeps the record -- same channel, same chat, same text as before, so nothing is lost from the existing log -- and Bark pushes an iOS critical alert, which ignores silent and DND by design and, with call, keeps ringing for thirty seconds.

Reserve it for the things live-everything paints red: no primary, a member down, Sentinel without quorum, a stalled change stream, a container being OOM-killed. An alert that pages for something that does not need a human teaches you to ignore the ones that do.

key identifies the condition, not the wording, and is what the cooldown counts against. Pass a stable one wherever the text carries a changing number -- "Member X is 12 mins behind" becomes 13 next minute and would otherwise ring forever. It defaults to the message, which is right only for alerts whose text is fixed.

email(title, body, email_address, value=None, error=None)

Send email

is_acceptable_email_address(value)

Whether value is an address mail can safely be sent to.

fullmatch, not match with a $: that anchor is satisfied just before a trailing newline, and a newline is one of the characters this is here to keep out. Anything that is not a string is not an address either -- the stored value comes from Mongo and is whatever was once written there.