WardrikChannel.Replies.State (wardrik_channel v0.1.0-rc.1)

Copy Markdown

The state of one room's replies.

Saved between restarts:

  • the cursor past what's posted
  • for each conversation, the run under way, the messages it answers and who asked
  • the arguments of each conversation's calls

Not saved: the channel, the follower, and when each thread's last status was shown.

Summary

Types

What an event asks to post in its thread. :none posts nothing. The rest match WardrikChannel.Outbound.body/0, except {:waiting, interrupt_ids, asked_by}.

t()

Functions

Returns the arguments of call id in conversation, or nil if unknown.

Returns who asked for the run under way in conversation, or nil if unknown.

Returns the part of state saved between restarts.

Restores the state from dump/1's result.

Returns the state of a room no one has posted in yet.

Returns what event of conversation asks to post, and the updated state.

Types

post()

@type post() ::
  {:reply, String.t(), [String.t()]}
  | {:status, String.t()}
  | {:waiting, [String.t()], String.t() | nil}
  | {:failed, String.t()}
  | {:stopped, [String.t()]}
  | {:said, String.t()}
  | :none

What an event asks to post in its thread. :none posts nothing. The rest match WardrikChannel.Outbound.body/0, except {:waiting, interrupt_ids, asked_by}.

run()

@type run() :: %{id: String.t(), answering: [String.t()], asked_by: String.t() | nil}

t()

@type t() :: %WardrikChannel.Replies.State{
  calls: %{required(String.t()) => %{required(String.t()) => term()}},
  channel: WardrikChannel.Channel.t() | nil,
  cursor: String.t() | nil,
  follower: pid() | nil,
  room: String.t(),
  runs: %{required(String.t()) => run()},
  senders: %{required(String.t()) => String.t()},
  shown: %{required(String.t()) => integer()},
  workspace: String.t()
}

Functions

arguments(state, conversation, id)

@spec arguments(t(), String.t(), String.t() | nil) :: term()

Returns the arguments of call id in conversation, or nil if unknown.

asked_by(state, conversation)

@spec asked_by(t(), String.t()) :: String.t() | nil

Returns who asked for the run under way in conversation, or nil if unknown.

dump(state)

@spec dump(t()) :: map()

Returns the part of state saved between restarts.

load(dumped)

@spec load(map()) :: t()

Restores the state from dump/1's result.

new(workspace, room)

@spec new(String.t(), String.t()) :: t()

Returns the state of a room no one has posted in yet.

take(state, conversation, event)

@spec take(t(), String.t(), Wardrik.Event.t()) :: {post(), t()}

Returns what event of conversation asks to post, and the updated state.