get(); $oDate = Carbon::now(); $sDateCN = $oDate->format('n月j日'); $sYear = date("Y"); $sCountrySpeed = CountrySpeedService::fn_b(); $sToken = FreenodeHelperService::tokenToday(); $aTags = [ "Shadowrocket", "Quantumult", "Clash", "Hiddify", "SingBox", "SSR", "节点", "订阅链接", "免费节点", "V2ray", "SSR", ]; $aResult = []; $aResult["site_code_short"] = ''; $aResult["article"] = [ "title" => "", "title_sub" => "", "content" => "", "tags" => $aTags, "7like" => rand(5, 55), ]; foreach ($oSites as $oSite) { $aResult["site_code_short"] = $oSite->code_short; $oArticleTemplate = ArticleTemplateFreenode::where("group_code", $oSite->group_code)->first(); $aSiteConfig = json_decode($oSite->config, true); $sTelegramLink = $aSiteConfig["telegram"]; $aShipCode = $aSiteConfig["ship_code"]; $aSiteFnClient = $aSiteConfig["freenode_client"]; $aDylj = []; foreach ($aSiteFnClient as $sSiteFnClient) { $sFeedLink = "https://".FreenodeHelperService::urlFeedToday($oSite->code_short, $sSiteFnClient); $str = ""; $str .= "".$sSiteFnClient."订阅链接:\n\n"; $str .= " ".$sFeedLink.""; $aDylj[$sSiteFnClient] = $str; } $sDylj = implode("\n\n", $aDylj); $sJctj = ServiceShipHtml::byShipCode($aSiteConfig['ship_code']); $aFilter = [ // '$sShipWww' => $oShip->www, // '$sShipName' => $oShip->name, '$sDateCN' => $sDateCN, '$sYear' => $sYear, '$sTitleSub' => $sCountrySpeed, '$sTelegramLink'=> $sTelegramLink, '$sCountrySpeed'=> $sCountrySpeed, '$sJctj' => $sJctj, '$sDylj' => $sDylj, '$sGithubLink' => $aSiteConfig['github'], '$sSiteUrl' => $oSite->url ]; $aResult["article"]["content"] = self::nl2p(str_replace(array_keys($aFilter), array_values($aFilter), $oArticleTemplate->content)); $aResult["article"]["title"] = str_replace(array_keys($aFilter), array_values($aFilter), $oArticleTemplate->title); $aResult["article"]["title_sub"] = $sCountrySpeed; // todo 发送文章 $aApiPath = json_decode($oSite->api_path, true); $sArticleReceiveFreenode = "https://".$oSite->url."/".$aApiPath["article_receive_freenode"]; $sFlow = HttpV2::make($sArticleReceiveFreenode, "post")->setDataA($aResult)->send(); $aFlow = json_decode($sFlow, true); if (!isset($aFlow["isDone"]) || !$aFlow["isDone"]) { echo $sFlow; TeleSlave::warn()->send('FnSitePublish::fn_b()的发送文章失败'); continue; } } echo "/n - ok"; } public static function nl2p($text) { // 将文本按换行符拆分成数组 $paragraphs = explode("\n", $text); // 将每一段用

标签包裹 $paragraphs = array_map(function($paragraph) { return '

' . trim($paragraph) . '

'; }, $paragraphs); // 使用 implode 拼接成一个字符串 return implode('', $paragraphs); } }