# `ExGram.FSM.Filter.State`
[🔗](https://github.com/rockneurotiko/ex_gram_fsm/blob/v0.1.0/lib/ex_gram/fsm/filter/state.ex#L1)

An `ExGram.Router.Filter` that matches on the current FSM state or FSM data.

This filter is automatically registered as the `:fsm_state` alias when
`use ExGram.FSM` detects that `use ExGram.Router` has also been called on
the same module.

## Usage

Match on FSM state atom:

    scope do
      filter :fsm_state, :get_name
      filter :text
      handle &MyBot.Handlers.got_name/1
    end

Match on a key in FSM data:

    scope do
      filter :fsm_state, {:step, :confirm}
      handle &MyBot.Handlers.confirm/1
    end

## Options

- `atom` — matches when `context.extra.fsm.state == atom`
- `{key, value}` — matches when `context.extra.fsm.data[key] == value`
- `nil` — matches when there is no FSM state set (`state == nil`)

# `call`

```elixir
@spec call(term(), ExGram.Cnt.t(), atom() | nil | {term(), term()}) :: boolean()
```

Filter callback.

- `opts` is an atom: returns `true` when the current FSM state equals that atom.
- `opts` is `{key, value}`: returns `true` when `context.extra.fsm.data[key] == value`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
