defstudio / telegraph

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

Keyboard::fromArray() method doesn't restore switch_inline_query & switch_inline_query_current_chat properties #533

Closed varemel closed 7 months ago

varemel commented 7 months ago

Hi,

When trying to restore keyboard from array switch_inline_query & switch_inline_query_current_chat properties are missing. Suggest to add this to Keyboard::fromArray() method https://github.com/defstudio/telegraph/blob/722d94f83790fef66bb940b57f7b7e9f255d2acc/src/Keyboard/Keyboard.php#L60

if (array_key_exists('switch_inline_query', $button)) {
    $rowButton = $rowButton->switchInlineQuery($button['switch_inline_query']);
}

if (array_key_exists('switch_inline_query_current_chat', $button)) {
    $rowButton = $rowButton->switchInlineQuery($button['switch_inline_query_current_chat'])->currentChat();
}
fabio-ivona commented 7 months ago

Hi @varemel, thanks for your suggestion!

Feel free to open a PR for this

varemel commented 7 months ago

Hi @fabio-ivona I created PR. I don't think there is a need to add test for this. Is it ok?

fabio-ivona commented 7 months ago

Thanks!