BotexTelegram.Services.Menu.Api (botex_telegram v2.0.1)

Summary

Functions

Dynamically add new menu

Returns a specification to start this module under a supervisor.

Function return all menu struct

Returns generated menu buttons

Callback implementation for GenServer.init/1.

Method for displaying a specific menu

Functions

add_menu(menu)

@spec add_menu(BotEx.Models.Menu.t()) :: :ok

Dynamically add new menu

Parameters:

  • menu: BotEx.Models.Menu for adding

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_all()

@spec get_all() :: map()

Function return all menu struct

get_menu_buttons(name, params \\ [])

@spec get_menu_buttons(term(), list()) :: list()

Returns generated menu buttons

Parameters

  • name: menu name
  • params: in case the buttons in the menu (BotEx.Models.Menu.buttons: fn (params) -> [BotEx.Models.Button.t()] end) is function, this params will be applying as argument

init(opts)

@spec init(any()) :: {:ok, %{menu: map()}}

Callback implementation for GenServer.init/1.

show_menu(name, user_id, params \\ [])

Method for displaying a specific menu

Parameters

  • name: menu name (BotEx.Models.Menu.name) from menu.exs file
  • uId: user telegram id, for displaying a menu
  • params: in case the buttons in the menu is function, (BotEx.Models.Menu.buttons: fn (params) -> [BotEx.Models.Button.t()] end) this params will be applying as argument

start_link(state \\ [])

@spec start_link(any()) :: :ignore | {:error, any()} | {:ok, pid()}