seven 1 day ago
parent
commit
c1109fd6bc
1 changed files with 15 additions and 1 deletions
  1. 15 1
      app/Http/Controllers/api/TelegramWebHook.php

+ 15 - 1
app/Http/Controllers/api/TelegramWebHook.php

@@ -29,6 +29,7 @@ use App\Services\GameplayRuleService;
 use App\Services\BetService;
 use App\Services\IssueService;
 use App\Services\KeyboardService;
+use Telegram\Bot\FileUpload\InputFile;
 
 class TelegramWebHook extends Controller
 {
@@ -534,11 +535,14 @@ class TelegramWebHook extends Controller
             ['投注大群']
         ];
 
+        $botMsg = [];
+        $botMsg['chat_id'] = $chatId;
         $replyMarkup = [
             'keyboard' => $keyboard,
             'resize_keyboard' => true,    // 自适应大小
             'one_time_keyboard' => false, // 保持显示,不会点击后收起
         ];
+        $botMsg['reply_markup'] = json_encode($replyMarkup);
 
         if($replyInfo){
             $image = '';
@@ -546,7 +550,17 @@ class TelegramWebHook extends Controller
                 $image = url($replyInfo->image);
 
             }
-            KeyboardService::sendMessage($chatId, $replyInfo->text, $keyboard ,$image);
+            
+            if($image != ''){
+                $botMsg['photo'] = InputFile::create($image);
+                $botMsg['caption'] = $replyInfo->reply;
+                $botMsg['protect_content'] = true;  // 防止转发
+                KeyboardService::telegram()->sendPhoto($botMsg);
+            }else{
+                $botMsg['text'] = '你好,请选择功能菜单';
+                
+                KeyboardService::telegram()->sendMessage($botMsg);
+            }
         }else{
              $telegram->sendMessage([
                 'chat_id' => $chatId,