1

내 .php 파일에서이 코드를 만들었습니다. 여기서 작동하는 webHook을 설정했습니다.전보 봇 스위치 업데이트()

$token = "my token"; 
$website = "https://api.telegram.org/bot" . $token . "/"; 
$updates = file_get_contents("php://input"); 
$updates = json_decode($updates, true); 
$text = $updates["message"]["text"]; 
$chatID = $updates["message"]["chat"]["id"]; 

switch($text){ 
    case "/prova_gratuita": 
     if(check($chatID)){ 
      sendMessage($chatID, "Are you sure? Demo is available only one time. Write confirm to continue"); 
      switch($text){ 
      case "confirm": 
       ... 
       break; 
      } 
     } 

두 번째 switch()이 작동하지 않습니다. 왜? 내가 무엇을 할 수 있을지? 나는 $text의 값을 업데이트해야한다는 것을 알고 있지만 어떻게 할 수 있는지 모르겠다.

+1

왜 작동해야합니까? –

+0

죄송합니다. 질문을 완료하지 못했습니다. @u_mulder – Riccardo

답변

0

나는이 문제를 어떻게 설정하는지 생각한다. 각 봇 입력은 해당 WebHook에 대한 호출입니다. 그렇다면 $ text는 그런 식으로 될 수 없습니다.

두 번째 스위치의 "첫 번째"스위치도 포함해야합니다.

$token = "my token"; 
$website = "https://api.telegram.org/bot" . $token . "/"; 
$updates = file_get_contents("php://input"); 
$updates = json_decode($updates, true); 
$text = $updates["message"]["text"]; 
$chatID = $updates["message"]["chat"]["id"]; 

switch($text){ 
    case "/prova_gratuita": 
     if(check($chatID)) sendMessage($chatID, "Are you sure? Demo is available only one time. Write confirm to continue"); 
    case "confirm": 
    ... 

} 

봇에게 메시지를 보낼 때마다 그는 WebHook에 전화를 겁니다. 따라서 $ 업데이트의 상태를 변경하려면 스크립트가 다시 시작해야하는 $ 텍스트도 변경하십시오.

+0

알겠습니다. 감사합니다. – Riccardo

+0

봇에 메시지를 보낼 때마다 WebHook에 전화를 겁니다. 따라서 $ 업데이트 상태를 변경하려면 스크립트가 다시 시작해야하는 $ 텍스트도 변경하십시오. –

+0

시시히도 도착 예정. Grazie di nuovo – Riccardo