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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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


[View source]
def self.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

[View source]

Instance Method Detail

def <<(*args, **options) #

[View source]
def <<(*args, **options, &) #

[View source]
def back_button_procs : Array(Proc(PaginatedKeyboard, Nil)) #

[View source]
def back_button_procs=(back_button_procs : Array(Proc(PaginatedKeyboard, Nil))) #

[View source]
def current_page #

Returns the content for the current page


[View source]
def delete(*args, **options) #

[View source]
def delete(*args, **options, &) #

[View source]
def each(*args, **options) #

[View source]
def each(*args, **options, &) #

[View source]
def event_handler : CallbackQueryHandler #

[View source]
def footer : String | Nil #

[View source]
def footer=(footer : String | Nil) #

[View source]
def header : String | Nil #

[View source]
def header=(header : String | Nil) #

[View source]
def id : String #

[View source]
def index(*args, **options) #

[View source]
def index(*args, **options, &) #

[View source]
def keyboard : InlineKeyboardMarkup #

[View source]
def next_button_procs : Array(Proc(PaginatedKeyboard, Nil)) #

[View source]
def next_button_procs=(next_button_procs : Array(Proc(PaginatedKeyboard, Nil))) #

[View source]
def on_back(&block : self -> ) #

Adds a back button callback handler


[View source]
def on_next(&block : self -> ) #

Adds a next button callback handler


[View source]
def pages #

Returns each page, with it's items


[View source]
def per_page : Int32 #

[View source]
def per_page=(per_page : Int32) #

[View source]
def prefix : String | Nil #

[View source]
def prefix=(prefix : String | Nil) #

[View source]
def push(*args, **options) #

[View source]
def push(*args, **options, &) #

[View source]
def results : Array(String) #

[View source]
def results=(results : Array(String)) #

[View source]