no message

This commit is contained in:
hellcat 2026-02-26 16:55:58 +08:00
parent 7291b92423
commit c79a1c2d0b

View File

@ -56,86 +56,25 @@ final class FreenodeSync
echo " - ok \n";
}
static function nodehub()
{
echo "\nFeenodeSync::nodehub() - 开始 \n";
$sDirBase = $_ENV["dir_base"];
$oFnSiteList = ModelSiteMap::where("group_code", "nodehub")->get();
$aResultAll = [];
foreach ($oFnSiteList as $oFnSite) {
$aSiteConfig = json_decode($oFnSite->config, true);
$aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? [];
$aSiteApi = json_decode($oFnSite->api_path, true);
$sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? "";
$aFnContent = [];
foreach ($aSiteConfigFnClient as $aSiteConfigFnClientRow) {
$sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt";
if (!file_exists($sFilePath)) {
$sMsg = "freenodeSync的run没有当天文件".$sFilePath;
TeleSlave::warn()->send($sMsg);
echo "\n - ".$sMsg;
continue;
}
$aFnContent[$aSiteConfigFnClientRow] = file_get_contents($sFilePath);
}
$sApiUrl = "https://".$oFnSite->url."/".$sSiteApiFreenodeReceive; //// test
$sResult = HttpV2::make($sApiUrl, "post")->setDataA($aFnContent)->enableJsonSend()->send();
$aResult = json_decode($sResult, true);
if (!isset($aResult["isDone"]) || $aResult["isDone"] != true) {
$sMsg = "freenodeSync::同步失败 ->".$oFnSite->name;
echo $sMsg.$sResult;
TeleSlave::warn()->setMsgS($sMsg)->send();
continue;
}
if (isset($aResult["sMsg"])) {
$sMsg = json_encode($aResult["sMsg"]);
TeleSlave::notify()->setMsgS($sMsg)->send();
} else {
TeleSlave::log()->setMsgS("nodehub同步完成")->send();
}
}
echo " - 完成 \n";
}
// static function run_b()
// static function nodehub()
// {
// echo "\nFeenodeSync::run_b() - 开始 \n";
// echo "\nFeenodeSync::nodehub() - 开始 \n";
//
// $sDirBase = $_ENV["dir_base"];
//
// $oNodehub = ModelSiteMap::where("group_code", "nodehub")->first();
// $oFnSiteList = ModelSiteMap::where("group_code", "fn_b")->get();
// $oSiteNodehub = ModelSiteMap::where("code", "nodehub")->first();
// $aSiteNodehubConfig = json_decode($oSiteNodehub->config ?? '', true);
//
// $aFreenodeClient = $aSiteNodehubConfig["freenode_client"] ?? [];
// $aNodehubApis = json_decode($oSiteNodehub->api_path, true);
// $sSiteApiFreenodeReceive = $aNodehubApis["freenode_receive"] ?? "";
//
//// tomd($oNodehub, 1);
// $aResultAll = [];
// foreach ($oFnSiteList as $oFnSite) {
//
//// $aSiteConfig = json_decode($oFnSite->config, true);
//// $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? [];
//// $aSiteConfigFnClient = ["clash", "v2ray"];
//// $aSiteApi = json_decode($oFnSite->api_path, true);
//// $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? "";
// $aSiteConfig = json_decode($oFnSite->config, true);
// $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? [];
// $aSiteApi = json_decode($oFnSite->api_path, true);
// $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? "";
//
// $aData = [];
// $aData["site_code_short"] = $oFnSite->code_short;
// foreach ($aFreenodeClient as $aSiteConfigFnClientRow) {
// $aFnContent = [];
// foreach ($aSiteConfigFnClient as $aSiteConfigFnClientRow) {
// $sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt";
//
// if (!file_exists($sFilePath)) {
@ -145,28 +84,93 @@ final class FreenodeSync
// continue;
// }
//
// $aData["raw"][$aSiteConfigFnClientRow] = file_get_contents($sFilePath);
// $aFnContent[$aSiteConfigFnClientRow] = file_get_contents($sFilePath);
//
// }
//
// $sApiUrl = "https://".$oSiteNodehub->url."/".$sSiteApiFreenodeReceive;
//// tomd($sApiUrl, 1);
// $sResult = HttpV2::make($sApiUrl, "post")->setDataA($aData)->enableJsonSend()->send();
////tomd($aFnContent, 1);
// $sApiUrl = "https://".$oFnSite->url."/".$sSiteApiFreenodeReceive; //// test
// $sResult = HttpV2::make($sApiUrl, "post")->setDataA($aFnContent)->enableJsonSend()->send();
// $aResult = json_decode($sResult, true);
//
// if (!isset($aResult["isDone"]) || $aResult["isDone"] != true) {
// $sMsg = "freenodeSync::同步失败 ->".$oFnSite->name."->".$sResult;
// echo $sMsg;
//// TeleSlave::warn()->setMsgS($sMsg)->send();
// $sMsg = "freenodeSync::同步失败 ->".$oFnSite->name;
// echo $sMsg.$sResult;
// TeleSlave::warn()->setMsgS($sMsg)->send();
// continue;
// }
//
// if (isset($aResult["sMsg"])) {
// $sMsg = json_encode($aResult["sMsg"]);
//// TeleSlave::warn()->setMsgS($sMsg)->send();
// TeleSlave::notify()->setMsgS($sMsg)->send();
// } else {
// TeleSlave::log()->setMsgS("nodehub同步完成")->send();
// }
//
// }
//
// echo " - 完成 \n";
// }
static function nodehub()
{
echo "\nFeenodeSync::nodehub() - 开始 \n";
$sDirBase = $_ENV["dir_base"];
$oFnSiteList = ModelSiteMap::where("group_code", "fn_b")->get();
$oSiteNodehub = ModelSiteMap::where("code", "nodehub")->first();
$aSiteNodehubConfig = json_decode($oSiteNodehub->config ?? '', true);
$aFreenodeClient = $aSiteNodehubConfig["freenode_client"] ?? [];
$aNodehubApis = json_decode($oSiteNodehub->api_path, true);
$sSiteApiFreenodeReceive = $aNodehubApis["freenode_receive"] ?? "";
$aResultAll = [];
foreach ($oFnSiteList as $oFnSite) {
// $aSiteConfig = json_decode($oFnSite->config, true);
// $aSiteConfigFnClient = $aSiteConfig["freenode_client"] ?? [];
// $aSiteConfigFnClient = ["clash", "v2ray"];
// $aSiteApi = json_decode($oFnSite->api_path, true);
// $sSiteApiFreenodeReceive = $aSiteApi["freenode_receive"] ?? "";
$aData = [];
$aData["site_code_short"] = $oFnSite->code_short;
foreach ($aFreenodeClient as $aSiteConfigFnClientRow) {
$sFilePath = $sDirBase."public/freenode/merge/".$oFnSite->code."/".$aSiteConfigFnClientRow."/".date("Y-m-d").".txt";
if (!file_exists($sFilePath)) {
$sMsg = "freenodeSync的run没有当天文件".$sFilePath;
TeleSlave::warn()->send($sMsg);
echo "\n - ".$sMsg;
continue;
}
$aData["raw"][$aSiteConfigFnClientRow] = file_get_contents($sFilePath);
}
$sApiUrl = "https://".$oSiteNodehub->url."/".$sSiteApiFreenodeReceive;
// tomd($sApiUrl, 1);
$sResult = HttpV2::make($sApiUrl, "post")->setDataA($aData)->enableJsonSend()->send();
$aResult = json_decode($sResult, true);
if (!isset($aResult["isDone"]) || $aResult["isDone"] != true) {
$sMsg = "freenodeSync::同步失败 ->".$oFnSite->name."->".$sResult;
echo $sMsg;
TeleSlave::warn()->setMsgS($sMsg)->send();
continue;
}
if (isset($aResult["sMsg"])) {
$sMsg = json_encode($aResult["sMsg"]);
echo $sMsg;
// TeleSlave::warn()->setMsgS($sMsg)->send();
}
echo "\n nodehub";
}
echo " - 完成 \n";
}
}