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:

Constructors

Instance Method Summary

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 = [] of Array(InlineKeyboardButton))
new(*lines : Array(InlineKeyboardButton))
new

Class methods inherited from class Tourmaline::InlineKeyboardMarkup

build(*args, columns = nil, **options, &) build

Constructor Detail

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


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


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

Instance Method Detail

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

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

def back_button_procs : Array(Proc(PaginatedKeyboard, Nil)) #

def back_button_procs=(back_button_procs : Array(Proc(PaginatedKeyboard, Nil))) #

def current_page #

Returns the content for the current page


def delete(*args, **options, &) #

def delete(*args, **options) #

def each(*args, **options) #

def each(*args, **options, &) #

def footer : String? #

def footer=(footer : String?) #

def header : String? #

def header=(header : String?) #

def id : String #

def index(*args, **options) #

def index(*args, **options, &) #

def next_button_procs : Array(Proc(PaginatedKeyboard, Nil)) #

def next_button_procs=(next_button_procs : Array(Proc(PaginatedKeyboard, Nil))) #

def on_back(&block : self -> ) #

Adds a back button callback handler


def on_next(&block : self -> ) #

Adds a next button callback handler


def pages #

Returns each page, with it's items


def per_page : Int32 #

def per_page=(per_page : Int32) #

def prefix : String? #

def prefix=(prefix : String?) #

def push(*args, **options) #

def push(*args, **options, &) #

def results : Array(String) #

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