Commit 1afa177b authored by MBoretto's avatar MBoretto

updating Update for inline

parent 1d02c86f
<?php
/*
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class ChosenInlineResult extends Entity
{
protected $result_id;
protected $from;
protected $query;
public function __construct(array $data)
{
$this->result_id = isset($data['result_id']) ? $data['result_id'] : null;
if (empty($this->result_id)) {
throw new TelegramException('result_id is empty!');
}
$this-> = isset($data['from']) ? $data['from'] : null;
if (empty($this->from)) {
throw new TelegramException('from is empty!');
}
$this->from = new User($this->from);
$this->query = isset($data['query']) ? $data['query'] : null;
$this->offset = isset($data['offset']) ? $data['offset'] : null;
}
public function getId()
{
return $this->id;
}
public function geFrom()
{
return $this->from;
}
public function getQuery()
{
return $this->query;
}
}
<?php
/*
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class InlineQuery extends Entity
{
protected $id;
protected $from;
protected $query;
protected $offset;
public function __construct(array $data)
{
$this->id = isset($data['id']) ? $data['id'] : null;
if (empty($this->id)) {
throw new TelegramException('id is empty!');
}
$this-> = isset($data['from']) ? $data['from'] : null;
if (empty($this->from)) {
throw new TelegramException('from is empty!');
}
$this->from = new User($this->from);
$this->query = isset($data['query']) ? $data['query'] : null;
$this->offset = isset($data['offset']) ? $data['offset'] : null;
}
public function getId()
{
return $this->id;
}
public function geFrom()
{
return $this->from;
}
public function getQuery()
{
return $this->query;
}
public function getOffset()
{
return $this->offset;
}
}
......@@ -17,32 +17,53 @@ class Update extends Entity
protected $update_id;
protected $message;
protected $inline_query;
protected $chosen_inline_result;
public function __construct(array $data, $bot_name, $let_update_id_empty = 0)
{
$this->bot_name = $bot_name;
$update_id = isset($data['update_id']) ? $data['update_id'] : null;
$this->update_id = $update_id;
$message = isset($data['message']) ? $data['message'] : null;
$this->message = isset($data['message']) ? $data['message'] : null;
if (!empty($this->message)) {
$this->message = new Message($this->message, $bot_name);
}
if (empty($update_id) && !$let_update_id_empty) {
throw new TelegramException('update_id is empty!');
}
$this->bot_name = $bot_name;
$this->update_id = $update_id;
$this->message = new Message($message, $bot_name);
$this->inline_query = isset($data['inline_query']) ? $data['inline_query'] : null;
if (!empty($this->inline_query)) {
$this->inline_query = new InlineQuery($this->inline_query);
}
$this->chosen_inline_result = isset($data['chosen_inline_result']) ? $data['chosen_inline_result'] : null;
if (!empty($this->chosen_inline_result)) {
$this->chosen_inline_result = new ChosenInlineResult($this->chosen_inline_result);
}
}
public function getUpdateId()
{
return $this->update_id;
}
public function getMessage()
{
return $this->message;
}
public function getInlineQuery()
{
return $this->inline_query;
}
public function getChosenInlineResult()
{
return $this->chosen_inline_result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment