1 | <?php |
||
30 | trait CallbackCommand |
||
31 | { |
||
32 | /** @} */ |
||
33 | |||
34 | /** \brief Chat ID of the current user/group/channel. */ |
||
35 | protected $_chat_id; |
||
36 | |||
37 | /** |
||
38 | * \addtogroup Bot Bot |
||
39 | * @{ |
||
40 | */ |
||
41 | |||
42 | /** |
||
43 | * \addtogroup Commands |
||
44 | * @{ |
||
45 | */ |
||
46 | |||
47 | /** \brief Store the command triggered on callback query. */ |
||
48 | protected $_callback_commands; |
||
49 | |||
50 | /** |
||
51 | * \brief Add a function that will be executed everytime a callback query contains a string as data |
||
52 | * \details Use this syntax: |
||
53 | * |
||
54 | * addMessageCommand("menu", function($bot, $callback_query) { |
||
55 | * $bot->editMessageText($callback_query['message']['message_id'], "This is the menu"); }); |
||
56 | * @param string $data The string that will trigger this function. |
||
57 | * @param callable $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). |
||
58 | */ |
||
59 | public function addCallbackCommand(string $data, callable $script) |
||
66 | |||
67 | /** |
||
68 | * \brief (<i>Internal</i>) Process the callback query and check if it triggers a command of this type. |
||
69 | * @param array $callback_query Callback query to process. |
||
70 | * @return bool True if the callback query triggered a command. |
||
71 | */ |
||
72 | protected function processCallbackCommand(array $callback_query) : bool |
||
89 | |||
90 | /** @} */ |
||
91 | |||
92 | /** @} */ |
||
93 | } |
||
94 |