phptelebot icon indicating copy to clipboard operation
phptelebot copied to clipboard

How to get data after clicking button ?

Open bamboriz opened this issue 6 years ago • 1 comments

Hi, I know it's been a long time but I was hoping you could help me out. How do I get the "/whoami" commands executed when the buttons are clicked. Thanks

// inline keyboard $bot->cmd('/keyboard', function () { $keyboard[] = [ ['text' => 'PHPTelebot', 'callback_data' => '/whoami'], ['text' => 'Haru bot', 'callback_data' => '/whoami'], ]; $options = [ 'reply_markup' => ['inline_keyboard' => $keyboard], ];

return Bot::sendMessage('Inline keyboard', $options);

});

bamboriz avatar Aug 19 '18 22:08 bamboriz

Hi, I know it's been a long time but I was hoping you could help me out. How do I get the "/whoami" commands executed when the buttons are clicked. Thanks

// inline keyboard $bot->cmd('/keyboard', function () { $keyboard[] = [ ['text' => 'PHPTelebot', 'callback_data' => '/whoami'], ['text' => 'Haru bot', 'callback_data' => '/whoami'], ]; $options = [ 'reply_markup' => ['inline_keyboard' => $keyboard], ];

return Bot::sendMessage('Inline keyboard', $options);

});

using mw keyboard button $bot->cmd('/button', function ($pesan) { $info = bot::message(); $id = $info['chat']['id']; $text = "Working";

$keyboard = array( "keyboard" => array(array(array( "text" => "/button"

), array( "text" => "contact", "request_contact" => true // This is OPTIONAL telegram button

), array( "text" => "location", "request_location" => true // This is OPTIONAL telegram button

)

)), "one_time_keyboard" => true, // Can be FALSE (hide keyboard after click) "resize_keyboard" => true // Can be FALSE (vertical resize) );

$postfields = [

'reply_markup' => json_encode($keyboard)

];

Bot::sendMessage($text, $postfields);

});

BangAchil avatar Jan 21 '19 14:01 BangAchil