no message

This commit is contained in:
hellcat 2025-11-21 20:10:24 +08:00
parent 074e671f2e
commit 985556611f
9 changed files with 209 additions and 139 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
public/fn/
README.md
_env/
public/upload/

View File

@ -219,15 +219,16 @@ final class CacheTg
$sType = $aDataMixRow['type'] ?? "str";
if ($sType == 'str') {
$sRowName = 'str';
// $sContent = str_replace("<br />", " ", $sContent);
$aContent = $this->ffq_tg_str_fetch($sContent);
$sArticleName = $aContent["name"] ?? '';
$sStrTiqu = $aContent["tiqu"] ?? '';
$sStrBaoliu = $aContent["baoliu"] ?? '';
$sStrBaoliu = str_replace("翻翻墙", "{{sAuthorName}}", $sStrBaoliu);
$sStrBaoliu = str_replace("😀", "{{sIconText}}", $sStrBaoliu);
$sStrBaoliu = str_replace("📊", "{{sIconText}}", $sStrBaoliu);
if (!$sStrTiqu) {
$aDataMixNew["data"][] = [
"type" => "str",
@ -250,6 +251,81 @@ final class CacheTg
];
}
$sStrBaoliu = nl2br($sStrBaoliu);
$sStrBaoliu = str_replace(array("\r", "\n"), '', $sStrBaoliu);
$tmp = "<br \/><br \/>";
if (preg_match('/机场自介(.*?)'.$tmp.'/', $sStrBaoliu, $matches)) {
$sStr = $matches[1];
$aDataMixNew["data"][] = [
"type" => "str",
"name" => "jichangzijie",
"content" => [
"title" => "机场自介",
"base" => $sStr
],
];
}
if (preg_match('/链接导航(.*?)'.$tmp.'/', $sStrBaoliu, $matches)) {
$sStr = $matches[1];
$aDataMixNew["data"][] = [
"type" => "str",
"name" => "lianjiedaohang",
"content" => [
"title" => "链接导航",
"base" => $sStr,
],
];
}
if (preg_match('/主观点评(.*?)'.$tmp.'/', $sStrBaoliu, $matches)) {
$sStr = $matches[1];
$aDataMixNew["data"][] = [
"type" => "str",
"name" => "zhuguandianping",
"content" => [
"title" => "{{sAuthorName}}主观点评",
"base" => $sStr
],
];
}
if (preg_match('/主观评分(.*?)'.$tmp.'/', $sStrBaoliu, $matches)) {
$sStr = $matches[1];
$aDataMixNew["data"][] = [
"type" => "str",
"name" => "zhuguanpingfen",
"content" => [
"title" => "{{sAuthorName}}主观评分",
"base" => $sStr
],
];
}
// if (preg_match('/提醒您(.*?)'.$tmp.'/', $sStrBaoliu, $matches)) {
// $sStr = $matches[1];
// $aDataMixNew["data"][] = [
// "type" => "str",
// "name" => "tixingnin",
// "content" => [
// "title" => "提醒",
// "base" => $sStr
// ],
// ];
// }
$aDataMixNew["data"][] = [
"type" => "str",
"name" => "tixingnin",
"content" => [
"title" => "提醒",
"base" => "任何机场都有跑路可能,建议仅月付,以降低风险。(不针对任何机场)",
],
];
preg_match('/论坛[:]\s*(https?:\/\/[^\s]*?\.html)/u', $sStrBaoliu, $matches);
if (isset($matches[1])) {
$sUrl = $matches[1];
@ -278,42 +354,30 @@ final class CacheTg
],
];
} else if ($sType == 'img') {
// $aDataMixNew["images"][] = $aDataMixRow;
$aDataMixNew["data"][] = $aDataMixRow;
} else {
$aDataMixNew["data"][] = $aDataMixRow;
}
}
return $aDataMixNew;
}
private function ffq_tg_str_fetch($str) {
$start = strpos($str, '#');
$end = strpos($str, '📊');
$arr = [
"tiqu" => '',
"baoliu" => $str,
"name" => '',
"tiqu" => '',
"baoliu" => $str,
"name" => '',
];
if ($start !== false && $end !== false && $end > $start) {
$length = $end - $start;
$extracted = mb_substr($str, $start, $length, 'UTF-8');
if (preg_match('/#([^📊]+)📊/u', $str, $matches)) {
$arr["tiqu"] = $matches[1]; // 提取内容(不含 # 和 📊)
$arr["baoliu"] = preg_replace('/#([^📊]+)📊/u', '', $str); // 去掉提取部分
$cleaned = str_replace($extracted, '', $str);
$arr["tiqu"] = $extracted;
$arr["baoliu"] = $cleaned;
}
if (!empty($arr["tiqu"])) {
$arr["tiqu"] = substr($arr["tiqu"], 1);
$tmp = explode("#", $arr["tiqu"]);
$name = $tmp[0] ?? '';
if ($name) {
$arr["name"] = $name;
}
$arr["name"] = $tmp[0] ?? '';
}
return $arr;

View File

@ -10,7 +10,7 @@ use App\Models\Option as ModelOption;
use App\Services\TomTool\Telegram\Slave as TeleSlave;
use App\Services\TomTool\Flow;
//use App\Services\Article\Cmd as ServiceArticleCmd;
use App\Models\DogOption as ModelDogOption;
//use App\Models\Option as ModelOption;
final class Schema
{
@ -116,10 +116,8 @@ final class Schema
$sSiteUrl = $this->sSiteUrl;
$aSchema = json_decode($this->oArticle->schema, true);
$isTest = $this->isTest;
$aArticle["data"] = [];
foreach ($aSchema as $k => $aArticleSchemaRow) {
$sContent = $aArticleSchemaRow["content"]["base"] ?? "⚠️ 没有content";
if ($aArticleSchemaRow['type'] == 'str') {
@ -172,51 +170,95 @@ final class Schema
////// step 3 文章化
$aArticleOrder = $aArticle["dataOrder"];
$sEnter = "
";
$sArticle = '';
$sArticle .= $sEnter;
$j = false;
foreach ($aArticleOrder as $aArticleOrderRow) {
$sContent = $aArticleOrderRow["content"]["base"] ?? "⚠️ content里的base没有";
$sContent = trim($sContent);
$sContent = nl2br($sContent);
$sContent = str_replace("<br />", " ", $sContent);
$sContent = str_replace("<br />", $sEnter, $sContent);
$sTmpName = $aArticleOrderRow["name"] ?? '';
if ($sTmpName == "str_jieshao") {
$sContent = preg_replace('/套餐.*'.$sEnter.'/', '', $sContent);
$sContent = preg_replace('/论坛.*'.$sEnter.'/', '', $sContent);
if ($sTmpName == "tixingnin") {
$sArticle .= "::: tip 提醒您";
$sArticle .= $sContent;
$sArticle .= $sEnter;
$sArticle .= ":::";
$sArticle .= $sEnter;
} else if ($sTmpName == "jichangzijie") {
$sArticle .= "::: note 机场自介";
$sArticle .= $sContent;
$sArticle .= $sEnter;
$sArticle .= ":::";
$sArticle .= $sEnter;
} else if ($sTmpName == "lianjiedaohang") {
$sContent = nl2br($sContent);
$br = "<br \/>";
$sContent = preg_replace('/套餐.*'.$br.'/', '', $sContent);
$sContent = preg_replace('/论坛.*\.html/', '', $sContent);
$sArticle .= "::: info 链接导航";
$sArticle .= $this->clearBr($sContent);
$sArticle .= $sEnter;
$sArticle .= ":::";
$sArticle .= $sEnter;
} else if ($sTmpName == "zhuguandianping") {
$sArticle .= "::: important {$sSiteName}点评";
$sArticle .= $sContent;
$sArticle .= $sEnter;
$sArticle .= ":::";
$sArticle .= $sEnter;
} else if ($sTmpName == "zhuguanpingfen") {
$sContent = preg_replace('/(以上评分仅供参考)/', '', $sContent);
$sContent = preg_replace('/(?<! ) (?! )/', '', $sContent);
$sContent = preg_replace('/★/', '⭐️', $sContent);
$sArticle .= "::: important {$sSiteName}打分";
$sArticle .= $sContent;
$sArticle .= $sEnter;
$sArticle .= ":::";
$sArticle .= $sEnter;
$sArticle .= "## 机场介绍";
$sArticle .= $sEnter;
$sArticle .= $sEnter;
} else if ($sTmpName == "str_jieshao") {
} else if ($sTmpName == "table_taocan") {
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$sArticle .= "## 套餐价格";
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$sArticle .= $sContent;
} else if ($sTmpName == "img_cesu") {
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$sArticle .= "## 节点测试";
$sArticle .= $sEnter;
$sArticle .= $sEnter;
if ($j === false) {
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$sArticle .= "## 节点测试";
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$j = true;
}
$sArticle .= $sContent;
} else if ($sTmpName == "tag_tiqu") {
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$sArticle .= $sContent;
} else {
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$sArticle .= "## 其他";
$sArticle .= $sEnter;
$sArticle .= $sEnter;
$sArticle .= $sContent;
}
$sArticle .= $sContent;
}
// foreach ($aArticleOrder["images"] as $aArticleImagesRow) {
//
// }
////// step 5 返回 通知提取
$aResultData = [
@ -227,6 +269,13 @@ final class Schema
return $oFlow->setDataA($aResultData)->done();
}
private function clearBr($sStr)
{
$sEnter = "
";
return str_replace("<br />", $sEnter, $sStr);
}
private function articleSort(array $data, string $field, array $priorityOrder): array
{
// 保留原始键名
@ -249,12 +298,12 @@ final class Schema
private function nameToTitleCS($sName)
{
$sTitle = $sName;
$sTitle = trim($sName);
$iCesuCount = ModelArticleSchema::where("name", $sName)->count();
if ($iCesuCount > 1) {
$sWrap = ModelDogOption::_hit("article", "ffq_tg-title_wrap");
$sWrap = ModelOption::_hit("ffq_tg_a-title_wrap");
if (!$sWrap) {
return "未设置dog_option::ffq_tg-title_wrap";
@ -265,7 +314,7 @@ final class Schema
$sTitle = str_replace('{{cesu_count}}', (string) $iCesuCount, $sTitle);
} else {
$sWrap = ModelDogOption::_hit("article", "ffq_tg-title_wrap-first");
$sWrap = ModelOption::_hit("ffq_tg_a-title_wrap-first");
if (!$sWrap) {
return "未设置dog_option::ffq_tg-title_wrap-first";

View File

@ -29,6 +29,11 @@ final class ArticleSchema
echo " - 没有需要同步的文章\n";
}
// foreach ($oArticleSchemaList->toArray() as $R) {
// unset($R["schema"]);
// tomd($R);
// }
foreach ($oArticleSchemaList as $oArticleSchema) {
$aCmdList = json_decode($oArticleSchema->cmd, true);
@ -122,89 +127,6 @@ final class ArticleSchema
echo "ok\n";
}
// 废弃,不是通知了,直接推
public static function notifySalve()
{
echo "\nnotifySlave::开始\n";
$oArticleSchemaList = ModelArticleSchema::where("enable_sync", 1)->where("status", 1)->get();
if ($oArticleSchemaList->isEmpty()) {
echo " - 没有需要同步的文章\n";
}
foreach ($oArticleSchemaList as $oArticleSchema) {
$aCmdList = json_decode($oArticleSchema->cmd, true);
foreach ($aCmdList as $sCmdKey => $aCmd) {
$sSiteCode = $aCmd["site_code"] ?? "none";
$oSite = ModelSiteMap::where("code", $sSiteCode)->first();
if (!$oSite) {
$sMsg = "siteMap里的code没有映射{$sSiteCode}\n";
TeleSlave::warn()->send($sMsg);
echo $sMsg;
continue;
}
$sSiteGroupCode = $oSite->group_code;
$sSiteUrlBase = $oSite->url;
$sSiteArticleApiPath = ModelSitePathMap::where("site_group_code", $sSiteGroupCode)->where("path_group_code", "article_receive_schema")->first()?->path;
if (!$sSiteArticleApiPath) {
$sMsg = "sitePathMap里没找到映射{$sSiteGroupCode}:article_receive_schema\n";
TeleSlave::warn()->send($sMsg);
echo $sMsg;
continue;
}
$aCmd["key"] = $sCmdKey;
$aCmd["article_code"] = $oArticleSchema->code;
$sSiteArticleApiUrl = "https://".$sSiteUrlBase.$sSiteArticleApiPath;
// 附加config
$sArticleConfig = ModelArticleConfig::where("article_group_code", $oArticleSchema->group_code)->where("site_group_code", $sSiteGroupCode)->first()?->config;
$aArticleConfig = json_decode($sArticleConfig, true);
$aCmd["config"] = $aArticleConfig;
// 按需要附加其他
if ($aCmd["cmd"] == "new") {
ServiceArticleSchema::start($oArticleSchema->code,);
}
tomd($aCmd);
tomd($oArticleSchema->group_code);
tomd($sSiteGroupCode);
tomd($sArticleConfig, 1);
// $aA
$sHttpResult = HttpV2::make($sSiteArticleApiUrl)->enableJsonAs()->setDataA($aCmd)->send();
$aHttpResult = json_decode($sHttpResult, true);
$bHttpIsDone = $aHttpResult["isDone"] ?? false;
if (!$bHttpIsDone) {
$sMsg = "slave那边同步失败";
TeleSlave::warn()->send($sMsg);
continue;
}
$oCmdFLow = ServiceArticleCmd::startWithO($oArticleSchema)->moveToLog($sCmdKey);
if ($oCmdFLow->isFail()) {
$sMsg = "movetolog失败";
TeleSlave::warn()->send($sMsg);
continue;
}
}
}
echo "ok\n";
}
public static function cacheTgSave()
{

View File

@ -3,8 +3,8 @@
namespace App\Services\Tg\Hook\Mod;
use App\Models\ArticleSchema as ModelArticleSchema;
//use App\Models\ArticleCache as ModelArticleCache;
//use App\Models\ArticleCacheTime as ModelArticleCacheTime;
use App\Models\ArticleCache as ModelArticleCache;
use App\Models\ArticleCacheTime as ModelArticleCacheTime;
use App\Services\Tg\Hook\Dog;
use App\Services\Article\CacheTg as ServiceArticleCacheTg;
use App\Services\Article\Schema as ServiceArticleSchema;
@ -43,15 +43,6 @@ class Article extends Base {
return $r;
}
// public function testCron()
public function cacheSave($aParam)
{
$r = ServiceArticleCacheTg::start()->saveToSchema();
return $r->getResult();
}
public function build_test_ttcp($aParam)
{
$oArticleCodeFirst = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first();

View File

@ -25,4 +25,23 @@ class ArticleCache extends Base {
return $this->oDog->$sName($aArg[0]);
}
public function save($aParam)
{
$r = ServiceArticleCacheTg::start()->saveToSchema();
return $r->getResult();
}
public function reCron()
{
$o = ModelArticleCacheTime::first();
$o->time = time() - 600;
$o->save();
$o = ModelArticleCache::orderBy("id", "desc")->first();
$o->status = 1;
$o->save();
return $o;
}
}

View File

@ -26,4 +26,16 @@ class ArticleSchema extends Base {
return $this->oDog->$sName($aArg[0]);
}
public function last()
{
$iLastId = ModelArticleSchema::where("status", 1)->orderBy("id", "desc")->first()?->id;
$aParam = [];
$aParam["aArg"][1] = $iLastId;
$r = $this->find($aParam);
return $r;
}
}

View File

@ -32,6 +32,15 @@ class Dev extends Base {
}
public function ff()
{
$str = "{\"update_id\":897485962,\n\"message\":{\"message_id\":55,\"from\":{\"id\":7740568271,\"is_bot\":false,\"first_name\":\"sakai\",\"username\":\"gemcode_business\",\"language_code\":\"zh-hans\"},\"chat\":{\"id\":7740568271,\"first_name\":\"sakai\",\"username\":\"gemcode_business\",\"type\":\"private\"},\"date\":1763118782,\"forward_origin\":{\"type\":\"channel\",\"chat\":{\"id\":-1001566003179,\"title\":\"\\u7ffb\\u7ffb\\u5899 | \\u673a\\u573a\\u8bc4\\u6d4b\",\"username\":\"ffqchannel\",\"type\":\"channel\"},\"message_id\":13130,\"date\":1763035978},\"forward_from_chat\":{\"id\":-1001566003179,\"title\":\"\\u7ffb\\u7ffb\\u5899 | \\u673a\\u573a\\u8bc4\\u6d4b\",\"username\":\"ffqchannel\",\"type\":\"channel\"},\"forward_from_message_id\":13130,\"forward_date\":1763035978,\"media_group_id\":\"14104950256698836\",\"document\":{\"file_name\":\"\\u9752\\u4e1d\\u4e91\\u4e28\\u5355\\u7ebf\\u7a0b\\u6d59\\u6c5f\\u7535\\u4fe1@1Gbps.jpg\",\"mime_type\":\"image/jpeg\",\"thumbnail\":{\"file_id\":\"AAMCBQADGQEAAxVpFwZD2UKeOXZ0S3KpGyd0PBNsMQAC3RkAAuIusVSVoOT9g1zrBAEAB20AAzYE\",\"file_unique_id\":\"AQAD3RkAAuIusVRy\",\"file_size\":36130,\"width\":320,\"height\":309},\"thumb\":{\"file_id\":\"AAMCBQADGQEAAxVpFwZD2UKeOXZ0S3KpGyd0PBNsMQAC3RkAAuIusVSVoOT9g1zrBAEAB20AAzYE\",\"file_unique_id\":\"AQAD3RkAAuIusVRy\",\"file_size\":36130,\"width\":320,\"height\":309},\"file_id\":\"BQACAgUAAxkBAAMVaRcGQ9lCnjl2dEtyqRsndDwTbDEAAt0ZAALiLrFUlaDk_YNc6wQ2BA\",\"file_unique_id\":\"AgAD3RkAAuIusVQ\",\"file_size\":682117},\"caption\":\"#\\u9752\\u4e1d\\u4e91 #ss #trojan\\n\\n\\ud83d\\udcca \\u4e3b\\u89c2\\u8bc4\\u5206 \\n\\u7a33\\u5b9a \\u2605\\u2606\\u2606\\u2606\\u2606\\n\\u901f\\u5ea6 \\u2605\\u2605\\u2606\\u2606\\u2606\\n\\u5ef6\\u8fdf \\u2605\\u2605\\u2605\\u2606\\u2606\\n\\u6027\\u4ef7\\u6bd4 \\u2605\\u2605\\u2605\\u2606\\u2606\\n\\uff08\\u4ee5\\u4e0a\\u8bc4\\u5206\\u4ec5\\u4f9b\\u53c2\\u8003\\uff09\\n\\n\\ud83d\\ude00 \\u673a\\u573a\\u81ea\\u4ecb \\n\\ud83d\\udcf6 \\u9999\\u6e2f/\\u65e5\\u672c/\\u65b0\\u52a0\\u5761/\\u53f0\\u6e7e/\\u7f8e\\u56fd+\\u5341\\u4f59\\u4e2a\\u51b7\\u95e8\\u8282\\u70b9\\n\\ud83e\\uddd8 \\u8f7b\\u677e\\u89e3\\u9501 Netflix / ChatGPT / Disney+\\uff0c\\u7545\\u6e38\\u5168\\u7403\\u6d41\\u5a92\\u4f53\\n\\n\\ud83d\\ude00 \\u94fe\\u63a5\\u5bfc\\u822a\\n\\u5f00\\u4e1a\\uff1a2025.4.1\\n\\u5b98\\u7f51\\uff1a\\u70b9\\u51fb\\u8fdb\\u5165\\n\\u9891\\u9053\\uff1ahttps://t.me/qingsiyun_offical_channel\\n\\u7fa4\\u7ec4\\uff1ahttps://t.me/qingsiyun_offical_group\\n\\u5957\\u9910\\uff1ahttps://t.me/ffqimages/102 2025.4.23\\u66f4\\u65b0\\n\\u8bba\\u575b\\uff1ahttps://www.ffqla.net/thread-689-1-1.html\\n\\n\\ud83d\\ude00\\u4e3b\\u89c2\\u70b9\\u8bc4\\n\\u7a33\\u5b9a\\u6027\\u6781\\u5dee\\uff0c\\u622a\\u6b62\\u76ee\\u524d\\uff0c\\u8282\\u70b9\\u5168\\u90e8\\u8d85\\u65f6\\n\\n\\ud83d\\ude00\\u7ffb\\u7ffb\\u5899\\u63d0\\u9192\\u60a8 \\n\\u4efb\\u4f55\\u673a\\u573a\\u90fd\\u6709\\u8dd1\\u8def\\u53ef\\u80fd\\uff0c\\u5efa\\u8bae\\u4ec5\\u6708\\u4ed8\\uff0c\\u4ee5\\u964d\\u4f4e\\u98ce\\u9669\\u3002\\uff08\\u672c\\u6d88\\u606f\\u4e0d\\u9488\\u5bf9\\u4efb\\u4f55\\u673a\\u573a\\uff09\",\"caption_entities\":[{\"offset\":0,\"length\":4,\"type\":\"hashtag\"},{\"offset\":5,\"length\":3,\"type\":\"hashtag\"},{\"offset\":9,\"length\":7,\"type\":\"hashtag\"},{\"offset\":18,\"length\":9,\"type\":\"bold\"},{\"offset\":77,\"length\":2,\"type\":\"custom_emoji\",\"custom_emoji_id\":\"6190348849194734065\"},{\"offset\":80,\"length\":6,\"type\":\"bold\"},{\"offset\":159,\"length\":2,\"type\":\"custom_emoji\",\"custom_emoji_id\":\"6190313819441468309\"},{\"offset\":162,\"length\":4,\"type\":\"bold\"},{\"offset\":182,\"length\":4,\"type\":\"text_link\",\"url\":\"https://302verify.com/xyzF6\"},{\"offset\":190,\"length\":38,\"type\":\"url\"},{\"offset\":232,\"length\":36,\"type\":\"url\"},{\"offset\":272,\"length\":26,\"type\":\"url\"},{\"offset\":314,\"length\":41,\"type\":\"url\"},{\"offset\":357,\"length\":2,\"type\":\"custom_emoji\",\"custom_emoji_id\":\"6190543385443439890\"},{\"offset\":359,\"length\":4,\"type\":\"bold\"},{\"offset\":383,\"length\":2,\"type\":\"bold\"},{\"offset\":383,\"length\":2,\"type\":\"custom_emoji\",\"custom_emoji_id\":\"6190543385443439890\"},{\"offset\":385,\"length\":6,\"type\":\"bold\"}]}}";
$aStr = json_decode($str, true);
$s = $this->toJson($aStr);
tomd($s, 1);
}
public function test2()
{
// $r = TeleSlave::warn()->enableSlaveQueue(false)->send("xxxx");

View File

@ -120,8 +120,11 @@ class Flow
}
// data
public function msg(string $msg): self
public function msg($msg = "msg未设置"): self
{
if (is_array($msg)) {
$msg = json_encode($msg);
}
$this->put('sMsg', $msg);
return $this;
}