本文整理匯總了PHP中Longman\TelegramBot\Request::getInput方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getInput方法的具體用法?PHP Request::getInput怎麽用?PHP Request::getInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Longman\TelegramBot\Request
的用法示例。
在下文中一共展示了Request::getInput方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handle
/**
* Handle bot request from webhook
*
* @return bool
*/
public function handle()
{
$this->input = Request::getInput();
if (empty($this->input)) {
throw new TelegramException('Input is empty!');
}
$post = json_decode($this->input, true);
if (empty($post)) {
throw new TelegramException('Invalid JSON!');
}
return $this->processUpdate(new Update($post, $this->bot_name))->isOk();
}
示例2: handle
/**
* Handle bot request
*
* @return \Longman\TelegramBot\Telegram
*/
public function handle()
{
$this->input = Request::getInput();
if (empty($this->input)) {
throw new TelegramException('Input is empty!');
}
$post = json_decode($this->input, true);
if (empty($post)) {
throw new TelegramException('Invalid JSON!');
}
$update = new Update($post, $this->bot_name);
$this->insertRequest($update);
$message = $update->getMessage();
// check type
$type = $message->getType();
switch ($type) {
default:
case 'text':
// do nothing
break;
case 'command':
// execute command
$command = $message->getCommand();
return $this->executeCommand($command, $update);
break;
case 'new_chat_participant':
// trigger new participant
$command = 'new_chat_participant';
return $this->executeCommand($command, $update);
break;
case 'left_chat_participant':
// trigger left chat participant
$command = 'left_chat_participant';
return $this->executeCommand($command, $update);
break;
case 'new_chat_title':
// trigger new_chat_title
break;
case 'delete_chat_photo':
// trigger delete_chat_photo
break;
case 'group_chat_created':
// trigger group_chat_created
break;
}
}
示例3: handle
/**
* Handle bot request
*
* @return \Longman\TelegramBot\Telegram
*/
public function handle()
{
$this->input = Request::getInput();
if (empty($this->input)) {
throw new TelegramException('Input is empty!');
}
$post = json_decode($this->input, true);
if (empty($post)) {
throw new TelegramException('Invalid JSON!');
}
$update = new Update($post, $this->bot_name);
//Load admin Commands
if ($this->admin_enabled) {
$message = $update->getMessage();
//$from = $message->getFrom();
//$user_id = $from->getId();
//Admin command avaiable only in single chat with the bot
$chat = $message->getChat();
$user_id = $chat->getId();
if (in_array($user_id, $this->admins_list)) {
$this->addCommandsPath(BASE_PATH . '/Admin');
}
}
$this->insertRequest($update);
$message = $update->getMessage();
// check type
$type = $message->getType();
switch ($type) {
default:
case 'text':
// do nothing
break;
case 'command':
// execute command
$command = $message->getCommand();
return $this->executeCommand($command, $update);
break;
case 'new_chat_participant':
// trigger new participant
return $this->executeCommand('Newchatparticipant', $update);
break;
case 'left_chat_participant':
// trigger left chat participant
return $this->executeCommand('Leftchatparticipant', $update);
break;
case 'new_chat_title':
// trigger new_chat_title
return $this->executeCommand('Newchattitle', $update);
break;
case 'delete_chat_photo':
// trigger delete_chat_photo
return $this->executeCommand('Deletechatphoto', $update);
break;
case 'group_chat_created':
// trigger group_chat_created
return $this->executeCommand('Groupchatcreated', $update);
break;
}
}
示例4: handle
/**
* Handle bot request
*
* @return \Longman\TelegramBot\Telegram
*/
public function handle()
{
$this->input = Request::getInput();
if (empty($this->input)) {
throw new TelegramException('Input is empty!');
}
$post = json_decode($this->input, true);
if (empty($post)) {
throw new TelegramException('Invalid JSON!');
}
$update = new Update($post, $this->bot_name);
$this->insertRequest($update);
$command = $update->getMessage()->getCommand();
if (!empty($command)) {
return $this->executeCommand($command, $update);
}
}
示例5: handle
/**
* Handle bot request
*
* @return \Longman\TelegramBot\Telegram
*/
public function handle()
{
$this->input = Request::getInput();
if (empty($this->input)) {
throw new TelegramException('Input is empty!');
}
$post = json_decode($this->input, true);
if (empty($post)) {
throw new TelegramException('Invalid JSON!');
}
$update = new Update($post, $this->bot_name);
$this->insertRequest($update);
$message = $update->getMessage();
// check type
$type = $message->getType();
switch ($type) {
default:
case 'text':
// do nothing
$chat_id = $message->getChat()->getId();
$message_id = $message->getMessageId();
$text = $message->getText();
//Si estamos en modo test
$test = new Test();
$datatest = $test->realizarAccionesTest($message);
if (!is_null($datatest)) {
return Request::sendMessage($datatest);
} else {
// do nothing
}
break;
case 'command':
// execute command
$command = $message->getCommand();
return $this->executeCommand($command, $update);
break;
case 'new_chat_participant':
// trigger new participant
return $this->executeCommand('Newchatparticipant', $update);
break;
case 'left_chat_participant':
// trigger left chat participant
return $this->executeCommand('Leftchatparticipant', $update);
break;
case 'new_chat_title':
// trigger new_chat_title
break;
case 'delete_chat_photo':
// trigger delete_chat_photo
break;
case 'group_chat_created':
// trigger group_chat_created
break;
}
}