Sexy.Bot.Screen (Sexy v0.9.13)

Copy Markdown View Source

Converts plain maps into Sexy.Utils.Object structs ready for sending.

This is a thin wrapper — build/1 simply calls struct/2. The module exists to provide a clear semantic entry point in the pipeline:

%{chat_id: 123, text: "Hello", kb: %{inline_keyboard: [...]}}
|> Sexy.Bot.build()    # => %Sexy.Utils.Object{...}
|> Sexy.Bot.send()

Usually called via Sexy.Bot.build/1.

Summary

Functions

Build an Object struct from a map or a list of maps.

Functions

build(items)

@spec build([map()]) :: [Sexy.Utils.Object.t()]
@spec build(map()) :: Sexy.Utils.Object.t()

Build an Object struct from a map or a list of maps.

Examples

iex> Sexy.Bot.build(%{chat_id: 123, text: "Hi"})
%Sexy.Utils.Object{chat_id: 123, text: "Hi"}

iex> Sexy.Bot.build([%{chat_id: 1, text: "A"}, %{chat_id: 2, text: "B"}])
[%Sexy.Utils.Object{chat_id: 1, text: "A"}, %Sexy.Utils.Object{chat_id: 2, text: "B"}]