NAME
Telegram::BotKit::Keyboards - Easy creation of keyboards for Telegram bots
VERSION
version 0.02
SYNOPSIS
use Telegram::Keyboards qw(create_one_time_keyboard create_inline_keyboard);
my $api = WWW::Telegram::BotAPI->new(token => 'my_token');
$api->sendMessage ({
chat_id => 123456,
text => 'This is a regular keyboard',
reply_markup => create_one_time_keyboard(['Button1','Button2'])
});
$api->sendMessage ({
chat_id => 123456,
text => 'This is a regular keyboard',
reply_markup => create_inline_keyboard(['Button1','Button2'], 2)
});
METHODS
create_one_time_keyboard
Create a regular one time keyboard. For using with (reply_markup) param of API sendMessage method
$keyboard = create_one_time_keyboard($arrayref, $max_keys_per_row);
$api->sendMessage ({ chat_id => 123456, reply_markup => $keyboard });
If no $max_keys_per_row specified keyboard will have only one column
create_inline_keyboard
Create an INLINE keyboard. For using with (reply_markup) param of API sendMessage method
my $api = WWW::Telegram::BotAPI->new ( token => 'my_token' );
# $keyboard = create_one_time_keyboard($arrayref, $max_keys_per_row); $keyboard = create_one_time_keyboard(['Button1', 'Button2', 'Button3'], 2);
$api->sendMessage ({ chat_id => 123456, reply_markup => $keyboard });
available_keys
Helper function for tg-botkit simulator. Return string of possible answers in Backus–Naur notation
print Dumper available_keys(['B1', 'B2', 'B3' ]) # '[ B1 | B2 | B3 ]'
parse_reply_markup
Helper function for tg-botkit simulator. Function opposite to create_inline_keyboard and create_one_time_keyboard Transform $reply_markup JSON object into perl array
TODO
build_optimal()
build keyboard with optimalrows and columns based on keyboard content
build_optimal_according_order()
build keyboard with optimal rows and columns based on keyboard content WITHOUT changing buttons order
= cut
AUTHOR
Pavel Serikov <pavelsr@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Pavel Serikov.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.