BotexTelegram.Helpers.Buttons (botex_telegram v2.0.1)

Buttons creating helper

Summary

Functions

create button object

Create button with no caption and no action in it

Create telegram menu buttons from list BotEx.Models.Button

create set of buttons, which already fits one entire row

create set of buttons, which already fits one entire row

a set of buttons, fits entire single row, with only a "back" button inside

a set of buttons, fits entire single row, with only a "back" button inside

Functions

create_button(action, caption)

@spec create_button(binary(), binary()) :: %{callback_data: binary(), text: binary()}

create button object

Parameters

  • action: command routing action
  • caption: button caption

create_button(module, action, data, caption)

@spec create_button(binary(), binary(), binary(), binary()) :: %{
  callback_data: binary(),
  text: binary()
}

create button object

Parameters

  • module: command routing module
  • action: command routing action
  • data: command routing data
  • caption: button caption

create_empty_button(caption \\ " ")

@spec create_empty_button(binary()) :: %{callback_data: binary(), text: binary()}

Create button with no caption and no action in it

Parameters

  • caption: button caption

create_from_model(buttons)

@spec create_from_model([[BotEx.Models.Button.t()]]) ::
  %Telegex.Type.InlineKeyboardMarkup{
    inline_keyboard: [[Telegex.Type.InlineKeyboardButton.t()]]
  }

Create telegram menu buttons from list BotEx.Models.Button

Parameters

  • buttons: list of [[BotEx.Models.Button]]

create_single_row_button(action, caption)

@spec create_single_row_button(binary(), binary()) :: [
  [%{callback_data: binary(), text: binary()}]
]

create set of buttons, which already fits one entire row

create_single_row_button(module, action, data, caption)

@spec create_single_row_button(binary(), binary(), binary(), binary()) :: [
  [%{callback_data: binary(), text: binary()}]
]

create set of buttons, which already fits one entire row

Parameters

  • module: command routing module
  • action: command routing action
  • data: command routing data
  • caption: button caption

get_back_button(back_action)

@spec get_back_button(binary()) :: [[%{callback_data: binary(), text: binary()}]]

a set of buttons, fits entire single row, with only a "back" button inside

Parameters

  • action: back action

get_back_button(back_action, caption)

@spec get_back_button(binary(), binary()) :: [
  [%{callback_data: binary(), text: binary()}]
]

a set of buttons, fits entire single row, with only a "back" button inside

Parameters

  • action: back action
  • caption: button caption

get_pagination(module, action, page, data, next_symbol, prev_symbol, last_symbol, first_symbol)

@spec get_pagination(
  binary(),
  binary(),
  %{total_pages: integer(), page_size: integer(), page_number: integer()},
  binary(),
  binary(),
  binary(),
  binary(),
  binary()
) :: [[%{text: binary(), callback_data: binary()}]]

create pagination button set

Parameters

  • module: command routing module
  • action: command routing action
  • page: scrivener_ecto pagination object
  • data: command additional data
  • next_symbol: next page symbol
  • prev_symbol: prev page symbol
  • last_symbol: last page symbol
  • first_symbol: first page symbol