Задача: отправить информацию из шаблона в телегу.
Решение: создаем в домашних страницах нужный шаблон, например вставляем в него
Код: Выделить всё
<table width="100">
<tr><td>
[#module name="yandexweather" type="TODAYMINI" skin="1" width="30" height="30" #]
</td></tr>
Далее добавляем сценарий html2tlg:/page/39.html
Код: Выделить всё
$url=$params['url'];
$w=$params['w'];
$h=$params['h'];
if ($url==""){
$url='http://login:password@ip/page/39.html';
}
if ($w==""){$w=200;}
if ($h==""){$h=900;}
$fc=file_get_contents('http://api.rest7.com/v1/html_to_image.php?url=' . $url . '&format=png');
echo $fc;
$data = json_decode($fc);
if (@$data->success !== 1)
{
die('Failed');
}
$image = file_get_contents($data->file);
$save_to="./cached/screen.png"; // куда сохранять
file_put_contents($save_to, $image);
//SaveFile($save_to, $result);
$image = new Imagick($save_to);
$image->cropImage($h,$w, 0,0);
$image->writeImage($save_to.'1');
include_once(DIR_MODULES . 'telegram/telegram.class.php');
$telegram_module = new telegram();
$telegram_module->sendImageToAll($save_to.'1');
Код: Выделить всё
include_once(DIR_MODULES . 'telegram/telegram.class.php');
$telegram_module = new telegram();
$option = array(
$telegram_module->buildInlineKeyboardButton($text="Погода","", "Callback_html2tlg_pogoda","")
) ;
$count_row = 3;
$option = array_chunk($option, $count_row);
$keyb = $telegram_module->buildInlineKeyBoard($option);
$content = array('chat_id' => $chat_id, 'text' => "Датчики: ".$dir, 'reply_markup' => $keyb, 'parse_mode' => 'HTML');
$telegram_module->sendContent($content);
И callback:
Код: Выделить всё
//$telegram_module->sendMessageToAll($callback);
//$telegram_module->sendMessageToAll(substr($callback,9,6));
//$telegram_module->sendMessageToAll(substr($callback,16));
if (substr($callback,9,8) == 'html2tlg')
{
if (substr($callback,18)=='pogoda') {$url='http://логин:пароль@вашипадрес/page/39.html';}
//$url=substr($callback,18);
include_once(DIR_MODULES . 'telegram/telegram.class.php');
$telegram_module = new telegram();
$telegram_module->sendMessageToAll($url);
//rs('sensor2telega', array('zapros' =>substr($callback,16)));
runScriptSafe('html2tlg', array('url' =>substr($url), 'h'=>250));
//$telegram_module->sendMessageToAll(substr($callback,16));
}