| 1 | <?php |
||
| 5 | trait CallbackCommand { |
||
| 6 | |||
| 7 | /** |
||
| 8 | * \addtogroup Commands |
||
| 9 | * @{ |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** \brief Store the command triggered on callback query. */ |
||
| 13 | protected $_callback_commands; |
||
| 14 | |||
| 15 | /** \brief Does the bot has message commands? Set by initBot. */ |
||
| 16 | protected $_callback_commands_set; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * \brief Add a function that will be executed everytime a callback query contains a string as data |
||
| 20 | * \details Use this syntax: |
||
| 21 | * |
||
| 22 | * addMessageCommand("menu", function($bot, $callback_query) { |
||
| 23 | * $bot->editMessageText($callback_query['message']['message_id'], "This is the menu"); }); |
||
| 24 | * @param $data The string that will trigger this function. |
||
| 25 | * @param $script The function that will be triggered by the callback query if it contains the $data string. Must take an object(the bot) and an array(the callback query received). |
||
| 26 | */ |
||
| 27 | public function addCallbackCommand(string $data, callable $script) { |
||
| 35 | |||
| 36 | /** @} */ |
||
| 37 | |||
| 38 | } |
||
| 39 |