Closed jenokizm closed 4 years ago
Что-то вроде такого:
$commandFunc = function ($message) use ($bot) {
$bot->sendMessage($message->getChat()->getId(), 'my command');
};
$bot->command('help', $commandFunc);
$bot->command('menu', $commandFunc);
Или так:
$bot->on(
function (Update $update) use ($bot) {
$bot->sendMessage($update->getMessage()->getChat()->getId(), 'my command');
},
function (Update $update) {
return in_array($update->getMessage()->getText(), ['/help', '/menu']);
}
);
Привет. Допустим есть команда /help есть /menu, как их объединить в одной чтобы не дублировать их код? Или другой случай, внутри $bot->on() при достижении оперделенного условия вызвать пользователю код из /menu?