# `ExGram.Bot`
[🔗](https://github.com/rockneurotiko/ex_gram/blob/0.65.0/lib/ex_gram/bot.ex#L1)

Bot creation helper.

Usage:

- Create one or more bots

``` elixir
defmodule MyBot do
  use ExGram.Bot, name: :my_bot, setup_commands: true

  command("echo", description: "Echo the message back to the user")

  middleware(ExGram.Middleware.IgnoreUsername)

  # Command received as `:echo` instead of `"echo"` because it was configured as a command before
  def handle({:command, :echo, %{text: t}}, cnt) do
    cnt |> answer(t)
  end

  def handle(msg, _cnt) do
    IO.puts("Unknown message " <> inspect(msg))
  end
end
```

- Add `ExGram` and your bots to your application children

``` elixir
children = [
  # ...
  ExGram,
  {MyBot, [method: :polling, token: "bot_token"]}
]
```

# `middleware`

```elixir
@type middleware() :: {module() | middleware_fn(), opts :: any()}
```

# `middleware_fn`

```elixir
@type middleware_fn() :: (ExGram.Cnt.t(), opts :: any() -&gt; ExGram.Cnt.t())
```

---

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