Skip to main content

Crate mxblocks_asks

Crate mxblocks_asks 

Source
Expand description

Reaction asks in a bot’s plain-text reply: a paragraph that asks the reader to react gets those reactions seeded (and mxblocks buttons), so on a phone they tap one instead of hunting for the emoji, and the tap can be handled like a button press.

  • The marker. [ask: ✅ deploy | ❌ skip] (2 to 4 options, an emoji and a short label each) anywhere in a paragraph: that paragraph goes as its own message, the marker replaced by ✅ deploy · ❌ skip, with a buttons block and the keys seeded. A label over MAX_LABEL is shortened on its button, kept whole in the text. A marker that still doesn’t parse is never posted raw: it becomes its options joined with ·.
  • The safety net. Without a marker, only the end of the reply’s last paragraph, only strict shapes: ✅ to deploy, ❌ to skip (two or three, buttons too), react ✅, 👍/👎? and 👍 or 👎 (seeds only). A last paragraph that is only the marker’s rendered form (✅ deploy · ❌ skip, written instead of the marker) stays text: rendered_only lets the sender log it. A press note can quote the ask in marker form (Ask::marker, Ask::quoted), so the model never sees the rendered form as its own.

Pure: plan says what each message carries; the sender seeds the reactions and registers the buttons.

§mxblocks-asks

Reaction asks for Matrix bots. A paragraph of a bot’s reply with a marker, Deploy? [ask: ✅ deploy | ❌ skip], goes out as its own message reading Deploy? ✅ deploy · ❌ skip, with an mxblocks buttons block and the reactions to seed, so a reader taps one instead of typing. Without a marker, a strict safety net catches ✅ to deploy, ❌ to skip, react ✅ and 👍/👎? at the end of the reply.

Pure: plan splits a reply and says what each message carries; seeding the reactions and handling the taps is the caller’s.

let (_, ask) = mxblocks_asks::take_marker("Deploy? [ask: ✅ deploy | ❌ skip]").unwrap();
assert_eq!(ask.opts.len(), 2);

Apache-2.0.

Structs§

Ask
A message’s ask: its options, and whether Element shows them as buttons (the seeds go either way).
Opt
One option: the reaction key and its label (empty: the key alone).

Functions§

detect
The safety net: an ask in one of the strict shapes at the very end of text (a reply’s last paragraph), outside code.
paragraphs
text’s paragraphs (blank-line separated) of Markdown; a fenced code block stays in one piece even with blank lines inside.
plain_markers
text with every marker outside code that take_marker left (one that doesn’t parse, or a second one in a paragraph) made readable: its options joined with ·, without the brackets and ask:.
plan
What each message of a reply carries: the parts (each with the caller’s per-message data M: a reply target, a thread, …) with every paragraph (paragraphs) that has a marker split off as its own message (the marker replaced by its fallback), each with its ask; without any marker, the last one’s ask by detect. A split part’s M goes on its first message, the rest get M::default().
plan_with
plan with the caller’s paragraph splitter.
rendered_only
Whether text’s last paragraph is only the marker’s rendered form (✅ deploy · ❌ skip, two to four options, distinct keys): an ask written without its marker, which goes out as text.
take_marker
The first valid marker in para outside code: the paragraph with it replaced by its fallback, and the ask.