138 lines
5.1 KiB
PHP
Executable File
138 lines
5.1 KiB
PHP
Executable File
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Services\Cron;
|
||
|
||
//use App\Models\CrawlFreenode as ModelCrawlFreenode;
|
||
use App\Services\TomTool\Telegram\Slave as TeleSlave;
|
||
//use App\Services\TomTool\Telegram\Master as TeleMaster;
|
||
use App\Models\SiteMap as ModelSiteMap;
|
||
use App\Services\TomTool\HttpV2;
|
||
//use Symfony\Component\Yaml\Yaml;
|
||
|
||
final class FnTgPublish
|
||
{
|
||
public static function run()
|
||
{
|
||
echo "\n\nFnTgPublish::run()";
|
||
|
||
$aSiteList = ModelSiteMap::whereIn("group_code", ["fn_a"])->get()->toArray();
|
||
|
||
foreach ($aSiteList as $aSite) {
|
||
$sConfig = $aSite["config"] ?? "";
|
||
$sApiPath = $aSite["api_path"] ?? "";
|
||
$sSiteDomain = $aSite["url"] ?? "";
|
||
$sSiteCode = $aSite["code"] ?? "";
|
||
|
||
//// test
|
||
// $sSiteCode = "clashfreenode.com";
|
||
|
||
$aConfig = json_decode($sConfig, true);
|
||
$aApiPath = json_decode($sApiPath, true);
|
||
|
||
$sApiPath = $aApiPath["article_find"] ?? "";
|
||
$sApiUrl = "https://".$sSiteDomain."/".$sApiPath;
|
||
|
||
$aData = [
|
||
"articleType" => "node",
|
||
"code" => date("Ymd")
|
||
];
|
||
|
||
$sResult = HttpV2::make($sApiUrl, "post")->setDataA($aData)->enableJsonSend(true)->send();
|
||
$aResult = json_decode($sResult, true);
|
||
|
||
if (!isset($aResult["isDone"])) {
|
||
throw new \Exception("没有isDone? >>> $sApiUrl >>>".$sResult);
|
||
}
|
||
|
||
if (!$aResult["isDone"]) {
|
||
throw new \Exception($sResult);
|
||
}
|
||
|
||
$iImgId = $aResult["aData"]["img_id"] ?? 0;
|
||
|
||
$sTitle = "「".date("m月d日")."」最新免费节点,SSR/V2ray/Clash/Shadowrocket";
|
||
|
||
$sStr = $sTitle."\n\n👉 https://".$sSiteDomain."/fn/".date("Ymd").".html";
|
||
|
||
$sImgUrl = "https://".$sSiteDomain."/site/".$sSiteCode."/images/article/".$iImgId.".png";
|
||
// $sImgUrl = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png";
|
||
// $sImgUrl = "https://clashfreenode.com/site/clashfreenode.com/images/article/5.png";
|
||
// $sImgUrl = "https://gips3.baidu.com/it/u=1821127123,1149655687&fm=3028&app=3028&f=JPEG&fmt=auto?w=720&h=1280";
|
||
// $sImgUrl = "";
|
||
|
||
$r = TeleSlave::start($sSiteCode, $sSiteCode)
|
||
// ->enableSlaveQueue(false)
|
||
->enableDetail(false)
|
||
->enableAsync(false)
|
||
->setPhotoUrl($sImgUrl, 1280, 720)
|
||
->setMsgS($sStr)
|
||
->setType("html")
|
||
->send();
|
||
|
||
echo "\n - ok";
|
||
}
|
||
}
|
||
|
||
public static function run_b()
|
||
{
|
||
echo "\n\nFnTgPublish::run_b()";
|
||
|
||
$aSiteList = ModelSiteMap::whereIn("group_code", ["fn_b"])->get()->toArray();
|
||
|
||
foreach ($aSiteList as $aSite) {
|
||
$sConfig = $aSite["config"] ?? "";
|
||
$sApiPath = $aSite["api_path"] ?? "";
|
||
$sSiteDomain = $aSite["url"] ?? "";
|
||
$sSiteCode = $aSite["code"] ?? "";
|
||
|
||
//// test
|
||
// $sSiteCode = "clashfreenode.com";
|
||
|
||
$aConfig = json_decode($sConfig, true);
|
||
$aApiPath = json_decode($sApiPath, true);
|
||
|
||
$sApiPath = $aApiPath["article_find"] ?? "";
|
||
$sApiUrl = "https://".$sSiteDomain."/".$sApiPath;
|
||
|
||
$aData = [
|
||
"articleType" => "freenode",
|
||
"code" => "fn".date("Ymd")
|
||
];
|
||
|
||
$sResult = HttpV2::make($sApiUrl, "post")->setDataA($aData)->enableJsonSend(true)->send();
|
||
$aResult = json_decode($sResult, true);
|
||
$sImgUrl = $aResult["sThumb"] ?? '';
|
||
|
||
if (!$sImgUrl) {
|
||
throw new \Exception("没得到sThumb >>> ".$sResult);
|
||
}
|
||
|
||
$iImgId = $aResult["aData"]["img_id"] ?? 0;
|
||
|
||
$sTitle = "「".date("m月d日")."」最新免费节点,SSR/V2ray/Clash/Shadowrocket";
|
||
|
||
$sStr = $sTitle."\n\n👉 https://".$sSiteDomain."/a/fn".date("Ymd").".html";
|
||
|
||
// $sImgUrl = "https://".$sSiteDomain."/site/".$sSiteCode."/images/article/".$iImgId.".png";
|
||
// $sImgUrl = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png";
|
||
// $sImgUrl = "https://clashfreenode.com/site/clashfreenode.com/images/article/5.png";
|
||
// $sImgUrl = "https://gips3.baidu.com/it/u=1821127123,1149655687&fm=3028&app=3028&f=JPEG&fmt=auto?w=720&h=1280";
|
||
// $sImgUrl = "";
|
||
|
||
$r = TeleSlave::start($sSiteCode, $sSiteCode)
|
||
// ->enableSlaveQueue(false)
|
||
->enableDetail(false)
|
||
->enableAsync(false)
|
||
->setPhotoUrl($sImgUrl, 1280, 720)
|
||
->setMsgS($sStr)
|
||
->setType("html")
|
||
->send();
|
||
|
||
echo "\n - ok";
|
||
}
|
||
}
|
||
|
||
}
|