Noizu.Comms.Message (noizu_comms v0.1.0)

Copy Markdown View Source

Channel-agnostic outbound message (contract shape).

  • :text is required; everything else is optional.
  • :format — :markdown (CommonMark subset: bold, italic, code, code block, link) or :plain.
  • :fields — key/value facts, rendered as embed fields (Discord), block lines (Slack), or bold-key lines elsewhere.
  • :level — :info | :success | :warning | :error (colour / emoji prefix).

  • :attachments — by URL only in v1: %{url:, name: | nil, mime: | nil}.

  • :silent — suppress notification where the channel supports it.

Summary

Functions

Validates and builds a message from a map or keyword list.

Like new/1 but raises Noizu.Comms.Error on invalid input.

Types

attachment()

@type attachment() :: %{
  url: String.t(),
  name: String.t() | nil,
  mime: String.t() | nil
}

field()

@type field() :: {String.t(), String.t()}

t()

@type t() :: %Noizu.Comms.Message{
  attachments: [attachment()],
  fields: [field()],
  format: :markdown | :plain,
  idempotency_key: String.t() | nil,
  level: :info | :success | :warning | :error | nil,
  metadata: map(),
  reply_to: String.t() | nil,
  silent: boolean(),
  text: String.t() | nil,
  thread: String.t() | nil,
  title: String.t() | nil
}

Functions

new(attrs)

@spec new(map() | keyword()) :: {:ok, t()} | {:error, Noizu.Comms.Error.t()}

Validates and builds a message from a map or keyword list.

new!(attrs)

@spec new!(map() | keyword()) :: t()

Like new/1 but raises Noizu.Comms.Error on invalid input.