<?php | |
$content = file_get_contents("php://input"); | |
$update = json_decode($content, true); | |
if(!$update) | |
{ | |
exit; | |
} | |
$message = isset($update['message']) ? $update['message'] : ""; | |
$messageId = isset($message['message_id']) ? $message['message_id'] : ""; | |
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : ""; | |
$firstname = isset($message['chat']['first_name']) ? $message['chat']['first_name'] : ""; | |
$lastname = isset($message['chat']['last_name']) ? $message['chat']['last_name'] : ""; | |
$username = isset($message['chat']['username']) ? $message['chat']['username'] : ""; | |
$date = isset($message['date']) ? $message['date'] : ""; | |
$text = isset($message['text']) ? $message['text'] : ""; | |
$text = trim($text); | |
$text = strtolower($text); | |
header("Content-Type: application/json"); | |
$response = ''; | |
if(strpos($text, "/start") === 0 || $text=="ciao") | |
{ | |
$response = "Ciao $firstname, benvenuto!"; | |
} | |
elseif($text=="domanda 1") | |
{ | |
$response = "risposta 1"; | |
} | |
elseif($text=="domanda 2") | |
{ | |
$response = "risposta 2"; | |
} | |
else | |
{ | |
$response = "Comando non valido!"; | |
} | |
$parameters = array('chat_id' => $chatId, "text" => $response); | |
$parameters["method"] = "sendMessage"; | |
echo json_encode($parameters); |
This comment has been minimized.
This comment has been minimized.
Ciao @parsec82, ho letto adesso il tuo commento. Fammi sapere, a presto, |
This comment has been minimized.
This comment has been minimized.
isketch93
commented
Sep 25, 2016
•
Ciao Salvatore, |
This comment has been minimized.
This comment has been minimized.
gio700
commented
Jan 26, 2017
Ciao salvatore , come faccio per farmi dare un file da dropbox facendo la richiesta a bot? |
This comment has been minimized.
This comment has been minimized.
shadowkrad
commented
Mar 10, 2017
Ciao Salvatore sto usando questo script ma vorrei ottenere una risposta random anziche la risposta singola è possibile? Grazie |
This comment has been minimized.
parsec82 commentedJul 25, 2016
Ciao!,
ho provato ad utilizzare il sample utilizzando le domande/risposte che servivano.
Quando viene utilizzato direttamente come bot va perfettamente ma avrei bisogno di poter fare rilevare i comandi anche quando viene usato il comando /domanda1@nomebot
in quanto nei testi ho fatto riferimento ad altri comandi e quando vengono cliccati invece di dare (come è scritto) /domanda1 appare /domanda1@nomebot
come è possibile risolvere tale problematica?