Просмотр исходного кода

Merge branch 'master' of 47.76.126.2:seven/bot-28

seven 1 неделя назад
Родитель
Сommit
3793380125
1 измененных файлов с 66 добавлено и 67 удалено
  1. 66 67
      app/Services/BaseService.php

+ 66 - 67
app/Services/BaseService.php

@@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Log;
 use App\Jobs\SendTelegramMessageJob;
 use App\Jobs\SendTelegramGroupMessageJob;
 
-class BaseService 
+class BaseService
 {
     const YES = 1;
     const NOT = 0;
@@ -19,7 +19,7 @@ class BaseService
      * @description: 生成充值二维码
      * @param {*} $address 充值地址
      * @return {*}
-     */    
+     */
     public static function createRechargeQrCode($address = '')
     {
         $content = $address;
@@ -82,7 +82,7 @@ class BaseService
      * 判断指定地址的二维码是否已生成(已存在文件)
      *
      * @param string $address 充值地址
-     * @return 
+     * @return
      */
     public static function rechargeQrCodeExists(string $address)
     {
@@ -105,7 +105,7 @@ class BaseService
      * @param {*} $pid_name pid字段名称 默认pid
      * @param {*} $id_name  主键id 名称
      * @return {*}
-     */    
+     */
     public static function toTree($list,$pid=0,$level=0,$pid_name='pid',$id_name='id')
     {
         $arr=[];
@@ -123,7 +123,7 @@ class BaseService
     /**
      * @description: 实例化TG
      * @return {*}
-     */    
+     */
     public static function telegram()
     {
         return app(Api::class);
@@ -136,56 +136,55 @@ class BaseService
     //  * @param string $image 图片路径(可选)
     //  * @param bool $isTop 是否置顶第一条消息
     //  */
-    // public static function bettingGroupNotice($text, $keyboard = [], $image = '', $isTop = false)
-    // {
-    //     $bettingGroup = Config::where('field', 'betting_group')->first()->val;
-    //     $telegram = self::telegram();
-
-    //     $maxLen = 1024; // Telegram 限制:最多 1024 个字符
-    //     $textParts = [];
-
-    //     $textLength = mb_strlen($text, 'UTF-8');
-    //     for ($i = 0; $i < $textLength; $i += $maxLen) {
-    //         $textParts[] = mb_substr($text, $i, $maxLen, 'UTF-8');
-    //     }
-
-    //     $firstMessageId = null;
-
-    //     foreach ($textParts as $index => $partText) {
-    //         $botMsg = [
-    //             'chat_id' => "@{$bettingGroup}",
-    //             'text' => $partText,
-    //         ];
-
-    //         if (count($keyboard) > 0 && $index === 0) {
-    //             $botMsg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
-    //         }
-
-    //         if (!empty($image) && $index === 0) {
-    //             // 第一条带图片
-    //             $botMsg['photo'] = InputFile::create($image);
-    //             $botMsg['caption'] = $partText;
-    //             $botMsg['protect_content'] = true;
-    //             $response = $telegram->sendPhoto($botMsg);
-    //         } else {
-    //             $response = $telegram->sendMessage($botMsg);
-    //         }
-
-    //         if ($isTop && $index === 0 && $response && $response->get('message_id')) {
-    //             $firstMessageId = $response->get('message_id');
-    //         }
-
-    //         // 防止限流(可选)
-    //         usleep(300000);
-    //     }
-
-    //     if ($isTop && $firstMessageId) {
-    //         $telegram->pinChatMessage([
-    //             'chat_id' => "@{$bettingGroup}",
-    //             'message_id' => $firstMessageId
-    //         ]);
-    //     }
-    // }
+//     public static function bettingGroupNotice($text, $keyboard = [], $image = '', $isTop = false)
+//     {
+//         $bettingGroup = Config::where('field', 'betting_group')->first()->val;
+//         $telegram = self::telegram();
+//
+//         $maxLen = 1024; // Telegram 限制:最多 1024 个字符
+//         $textParts = [];
+//         $textLength = mb_strlen($text, 'UTF-8');
+//         for ($i = 0; $i < $textLength; $i += $maxLen) {
+//             $textParts[] = mb_substr($text, $i, $maxLen, 'UTF-8');
+//         }
+//
+//         $firstMessageId = null;
+//
+//         foreach ($textParts as $index => $partText) {
+//             $botMsg = [
+//                 'chat_id' => "@{$bettingGroup}",
+//                 'text' => $partText,
+//             ];
+//
+//             if (count($keyboard) > 0 && $index === 0) {
+//                 $botMsg['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
+//             }
+//
+//             if (!empty($image) && $index === 0) {
+//                 // 第一条带图片
+//                 $botMsg['photo'] = InputFile::create($image);
+//                 $botMsg['caption'] = $partText;
+//                 $botMsg['protect_content'] = true;
+//                 $response = $telegram->sendPhoto($botMsg);
+//             } else {
+//                 $response = $telegram->sendMessage($botMsg);
+//             }
+//
+//             if ($isTop && $index === 0 && $response && $response->get('message_id')) {
+//                 $firstMessageId = $response->get('message_id');
+//             }
+//
+//             // 防止限流(可选)
+//             usleep(300000);
+//         }
+//
+//         if ($isTop && $firstMessageId) {
+//             $telegram->pinChatMessage([
+//                 'chat_id' => "@{$bettingGroup}",
+//                 'message_id' => $firstMessageId
+//             ]);
+//         }
+//     }
 
     /**
      * @description: 群组通知
@@ -193,7 +192,7 @@ class BaseService
      * @param {array} $keyboard 操作按钮
      * @param {*string} $image  图片
      * @return {*}
-     */    
+     */
     public static function bettingGroupNotice($text ,$keyboard = [], $image = '' ,$isTop = false)
     {
         $bettingGroup = Config::where('field', 'betting_group')->first()->val;
@@ -223,7 +222,7 @@ class BaseService
                 'message_id' => $messageId
             ]);
         }
-        
+
     }
 
     /**
@@ -306,10 +305,10 @@ class BaseService
     {
 
         $replyInfo = KeyboardService::findOne(['button' => '投注菜单']);
-        
+
         if($replyInfo && $replyInfo->buttons){
             $buttons = json_decode($replyInfo->buttons, true);
-            
+
            foreach ($buttons as $row) {
                 $inlineButton[] = [];
                 foreach ($row as $button) {
@@ -334,7 +333,7 @@ class BaseService
             }
             $inlineButton = array_values($inlineButton);
             return $inlineButton;
-           
+
 
         }
         // $username = config('services.telegram.username');
@@ -369,22 +368,22 @@ class BaseService
     public static function generateRandomString($length = 8) {
         $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
         $randomString = '';
-        
+
         for ($i = 0; $i < $length; $i++) {
             $randomString .= $characters[rand(0, strlen($characters) - 1)];
         }
-        
+
         return $randomString;
     }
 
     public static function generateRandomNumber($length = 8) {
         $characters = '0123456789';
         $randomString = '';
-        
+
         for ($i = 0; $i < $length; $i++) {
             $randomString .= rand(1, 9);
         }
-        
+
         return $randomString;
     }
 
@@ -415,13 +414,13 @@ class BaseService
         } else {
             $memberSuffix = '0000'; // 默认值
         }
-        
+
         // 时间部分
         $timePart = date('YmdHis');
-        
+
         // 随机部分增加唯一性
         $randomPart = mt_rand(1000, 9999);
-        
+
         return $prefix . $timePart . $randomPart . $memberSuffix;
     }