From b9dd933085b729d5893c3143c4198de72ac61aa8 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Thu, 26 Jun 2025 21:10:32 +0800 Subject: [PATCH] no message --- app/Services/TG/Hook/Mod/Article.php | 43 +++++++++++++++++++-------- app/Services/TG/Hook/Mod/Git.php | 10 ++++--- app/Services/TG/Hook/Mod/SaleCode.php | 17 +++++++---- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/app/Services/TG/Hook/Mod/Article.php b/app/Services/TG/Hook/Mod/Article.php index c2be152..19554a6 100644 --- a/app/Services/TG/Hook/Mod/Article.php +++ b/app/Services/TG/Hook/Mod/Article.php @@ -15,13 +15,16 @@ class Article extends Base { $aArticleList = ModelArticle::orderBy($sOrderBy)->get()->toArray(); + $aTmp = []; foreach ($aArticleList as &$row) { // 使用引用来修改原数组 unset($row['updated_at']); // 移除 updated_at 字段 unset($row['created_at']); // 移除 created_at 字段 - $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + $aTmp[] = $this->toJson($row); +// $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); } - $this->oHttp::response(200, 'ok'); + return $aTmp; +// $this->oHttp::response(200, 'ok'); } public function Find($aParam) @@ -33,7 +36,8 @@ class Article extends Base { unset($aSingle['updated_at']); unset($aSingle['created_at']); - return json_encode($aSingle, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); +// return json_encode($aSingle, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); + return $this->toJson($aSingle); } @@ -47,14 +51,18 @@ class Article extends Base { if (empty($aArticleList)) { $this->oTGHttp->sendToTG("没有"); } else { + + $aTmp = []; foreach ($aArticleList as &$row) { // 使用引用来修改原数组 unset($row['updated_at']); // 移除 updated_at 字段 unset($row['created_at']); // 移除 created_at 字段 - $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + $aTmp[] = $this->toJson($row); } } - $this->oHttp::response(200, 'ok'); + return $aTmp; +// $this->oHttp::response(200, 'ok'); } public function Clone($aParam) @@ -77,10 +85,13 @@ class Article extends Base { // 发送新文章的 ID 到 Telegram $sMsg = "新文章已创建,ID: " . $newArticle->id; - $this->oTGHttp->sendToTG($sMsg); +// $this->oTGHttp->sendToTG($sMsg); // 返回 HTTP 响应 - $this->oHttp::response(200, 'ok'); +// $this->oHttp::response(200, 'ok'); + + return $this->toJson($sMsg); + } else { throw new \Exception("没有这个id"); } @@ -93,9 +104,11 @@ class Article extends Base { $newArticle->user_name = $aParams['aArg'][1]; $r = $newArticle->save(); - $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + return $r; - $this->oHttp::response(200, 'ok'); +// $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + +// $this->oHttp::response(200, 'ok'); } @@ -110,9 +123,11 @@ class Article extends Base { $r = false; } - $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + return $r; - $this->oHttp::response(200, 'ok'); +// $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + +// $this->oHttp::response(200, 'ok'); } @@ -134,9 +149,11 @@ class Article extends Base { throw new \Exception("Article not found"); } - $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + return $r; - $this->oHttp::response(200, 'ok'); +// $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + +// $this->oHttp::response(200, 'ok'); } } diff --git a/app/Services/TG/Hook/Mod/Git.php b/app/Services/TG/Hook/Mod/Git.php index 8f9fb47..8089a51 100644 --- a/app/Services/TG/Hook/Mod/Git.php +++ b/app/Services/TG/Hook/Mod/Git.php @@ -76,9 +76,10 @@ class Git extends Base { $sMsg = "无法获取 $host 的公钥\n"; } - $this->oTGHttp->sendToTG($sMsg); + return $sMsg; +// $this->oTGHttp->sendToTG($sMsg); - $this->oHttp::response(200, 'ok'); +// $this->oHttp::response(200, 'ok'); } @@ -103,9 +104,10 @@ class Git extends Base { // 硬重置到远程主分支 $this->runCommand('git reset --hard origin/main'); - $this->oTGHttp->sendToTG("操作完成:已重置到远程主分支"); + return "操作完成:已重置到远程主分支"; +// $this->oTGHttp->sendToTG("操作完成:已重置到远程主分支"); - $this->oHttp::response(200, 'ok'); +// $this->oHttp::response(200, 'ok'); } diff --git a/app/Services/TG/Hook/Mod/SaleCode.php b/app/Services/TG/Hook/Mod/SaleCode.php index a638ae8..b147a7e 100644 --- a/app/Services/TG/Hook/Mod/SaleCode.php +++ b/app/Services/TG/Hook/Mod/SaleCode.php @@ -10,9 +10,10 @@ class SaleCode extends Base { $updatedRows = ModelArticle::where('sale_code', $aParams['aOption'][1]) ->update(['sale_rate' => $aParams['aArg'][1]]); - $this->oTGHttp->sendToTG(json_encode($updatedRows, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + return $this->toJson($updatedRows); +// $this->oTGHttp->sendToTG(json_encode($updatedRows, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); - $this->oHttp::response(200, 'ok'); +// $this->oHttp::response(200, 'ok'); } @@ -24,9 +25,11 @@ class SaleCode extends Base { ->get() ->toArray(); - $this->oTGHttp->sendToTG(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + return $this->toJson($aSaleCodeList); - $this->oHttp::response(200, 'ok'); +// $this->oTGHttp->sendToTG(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + +// $this->oHttp::response(200, 'ok'); } public function Find($aParams) @@ -39,9 +42,11 @@ class SaleCode extends Base { ->get() ->toArray(); - $this->oTGHttp->sendToTG(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + return $this->toJson($aSaleCodeList); - $this->oHttp::response(200, 'ok'); +// $this->oTGHttp->sendToTG(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + +// $this->oHttp::response(200, 'ok'); }