|
|
@@ -50,89 +50,96 @@ class TelegramWebHook extends BaseController
|
|
|
public function handle(Request $request)
|
|
|
{
|
|
|
Log::error('Telegram 日志写入测试: ' . json_encode([$request->ip()], JSON_UNESCAPED_UNICODE));
|
|
|
- $telegram = new Api(config('services.telegram.token'));
|
|
|
- $update = $telegram->getWebhookUpdate(); // 获取更新数据
|
|
|
- $update->callbackQuery;
|
|
|
- if ($update->has('callback_query')) {
|
|
|
- $callbackQuery = $update->callbackQuery;
|
|
|
- $message = $callbackQuery->message;
|
|
|
- $from = $callbackQuery->from;
|
|
|
- $data = $callbackQuery->data; // 获取 callback_data
|
|
|
- $callbackId = $callbackQuery->id; // 获取 callback_query 的 ID
|
|
|
- Util::delCache($message->chat->id);
|
|
|
- // Log::error('Telegram 回调数据(JSON): ' . json_encode($update, JSON_UNESCAPED_UNICODE));
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- $chatId = $message->chat->id;
|
|
|
- $firstName = $message->chat->firstName;
|
|
|
- $username = '';
|
|
|
- $messageId = $message->messageId;
|
|
|
- if (!$from->isBot) {
|
|
|
- $chatId = $from->id;
|
|
|
- $firstName = $from->firstName;
|
|
|
- $username = $from->username;
|
|
|
- }
|
|
|
|
|
|
- $user = User::where('member_id', $chatId)->first();
|
|
|
- if (!$user) {
|
|
|
- $user = new User();
|
|
|
- $user->member_id = $chatId;
|
|
|
- }
|
|
|
- if ($username) $user->username = $username;
|
|
|
- $user->first_name = $firstName;
|
|
|
- $user->save();
|
|
|
- App::setLocale($user->language);
|
|
|
+ try {
|
|
|
+ $telegram = new Api(config('services.telegram.token'));
|
|
|
+ } catch (TelegramSDKException $e) {
|
|
|
+ return response()->json(['status' => 'ok']);
|
|
|
+ }
|
|
|
|
|
|
- //给每个用户生成一个专属的USDT钱包
|
|
|
- WalletService::getUserWallet($chatId);
|
|
|
+ try {
|
|
|
+ $update = $telegram->getWebhookUpdate(); // 获取更新数据
|
|
|
+ $update->callbackQuery;
|
|
|
+ if ($update->has('callback_query')) {
|
|
|
+ $callbackQuery = $update->callbackQuery;
|
|
|
+ $message = $callbackQuery->message;
|
|
|
+ $from = $callbackQuery->from;
|
|
|
+ $data = $callbackQuery->data; // 获取 callback_data
|
|
|
+ $callbackId = $callbackQuery->id; // 获取 callback_query 的 ID
|
|
|
+ Util::delCache($message->chat->id);
|
|
|
+ // Log::error('Telegram 回调数据(JSON): ' . json_encode($update, JSON_UNESCAPED_UNICODE));
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $chatId = $message->chat->id;
|
|
|
+ $firstName = $message->chat->firstName;
|
|
|
+ $username = '';
|
|
|
+ $messageId = $message->messageId;
|
|
|
+ if (!$from->isBot) {
|
|
|
+ $chatId = $from->id;
|
|
|
+ $firstName = $from->firstName;
|
|
|
+ $username = $from->username;
|
|
|
+ }
|
|
|
|
|
|
+ $user = User::where('member_id', $chatId)->first();
|
|
|
+ if (!$user) {
|
|
|
+ $user = new User();
|
|
|
+ $user->member_id = $chatId;
|
|
|
+ }
|
|
|
+ if ($username) $user->username = $username;
|
|
|
+ $user->first_name = $firstName;
|
|
|
+ $user->save();
|
|
|
+ App::setLocale($user->language);
|
|
|
|
|
|
- QianBaoWithdrawService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
- SanJinRechargeService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
- SecretService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
- UserService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
+ //给每个用户生成一个专属的USDT钱包
|
|
|
+ WalletService::getUserWallet($chatId);
|
|
|
|
|
|
|
|
|
- // 查看余额弹窗
|
|
|
- if ($data === 'balanceAlert') {
|
|
|
- $alertText = WalletService::getBalance($chatId)['text'];
|
|
|
- WalletService::alertNotice($callbackId, $alertText);
|
|
|
- }
|
|
|
- // 今日流水弹窗
|
|
|
- if ($data === 'todayFlowAlert') {
|
|
|
- $alertText = BalanceLogService::getTodayFlowing($chatId)['text'];
|
|
|
- BalanceLogService::alertNotice($callbackId, $alertText);
|
|
|
- }
|
|
|
- // 近期注单弹窗
|
|
|
- if ($data === 'betsAlert') {
|
|
|
- Cache::put('message_id_bet_record_' . $chatId, 0, 600);
|
|
|
- $alertText = BetService::recentlyRecord($chatId);
|
|
|
- BetService::alertNotice($callbackId, $alertText);
|
|
|
- }
|
|
|
+ QianBaoWithdrawService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
+ SanJinRechargeService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
+ SecretService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
+ UserService::init($telegram, $data, $chatId, $firstName, $messageId);
|
|
|
|
|
|
- //选择充值地址
|
|
|
- if ($data === "topUp@@TRC20" || $data === "topUp@@ERC20") {
|
|
|
- $type = preg_replace('/^topUp@@/', '', $data);
|
|
|
- $topService = new TopUpService();
|
|
|
- $res = $topService->scan($chatId, $messageId, $type);
|
|
|
- $telegram->deleteMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'message_id' => $messageId,
|
|
|
- ]);
|
|
|
- $telegram->sendPhoto($res);
|
|
|
- }
|
|
|
|
|
|
- //点击充值按钮
|
|
|
- if ($data === 'topup@@topup') {
|
|
|
+ // 查看余额弹窗
|
|
|
+ if ($data === 'balanceAlert') {
|
|
|
+ $alertText = WalletService::getBalance($chatId)['text'];
|
|
|
+ WalletService::alertNotice($callbackId, $alertText);
|
|
|
+ }
|
|
|
+ // 今日流水弹窗
|
|
|
+ if ($data === 'todayFlowAlert') {
|
|
|
+ $alertText = BalanceLogService::getTodayFlowing($chatId)['text'];
|
|
|
+ BalanceLogService::alertNotice($callbackId, $alertText);
|
|
|
+ }
|
|
|
+ // 近期注单弹窗
|
|
|
+ if ($data === 'betsAlert') {
|
|
|
+ Cache::put('message_id_bet_record_' . $chatId, 0, 600);
|
|
|
+ $alertText = BetService::recentlyRecord($chatId);
|
|
|
+ BetService::alertNotice($callbackId, $alertText);
|
|
|
+ }
|
|
|
|
|
|
- $res = TopUpService::chooseAddress($chatId, $messageId);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
+ //选择充值地址
|
|
|
+ if ($data === "topUp@@TRC20" || $data === "topUp@@ERC20") {
|
|
|
+ $type = preg_replace('/^topUp@@/', '', $data);
|
|
|
+ $topService = new TopUpService();
|
|
|
+ $res = $topService->scan($chatId, $messageId, $type);
|
|
|
+ $telegram->deleteMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'message_id' => $messageId,
|
|
|
+ ]);
|
|
|
+ $telegram->sendPhoto($res);
|
|
|
+ }
|
|
|
|
|
|
- //点击充值的账单按钮
|
|
|
- if ($data === 'topup@@bill') {
|
|
|
- $res = (new TopUpService())->bill($chatId, $firstName, $messageId);
|
|
|
- $telegram->editMessageText($res);
|
|
|
+ //点击充值按钮
|
|
|
+ if ($data === 'topup@@topup') {
|
|
|
+
|
|
|
+ $res = TopUpService::chooseAddress($chatId, $messageId);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
+
|
|
|
+ //点击充值的账单按钮
|
|
|
+ if ($data === 'topup@@bill') {
|
|
|
+ $res = (new TopUpService())->bill($chatId, $firstName, $messageId);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
|
|
|
|
|
|
// $text = "📅 请输入查询日期\n";
|
|
|
@@ -143,105 +150,105 @@ class TelegramWebHook extends BaseController
|
|
|
// 'chat_id' => $chatId,
|
|
|
// 'text' => $text
|
|
|
// ]);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- //点击我已付款按钮
|
|
|
- //手动充值(后台审核后到账)
|
|
|
- if ($data === 'topUp@@pay2') {
|
|
|
- $telegram->deleteMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'message_id' => $messageId
|
|
|
- ]);
|
|
|
- $res = TopUpService::pay2($chatId);
|
|
|
- $telegram->sendMessage($res);
|
|
|
- } //
|
|
|
- //自动充值
|
|
|
- elseif ($data === 'topUp@@pay') {
|
|
|
- $telegram->deleteMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'message_id' => $messageId
|
|
|
- ]);
|
|
|
- $topService = new TopUpService();
|
|
|
- $res = $topService->done($chatId);
|
|
|
- $telegram->sendMessage($res);
|
|
|
- }
|
|
|
+ //点击我已付款按钮
|
|
|
+ //手动充值(后台审核后到账)
|
|
|
+ if ($data === 'topUp@@pay2') {
|
|
|
+ $telegram->deleteMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'message_id' => $messageId
|
|
|
+ ]);
|
|
|
+ $res = TopUpService::pay2($chatId);
|
|
|
+ $telegram->sendMessage($res);
|
|
|
+ } //
|
|
|
+ //自动充值
|
|
|
+ elseif ($data === 'topUp@@pay') {
|
|
|
+ $telegram->deleteMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'message_id' => $messageId
|
|
|
+ ]);
|
|
|
+ $topService = new TopUpService();
|
|
|
+ $res = $topService->done($chatId);
|
|
|
+ $telegram->sendMessage($res);
|
|
|
+ }
|
|
|
+
|
|
|
+ //充值首页
|
|
|
+ if ($data === "topUp@@home" || $data === "topUp@@home1") {
|
|
|
+ $returnMsg = WalletService::getBalance($chatId);
|
|
|
+ if ($returnMsg) {
|
|
|
+ if ($data === "topUp@@home1") {
|
|
|
+ $telegram->deleteMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'message_id' => $messageId
|
|
|
+ ]);
|
|
|
+ $this->telegram->sendMessage($returnMsg);
|
|
|
+ } else {
|
|
|
+ $returnMsg['message_id'] = $messageId;
|
|
|
+ $telegram->editMessageText($returnMsg);
|
|
|
+ }
|
|
|
|
|
|
- //充值首页
|
|
|
- if ($data === "topUp@@home" || $data === "topUp@@home1") {
|
|
|
- $returnMsg = WalletService::getBalance($chatId);
|
|
|
- if ($returnMsg) {
|
|
|
- if ($data === "topUp@@home1") {
|
|
|
- $telegram->deleteMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'message_id' => $messageId
|
|
|
- ]);
|
|
|
- $this->telegram->sendMessage($returnMsg);
|
|
|
- } else {
|
|
|
- $returnMsg['message_id'] = $messageId;
|
|
|
- $telegram->editMessageText($returnMsg);
|
|
|
}
|
|
|
|
|
|
+ // $res = (new TopUpService())->index($chatId, $firstName, $messageId);
|
|
|
+ // if ($data === "topUp@@home1") {
|
|
|
+ // $telegram->deleteMessage([
|
|
|
+ // 'chat_id' => $chatId,
|
|
|
+ // 'message_id' => $messageId
|
|
|
+ // ]);
|
|
|
+ // $telegram->sendMessage($res);
|
|
|
+ // } else {
|
|
|
+ // $telegram->editMessageText($res);
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
- // $res = (new TopUpService())->index($chatId, $firstName, $messageId);
|
|
|
- // if ($data === "topUp@@home1") {
|
|
|
- // $telegram->deleteMessage([
|
|
|
- // 'chat_id' => $chatId,
|
|
|
- // 'message_id' => $messageId
|
|
|
- // ]);
|
|
|
- // $telegram->sendMessage($res);
|
|
|
- // } else {
|
|
|
- // $telegram->editMessageText($res);
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- //点击提现按钮
|
|
|
- if ($data === "withdraw@@apply") {
|
|
|
- $res = (new WithdrawService())->apply($chatId, $messageId);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
+ //点击提现按钮
|
|
|
+ if ($data === "withdraw@@apply") {
|
|
|
+ $res = (new WithdrawService())->apply($chatId, $messageId);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- //地址管理
|
|
|
- if ($data === 'withdraw@@address') {
|
|
|
- $res = WithdrawService::getAddress($chatId, $messageId);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
+ //地址管理
|
|
|
+ if ($data === 'withdraw@@address') {
|
|
|
+ $res = WithdrawService::getAddress($chatId, $messageId);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- //关闭本条消息
|
|
|
- if ($data === 'message@@close') {
|
|
|
- $telegram->deleteMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'message_id' => $messageId
|
|
|
- ]);
|
|
|
- }
|
|
|
+ //关闭本条消息
|
|
|
+ if ($data === 'message@@close') {
|
|
|
+ $telegram->deleteMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'message_id' => $messageId
|
|
|
+ ]);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- if ($data === 'withdrawAddress@@add') {
|
|
|
- $res = WithdrawService::addAddress($chatId, $messageId);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
+ if ($data === 'withdrawAddress@@add') {
|
|
|
+ $res = WithdrawService::addAddress($chatId, $messageId);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
- //提现管理
|
|
|
- if ($data === "withdraw@@home") {
|
|
|
- // $res = WithdrawService::index($chatId, $firstName, $messageId);
|
|
|
- // $telegram->editMessageText($res);
|
|
|
- $telegram->deleteMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'message_id' => $messageId
|
|
|
- ]);
|
|
|
- $returnMsg = WalletService::getBalance($chatId);
|
|
|
- if ($returnMsg) {
|
|
|
- $this->telegram->sendMessage($returnMsg);
|
|
|
+ //提现管理
|
|
|
+ if ($data === "withdraw@@home") {
|
|
|
+ // $res = WithdrawService::index($chatId, $firstName, $messageId);
|
|
|
+ // $telegram->editMessageText($res);
|
|
|
+ $telegram->deleteMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'message_id' => $messageId
|
|
|
+ ]);
|
|
|
+ $returnMsg = WalletService::getBalance($chatId);
|
|
|
+ if ($returnMsg) {
|
|
|
+ $this->telegram->sendMessage($returnMsg);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //点击提现的账单按钮
|
|
|
- if ($data === "withdraw@@bill") {
|
|
|
- $res = (new WithdrawService())->bill($chatId, $firstName, $messageId);
|
|
|
- $telegram->editMessageText($res);
|
|
|
+ //点击提现的账单按钮
|
|
|
+ if ($data === "withdraw@@bill") {
|
|
|
+ $res = (new WithdrawService())->bill($chatId, $firstName, $messageId);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
// $telegram->sendMessage($res);
|
|
|
// $text = "📅 请输入查询日期\n";
|
|
|
// $date = date('Y-m-d');
|
|
|
@@ -251,157 +258,102 @@ class TelegramWebHook extends BaseController
|
|
|
// 'chat_id' => $chatId,
|
|
|
// 'text' => $text
|
|
|
// ]);
|
|
|
- }
|
|
|
-
|
|
|
- if ($data === 'withdrawAddress@@done') {
|
|
|
- $res = WithdrawService::done($chatId, $messageId, $firstName);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
-
|
|
|
- // 今日汇率
|
|
|
- if ($data === 'todayExchangeRate@@rate') {
|
|
|
- $res = BetService::todayExchangeRate($chatId);
|
|
|
- // $telegram->sendMessage($res);
|
|
|
- }
|
|
|
-
|
|
|
- //查看开奖历史图片
|
|
|
- $pattern = "/^showLotteryHistory@@\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $id = preg_replace('/^showLotteryHistory@@/', '', $data);
|
|
|
- $res = IssueService::sendLotteryImage($chatId, $id);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- //选择投注记录
|
|
|
- $pattern = "/^betRecordType@@\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $type = preg_replace('/^betRecordType@@/', '', $data);
|
|
|
- Cache::put('message_id_bet_record_' . $chatId, intval($type), 600);
|
|
|
- $telegram->deleteMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'message_id' => $messageId,
|
|
|
- ]);
|
|
|
- $returnMsg = BetService::record($chatId);
|
|
|
- $telegram->sendMessage($returnMsg);
|
|
|
- }
|
|
|
+ if ($data === 'withdrawAddress@@done') {
|
|
|
+ $res = WithdrawService::done($chatId, $messageId, $firstName);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
+ // 今日汇率
|
|
|
+ if ($data === 'todayExchangeRate@@rate') {
|
|
|
+ $res = BetService::todayExchangeRate($chatId);
|
|
|
+ // $telegram->sendMessage($res);
|
|
|
+ }
|
|
|
|
|
|
- //选择提现地址
|
|
|
- $pattern = "/^withdrawAddress@@choose\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $id = preg_replace('/^withdrawAddress@@choose/', '', $data);
|
|
|
- $res = WithdrawService::chooseAddress($chatId, $firstName, $messageId, $id);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
+ //查看开奖历史图片
|
|
|
+ $pattern = "/^showLotteryHistory@@\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $id = preg_replace('/^showLotteryHistory@@/', '', $data);
|
|
|
+ $res = IssueService::sendLotteryImage($chatId, $id);
|
|
|
+ }
|
|
|
|
|
|
- //删除地址
|
|
|
- $pattern = "/^withdrawAddress@@del\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $id = preg_replace('/^withdrawAddress@@del/', '', $data);
|
|
|
- $res = WithdrawService::delAddress($chatId, $id, $messageId);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
- //地址详情
|
|
|
- $pattern = "/^withdrawAddress@@detail\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $id = preg_replace('/^withdrawAddress@@detail/', '', $data);
|
|
|
- $res = WithdrawService::addressDetails($chatId, $messageId, $id);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
+ //选择投注记录
|
|
|
+ $pattern = "/^betRecordType@@\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $type = preg_replace('/^betRecordType@@/', '', $data);
|
|
|
+ Cache::put('message_id_bet_record_' . $chatId, intval($type), 600);
|
|
|
+ $telegram->deleteMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'message_id' => $messageId,
|
|
|
+ ]);
|
|
|
+ $returnMsg = BetService::record($chatId);
|
|
|
+ $telegram->sendMessage($returnMsg);
|
|
|
+ }
|
|
|
|
|
|
- //充值账单,下一页
|
|
|
- $pattern = "/^topUpBillNextPage@@\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $page = preg_replace('/^topUpBillNextPage@@/', '', $data);
|
|
|
- $page = intval($page);
|
|
|
- $res = (new TopUpService())->bill($chatId, $firstName, $messageId, $page);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
|
|
|
- //流水列表,下一页
|
|
|
- $pattern = "/^FlowingHistoryPage@@\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $page = preg_replace('/^FlowingHistoryPage@@/', '', $data);
|
|
|
- $page = intval($page);
|
|
|
- $returnMsg = BalanceLogService::getFlowingHistory($chatId, $messageId, $page);
|
|
|
- $telegram->editMessageText($returnMsg);
|
|
|
- }
|
|
|
+ //选择提现地址
|
|
|
+ $pattern = "/^withdrawAddress@@choose\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $id = preg_replace('/^withdrawAddress@@choose/', '', $data);
|
|
|
+ $res = WithdrawService::chooseAddress($chatId, $firstName, $messageId, $id);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
+ //删除地址
|
|
|
+ $pattern = "/^withdrawAddress@@del\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $id = preg_replace('/^withdrawAddress@@del/', '', $data);
|
|
|
+ $res = WithdrawService::delAddress($chatId, $id, $messageId);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
+ //地址详情
|
|
|
+ $pattern = "/^withdrawAddress@@detail\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $id = preg_replace('/^withdrawAddress@@detail/', '', $data);
|
|
|
+ $res = WithdrawService::addressDetails($chatId, $messageId, $id);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
- //提现账单,下一页
|
|
|
- $pattern = "/^withdrawBillNextPage@@\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $page = preg_replace('/^withdrawBillNextPage@@/', '', $data);
|
|
|
- $page = intval($page);
|
|
|
- $res = (new WithdrawService())->bill($chatId, $firstName, $messageId, $page);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
+ //充值账单,下一页
|
|
|
+ $pattern = "/^topUpBillNextPage@@\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $page = preg_replace('/^topUpBillNextPage@@/', '', $data);
|
|
|
+ $page = intval($page);
|
|
|
+ $res = (new TopUpService())->bill($chatId, $firstName, $messageId, $page);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
- //近期注单,下一页
|
|
|
- $pattern = "/^betRecordNextPage@@\d+$/";
|
|
|
- if (preg_match($pattern, $data)) {
|
|
|
- $page = preg_replace('/^betRecordNextPage@@/', '', $data);
|
|
|
- $page = intval($page);
|
|
|
- $res = BetService::record($chatId, $messageId, $page);
|
|
|
- $telegram->editMessageText($res);
|
|
|
- }
|
|
|
- DB::commit();
|
|
|
- } //
|
|
|
- catch (MessageException $e) {
|
|
|
- DB::rollBack();
|
|
|
- $msg = $e->getMessage();
|
|
|
- $msg = json_decode($msg, true);
|
|
|
- $telegram->sendMessage($msg);
|
|
|
- } //
|
|
|
- catch (TelegramSDKException $e) {
|
|
|
- DB::rollBack();
|
|
|
- $m = new Message();
|
|
|
- $m->json = $e->getMessage();
|
|
|
- $m->save();
|
|
|
- $telegram->sendMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'text' => '‼️‼️系统发生了错误,请联系客服'
|
|
|
- ]);
|
|
|
- }//
|
|
|
- catch (\Exception $e) {
|
|
|
- DB::rollBack();
|
|
|
- $m = new Message();
|
|
|
- $m->json = json_encode([
|
|
|
- 'line' => $e->getLine(),
|
|
|
- 'message' => $e->getMessage()
|
|
|
- ]);
|
|
|
- $m->save();
|
|
|
- $telegram->sendMessage([
|
|
|
- 'chat_id' => $chatId,
|
|
|
- 'text' => '‼️‼️系统发生了错误,请联系客服'
|
|
|
- ]);
|
|
|
- }
|
|
|
+ //流水列表,下一页
|
|
|
+ $pattern = "/^FlowingHistoryPage@@\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $page = preg_replace('/^FlowingHistoryPage@@/', '', $data);
|
|
|
+ $page = intval($page);
|
|
|
+ $returnMsg = BalanceLogService::getFlowingHistory($chatId, $messageId, $page);
|
|
|
+ $telegram->editMessageText($returnMsg);
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- $update = $request->all();
|
|
|
- Log::error('Telegram 文字消息回复: ' . json_encode($update, JSON_UNESCAPED_UNICODE));
|
|
|
- if (isset($update['message'])) {
|
|
|
- $message = $update['message'];
|
|
|
- $chatId = $message['chat']['id'];
|
|
|
- $messageId = $message['message_id'];
|
|
|
- DB::beginTransaction();
|
|
|
- try {
|
|
|
- $m = new Message();
|
|
|
- $m->json = json_encode($update);
|
|
|
- $m->save();
|
|
|
|
|
|
- $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'] != '') {
|
|
|
- $this->telegram->sendPhoto($returnMsg);
|
|
|
- } else {
|
|
|
- $this->telegram->sendMessage($returnMsg);
|
|
|
- }
|
|
|
+ //提现账单,下一页
|
|
|
+ $pattern = "/^withdrawBillNextPage@@\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $page = preg_replace('/^withdrawBillNextPage@@/', '', $data);
|
|
|
+ $page = intval($page);
|
|
|
+ $res = (new WithdrawService())->bill($chatId, $firstName, $messageId, $page);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
+ }
|
|
|
|
|
|
+ //近期注单,下一页
|
|
|
+ $pattern = "/^betRecordNextPage@@\d+$/";
|
|
|
+ if (preg_match($pattern, $data)) {
|
|
|
+ $page = preg_replace('/^betRecordNextPage@@/', '', $data);
|
|
|
+ $page = intval($page);
|
|
|
+ $res = BetService::record($chatId, $messageId, $page);
|
|
|
+ $telegram->editMessageText($res);
|
|
|
}
|
|
|
DB::commit();
|
|
|
- } catch (MessageException $e) {
|
|
|
+ } //
|
|
|
+ catch (MessageException $e) {
|
|
|
DB::rollBack();
|
|
|
$msg = $e->getMessage();
|
|
|
$msg = json_decode($msg, true);
|
|
|
@@ -425,14 +377,73 @@ class TelegramWebHook extends BaseController
|
|
|
'message' => $e->getMessage()
|
|
|
]);
|
|
|
$m->save();
|
|
|
- Log::error('Telegram 处理消息异常: ' . $e->getMessage());
|
|
|
$telegram->sendMessage([
|
|
|
'chat_id' => $chatId,
|
|
|
'text' => '‼️‼️系统发生了错误,请联系客服'
|
|
|
]);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ } //
|
|
|
+ else {
|
|
|
+ $update = $request->all();
|
|
|
+ Log::error('Telegram 文字消息回复: ' . json_encode($update, JSON_UNESCAPED_UNICODE));
|
|
|
+ if (isset($update['message'])) {
|
|
|
+ $message = $update['message'];
|
|
|
+ $chatId = $message['chat']['id'];
|
|
|
+ $messageId = $message['message_id'];
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $m = new Message();
|
|
|
+ $m->json = json_encode($update);
|
|
|
+ $m->save();
|
|
|
+
|
|
|
+ $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'] != '') {
|
|
|
+ $this->telegram->sendPhoto($returnMsg);
|
|
|
+ } else {
|
|
|
+ $this->telegram->sendMessage($returnMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ DB::commit();
|
|
|
+ } catch (MessageException $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ $msg = json_decode($msg, true);
|
|
|
+ $telegram->sendMessage($msg);
|
|
|
+ } //
|
|
|
+ catch (TelegramSDKException $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ $m = new Message();
|
|
|
+ $m->json = $e->getMessage();
|
|
|
+ $m->save();
|
|
|
+ $telegram->sendMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'text' => '‼️‼️系统发生了错误,请联系客服'
|
|
|
+ ]);
|
|
|
+ }//
|
|
|
+ catch (\Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ $m = new Message();
|
|
|
+ $m->json = json_encode([
|
|
|
+ 'line' => $e->getLine(),
|
|
|
+ 'message' => $e->getMessage()
|
|
|
+ ]);
|
|
|
+ $m->save();
|
|
|
+ Log::error('Telegram 处理消息异常: ' . $e->getMessage());
|
|
|
+ $telegram->sendMessage([
|
|
|
+ 'chat_id' => $chatId,
|
|
|
+ 'text' => '‼️‼️系统发生了错误,请联系客服'
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ return response()->json(['status' => 'ok']);
|
|
|
}
|
|
|
return response()->json(['status' => 'ok']);
|
|
|
}
|