diff --git a/app/Http/Controllers/Api/TG/HookController.php b/app/Http/Controllers/Api/TG/HookController.php index 1798f95..5bfd1af 100755 --- a/app/Http/Controllers/Api/TG/HookController.php +++ b/app/Http/Controllers/Api/TG/HookController.php @@ -28,11 +28,11 @@ final class HookController $aData['chatId'] = $aUpdate["message"]["chat"]["id"]; $aData['fromId'] = $aUpdate["message"]["from"]["id"]; - $mSendType = false; - - if (isset($aUpdate["is_dove"])) { - $mSendType = "dove"; - } +// $mSendType = false; +// +// if (isset($aUpdate["is_dove"])) { +// $mSendType = "dove"; +// } // tomd($mSendType, 1); @@ -81,10 +81,10 @@ final class HookController // 返回可以是数组 if (is_array($r)) { foreach ($r as $row) { - $oTGHttp->sendToTG($row, $mSendType); + $oTGHttp->sendToTG($row, $aUpdate); } } else { - $oTGHttp->sendToTG($r, $mSendType); + $oTGHttp->sendToTG($r, $aUpdate); } Http::response(200); @@ -97,7 +97,7 @@ final class HookController } catch (\Throwable $e) { $sMessage = "错误(line:".$e->getLine()."): " . $e->getMessage(); - $oTGHttp->sendToTG($sMessage, $mSendType); + $oTGHttp->sendToTG($sMessage, $aUpdate); Http::response(200, 'error'); } diff --git a/app/Services/TG/Hook/Mod/Tom.php b/app/Services/TG/Hook/Mod/Tom.php new file mode 100644 index 0000000..68d0a5b --- /dev/null +++ b/app/Services/TG/Hook/Mod/Tom.php @@ -0,0 +1,15 @@ +sApiChatId = env('telegram_chatid'); } - public function sendToTG($sMsg, $mType = false) + public function sendToTG($sMsg, $aUpdate = []) { - if ($mType == "dove") { + if (isset($aUpdate["shell"]) && $aUpdate["shell"] == "cmd") { + + echo $sMsg; - if (env("is_loc") == true) { - echo "
";
-            }
+        } else if (isset($aUpdate["is_dove"]) && $aUpdate["is_dove"] == true) {
             
             echo $sMsg;
             
         } else {
             
-            if (env("is_loc") == true) {
-                echo "
";
-                echo($sMsg);
-            } else {
-                $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
-                file_get_contents($url);
-            }
-
+            $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
+            file_get_contents($url);
+            
         }
         
         
         
         
+//        if ($mType == "dove") {
+//            
+//            if (env("is_loc") == true) {
+//                echo "
";
+//            }
+//            
+//            echo $sMsg;
+//            
+//        } else {
+//            
+//            if (env("is_loc") == true) {
+//                echo "
";
+//                echo($sMsg);
+//            } else {
+//                $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
+//                file_get_contents($url);
+//            }
+//
+//        }
+        
+        
+        
+        
 //        if ($mType == "dove") {
 //            
 //            echo $sMsg;