I use WWW::Telegram::BotAPI (Perl implementation of the Telegram Bot API) for simple bot development.
I need create a custom keyboard (https://core.telegram.org/bots#keyboards) for reply (sendMessage method).
Telegram API for keyboards https://core.telegram.org/bots/api/#replykeyboardmarkup describe field ‘keyboard’ with type Array of Array of string.
Example:
my @buttons=(['one','two'],['three','four'],['five']);
But i make something wrong
print Dumper $api->SendMessage
({
chat_id => $from_id,
text => 'question text ?',
reply_to_message_id => $message_id,
reply_markup => {
keyboard => (['one','two'],['three','four'],['five']);
resize_keyboard => 1,
one_time_keyboard => 1
}
});
in output dump – reply_markup not present. What wrong can do? How to define ‘keyboard’ field correctly?
2
Answers
In a hash, all the values must be scalars. You can’t use a list as the value of
keyboard
. I’d try an anonymous array instead:Also note that semicolon is a statement terminator, you can’t use it instead of a comma.
#That should Work