Current section

Files

Jump to
ex_gram lib examples simple.ex
Raw

lib/examples/simple.ex

defmodule Examples.Simple do
@moduledoc false
@bot :simple_bot
use ExGram.Bot, name: @bot, setup_commands: true
require Logger
command("echo", description: "Echo the message back to the user")
middleware(ExGram.Middleware.IgnoreUsername)
def handle({:command, :echo, %{text: t}}, cnt) do
answer(cnt, t)
end
def handle({:bot_message, from, msg}, %{name: name}) do
Logger.info("Message from bot #{inspect(from)} to #{inspect(name)} : #{inspect(msg)}")
:hi
end
def handle(msg, _) do
IO.puts("Unknown message #{inspect(msg)}")
end
end