Skip to content

PaginatedKeyboard

class Tourmaline::PaginatedKeyboard
inherits Tourmaline::InlineKeyboardMarkup #

Convenience class for creating an InlineKeyboard with built in pagination. It is designed to be customizable so as not to get in your way.

Class methods#

.new(pull : JSON::PullParser) #

Convenience class for creating an InlineKeyboard with built in pagination. It is designed to be customizable so as not to get in your way.

.new(client : Tourmaline::Client, results = [] of String, per_page = 10, header = nil, footer = nil, prefix = nil, back_text = "Back", next_text = "Next", id = 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

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 item
  • back_text - text to use for the back button
  • next_text - text to use for the next button
  • id - an id to be used both as the group 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

Methods#

#<< #

#<<(*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 #

#delete(*args, **options) #

#each(*args, **options) #

#each #

#footer : String? #

#footer=(footer : String?) #

#header : String? #

#header=(header : String?) #

#id : String #

#index(*args, **options) #

#index #

#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? #

#prefix=(prefix : String?) #

#push(*args, **options) #

#push #

#results : Array(String) #

#results=(results : Array(String)) #