Ken 5 dagar sedan
förälder
incheckning
fd126c9170
1 ändrade filer med 4 tillägg och 4 borttagningar
  1. 4 4
      app/Http/Controllers/api/TelegramWebHook.php

+ 4 - 4
app/Http/Controllers/api/TelegramWebHook.php

@@ -40,7 +40,7 @@ class TelegramWebHook extends BaseController
 
     public function handle(Request $request): JsonResponse
     {
-        Log::error('Telegram 日志写入测试: ' . json_encode([$request->ip()], JSON_UNESCAPED_UNICODE));
+//        Log::error('Telegram 日志写入测试: ' . json_encode([$request->ip()], JSON_UNESCAPED_UNICODE));
 
         try {
             $telegram = new Api(config('services.telegram.token'));
@@ -100,7 +100,7 @@ class TelegramWebHook extends BaseController
                     DB::beginTransaction();
                     try {
                         $returnMsg = $this->processChatMessage($chatId, $messageId, $message, $message['from']);
-                        if ($returnMsg) {
+                        if (!empty($returnMsg)) {
                             if (isset($returnMsg['image']) && $returnMsg['image'] != '') {
                                 KeyboardService::sendMessage($returnMsg['chat_id'], $returnMsg['text'] ?? '', $returnMsg['keyboard'] ?? [], $returnMsg['image'] ?? '');
                             } else if (isset($returnMsg['photo']) && $returnMsg['photo'] != '') {
@@ -110,7 +110,8 @@ class TelegramWebHook extends BaseController
                             }
                         }
                         DB::commit();
-                    } catch (TelegramSDKException $e) {
+                    } //
+                    catch (TelegramSDKException $e) {
                         DB::rollBack();
                         $telegram->sendMessage(['chat_id' => $chatId, 'text' => '‼️‼️系统发生了错误,请联系客服']);
                     }//
@@ -147,7 +148,6 @@ class TelegramWebHook extends BaseController
      */
     public function processChatMessage($chatId, $messageId, $message, $from)
     {
-
         //用户发送图片,结算截图
         if (isset($message['photo'])) {
             $stepStatus = Cache::get(get_step_key($chatId), -1);