Ken 1 주 전
부모
커밋
96093fba09
1개의 변경된 파일11개의 추가작업 그리고 8개의 파일을 삭제
  1. 11 8
      app/Services/BaseService.php

+ 11 - 8
app/Services/BaseService.php

@@ -188,7 +188,7 @@ class BaseService
 //         }
 //     }
 
-    public static function bettingGroupNotice2($text, $keyboard = [], $image = '', $isTop = false): array
+    public static function bettingGroupNotice2($text, $keyboard = [], $image = '', $isTop = false): void
     {
 
         $bettingGroup = Config::where('field', 'betting_group')->first()->val;
@@ -203,7 +203,6 @@ class BaseService
                 $texts[] = $item;
             }
         }
-        $res = [];
         foreach ($texts as $index => $item) {
             $botMsg = [
                 'chat_id' => "@{$bettingGroup}",
@@ -220,17 +219,21 @@ class BaseService
                 $botMsg['photo'] = $image;
                 $botMsg['caption'] = $item;
                 $botMsg['protect_content'] = true;  // 防止转发
-
+                $response = self::telegram()->sendPhoto($botMsg);
             } else {
-//                $res[] = $botMsg;
+           $response = self::telegram()->sendMessage($botMsg);
             }
 
-            if ($index == 0 && $isTop) {
-                $botMsg['is_top'] = $isTop;
+            if ($index == 0 && $isTop === true) {
+                // 获取消息ID
+                $messageId = $response->get('message_id');
+                // 置顶消息
+                self::telegram()->pinChatMessage([
+                    'chat_id' => "@{$bettingGroup}",
+                    'message_id' => $messageId
+                ]);
             }
-            $res[] = $botMsg;
         }
-        return $res;
     }
 
     /**