Telegram.Bot behaviour (telegram v2.1.0)
View SourceTelegram Bot behaviour.
Example
defmodule HelloBot do
use Telegram.Bot
@impl Telegram.Bot
def handle_update(
%{"message" => %{"text" => "/hello", "chat" => %{"id" => chat_id, "username" => username}, "message_id" => message_id}},
token
) do
Telegram.Api.request(token, "sendMessage",
chat_id: chat_id,
reply_to_message_id: message_id,
text: "Hello #{username}!"
)
end
def handle_update(_update, _token) do
# ignore unknown updates
:ok
end
end
Summary
Callbacks
The function receives the telegram update event.
Callbacks
@callback handle_update( update :: Telegram.Types.update(), token :: Telegram.Types.token() ) :: any()
The function receives the telegram update event.