From 335945a35792cf134dfb6d363f8b201b0704bf49 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Sun, 13 Apr 2025 21:09:12 +0800 Subject: [PATCH] no message --- .../Controllers/Api/TG/HookController 2.php | 283 ++++++++++++++++++ .../Controllers/Api/TG/HookController.php | 100 +++++++ .../Controllers/Api/Tg/HookController.php | 230 -------------- app/Http/Controllers/TestsController.php | 2 +- app/Services/TG/Hook/Article.php | 93 ++++++ app/Services/TG/Hook/Base.php | 53 ++++ app/Services/TG/Hook/Cmd.php | 28 ++ app/Services/TG/Hook/SaleCode.php | 48 +++ app/Services/TG/Http.php | 23 ++ public/index.php | 10 + routes/web.php | 2 +- 11 files changed, 640 insertions(+), 232 deletions(-) create mode 100755 app/Http/Controllers/Api/TG/HookController 2.php create mode 100755 app/Http/Controllers/Api/TG/HookController.php delete mode 100755 app/Http/Controllers/Api/Tg/HookController.php create mode 100644 app/Services/TG/Hook/Article.php create mode 100644 app/Services/TG/Hook/Base.php create mode 100644 app/Services/TG/Hook/Cmd.php create mode 100644 app/Services/TG/Hook/SaleCode.php create mode 100644 app/Services/TG/Http.php diff --git a/app/Http/Controllers/Api/TG/HookController 2.php b/app/Http/Controllers/Api/TG/HookController 2.php new file mode 100755 index 0000000..2b23d97 --- /dev/null +++ b/app/Http/Controllers/Api/TG/HookController 2.php @@ -0,0 +1,283 @@ +middleware('csrf')->except(['cmd']); + // 或者 $this->middleware('csrf')->only(['specificMethod']); + } + + + public function cmd() + { + + try { + + $this->sApiToken = env('telegram_token'); + $this->sApiChatId = env('telegram_chatid'); + + $sUpdate = file_get_contents("php://input"); + + $aUpdate = json_decode($sUpdate, true); + + @file_put_contents('/www/_tg/bot_log.txt', json_encode($aUpdate, JSON_PRETTY_PRINT)); + + $aData['chatId'] = $aUpdate["message"]["chat"]["id"]; + $aData['fromId'] = $aUpdate["message"]["from"]["id"]; + + if (!isset($aUpdate["message"]["text"])) { + http_response_code(200); + echo "not have text"; + exit; + } + + $sText = $aUpdate["message"]["text"]; + + + // 打断 + if ($sText === "/break") { + + $oTgStep->clearByFromId($aData["fromId"]); + + $this->sendMessage("ok"); + + Http::response(200, 'ok'); + + } + + // 命令列表 + // /cmdList +// if (strpos($sText, '/cmdList') === 0 || strpos($sText, '\/cmdList') === 0) { +// +// $aCmdList = [ +// '优惠码list' => '/saleCodeList', +// '优惠码find' => '/saleCodeFind xxhh', +// '优惠码rate' => '/saleCodeSetRate__xxzz 6.7', +// // '优惠码add' => '/saleCodeAdd xxhh', +// // '优惠码del' => '/saleCodeDel__xxhh', +// // '优惠码set' => '/saleCodeSet__xxhh__field set', +// '文章list' => '/articleList', +// '文章like' => '/articleLike__field like', +// '文章add' => '/articleAdd__name', +// '文章del' => '/articleDel__id', +// '文章set' => '/articleSet__id__fild set', +// ]; +// +// $this->sendMessage(json_encode($aCmdList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// Http::response(200, 'ok'); + + } + + // 优惠设置幅度(批量) +// if (strpos($sText, '/saleCodeSetRate') === 0 || strpos($sText, '\/saleCodeSetRate') === 0) { +// +// list($sCmd, $iRate) = explode(" ", $sText); +// list(, $sCode) = explode("__", $sCmd); +// +// $updatedRows = Article::where('sale_code', $sCode) +// ->update(['sale_rate' => $iRate]); +// +// $this->sendMessage(json_encode($updatedRows, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// Http::response(200, 'ok'); +// } + + // 优惠list +// if (strpos($sText, '/saleCodeList') === 0 || strpos($sText, '\/saleCodeList') === 0) { +// +// $aSaleCodeList = Article::select('sale_code', 'sale_rate') +// ->distinct() +// ->orderBy("sale_code") +// ->get() +// ->toArray(); +// +// $this->sendMessage(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// Http::response(200, 'ok'); +// } + + // 优惠find +// if (strpos($sText, '/saleCodeFind') === 0 || strpos($sText, '\/saleCodeFind') === 0) { +// +// list(, $sSaleCode) = explode(" ", $sText); +// +// $aSaleCodeList = Article::select('sale_code', 'sale_rate') +// ->where("sale_code", $sSaleCode) +// ->distinct() +// ->orderBy("sale_code") +// ->get() +// ->toArray(); +// +// $this->sendMessage(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// Http::response(200, 'ok'); +// +// } + + // 文章list +// if (strpos($sText, '/ArticleList') === 0 || strpos($sText, '\/ArticleList') === 0) { +// +// $aArticleList = Article::orderBy("user_name")->get()->toArray(); +// +// foreach ($aArticleList as $row) { +// $this->sendMessage(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// } +// +// Http::response(200, 'ok'); +// } + + // 文章 like + // /ArticleLike__user_name xxx +// if (strpos($sText, '/ArticleLike') === 0 || strpos($sText, '\/ArticleLike') === 0) { +// +// list($sCmd, $sLike) = explode(" ", $sText); +// list(, $sField) = explode("__", $sCmd); +// +// $aArticleList = Article::where($sField, 'like', '%' . $sLike . '%') +// ->orderBy("user_name") +// ->get() +// ->toArray(); +// +// +// foreach ($aArticleList as $row) { +// $this->sendMessage(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// } +// +// Http::response(200, 'ok'); +// } + + // 文章 add +// if (strpos($sText, '/articleAdd') === 0 || strpos($sText, '\/articleAdd') === 0) { +// +// list(, $sUserName) = explode(" ", $sText); +// +// $newArticle = new Article(); +// $newArticle->user_name = $sUserName; +// $r = $newArticle->save(); +// +// $this->sendMessage(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// Http::response(200, 'ok'); +// +// } + + // 文章 del +// if (strpos($sText, '/articleDel') === 0 || strpos($sText, '\/articleDel') === 0) { +// +// list(, $iId) = explode(" ", $sText); +// +// $article = Article::find($iId); +// +// if ($article) { +// $r = $article->delete(); +// } else { +// $r = false; +// } +// +// $this->sendMessage(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// Http::response(200, 'ok'); +// +// } + + // 文章 set + // /ArticleSet__id__user_name xxx +// if (strpos($sText, '/ArticleSet') === 0 || strpos($sText, '\/ArticleSet') === 0) { +// +// list($sCmd, $sSet) = explode(" ", $sText); +// list(, $iId, $sField) = explode("__", $sCmd, 3); +// $sField = $this->cmdGood($sField); +// +// $article = Article::find($iId); +// +// if ($article) { +// $article->$sField = $sSet; +// +// $r = $article->save(); +// } else { +// // 处理未找到的情况 +// throw new Exception("Article not found with ID: $iId"); +// } +// +// $this->sendMessage(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); +// +// Http::response(200, 'ok'); +// } + + } catch (\Exception $e) { + // 处理异常 + $errorMessage = $e->getMessage(); + $this->sendMessage(json_encode(['error' => $errorMessage], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + + Http::response(200, '不对'); + + } + + } + + private function sendMessage($sText = '?') { + + if (env('is_loc') === true) { + echo "
";
+            var_dump($sText);
+        } else {
+            $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sText);
+            file_get_contents($url);
+        }
+        
+    }
+    
+    private function cmdGood($sCmd) {
+        
+        $sCmdNew = "";
+        switch ($sCmd) {
+            case "user":
+                $sCmdNew = "user_name";
+                break;
+            case "project":
+                $sCmdNew = "project_name";
+                break;
+            case "code":
+                $sCmdNew = "sale_code";
+                break;
+            case "condition":
+                $sCmdNew = "cron_condition";
+                break;
+            default:
+                $sCmdNew = $sCmd;
+                break;
+        }
+        
+        return $sCmdNew;
+        
+    }
+    
+}
diff --git a/app/Http/Controllers/Api/TG/HookController.php b/app/Http/Controllers/Api/TG/HookController.php
new file mode 100755
index 0000000..3875209
--- /dev/null
+++ b/app/Http/Controllers/Api/TG/HookController.php
@@ -0,0 +1,100 @@
+middleware('csrf')->except(['cmd']);
+        // 或者 $this->middleware('csrf')->only(['specificMethod']);
+    }
+
+    
+    public function cmd()
+    {
+        
+        try {
+            
+            $oTGHttp = new TGHttp();
+            $oTGHttp->sApiToken = env('telegram_token');
+            $oTGHttp->sApiChatId = env('telegram_chatid');
+            
+            $sUpdate = file_get_contents("php://input");
+            
+            $aUpdate = json_decode($sUpdate, true);
+            
+            @file_put_contents('/www/_tg/bot_log.txt', json_encode($aUpdate, JSON_PRETTY_PRINT));
+            
+            $aData['chatId'] = $aUpdate["message"]["chat"]["id"];
+            $aData['fromId'] = $aUpdate["message"]["from"]["id"];
+            
+            if (!isset($aUpdate["message"]["text"])) {
+                Http::response(200, 'not have text');
+            }
+            
+            $sText = $aUpdate["message"]["text"];
+            
+            // test
+            $sText = "\\//Article#List ni__aaa__bbb 111 222";
+            $sText = "///\\\SaleCode#SetRate__zzxx 2";
+            $sText = "///\\\SaleCode#List";
+            $sText = "///\\\SaleCode#Find zzxx";
+            $sText = "/Article#Like__sale_code zzx";
+            $sText = "////Article#Add jxxjjjj";
+//            $sText = "//\\\//Article#Del 9";
+//            $sText = "/Article#Set__1__user_name xxx";
+            
+            @$aArg = explode(" ", $sText);
+            @$aOption = explode("__", $aArg[0]);
+            
+            $sCmd = $this->cleanCmd($aOption[0]);
+            
+            list($sClass, $sFunc) = explode("#", $sCmd);
+            
+            unset($aOption[0]);
+            unset($aArg[0]);
+            
+            $aParams['aOption'] = $aOption;
+            $aParams['aArg'] = $aArg;
+            
+            $sClassPath = "App\\Services\\TG\\Hook\\".$sClass;
+
+            if (method_exists($sClassPath, $sFunc)) {
+                
+                $oInstans = new $sClassPath();
+                $r = $oInstans->$sFunc($aParams);
+                
+            } else {
+                $this->sendMessage("没有这个方法");
+            }
+            
+        } catch (\Exception $e) {
+            
+            $sMessage = "错误: " . $e->getMessage();
+            
+            $oTGHttp->sendToTG($sMessage);
+            
+            Http::response(200, 'error');
+            
+        }
+        
+    }
+    
+    private function cleanCmd($input) {
+        // 去掉所有的反斜杠
+        $input = str_replace('\\', '', $input);
+        // 去掉所有的正斜杠
+        $input = str_replace('/', '', $input);
+        
+        return $input;
+    }
+    
+}
diff --git a/app/Http/Controllers/Api/Tg/HookController.php b/app/Http/Controllers/Api/Tg/HookController.php
deleted file mode 100755
index 45ca8ef..0000000
--- a/app/Http/Controllers/Api/Tg/HookController.php
+++ /dev/null
@@ -1,230 +0,0 @@
-middleware('csrf')->except(['cmd']);
-        // 或者 $this->middleware('csrf')->only(['specificMethod']);
-    }
-
-    
-    public function cmd()
-    {
-        
-        $this->sApiToken = env('telegram_token');
-        $this->sApiChatId = env('telegram_chatid');
-        
-        $sUpdate = file_get_contents("php://input");
-        
-        $aUpdate = json_decode($sUpdate, true);
-        
-        @file_put_contents('/www/_tg/bot_log.txt', json_encode($aUpdate, JSON_PRETTY_PRINT));
-        
-        $aData['chatId'] = $aUpdate["message"]["chat"]["id"];
-        $aData['fromId'] = $aUpdate["message"]["from"]["id"];
-        
-        if (!isset($aUpdate["message"]["text"])) {
-            http_response_code(200);
-            echo "not have text";
-            exit;
-        }
-        
-        $sText = $aUpdate["message"]["text"];
-        
-        
-        // 打断
-        if ($sText === "/break") {
-            
-            $oTgStep->clearByFromId($aData["fromId"]);
-            
-            $this->sendMessage("ok");
-            
-            Http::response(200, 'ok');
-            
-        }
-        
-        // 命令列表
-        // /cmdList
-        if (strpos($sText, '/cmdList') === 0 || strpos($sText, '\/cmdList') === 0) {
-            
-            $aCmdList = [
-                '优惠码list'  => '/saleCodeList',
-                '优惠码find'  => '/saleCodeFind xxhh',
-//                '优惠码add'  => '/saleCodeAdd xxhh',
-//                '优惠码del'  => '/saleCodeDel__xxhh',
-//                '优惠码set'  => '/saleCodeSet__xxhh__field set',
-                '文章list'  => '/articleList',
-                '文章like'  => '/articleLike__field like',
-                '文章add'  => '/articleAdd__name',
-                '文章del'  => '/articleDel__id',
-                '文章set'  => '/articleSet__id__fild set',
-            ];
-            
-            $this->sendMessage(json_encode($aCmdList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            
-            Http::response(200, 'ok');
-            
-        }
-        
-        // 优惠list
-        if (strpos($sText, '/saleCodeList') === 0 || strpos($sText, '\/saleCodeList') === 0) {
-            
-            $aSaleCodeList = Article::select('sale_code', 'sale_rate')
-                ->distinct()
-                ->orderBy("sale_code")
-                ->get()
-                ->toArray();
-            
-            $this->sendMessage(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            
-            Http::response(200, 'ok');
-        }
-        
-        // 优惠find
-        if (strpos($sText, '/saleCodeFind') === 0 || strpos($sText, '\/saleCodeFind') === 0) {
-            
-            list(, $sSaleCode) = explode(" ", $sText);
-            
-            $aSaleCodeList = Article::select('sale_code', 'sale_rate')
-                ->where("sale_code", $sSaleCode)
-                ->distinct()
-                ->orderBy("sale_code")
-                ->get()
-                ->toArray();
-            
-            $this->sendMessage(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            
-            Http::response(200, 'ok');
-            
-        }
-        
-        // 文章list
-        if (strpos($sText, '/ArticleList') === 0 || strpos($sText, '\/ArticleList') === 0) {
-            
-            $aArticleList = Article::orderBy("user_name")->get()->toArray();
-            
-            foreach ($aArticleList as $row) {
-                $this->sendMessage(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            }
-            
-            Http::response(200, 'ok');
-        }
-        
-        // 文章 like
-        // /ArticleLike__user_name xxx
-        if (strpos($sText, '/ArticleLike') === 0 || strpos($sText, '\/ArticleLike') === 0) {
-            
-            list($sCmd, $sLike) = explode(" ", $sText);
-            list(, $sField) = explode("__", $sCmd);
-
-            $aArticleList = Article::where($sField, 'like', '%' . $sLike . '%')
-                            ->orderBy("user_name")
-                            ->get()
-                            ->toArray();
-
-            
-            foreach ($aArticleList as $row) {
-                $this->sendMessage(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            }
-            
-            Http::response(200, 'ok');
-        }
-        
-        // 文章 add
-        if (strpos($sText, '/articleAdd') === 0 || strpos($sText, '\/articleAdd') === 0) {
-            
-            list(, $sUserName) = explode(" ", $sText);
-            
-            $newArticle = new Article();
-            $newArticle->user_name = $sUserName;
-            $r = $newArticle->save();
-            
-            $this->sendMessage(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            
-            Http::response(200, 'ok');
-            
-        }
-        
-        // 文章 del
-        if (strpos($sText, '/articleDel') === 0 || strpos($sText, '\/articleDel') === 0) {
-            
-            list(, $iId) = explode(" ", $sText);
-
-            $article = Article::find($iId);
-
-            if ($article) {
-                $r = $article->delete();
-            } else {
-                $r = false;
-            }
-            
-            $this->sendMessage(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            
-            Http::response(200, 'ok');
-            
-        }
-        
-        // 文章 set
-        // /ArticleSet__id__user_name xxx
-        if (strpos($sText, '/ArticleSet') === 0 || strpos($sText, '\/ArticleSet') === 0) {
-            
-            list($sCmd, $sSet) = explode(" ", $sText);
-            list(, $iId, $sField) = explode("__", $sCmd, 3);
-
-            $article = Article::find($iId);
-
-            if ($article) {
-                $article->$sField = $sSet;
-
-                $r = $article->save();
-            } else {
-                // 处理未找到的情况
-            }
-
-            $this->sendMessage(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
-            
-            Http::response(200, 'ok');
-        }
-        
-    }
-    
-    private function sendMessage($sText = '?') {
-        
-        if (env('is_loc') === true) {
-            echo "
";
-            var_dump($sText);
-        } else {
-            $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sText);
-            file_get_contents($url);
-        }
-        
-    }
-    
-}
diff --git a/app/Http/Controllers/TestsController.php b/app/Http/Controllers/TestsController.php
index cfa17da..055e4e7 100755
--- a/app/Http/Controllers/TestsController.php
+++ b/app/Http/Controllers/TestsController.php
@@ -37,7 +37,7 @@ class TestsController
                     'type' => 'private'
                 ],
                 'date' => 1610000000,
-                "text" => "\/ArticleSet__7__user_name xxxzz",
+                "text" => "\/ArticleSet__5__sale_rate 1118.118",
             ]
         ];
 
diff --git a/app/Services/TG/Hook/Article.php b/app/Services/TG/Hook/Article.php
new file mode 100644
index 0000000..d209ae9
--- /dev/null
+++ b/app/Services/TG/Hook/Article.php
@@ -0,0 +1,93 @@
+get()->toArray();
+        
+        foreach ($aArticleList as $row) {
+            $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        }
+        
+        $this->oHttp::response(200, 'ok');
+    }
+    
+    public function Like($aParams)
+    {
+
+        $aArticleList = ModelArticle::where($this->cmdGood($aParams['aOption'][1]), 'like', '%' . $aParams['aArg'][1] . '%')
+                        ->orderBy("user_name")
+                        ->get()
+                        ->toArray();
+
+        if (empty($aArticleList)) {
+            $this->oTGHttp->sendToTG("没有");
+        }
+        
+        foreach ($aArticleList as $row) {
+            $this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        }
+        
+        $this->oHttp::response(200, 'ok');
+        
+    }
+    
+    public function Add($aParams)
+    {
+        
+        $newArticle = new ModelArticle();
+        $newArticle->user_name = $aParams['aArg'][1];
+        $r = $newArticle->save();
+        
+        $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        
+        $this->oHttp::response(200, 'ok');
+        
+    }
+    
+    public function Del($aParams)
+    {
+        
+        $article = ModelArticle::find($aParams['aArg'][1]);
+
+        if ($article) {
+            $r = $article->delete();
+        } else {
+            $r = false;
+        }
+        
+        $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        
+        $this->oHttp::response(200, 'ok');
+        
+    }
+    
+    // /ArticleSet__id__user_name xxx
+    public function Set($aParams)
+    {
+        $sField = $this->cmdGood($aParams['aOption'][2]);
+
+        $article = ModelArticle::find($aParams['aOption'][1]);
+        
+        $sSet = $aParams['aArg'][1];
+
+        if ($article) {
+            $article->$sField = $sSet;
+
+            $r = $article->save();
+        } else {
+            // 处理未找到的情况
+            throw new \Exception("Article not found");
+        }
+
+        $this->oTGHttp->sendToTG(json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        
+        $this->oHttp::response(200, 'ok');
+    }
+    
+}
diff --git a/app/Services/TG/Hook/Base.php b/app/Services/TG/Hook/Base.php
new file mode 100644
index 0000000..259e25f
--- /dev/null
+++ b/app/Services/TG/Hook/Base.php
@@ -0,0 +1,53 @@
+oHttp = new Http();
+        $this->oTGHttp = new TGHttp();
+    }
+    
+//    protected function sendMessage($sText = '?') {
+//        
+//        if (env('is_loc') === true) {
+//            echo "
";
+//            var_dump($sText);
+//        } else {
+//            $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sText);
+//            file_get_contents($url);
+//        }
+//        
+//    }
+    
+    protected function cmdGood($sCmd) {
+        
+        $sCmdNew = "";
+        switch ($sCmd) {
+            case "user":
+                $sCmdNew = "user_name";
+                break;
+            case "project":
+                $sCmdNew = "project_name";
+                break;
+            case "code":
+                $sCmdNew = "sale_code";
+                break;
+            case "condition":
+                $sCmdNew = "cron_condition";
+                break;
+            default:
+                $sCmdNew = $sCmd;
+                break;
+        }
+        
+        return $sCmdNew;
+        
+    }
+    
+}
diff --git a/app/Services/TG/Hook/Cmd.php b/app/Services/TG/Hook/Cmd.php
new file mode 100644
index 0000000..23b93fc
--- /dev/null
+++ b/app/Services/TG/Hook/Cmd.php
@@ -0,0 +1,28 @@
+ '/SaleCode#List',
+            '优惠码find'  => '/SaleCode#Find xxhh',
+            '优惠码rate'  => '/SaleCode#SetRate__xxzz 6.7',
+            '文章list'  => '/Article#List',
+            '文章like'  => '/Article#Like__field like',
+            '文章add'  => '/Article#Add__name',
+            '文章del'  => '/Article#Del__id',
+            '文章set'  => '/Article#Set__id__fild set',
+        ];
+        
+        $this->oTGHttp->sendToTG(json_encode($aCmdList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        
+        $this->oHttp::response(200, 'ok');
+        
+    }
+    
+}
diff --git a/app/Services/TG/Hook/SaleCode.php b/app/Services/TG/Hook/SaleCode.php
new file mode 100644
index 0000000..834e8b5
--- /dev/null
+++ b/app/Services/TG/Hook/SaleCode.php
@@ -0,0 +1,48 @@
+update(['sale_rate' => $aParams['aArg'][1]]);
+
+        $this->oTGHttp->sendToTG(json_encode($updatedRows, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        
+        $this->oHttp::response(200, 'ok');
+        
+    }
+    
+    public function List()
+    {
+        $aSaleCodeList = ModelArticle::select('sale_code', 'sale_rate')
+            ->distinct()
+            ->orderBy("sale_code")
+            ->get()
+            ->toArray();
+        
+        $this->oTGHttp->sendToTG(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        
+        $this->oHttp::response(200, 'ok');
+    }
+    
+    public function Find($aParams)
+    {
+        
+        $aSaleCodeList = ModelArticle::select('sale_code', 'sale_rate')
+            ->where("sale_code", $aParams['aArg'][1])
+            ->distinct()
+            ->orderBy("sale_code")
+            ->get()
+            ->toArray();
+        
+        $this->oTGHttp->sendToTG(json_encode($aSaleCodeList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
+        
+        $this->oHttp::response(200, 'ok');
+        
+    }
+    
+}
diff --git a/app/Services/TG/Http.php b/app/Services/TG/Http.php
new file mode 100644
index 0000000..f92674d
--- /dev/null
+++ b/app/Services/TG/Http.php
@@ -0,0 +1,23 @@
+";
+            var_dump($sMsg);
+        } else {
+            $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sText);
+            file_get_contents($url);
+        }
+        
+    }
+    
+}
diff --git a/public/index.php b/public/index.php
index 947d989..5d52263 100755
--- a/public/index.php
+++ b/public/index.php
@@ -4,6 +4,16 @@ use Illuminate\Http\Request;
 
 define('LARAVEL_START', microtime(true));
 
+function tomd($d, $type)
+{
+    echo "
";
+    var_dump($d);
+    
+    if ($type) {
+        exit;
+    }
+}
+
 // Determine if the application is in maintenance mode...
 if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
     require $maintenance;
diff --git a/routes/web.php b/routes/web.php
index 303cf71..d5463dd 100755
--- a/routes/web.php
+++ b/routes/web.php
@@ -3,7 +3,7 @@
 use Illuminate\Support\Facades\Route;
 use App\Http\Controllers\CronController;
 use App\Http\Controllers\TestsController;
-use App\Http\Controllers\Api\Tg\HookController;
+use App\Http\Controllers\Api\TG\HookController;
 
 //Route::get('/', [ArticleListController::class, 'fn'])->middleware('test');