ExGram.Dsl (ex_gram v0.65.0)

Copy Markdown View Source

Mini DSL to build answers based on the context (ExGram.Cnt) easily.

This module is automatically imported when using ExGram.Bot. Functions in this module allow you to build responses declaratively by chaining operations on the context. The responses are queued and executed after your handler returns.

See the Sending Messages guide for detailed usage examples.

Summary

Types

message_type()

@type message_type() ::
  :text
  | :animation
  | :audio
  | :document
  | :photo
  | :sticker
  | :story
  | :video
  | :video_note
  | :voice
  | :contact
  | :dice
  | :game
  | :poll
  | :venue
  | :location
  | :invoice
  | :successful_payment
  | :giveaway

update_type()

@type update_type() ::
  :message
  | :edited_message
  | :channel_post
  | :edited_channel_post
  | :business_connection
  | :business_message
  | :edited_business_message
  | :deleted_business_messages
  | :message_reaction
  | :message_reaction_count
  | :inline_query
  | :chosen_inline_result
  | :callback_query
  | :shipping_query
  | :pre_checkout_query
  | :purchased_paid_media
  | :poll
  | :poll_answer
  | :my_chat_member
  | :chat_member
  | :chat_join_request
  | :chat_boost
  | :removed_chat_boost

Functions

answer(cnt, text, ops \\ [])

@spec answer(ExGram.Cnt.t(), String.t(), keyword()) :: ExGram.Cnt.t()
@spec answer(ExGram.Cnt.t(), ExGram.Model.Message.t(), String.t()) :: ExGram.Cnt.t()

answer(cnt, m, text, ops)

answer_callback(cnt, msg, ops \\ [])

@spec answer_callback(ExGram.Cnt.t(), ExGram.Model.Message.t(), keyword()) ::
  ExGram.Cnt.t()

answer_document(cnt, document, ops \\ [])

@spec answer_document(ExGram.Cnt.t(), ExGram.File.file(), keyword()) :: ExGram.Cnt.t()
@spec answer_document(ExGram.Cnt.t(), ExGram.Model.Message.t(), ExGram.File.file()) ::
  ExGram.Cnt.t()

answer_document(cnt, msg, document, ops)

@spec answer_document(
  ExGram.Cnt.t(),
  ExGram.Model.Message.t(),
  ExGram.File.file(),
  keyword()
) ::
  ExGram.Cnt.t()

answer_inline_query(cnt, articles, ops \\ [])

@spec answer_inline_query(
  ExGram.Cnt.t(),
  [ExGram.Model.InlineQueryResult.t()],
  keyword()
) ::
  ExGram.Cnt.t()

create_inline(data \\ [[]])

Deprecated, use create_inline_keyboard/1 instead

create_inline_keyboard(data \\ [[]])

@spec create_inline_keyboard([[map() | keyword()]]) ::
  ExGram.Model.InlineKeyboardMarkup.t()

create_reply_keyboard(data \\ [[]], opts \\ [])

@spec create_reply_keyboard(
  [[map() | keyword()]],
  keyword()
) :: ExGram.Model.ReplyKeyboardMarkup.t()

delete(cnt)

@spec delete(ExGram.Cnt.t()) :: ExGram.Cnt.t()

delete(cnt, msg)

@spec delete(ExGram.Cnt.t(), ExGram.Model.Message.t() | nil) :: ExGram.Cnt.t()

delete(cnt, msg, ops)

edit(cnt, atom, text)

@spec edit(ExGram.Cnt.t(), :inline, String.t()) :: ExGram.Cnt.t()
@spec edit(ExGram.Cnt.t(), :markup, keyword()) :: ExGram.Cnt.t()

edit(cnt, atom, text, ops)

@spec edit(ExGram.Cnt.t(), :inline, String.t(), keyword()) :: ExGram.Cnt.t()
@spec edit(ExGram.Cnt.t(), :markup, ExGram.Model.Message.t(), keyword()) ::
  ExGram.Cnt.t()

edit(cnt, arg2, m, text, ops)

@spec edit(ExGram.Cnt.t(), :inline, ExGram.Model.Message.t(), String.t(), keyword()) ::
  ExGram.Cnt.t()
@spec edit(ExGram.Cnt.t(), :markup, ExGram.Model.Message.t(), String.t(), keyword()) ::
  ExGram.Cnt.t()

extract_callback_id(cid)

extract_chat(arg1)

@spec extract_chat(ExGram.Model.Update.t()) :: {:ok, ExGram.Model.Chat.t()} | :error

extract_group(update)

@spec extract_group(ExGram.Model.Update.t() | ExGram.Model.Message.t()) ::
  {:ok, ExGram.Model.Chat.t()} | :error

extract_id(u)

@spec extract_id(ExGram.Model.Update.t() | ExGram.Model.Message.t()) ::
  {:ok, integer()} | -1

extract_inline_id_params(m)

extract_message_id(arg1)

extract_message_type(arg1)

@spec extract_message_type(ExGram.Model.Message.t()) :: {:ok, message_type()} | :error

extract_response_id(map)

extract_update_type(arg1)

@spec extract_update_type(ExGram.Model.Update.t()) :: {:ok, update_type()} | :error

extract_user(arg1)

@spec extract_user(ExGram.Model.Update.t() | ExGram.Model.Message.t()) ::
  {:ok, ExGram.Model.User.t()} | :error

on_result(cnt, func)

@spec on_result(ExGram.Cnt.t(), (response :: any(), name :: atom() -> any())) ::
  ExGram.Cnt.t()

send_answers(cnt)

@spec send_answers(ExGram.Cnt.t()) :: ExGram.Cnt.t()