TelegramWebHook.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <?php
  2. namespace App\Http\Controllers\api;
  3. use App\Constants\StepStatus;
  4. use App\Constants\Util;
  5. use App\Exceptions\MessageException;
  6. use App\Models\Message;
  7. use App\Models\User;
  8. use App\Services\QianBaoWithdrawService;
  9. use App\Services\SanJinRechargeService;
  10. use App\Services\SecretService;
  11. use App\Services\SettlementService;
  12. use App\Services\TopUpService;
  13. use App\Services\UserService;
  14. use App\Services\WalletService;
  15. use App\Services\WithdrawService;
  16. use App\Services\BalanceLogService;
  17. use Illuminate\Http\Request;
  18. use Illuminate\Support\Facades\App;
  19. use Illuminate\Support\Facades\Cache;
  20. use Illuminate\Support\Facades\DB;
  21. use Telegram\Bot\Api;
  22. use Telegram\Bot\Exceptions\TelegramSDKException;
  23. use Illuminate\Support\Facades\Log;
  24. use App\Services\BetService;
  25. use App\Services\IssueService;
  26. use App\Services\KeyboardService;
  27. use Telegram\Bot\FileUpload\InputFile;
  28. class TelegramWebHook extends BaseController
  29. {
  30. protected Api $telegram;
  31. public function __construct(Api $telegram)
  32. {
  33. $this->telegram = $telegram;
  34. parent::__construct();
  35. }
  36. public function handle(Request $request)
  37. {
  38. Log::error('Telegram 日志写入测试: ' . json_encode([$request->ip()], JSON_UNESCAPED_UNICODE));
  39. try {
  40. $telegram = new Api(config('services.telegram.token'));
  41. } catch (TelegramSDKException $e) {
  42. return response()->json(['status' => 'ok']);
  43. }
  44. try {
  45. $update = $telegram->getWebhookUpdate(); // 获取更新数据
  46. $update->callbackQuery;
  47. if ($update->has('callback_query')) {
  48. $callbackQuery = $update->callbackQuery;
  49. $message = $callbackQuery->message;
  50. $from = $callbackQuery->from;
  51. $data = $callbackQuery->data; // 获取 callback_data
  52. $callbackId = $callbackQuery->id; // 获取 callback_query 的 ID
  53. Util::delCache($message->chat->id);
  54. // Log::error('Telegram 回调数据(JSON): ' . json_encode($update, JSON_UNESCAPED_UNICODE));
  55. DB::beginTransaction();
  56. try {
  57. $chatId = $message->chat->id;
  58. $firstName = $message->chat->firstName;
  59. $username = '';
  60. $messageId = $message->messageId;
  61. if (!$from->isBot) {
  62. $chatId = $from->id;
  63. $firstName = $from->firstName;
  64. $username = $from->username;
  65. }
  66. $user = User::where('member_id', $chatId)->first();
  67. if (!$user) {
  68. $registerIp = request()->ip();
  69. $userStatus = 0;
  70. if(User::where('register_ip', $registerIp)->exists()){
  71. $userStatus = 1;
  72. }
  73. $user = new User();
  74. $user->member_id = $chatId;
  75. $user->register_ip = $registerIp;
  76. $user->status = $userStatus;
  77. }
  78. if ($username) $user->username = $username;
  79. $user->first_name = $firstName;
  80. $user->save();
  81. App::setLocale($user->language);
  82. //给每个用户生成一个专属的USDT钱包
  83. WalletService::getUserWallet($chatId);
  84. QianBaoWithdrawService::init($telegram, $data, $chatId, $firstName, $messageId);
  85. SanJinRechargeService::init($telegram, $data, $chatId, $firstName, $messageId);
  86. SecretService::init($telegram, $data, $chatId, $firstName, $messageId);
  87. UserService::init($telegram, $data, $chatId, $firstName, $messageId);
  88. // 查看余额弹窗
  89. if ($data === 'balanceAlert') {
  90. $alertText = WalletService::getBalance($chatId)['text'];
  91. WalletService::alertNotice($callbackId, $alertText);
  92. }
  93. // 今日流水弹窗
  94. if ($data === 'todayFlowAlert') {
  95. $alertText = BalanceLogService::getTodayFlowing($chatId)['text'];
  96. BalanceLogService::alertNotice($callbackId, $alertText);
  97. }
  98. // 近期注单弹窗
  99. if ($data === 'betsAlert') {
  100. Cache::put('message_id_bet_record_' . $chatId, 0, 600);
  101. $alertText = BetService::recentlyRecord($chatId);
  102. BetService::alertNotice($callbackId, $alertText);
  103. }
  104. //选择充值地址
  105. if ($data === "topUp@@TRC20" || $data === "topUp@@ERC20") {
  106. $type = preg_replace('/^topUp@@/', '', $data);
  107. $topService = new TopUpService();
  108. $res = $topService->scan($chatId, $messageId, $type);
  109. $telegram->deleteMessage([
  110. 'chat_id' => $chatId,
  111. 'message_id' => $messageId,
  112. ]);
  113. $telegram->sendPhoto($res);
  114. }
  115. //点击充值按钮
  116. if ($data === 'topup@@topup') {
  117. $res = TopUpService::chooseAddress($chatId, $messageId);
  118. $telegram->editMessageText($res);
  119. }
  120. //点击充值的账单按钮
  121. if ($data === 'topup@@bill') {
  122. $res = (new TopUpService())->bill($chatId, $firstName, $messageId);
  123. $telegram->editMessageText($res);
  124. }
  125. //点击我已付款按钮
  126. //手动充值(后台审核后到账)
  127. if ($data === 'topUp@@pay2') {
  128. $telegram->deleteMessage([
  129. 'chat_id' => $chatId,
  130. 'message_id' => $messageId
  131. ]);
  132. $res = TopUpService::pay2($chatId);
  133. $telegram->sendMessage($res);
  134. } //
  135. //自动充值
  136. elseif ($data === 'topUp@@pay') {
  137. $telegram->deleteMessage([
  138. 'chat_id' => $chatId,
  139. 'message_id' => $messageId
  140. ]);
  141. $topService = new TopUpService();
  142. $res = $topService->done($chatId);
  143. $telegram->sendMessage($res);
  144. }
  145. //充值首页
  146. if ($data === "topUp@@home" || $data === "topUp@@home1") {
  147. $returnMsg = WalletService::getBalance($chatId);
  148. if ($returnMsg) {
  149. if ($data === "topUp@@home1") {
  150. $telegram->deleteMessage([
  151. 'chat_id' => $chatId,
  152. 'message_id' => $messageId
  153. ]);
  154. $this->telegram->sendMessage($returnMsg);
  155. } else {
  156. $returnMsg['message_id'] = $messageId;
  157. $telegram->editMessageText($returnMsg);
  158. }
  159. }
  160. // $res = (new TopUpService())->index($chatId, $firstName, $messageId);
  161. // if ($data === "topUp@@home1") {
  162. // $telegram->deleteMessage([
  163. // 'chat_id' => $chatId,
  164. // 'message_id' => $messageId
  165. // ]);
  166. // $telegram->sendMessage($res);
  167. // } else {
  168. // $telegram->editMessageText($res);
  169. // }
  170. }
  171. //点击提现按钮
  172. if ($data === "withdraw@@apply") {
  173. $res = (new WithdrawService())->apply($chatId, $messageId);
  174. $telegram->editMessageText($res);
  175. }
  176. //地址管理
  177. if ($data === 'withdraw@@address') {
  178. $res = WithdrawService::getAddress($chatId, $messageId);
  179. $telegram->editMessageText($res);
  180. }
  181. //关闭本条消息
  182. if ($data === 'message@@close') {
  183. $telegram->deleteMessage([
  184. 'chat_id' => $chatId,
  185. 'message_id' => $messageId
  186. ]);
  187. }
  188. if ($data === 'withdrawAddress@@add') {
  189. $res = WithdrawService::addAddress($chatId, $messageId);
  190. $telegram->editMessageText($res);
  191. }
  192. //提现管理
  193. if ($data === "withdraw@@home") {
  194. // $res = WithdrawService::index($chatId, $firstName, $messageId);
  195. // $telegram->editMessageText($res);
  196. $telegram->deleteMessage([
  197. 'chat_id' => $chatId,
  198. 'message_id' => $messageId
  199. ]);
  200. $returnMsg = WalletService::getBalance($chatId);
  201. if ($returnMsg) {
  202. $this->telegram->sendMessage($returnMsg);
  203. }
  204. }
  205. //点击提现的账单按钮
  206. if ($data === "withdraw@@bill") {
  207. $res = (new WithdrawService())->bill($chatId, $firstName, $messageId);
  208. $telegram->editMessageText($res);
  209. // $telegram->sendMessage($res);
  210. // $text = "📅 请输入查询日期\n";
  211. // $date = date('Y-m-d');
  212. // $text .= "例如您要查询的日期 {$date}\n";
  213. // $text .= "那么请发送:【提现账单】{$date}\n";
  214. // $telegram->sendMessage([
  215. // 'chat_id' => $chatId,
  216. // 'text' => $text
  217. // ]);
  218. }
  219. if ($data === 'withdrawAddress@@done') {
  220. $res = WithdrawService::done($chatId, $messageId, $firstName);
  221. $telegram->editMessageText($res);
  222. }
  223. // 今日汇率
  224. if ($data === 'todayExchangeRate@@rate') {
  225. BetService::todayExchangeRate($chatId);
  226. // $telegram->sendMessage($res);
  227. }
  228. //查看开奖历史图片
  229. $pattern = "/^showLotteryHistory@@\d+$/";
  230. if (preg_match($pattern, $data)) {
  231. $id = preg_replace('/^showLotteryHistory@@/', '', $data);
  232. IssueService::sendLotteryImage($chatId, $id);
  233. }
  234. //选择投注记录
  235. $pattern = "/^betRecordType@@\d+$/";
  236. if (preg_match($pattern, $data)) {
  237. $type = preg_replace('/^betRecordType@@/', '', $data);
  238. Cache::put('message_id_bet_record_' . $chatId, intval($type), 600);
  239. $telegram->deleteMessage([
  240. 'chat_id' => $chatId,
  241. 'message_id' => $messageId,
  242. ]);
  243. $returnMsg = BetService::record($chatId);
  244. $telegram->sendMessage($returnMsg);
  245. }
  246. //选择提现地址
  247. $pattern = "/^withdrawAddress@@choose\d+$/";
  248. if (preg_match($pattern, $data)) {
  249. $id = preg_replace('/^withdrawAddress@@choose/', '', $data);
  250. $res = WithdrawService::chooseAddress($chatId, $firstName, $messageId, $id);
  251. $telegram->editMessageText($res);
  252. }
  253. //删除地址
  254. $pattern = "/^withdrawAddress@@del\d+$/";
  255. if (preg_match($pattern, $data)) {
  256. $id = preg_replace('/^withdrawAddress@@del/', '', $data);
  257. $res = WithdrawService::delAddress($chatId, $id, $messageId);
  258. $telegram->editMessageText($res);
  259. }
  260. //地址详情
  261. $pattern = "/^withdrawAddress@@detail\d+$/";
  262. if (preg_match($pattern, $data)) {
  263. $id = preg_replace('/^withdrawAddress@@detail/', '', $data);
  264. $res = WithdrawService::addressDetails($chatId, $messageId, $id);
  265. $telegram->editMessageText($res);
  266. }
  267. //充值账单,下一页
  268. $pattern = "/^topUpBillNextPage@@\d+$/";
  269. if (preg_match($pattern, $data)) {
  270. $page = preg_replace('/^topUpBillNextPage@@/', '', $data);
  271. $page = intval($page);
  272. $res = (new TopUpService())->bill($chatId, $firstName, $messageId, $page);
  273. $telegram->editMessageText($res);
  274. }
  275. //流水列表,下一页
  276. $pattern = "/^FlowingHistoryPage@@\d+$/";
  277. if (preg_match($pattern, $data)) {
  278. $page = preg_replace('/^FlowingHistoryPage@@/', '', $data);
  279. $page = intval($page);
  280. $returnMsg = BalanceLogService::getFlowingHistory($chatId, $messageId, $page);
  281. $telegram->editMessageText($returnMsg);
  282. }
  283. //提现账单,下一页
  284. $pattern = "/^withdrawBillNextPage@@\d+$/";
  285. if (preg_match($pattern, $data)) {
  286. $page = preg_replace('/^withdrawBillNextPage@@/', '', $data);
  287. $page = intval($page);
  288. $res = (new WithdrawService())->bill($chatId, $firstName, $messageId, $page);
  289. $telegram->editMessageText($res);
  290. }
  291. //近期注单,下一页
  292. $pattern = "/^betRecordNextPage@@\d+$/";
  293. if (preg_match($pattern, $data)) {
  294. $page = preg_replace('/^betRecordNextPage@@/', '', $data);
  295. $page = intval($page);
  296. $res = BetService::record($chatId, $messageId, $page);
  297. $telegram->editMessageText($res);
  298. }
  299. DB::commit();
  300. } //
  301. catch (MessageException $e) {
  302. DB::rollBack();
  303. $msg = $e->getMessage();
  304. $msg = json_decode($msg, true);
  305. $telegram->sendMessage($msg);
  306. } //
  307. catch (TelegramSDKException $e) {
  308. DB::rollBack();
  309. $m = new Message();
  310. $m->json = $e->getMessage();
  311. $m->save();
  312. $telegram->sendMessage([
  313. 'chat_id' => $chatId,
  314. 'text' => '‼️‼️系统发生了错误,请联系客服'
  315. ]);
  316. }//
  317. catch (\Exception $e) {
  318. DB::rollBack();
  319. $m = new Message();
  320. $m->json = json_encode([
  321. 'line' => $e->getLine(),
  322. 'message' => $e->getMessage()
  323. ]);
  324. $m->save();
  325. $telegram->sendMessage([
  326. 'chat_id' => $chatId,
  327. 'text' => '‼️‼️系统发生了错误,请联系客服'
  328. ]);
  329. }
  330. } //
  331. else {
  332. $update = $request->all();
  333. Log::error('Telegram 文字消息回复: ' . json_encode($update, JSON_UNESCAPED_UNICODE));
  334. if (isset($update['message'])) {
  335. $message = $update['message'];
  336. $chatId = $message['chat']['id'];
  337. $messageId = $message['message_id'];
  338. DB::beginTransaction();
  339. try {
  340. $m = new Message();
  341. $m->json = json_encode($update);
  342. $m->save();
  343. $returnMsg = $this->processChatMessage($chatId, $messageId, $message, $message['from']);
  344. if ($returnMsg) {
  345. if (isset($returnMsg['image']) && $returnMsg['image'] != '') {
  346. KeyboardService::sendMessage($returnMsg['chat_id'], $returnMsg['text'] ?? '', $returnMsg['keyboard'] ?? [], $returnMsg['image'] ?? '');
  347. } else if (isset($returnMsg['photo']) && $returnMsg['photo'] != '') {
  348. $this->telegram->sendPhoto($returnMsg);
  349. } else {
  350. $this->telegram->sendMessage($returnMsg);
  351. }
  352. }
  353. DB::commit();
  354. } catch (MessageException $e) {
  355. DB::rollBack();
  356. $msg = $e->getMessage();
  357. $msg = json_decode($msg, true);
  358. $telegram->sendMessage($msg);
  359. } //
  360. catch (TelegramSDKException $e) {
  361. DB::rollBack();
  362. $m = new Message();
  363. $m->json = $e->getMessage();
  364. $m->save();
  365. $telegram->sendMessage([
  366. 'chat_id' => $chatId,
  367. 'text' => '‼️‼️系统发生了错误,请联系客服'
  368. ]);
  369. }//
  370. catch (\Exception $e) {
  371. DB::rollBack();
  372. $m = new Message();
  373. $m->json = json_encode([
  374. 'line' => $e->getLine(),
  375. 'message' => $e->getMessage()
  376. ]);
  377. $m->save();
  378. Log::error('Telegram 处理消息异常: ' . $e->getMessage());
  379. $telegram->sendMessage([
  380. 'chat_id' => $chatId,
  381. 'text' => '‼️‼️系统发生了错误,请联系客服'
  382. ]);
  383. }
  384. }
  385. }
  386. } //
  387. catch (\Exception $e) {
  388. $m = new Message();
  389. $m->json = $e->getMessage();
  390. $m->save();
  391. if (!empty($chatId)) {
  392. $telegram->sendMessage([
  393. 'chat_id' => $chatId,
  394. 'text' => '‼️‼️系统发生了错误,请联系客服'
  395. ]);
  396. }
  397. }
  398. return response()->json(['status' => 'ok']);
  399. }
  400. /**
  401. * @description: 处理聊天消息
  402. * @param {*} $chatId
  403. * @param {*} $messageId
  404. * @param {*} $message
  405. * @param {*} $from
  406. * @throws TelegramSDKException
  407. */
  408. public function processChatMessage($chatId, $messageId, $message, $from)
  409. {
  410. $returnMsg = [];
  411. //用户发送图片,结算截图
  412. if (isset($message['photo'])) {
  413. $stepStatus = Cache::get(get_step_key($chatId), -1);
  414. $stepStatus = intval($stepStatus);
  415. // //结算截图
  416. if ($stepStatus === StepStatus::INPUT_IMAGE) {
  417. $photo = $message['photo'][count($message['photo']) - 1];
  418. return (new SettlementService())->photo($photo, $chatId);
  419. }//
  420. //充值截图
  421. else if ($stepStatus === StepStatus::INPUT_TOP_UP_IMAGE) {
  422. $photo = $message['photo'][count($message['photo']) - 1];
  423. return TopUpService::photo($chatId, $photo);
  424. } else {
  425. return [];
  426. }
  427. } //用户发送了消息
  428. else if (isset($message['text'])) {
  429. $text = $message['text'];
  430. $user = User::where('member_id', $chatId)->first();
  431. if (!$user) {
  432. $registerIp = request()->ip();
  433. $userStatus = 0;
  434. if(User::where('register_ip', $registerIp)->exists()){
  435. $userStatus = 1;
  436. }
  437. $user = new User();
  438. $user->member_id = $chatId;
  439. $user->register_ip = $registerIp;
  440. $user->status = $userStatus;
  441. }
  442. $user->first_name = $message['chat']['first_name'];
  443. if (isset($message['chat']['username'])) {
  444. $user->username = $message['chat']['username'];
  445. }
  446. $user->save();
  447. App::setLocale($user->language);
  448. if ($message['chat']['type'] === 'private') {
  449. // 校验开始菜单事件
  450. $returnMsg = KeyboardService::checkStart($chatId, $text);
  451. if ($returnMsg) {
  452. return $returnMsg;
  453. }
  454. switch ($text) {
  455. case "/start":
  456. Util::delCache($chatId);
  457. //给每个用户生成一个专属的USDT钱包
  458. WalletService::getUserWallet($chatId);
  459. self::setReplyKeyboard($chatId, $user->language);
  460. break;
  461. default:
  462. // 关键字回复
  463. $keyboardText = KeyboardService::findOne(['button' => $text]);
  464. if ($keyboardText) {
  465. $keyboard = [];
  466. if ($keyboardText['buttons']) {
  467. $keyboard = json_decode($keyboardText['buttons'], true);
  468. }
  469. Util::delCache($chatId);
  470. $res = [
  471. 'chat_id' => $chatId,
  472. 'text' => $keyboardText['reply'],
  473. // 'reply_to_message_id' => $messageId
  474. ];
  475. if ($keyboard) {
  476. $res['reply_markup'] = json_encode(['inline_keyboard' => $keyboard]);
  477. }
  478. if ($keyboardText['image']) {
  479. $res['photo'] = InputFile::create(url($keyboardText['image']));
  480. unset($res['text']);
  481. $res['caption'] = $text;
  482. $res['protect_content'] = true; // 防止转发
  483. }
  484. return $res;
  485. }
  486. $stepStatus = Cache::get(get_step_key($chatId), -1);
  487. $stepStatus = intval($stepStatus);
  488. $res = QianBaoWithdrawService::onMessage($chatId, $text, $messageId, $stepStatus);
  489. if (empty($res)) $res = SanJinRechargeService::onMessage($chatId, $text, $messageId, $stepStatus);
  490. if (empty($res)) $res = SecretService::onMessage($chatId, $text, $messageId, $stepStatus);
  491. if (!empty($res)) return $res;
  492. switch ($stepStatus) {
  493. case StepStatus::INPUT_TOP_UP_MONEY:
  494. return TopUpService::inputAmount($chatId, $text, $messageId);
  495. case StepStatus::INPUT_WITHDRAW_MONEY:
  496. $res = (new WithdrawService())->inputAmount($chatId, $text, $messageId);
  497. return $res[0];
  498. case StepStatus::INPUT_ADDRESS_TRC20:
  499. return WithdrawService::inputAddress($chatId, $text, $messageId);
  500. case StepStatus::INPUT_ADDRESS_ALIAS:
  501. return WithdrawService::inputAlias($chatId, $text, $messageId);
  502. }
  503. $returnMsg = BetService::bet($chatId, $text, $messageId);
  504. }
  505. return $returnMsg;
  506. }
  507. }
  508. return [];
  509. }
  510. /**
  511. * @description: 设置 start 回复菜单
  512. * @param {*} $chatId
  513. * @throws TelegramSDKException
  514. */
  515. public static function setReplyKeyboard($chatId, $language = 'en'): void
  516. {
  517. $replyInfo = KeyboardService::findOne(['button' => '开始使用', 'language' => $language]);
  518. if (empty($replyInfo)) {
  519. $replyInfo = KeyboardService::findOne(['button' => '开始使用', 'language' => 'en']);
  520. }
  521. $telegram = new Api(config('services.telegram.token'));
  522. $keyboard = [
  523. [lang('近期注单'), lang('今日流水'), lang('联系客服')], // 第一排按钮
  524. [lang('开奖历史'), lang('当期下注'), lang('查看余额')], // 第二排按钮
  525. [lang('投注大群')]
  526. ];
  527. if ($replyInfo && $replyInfo->buttons) {
  528. $keyboard = [];
  529. $buttons = json_decode($replyInfo->buttons, true);
  530. foreach ($buttons as $rowIndex => $row) {
  531. if (!empty($row)) {
  532. foreach ($row as $buttonIndex => $button) {
  533. // $keyboard[$rowIndex][$buttonIndex] = lang($button['text']);
  534. $keyboard[$rowIndex][$buttonIndex] = $button['text'];
  535. }
  536. }
  537. }
  538. $keyboard = array_values($keyboard); // 重新索引数组
  539. Log::error('自定义开始使用按钮: ' . json_encode($keyboard));
  540. }
  541. $botMsg = [];
  542. $botMsg['chat_id'] = $chatId;
  543. $replyMarkup = [
  544. 'keyboard' => $keyboard,
  545. 'resize_keyboard' => true, // 自适应大小
  546. 'one_time_keyboard' => false, // 保持显示,不会点击后收起
  547. ];
  548. $botMsg['reply_markup'] = json_encode($replyMarkup);
  549. if ($replyInfo) {
  550. $image = '';
  551. if ($replyInfo->image) {
  552. $image = url($replyInfo->image);
  553. }
  554. if ($image != '') {
  555. $botMsg['photo'] = InputFile::create($image);
  556. $botMsg['caption'] = lang($replyInfo->reply);
  557. $botMsg['protect_content'] = true; // 防止转发
  558. KeyboardService::telegram()->sendPhoto($botMsg);
  559. } else {
  560. $botMsg['text'] = lang($replyInfo->reply);
  561. KeyboardService::telegram()->sendMessage($botMsg);
  562. }
  563. } else {
  564. $telegram->sendMessage([
  565. 'chat_id' => $chatId,
  566. 'text' => lang('你好,请选择功能菜单'),
  567. 'reply_markup' => json_encode($replyMarkup),
  568. ]);
  569. }
  570. }
  571. }