Saltar selección de monto si el cliente lo incluye en el mensaje de recarga
Tanto en Telegram como en el chat web, cuando el usuario escribe el monto directamente (ej: "recargar 10.000"), el bot ahora va directo al paso de método de pago sin volver a preguntar el monto. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
6bd0045826
commit
932a9b43c7
@@ -490,7 +490,9 @@ class PublicChat extends Component
|
||||
$action === 'promo.listar' => $this->listarPromociones(),
|
||||
$action === 'promo.ver' => $this->verPromocion((int) ($data['id'] ?? 0)),
|
||||
$action === 'promo.comprar.saldo' => $this->comprarPromoConSaldo((int) ($data['id'] ?? 0)),
|
||||
$action === 'recarga.iniciar' => $this->mostrarFormRecarga(),
|
||||
$action === 'recarga.iniciar' => isset($data['monto']) && (int) $data['monto'] >= 1000
|
||||
? $this->elegirMetodoRecarga((int) $data['monto'])
|
||||
: $this->mostrarFormRecarga(),
|
||||
$action === 'recarga.otro_valor' => $this->solicitarMontoPersonalizado(),
|
||||
$action === 'recarga.elegir_metodo' => $this->elegirMetodoRecarga((int) ($data['monto'] ?? 0)),
|
||||
$action === 'recarga.transferencia' => $this->mostrarTransferencia((int) ($data['monto'] ?? 0)),
|
||||
@@ -1572,7 +1574,16 @@ class PublicChat extends Component
|
||||
|
||||
foreach ($patrones as $action => $pattern) {
|
||||
if (preg_match($pattern, $t)) {
|
||||
return ['action' => $action, 'data' => []];
|
||||
$data = [];
|
||||
if ($action === 'recarga.iniciar') {
|
||||
if (preg_match('/\$?\s*(\d{1,3}(?:[.,]\d{3})+|\d{4,})\b/', $t, $m)) {
|
||||
$monto = (int) preg_replace('/[.,]/', '', $m[1]);
|
||||
if ($monto >= 1000) {
|
||||
$data['monto'] = $monto;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['action' => $action, 'data' => $data];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user