В класс "OperationalModes" добавил свойство "hide", чтобы скрывать режимы из клавиатуры в телеграм
Создаем команду "Режимы" с кодом
$this->sendAction($chat_id);
$off = hex2bin('F09F8C91');
$on = hex2bin('F09F8C95');
$objects=getObjectsByClass("OperationalModes");
//print_r($objects);
foreach($objects as $obj) {
if (gg($obj['TITLE'].".hide")!=1)
{
$state = $off;
if (gg($obj['TITLE'].".active") == 1)
$state = $on;
$option[] = $this->buildInlineKeyboardButton($text=$state.gg($obj['TITLE'].".title"),"","CallbackMode_".$obj['TITLE'],"");
}
}
$count_row = 3;
$option = array_chunk($option, $count_row);
$keyb = $this->buildInlineKeyBoard($option);
$content = array('chat_id' => $chat_id, 'text' => "Режимы:", 'reply_markup' => $keyb, 'parse_mode' => 'HTML');
$res = $this->sendContent($content);
Создаем обработчик события callback с кодом
$off = hex2bin('F09F8C91');
$on = hex2bin('F09F8C95');
if (strpos($callback, 'CallbackMode_') !== false) {
$skip = true;
$obj = substr($callback, 13);
$text = gg($obj.".title");
cm($obj.".switch");
if (gg($obj.".active") == 1)
$text .= " включен ". $on;
else
$text .= " выключен ". $off;
$this->sendAnswerCallbackQuery($callback_id,$text, false);
}
$objects=getObjectsByClass("OperationalModes");
//print_r($objects);
foreach($objects as $obj) {
if (gg($obj['TITLE'].".hide")!=1)
{
$state = $off;
if (gg($obj['TITLE'].".active") == 1)
$state = $on;
$option[] = $this->buildInlineKeyboardButton($text=$state.gg($obj['TITLE'].".title"),"","CallbackMode_".$obj['TITLE'],"");
}
}
$count_row = 3;
$option = array_chunk($option, $count_row);
$keyb = $this->buildInlineKeyBoard($option);
$this->editMessage($chat_id,$message_id,"Режимы:",$keyb);
Киров, Россия
На форуме: Eraser