Created
February 1, 2021 18:39
-
-
Save groza-a-a/918adf30bdc2fabb32929e92968e3956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$bot_object = new Client($token); | |
// Загружаем простые команды | |
$bot_object->command('say_hello', function ($message) use ($bot_object){ | |
$bot_object->sendMessage($message->getChat()->getId(), "Hello!"); | |
}); | |
// Отлавливаем более сложные команды | |
$bot_object->on( | |
function($hook) use ($bot_object) | |
{ | |
$message = false; | |
$commands = new Commands(); | |
$hook = $commands->parse_hook($hook); | |
if ($commands->is_command_match('do_some_think', $hook)) { | |
$message = $commands->do_some_think($hook); | |
} | |
elseif ($commands->is_command_match('do_some_think_else', $hook)) { | |
$message = $commands->do_some_think_else($hook); | |
} | |
if (!empty($message)) { | |
$bot_object->sendMessage($hook->action_chat_id, $message, 'HTML'); | |
} | |
}, | |
function ($foo) | |
{ | |
return true; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment