fix bug
This commit is contained in:
@@ -90,35 +90,24 @@ class Controller extends BaseController
|
||||
$send_sms = true;
|
||||
$user = User::where('mobile', $to)->first() ?: Customer::where('mobile', $to)->first();
|
||||
if ($user) {
|
||||
//
|
||||
// // Telegram
|
||||
// if (isset($credentials['telegram']) && $user->telegram) {
|
||||
// try {
|
||||
// $res = Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
// 'botToken' => $credentials['telegram']['token'],
|
||||
// 'chatId' => $user->telegram,
|
||||
// 'message' => "جناب {$user->name} {$msg}",
|
||||
// ]);
|
||||
// $data = $res->json();
|
||||
// if (isset($data['success']) && $data['success'] === true) {
|
||||
// $platforms[] = "telegram:{$user->telegram}";
|
||||
// $send_sms = false;
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Bale
|
||||
if (isset($credentials['bale']) && $user->bale) {
|
||||
$baleToken = trim((string) ($credentials['bale']['token'] ?? ''));
|
||||
$baleChatId = trim((string) ($user->bale ?? ''));
|
||||
if ($baleToken !== '' && $baleChatId !== '') {
|
||||
try {
|
||||
Http::withoutVerifying()->get("https://tapi.bale.ai/{$credentials['bale']['token']}/sendMessage", [
|
||||
'chat_id' => $user->bale,
|
||||
'text' => "جناب {$user->name} \n{$msg}",
|
||||
]);
|
||||
$platforms[] = "bale:{$user->bale}";
|
||||
$send_sms = false;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
$baleResponse = Http::withoutVerifying()->get(
|
||||
"https://tapi.bale.ai/bot{$baleToken}/sendMessage",
|
||||
[
|
||||
'chat_id' => $baleChatId,
|
||||
'text' => "جناب {$user->name} \n{$msg}",
|
||||
]
|
||||
);
|
||||
$balePayload = $baleResponse->json();
|
||||
if ($baleResponse->successful() && ($balePayload['ok'] ?? false) === true) {
|
||||
$platforms[] = "bale:{$baleChatId}";
|
||||
$send_sms = false;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +142,9 @@ class Controller extends BaseController
|
||||
'platform' => 'rayegansms',
|
||||
]);
|
||||
|
||||
$platforms[] = "rayegansms:{$to}";
|
||||
$platforms[] = $response->successful()
|
||||
? "rayegansms:{$to}"
|
||||
: "rayegansms_failed:{$to}:{$response->status()}";
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user