с выводом текущей громкости терминала
В командах модуля телеграмм добавляем новую запись, например с именем "громкость" сделующий код:
include_once(DIR_MODULES . 'telegram/telegram.class.php');
include_once(DIR_MODULES . 'app_player/app_player.class.php');
$telegram_module = new telegram();
$sql='SELECT * FROM terminals ';
$ts=sqlselect($sql);
$cnt=count($ts);
for ($i=0;$i<$cnt;$i++)
{
$tname=$ts[$i]['TITLE'];
//$vol=getPlayerStatus($tname)['volume']; //вариант не рекомендуется
$player = new app_player();
$player->play_terminal = $tname; // Имя терминала
$player->command = 'get_volume'; // Команда
$player->ajax = TRUE;
$player->intCall = TRUE;
$player->usual($out);
$vol=$player->json['data'];
unset($player);
//if (getPlayerStatus($tname)==true) {$vol=getPlayerStatus($tname)['volume'];}
//if ($tname<>'Chromecast01') {$vol=getPlayerStatus($tname)['volume'];}
//$vol=getPlayerStatus('Chromecast01')['volume'];
$id=$ts[$i]['ID'];
$option[] = $telegram_module->buildInlineKeyboardButton($text=$tname.':'.$vol,"","Callback_tm_sel_".$id,"");
}
$count_row = 3;
$option = array_chunk($option, $count_row);
$keyb = $telegram_module->buildInlineKeyBoard($option);
$content = array('chat_id' => $chat_id, 'text' => "Терминалы: ".$class, 'reply_markup' => $keyb, 'parse_mode' => 'HTML');
$telegram_module->sendContent($content);
В событиях добавляем callback
include_once(DIR_MODULES . 'telegram/telegram.class.php');
$telegram_module = new telegram();
//$telegram_module->sendMessageToAll($callback);
//$telegram_module->sendMessageToAll(substr($callback,0,12));
//$telegram_module->sendMessageToAll(substr($callback,0,15));
if (substr($callback,0,15) == 'Callback_tm_sel')
{
//$telegram_module->sendMessageToAll(substr($callback,16));
//$color=array();
for($i=0;$i<=10;$i++) {
$ii=$i*10;
$option[] = $this->buildInlineKeyboardButton($text=$ii,"","Callback_tm_set_".substr($callback,16).'_'.$ii,"");
}
$count_row = 3;
$option = array_chunk($option, $count_row);
$keyb = $this->buildInlineKeyBoard($option);
$sql='select * from terminals where ID="'.substr($callback,16).'"';
$term=SQLSelectOne($sql)['TITLE'];
$this->editMessage($chat_id,$message_id,"Выберите громкость для ".$term,$keyb);
}
if (substr($callback,0,15) == 'Callback_tm_set')
{
$ar=explode('_',$callback);
$set=$ar[4];
$obj=$ar[3];
$term=SQLSelectOne('select * from terminals where ID='.$obj)['TITLE'];
setPlayerVolume($term, $set) ;
$telegram_module->sendMessageToAll('Устанавливаем громкость '.$set.' для '.$term) ;
}
Екатеринбург, Россия
На форуме: directman66