class Tourmaline::PaginatedKeyboard
Overview
Convenience class for creating an InlineKeyboard
with built in pagination.
It is designed to be customizable so as not to get in your way.
Defined in:
tourmaline/extra/paginated_keyboard.crConstructors
-
.new(pull : JSON::PullParser)
Convenience class for creating an
InlineKeyboard
with built in pagination. -
.new(client : Tourmaline::Client, results : Array(String) = [] of String, per_page : Int32 = 10, header : Nil | String = nil, footer : Nil | String = nil, prefix : Nil | String = nil, back_text : String = "Back", next_text : String = "Next", id : String = Helpers.random_string(8))
Creates a new
PaginatedKeyboard
-
.new(results = [] of String, per_page = 10, &block : self -> )
Creates a new
PaginatedKeyboard
, yielding the newly created keyboard to the block
Instance Method Summary
- #<<(*args, **options)
- #<<(*args, **options, &)
- #back_button_procs : Array(Proc(PaginatedKeyboard, Nil))
- #back_button_procs=(back_button_procs : Array(Proc(PaginatedKeyboard, Nil)))
-
#current_page
Returns the content for the current page
- #delete(*args, **options)
- #delete(*args, **options, &)
- #each(*args, **options)
- #each(*args, **options, &)
- #footer : String | Nil
- #footer=(footer : String | Nil)
- #header : String | Nil
- #header=(header : String | Nil)
- #id : String
- #index(*args, **options)
- #index(*args, **options, &)
- #next_button_procs : Array(Proc(PaginatedKeyboard, Nil))
- #next_button_procs=(next_button_procs : Array(Proc(PaginatedKeyboard, Nil)))
-
#on_back(&block : self -> )
Adds a back button callback handler
-
#on_next(&block : self -> )
Adds a next button callback handler
-
#pages
Returns each page, with it's items
- #per_page : Int32
- #per_page=(per_page : Int32)
- #prefix : String | Nil
- #prefix=(prefix : String | Nil)
- #push(*args, **options)
- #push(*args, **options, &)
- #results : Array(String)
- #results=(results : Array(String))
Instance methods inherited from class Tourmaline::InlineKeyboardMarkup
<<(row, btn : InlineKeyboardButton)<<(btns : Array(InlineKeyboardButton)) <<, inline_keyboard : Array(Array(InlineKeyboardButton)) inline_keyboard, inline_keyboard=(inline_keyboard : Array(Array(InlineKeyboardButton))) inline_keyboard=
Constructor methods inherited from class Tourmaline::InlineKeyboardMarkup
new(pull : JSON::PullParser)new(inline_keyboard : Array(Array(Tourmaline::InlineKeyboardButton)) = [] of Array(InlineKeyboardButton))
new(*lines : Array(InlineKeyboardButton)) new
Class methods inherited from class Tourmaline::InlineKeyboardMarkup
build(*args, columns = nil, **options, &)
build
Instance methods inherited from module Tourmaline::Model
client
client
Constructor Detail
Convenience class for creating an InlineKeyboard
with built in pagination.
It is designed to be customizable so as not to get in your way.
Creates a new PaginatedKeyboard
, yielding the newly created keyboard to the block
Arguments
#results
- the initial set of results#per_page
- the number of results to show on each page#header
- text to be displayed above the results#footer
- text to be displayed below the results#prefix
- a string to be added to the beginning of each itemback_text
- text to use for the back buttonnext_text
- text to use for the next button#id
- an id to be used both as thegroup
name, and the prefix for the callback query data
Formatting
The params #header
, #footer
, and #prefix
are formatted prior to being injected into the message.
{page}
- will be replaced with the current page number, starting at 1{page count}
- will be replaced with the total number of pages{index}
- for#prefix
only, gets replaced with the index of the current item, starting at 1