Skip to main content

Crate notiflow

Crate notiflow 

Source
Expand description

notiflow — send a Telegram message from CI or from a terminal.

The same pipeline backs both faces of the tool: resolve settings → decide whether this status is worth notifying about → pick and render a template → truncate to Telegram’s limit → post with retries → report. notiflow the GitHub Action is this library with its outputs pointed at $GITHUB_OUTPUT; notiflow the CLI is the same code printing to a terminal.

use notiflow::config::{Config, Invocation, Need, Settings};
use notiflow::{RunOptions, run};

let settings = Settings {
    bot_token: Some(std::env::var("NOTIFLOW_BOT_TOKEN").unwrap()),
    chat_id: Some("-1001234567890".into()),
    ..Default::default()
};
let invocation = Invocation { status: Some("success".into()), ..Default::default() };
let config = Config::build(settings, invocation, false, Need::Full).unwrap();
let report = run(&config, RunOptions::default()).unwrap();
println!("delivered: {}", report.ok);

§What semver covers here

The stable surface of this crate is the notiflow command line and the GitHub Action built on it: their flags, inputs, outputs and exit codes follow semver, and the parity corpus exists to keep them honest.

The library is published because the binary is. Its items are pub so that the binary, the integration tests and the doc generators can reach across module boundaries, not because there is an external consumer whose build this crate has promised not to break. Treat everything below as internal: signatures, fields and variants can change in a minor release. If you are depending on it anyway, pin an exact version and open an issue — a real contract can be drawn around the parts somebody actually uses, which is a better trade than freezing all of it blind.

Modules§

actions
GitHub Actions workflow commands: masking, annotations, outputs, step summary.
cli
The command line: argument definitions and the five commands they drive.
config
Settings: where they come from, how they are layered, and what they must satisfy.
context
The values {{.Field}} placeholders resolve to.
error
Error taxonomy and the exit codes it maps to.
escape
Escaping of substituted values for each parse mode.
model
Newtypes for every value that used to be an unvalidated string in the bash version.
output
The three ways notiflow reports what it did.
redact
One place that guarantees the bot token never reaches a stream a human can read.
telegram
Everything that talks to the Telegram Bot API.
template
Template selection and single-pass {{.Field}} substitution.
truncate
Cutting a message down to Telegram’s 4096 limit without breaking its markup.

Macros§

safe_eprintln
eprintln! that scrubs first.
safe_println
println! that scrubs first.

Structs§

RenderResult
The rendered message plus how it was produced.
RunOptions
Per-invocation switches that are not settings.

Constants§

VERSION
The crate version, used by --version and by the Action’s install sanity check.

Functions§

build_request
Builds the Bot API request for config and an already-rendered text.
render_message
Picks the active template and renders it against ctx.
run
Runs the whole pipeline and returns what happened.