本文整理汇总了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;
}
}