Ken 2 주 전
부모
커밋
e41f39cb69
3개의 변경된 파일49개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 0
      app/Constants/StepStatus.php
  2. 6 3
      app/Http/Controllers/api/TelegramWebHook.php
  3. 39 0
      app/Services/SecretService.php

+ 4 - 0
app/Constants/StepStatus.php

@@ -35,4 +35,8 @@ class StepStatus
     const QB_INPUT_ALIAS = 22;//输入账号别名
 
     const INPUT_RECHARGE_SJ_MONEY = 21;//输入 三斤充值金额
+
+
+    const MY_INPUT_OLD_SECRET = 23;//输入原账号秘钥
+
 }

+ 6 - 3
app/Http/Controllers/api/TelegramWebHook.php

@@ -398,8 +398,8 @@ class TelegramWebHook extends Controller
                     $returnMsg = $this->processChatMessage($chatId, $messageId, $message, $message['from']);
                     if ($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'] != '') {
+                            KeyboardService::sendMessage($returnMsg['chat_id'], $returnMsg['text'] ?? '', $returnMsg['keyboard'] ?? [], $returnMsg['image'] ?? '');
+                        } else if (isset($returnMsg['photo']) && $returnMsg['photo'] != '') {
                             $this->telegram->sendPhoto($returnMsg);
                         } else {
                             $this->telegram->sendMessage($returnMsg);
@@ -627,9 +627,12 @@ class TelegramWebHook extends Controller
                         $stepStatus = Cache::get(get_step_key($chatId), -1);
                         $stepStatus = intval($stepStatus);
                         $res = QianBaoWithdrawService::onMessage($chatId, $text, $messageId, $stepStatus);
-                        if(empty($res)){
+                        if (empty($res)) {
                             $res = SanJinRechargeService::onMessage($chatId, $text, $messageId, $stepStatus);
                         }
+                        if (empty($res)) {
+                            $res = SecretService::onMessage($chatId, $text, $messageId, $stepStatus);
+                        }
                         if (!empty($res)) return $res;
                         switch ($stepStatus) {
                             case StepStatus::INPUT_TOP_UP_MONEY:

+ 39 - 0
app/Services/SecretService.php

@@ -2,6 +2,8 @@
 
 namespace App\Services;
 
+use App\Constants\StepStatus;
+use Illuminate\Support\Facades\Cache;
 use Telegram\Bot\Api;
 use Telegram\Bot\Exceptions\TelegramSDKException;
 
@@ -21,6 +23,43 @@ class SecretService
             $res = SecretService::index($chatId, $messageId);
             $telegram->editMessageText($res);
         }
+
+
+        //找回账号
+        if ($data === "secret@@retrieve") {
+            $res = SecretService::index($chatId, $messageId);
+            $telegram->editMessageText($res);
+        }
+    }
+
+    public static function onMessage($chatId, $text, $messageId, $stepStatus): null|array
+    {
+        return match ($stepStatus) {
+            StepStatus::MY_INPUT_OLD_SECRET => SecretService::inputOldSecret($chatId, $text, $messageId),
+        };
+    }
+
+
+    private static function inputOldSecret($chatId, $secret, $messageId): array
+    {
+        $text = "";
+        return [
+            'chat_id' => $chatId,
+            'text' => $text,
+        ];
+    }
+
+
+    private static function retrieve($chatId, $messageId): array
+    {
+
+
+        Cache::put(get_step_key($chatId), StepStatus::MY_INPUT_OLD_SECRET);
+        return [
+            'chat_id' => $chatId,
+            'text' => '请输入原账号的秘钥',
+            'message_id' => $messageId,
+        ];
     }
 
     private static function index($chatId, $messageId): array