defstudio / telegraph

Telegraph is a Laravel package for fluently interacting with Telegram Bots
MIT License
674 stars 116 forks source link

Sequential keyboard property assignment doesn't work #549

Closed oakymax closed 6 months ago

oakymax commented 6 months ago

Let's see next example from my code:

$telegraph->markdown('Registration needed')->replyKeyboard(
    ReplyKeyboard::make()
        ->button('Send contact')->requestContact()
        ->button('Cancel')
        ->resize()
        ->oneTime()
        ->inputPlaceholder("Waiting for input")
)->send();

In this case we will have in resulting markup only buttons and last set keyboard property input_field_placeholder, props resize_keyboard and one_time_keyboard will be skipped...

For now I fixed this in my code in following way:

$keyboard = ReplyKeyboard::make();
$keyboard->button('Send contact')->requestContact();
$keyboard->button('Cancel');

$keyboard = $keyboard->resize();
$keyboard = $keyboard->oneTime();
$keyboard = $keyboard->inputPlaceholder("Waiting for input");

$telegraph
    ->markdown('Registration needed')
    ->replyKeyboard($keyboard)
    ->send();

but imho the expected behavior is to keep keyboard's properties assigned in sequential fluent setters call