Telegram::BotKit::Keyboards - Easy creation of keyboards for Telegram bots
version 0.03
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) });
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 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);
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 ]'
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
build keyboard with optimalrows and columns based on keyboard content
build keyboard with optimal rows and columns based on keyboard content WITHOUT changing buttons order
= cut
Pavel Serikov <pavelsr@cpan.org>
This software is copyright (c) 2017 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.
To install Telegram::BotKit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Telegram::BotKit
CPAN shell
perl -MCPAN -e shell install Telegram::BotKit
For more information on module installation, please visit the detailed CPAN module installation guide.