From d73d851aba194b9eac70ec0c3f0358744e4f4464 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Thu, 15 Jan 2026 13:35:05 +0800 Subject: [PATCH] no message --- .../Controllers/Api/Tg/HookController.php | 30 ++++++++++++++++++- app/Services/Article/CacheTg.php | 4 +-- app/Services/Cron/ArticleSchema.php | 12 ++++++-- github的blade说明.md | 25 ++++++++++++++++ routes/web.php | 2 ++ 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 github的blade说明.md diff --git a/app/Http/Controllers/Api/Tg/HookController.php b/app/Http/Controllers/Api/Tg/HookController.php index 9669cdbb..bea7d49f 100755 --- a/app/Http/Controllers/Api/Tg/HookController.php +++ b/app/Http/Controllers/Api/Tg/HookController.php @@ -14,9 +14,37 @@ use App\Services\TomTool\Telegram\Slave as TelegramSlave; final class HookController { - private $sCustomText = ''; + public function cache_tg($sGroupCode) + { + try { + + $sUpdate = file_get_contents("php://input"); + $aUpdate = json_decode($sUpdate, true); + $sText = $aUpdate["message"]["text"] ?? "没有text"; + if (!str_starts_with($sText, '/')) { + $this->sCustomText = "/article#cacheAdd__{$sGroupCode}"." ".$sUpdate; + } + + $this->cmd(); + + } catch (\Throwable $e) { + + $aDataTg = ThrowableHandler::make($e)->enableTrace()->fetch(); + TelegramSlave::fail()->enableSlaveQueue(false)->setMsgA([ + "msg" => $aDataTg, + "data" => $sUpdate, + ])->send(); + + $aDataCmd = $aDataTg; + $sDataCmd = json_encode($aDataCmd, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + $sDataCmd = str_replace("\\n", "
", $sDataCmd); + echo $sDataCmd; + exit; + } + } + public function cmd_ffq_article() { try { diff --git a/app/Services/Article/CacheTg.php b/app/Services/Article/CacheTg.php index c641f5ed..34150180 100755 --- a/app/Services/Article/CacheTg.php +++ b/app/Services/Article/CacheTg.php @@ -101,7 +101,7 @@ final class CacheTg $oArticleSchema->name = $aDataMix["name"] ?? "none"; $oArticleSchema->save(); - ModelArticleCache::where("status", 1)->update([ + ModelArticleCache::where("status", 1)->where("group_code", $sFromPaichu)->update([ "status" => 0, // 上线改0 "code" => $sArticleCode, ]); @@ -180,7 +180,7 @@ final class CacheTg // } $fileName = basename($filePath); - $fileName = uniqid('ffq_tg-'.$k.'-'.time().'-').$fileName; // 加前缀并提高熵值 + $fileName = uniqid($sGroupCode.'-'.$k.'-'.time().'-').$fileName; // 加前缀并提高熵值 file_put_contents($sPathUpload . $fileName, $imageData); $aDataTmp["content"]["img"][$k] = $_ENV["APP_URL"].'/upload/'.$fileName;; diff --git a/app/Services/Cron/ArticleSchema.php b/app/Services/Cron/ArticleSchema.php index 412d9e75..48c47e49 100755 --- a/app/Services/Cron/ArticleSchema.php +++ b/app/Services/Cron/ArticleSchema.php @@ -7,6 +7,7 @@ namespace App\Services\Cron; use App\Models\SiteMap as ModelSiteMap; use App\Models\SitePathMap as ModelSitePathMap; use App\Models\ArticleConfig as ModelArticleConfig; +use App\Models\ArticleCache as ModelArticleCache; use App\Models\ArticleSchema as ModelArticleSchema; use App\Models\ArticleCacheTime as ModelArticleCacheTime; use App\Services\Article\CacheTg as ServiceArticleCacheTg; @@ -156,8 +157,15 @@ final class ArticleSchema return false; } - $oCacheTime->time = 0; - $oCacheTime->save(); + //// 如果cache里还存在未处理的,就维持cron + //// schema那边一次只处理一种group_code,等于就是多种group_code时维持cron,一次处理一种 + $b = ModelArticleCache::where('status', 1)->exists(); + if (!$b) { + $oCacheTime->time = 0; + $oCacheTime->save(); + } else { + echo " - 有其他group_code,维持cron\n"; + } echo " - ok\n"; } diff --git a/github的blade说明.md b/github的blade说明.md new file mode 100644 index 00000000..6e0f39b4 --- /dev/null +++ b/github的blade说明.md @@ -0,0 +1,25 @@ + +========可用变量================ + +$ex["good_rand"] = $sGoodRand; + +$sGoodShip = ModelGoodPool::_goodToGithub($aShip["good"]); +$ex["good_ship"] = $sGoodShip; + +$ex["url_sub_v2ray"] = "https://".$aArticle["fn_www"]."/sub/v2ray-".date("Ymd").".txt"; +$ex["url_sub_clash"] = "https://".$aArticle["fn_www"]."/sub/v2ray-".date("Ymd").".yaml"; +$ex["youhui"] = "购买套餐时输入【".$aArticle['sale_code']."】优惠码,可享".$aArticle['sale_rate']."折优惠,折后低至".$aArticle['sale_price']."元/月。"; + +$ex["url_github_clash"] = "https://raw.githubusercontent.com/".$aArticle["user_name"]."/".$aArticle["project_name"]."/main/feed/clash-".$sDateCode.".yaml"; +$ex["url_github_v2ray"] = "https://raw.githubusercontent.com/".$aArticle["user_name"]."/".$aArticle["project_name"]."/main/feed/v2ray-".$sDateCode.".txt"; + +$ex["url_github_io_clash"] = "https://".$aArticle["user_name"].".github.io/feed/clash-".$sDateCode.".yaml"; +$ex["url_github_io_v2ray"] = "https://".$aArticle["user_name"].".github.io/feed/v2ray-".$sDateCode.".txt"; + +$ex["huodong"] = $this->getHuodong($aShip); + +用法: + {$this->date(\"m月d日\")} + {$ex["url_github_clash"]} + + diff --git a/routes/web.php b/routes/web.php index 01c2ea90..21379db6 100755 --- a/routes/web.php +++ b/routes/web.php @@ -50,6 +50,8 @@ Route::get('/test5', [SakaiController::class, 'test5']); Route::any('/api/tg/hook', [HookController::class, 'cmd']); Route::any('/api/tg/hook/cmd_ffq_article', [HookController::class, 'cmd_ffq_article']); + +Route::any('/api/tg/hook/cache_tg/{group_code}', [HookController::class, 'cache_tg']); //Route::get('/', [ArticleListController::class, 'fn']); //Route::get('/fn', [ArticleListController::class, 'fn']); // 免费节点list