Ken před 1 týdnem
rodič
revize
9e953212bc
1 změnil soubory, kde provedl 7 přidání a 55 odebrání
  1. 7 55
      app/Services/BaseService.php

+ 7 - 55
app/Services/BaseService.php

@@ -188,52 +188,6 @@ class BaseService
 //         }
 //     }
 
-    public static function bettingGroupNotice2($text, $keyboard = [], $image = '', $isTop = false): void
-    {
-
-        $bettingGroup = Config::where('field', 'betting_group')->first()->val;
-        $array = explode("\n", $text);
-        $texts = [];
-        foreach ($array as $item) {
-            if (count($texts) == 0) {
-                $texts[] = $item;
-            } else if (strlen($texts[count($texts) - 1] . $item) <= 4096) {
-                $texts[count($texts) - 1] .= $item;
-            } else {
-                $texts[] = $item;
-            }
-        }
-        foreach ($texts as $index => $item) {
-            $botMsg = [
-                'chat_id' => "@{$bettingGroup}",
-                'text' => $item,
-                'index' => $index
-            ];
-
-            if ($index == 0 && count($keyboard) > 0) {
-                $botMsg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
-            }
-            if ($index == 0 && !empty($image)) {
-                unset($botMsg['text']);
-                $botMsg['photo'] = InputFile::create($image);
-                $botMsg['caption'] = $item;
-                $botMsg['protect_content'] = true;  // 防止转发
-                $response = self::telegram()->sendPhoto($botMsg);
-            } else {
-           $response = self::telegram()->sendMessage($botMsg);
-            }
-
-            if ($index == 0 && $isTop === true) {
-                // 获取消息ID
-                $messageId = $response->get('message_id');
-                // 置顶消息
-                self::telegram()->pinChatMessage([
-                    'chat_id' => "@{$bettingGroup}",
-                    'message_id' => $messageId
-                ]);
-            }
-        }
-    }
 
     /**
      * @description: 群组通知
@@ -243,24 +197,26 @@ class BaseService
      */
     public static function bettingGroupNotice($text, $keyboard = [], $image = '', $isTop = false): void
     {
+
         $bettingGroup = Config::where('field', 'betting_group')->first()->val;
         $array = explode("\n", $text);
         $texts = [];
         foreach ($array as $item) {
-            if (empty($texts) || strlen($texts[count($texts) - 1] . $item) <= 4096) {
+            if (count($texts) == 0) {
+                $texts[] = $item;
+            } else if (strlen($texts[count($texts) - 1] . $item) <= 4096) {
                 $texts[count($texts) - 1] .= $item;
             } else {
                 $texts[] = $item;
             }
         }
-
         foreach ($texts as $index => $item) {
             $botMsg = [
                 'chat_id' => "@{$bettingGroup}",
-                'text' => $item
+                'text' => $item,
+                'index' => $index
             ];
 
-
             if ($index == 0 && count($keyboard) > 0) {
                 $botMsg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
             }
@@ -271,7 +227,7 @@ class BaseService
                 $botMsg['protect_content'] = true;  // 防止转发
                 $response = self::telegram()->sendPhoto($botMsg);
             } else {
-                $response = self::telegram()->sendMessage($botMsg);
+           $response = self::telegram()->sendMessage($botMsg);
             }
 
             if ($index == 0 && $isTop === true) {
@@ -283,11 +239,7 @@ class BaseService
                     'message_id' => $messageId
                 ]);
             }
-
-
         }
-
-
     }
 
     /**