Commit 193aa44c authored by MBoretto's avatar MBoretto

Merge branch 'develop' of https://github.com/akalongman/php-telegram-bot into develop

parents 7147b12f 2bdd0d12
...@@ -21,3 +21,8 @@ N: Armando Lüscher ...@@ -21,3 +21,8 @@ N: Armando Lüscher
E: armando@noplanman.ch E: armando@noplanman.ch
W: http://noplanman.ch W: http://noplanman.ch
D: Maintainer and Collaborator D: Maintainer and Collaborator
N: Jack'lul (alias)
E: jacklul@jacklul.com
W: http://jacklul.com
D: Maintainer and Collaborator
...@@ -31,8 +31,6 @@ class SendtoallCommand extends AdminCommand ...@@ -31,8 +31,6 @@ class SendtoallCommand extends AdminCommand
/** /**
* Execute command * Execute command
* *
* @todo Don't use empty, as a string of '0' is regarded to be empty
*
* @return boolean * @return boolean
*/ */
public function execute() public function execute()
...@@ -42,7 +40,7 @@ class SendtoallCommand extends AdminCommand ...@@ -42,7 +40,7 @@ class SendtoallCommand extends AdminCommand
$chat_id = $message->getChat()->getId(); $chat_id = $message->getChat()->getId();
$text = $message->getText(true); $text = $message->getText(true);
if (empty($text)) { if ($text === '') {
$text = 'Write the message to send: /sendtoall <message>'; $text = 'Write the message to send: /sendtoall <message>';
} else { } else {
$results = Request::sendToActiveChats( $results = Request::sendToActiveChats(
......
...@@ -67,7 +67,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -67,7 +67,7 @@ class SendtochannelCommand extends AdminCommand
switch ($state) { switch ($state) {
case -1: case -1:
// getConfig has not been configured asking for channel to administer // getConfig has not been configured asking for channel to administer
if ($type != 'Message' || empty($text)) { if ($type != 'Message' || $text === '') {
$this->conversation->notes['state'] = -1; $this->conversation->notes['state'] = -1;
$this->conversation->update(); $this->conversation->update();
...@@ -116,7 +116,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -116,7 +116,7 @@ class SendtochannelCommand extends AdminCommand
// no break // no break
case 1: case 1:
insert: insert:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || ($type == 'Message' && empty($text))) { if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || ($type == 'Message' && $text === '')) {
$this->conversation->notes['state'] = 1; $this->conversation->notes['state'] = 1;
$this->conversation->update(); $this->conversation->update();
...@@ -245,7 +245,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -245,7 +245,7 @@ class SendtochannelCommand extends AdminCommand
$data = []; $data = [];
$data['chat_id'] = $chat_id; $data['chat_id'] = $chat_id;
if (empty($text)) { if ($text === '') {
$data['text'] = 'Usage: /sendtochannel <text>'; $data['text'] = 'Usage: /sendtochannel <text>';
} else { } else {
$channels = (array) $this->getConfig('your_channel'); $channels = (array) $this->getConfig('your_channel');
......
...@@ -21,10 +21,8 @@ class Audio extends Entity ...@@ -21,10 +21,8 @@ class Audio extends Entity
protected $mime_type; protected $mime_type;
protected $file_size; protected $file_size;
public function __construct(array $data) public function __construct(array $data)
{ {
$this->file_id = isset($data['file_id']) ? $data['file_id'] : null; $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
if (empty($this->file_id)) { if (empty($this->file_id)) {
throw new TelegramException('file_id is empty!'); throw new TelegramException('file_id is empty!');
...@@ -40,7 +38,6 @@ class Audio extends Entity ...@@ -40,7 +38,6 @@ class Audio extends Entity
$this->title = isset($data['title']) ? $data['title'] : null; $this->title = isset($data['title']) ? $data['title'] : null;
$this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null; $this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
$this->file_size = isset($data['file_size']) ? $data['file_size'] : null; $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
} }
public function getFileId() public function getFileId()
...@@ -57,10 +54,12 @@ class Audio extends Entity ...@@ -57,10 +54,12 @@ class Audio extends Entity
{ {
return $this->performer; return $this->performer;
} }
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
public function getMimeType() public function getMimeType()
{ {
return $this->mime_type; return $this->mime_type;
......
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class Chat extends Entity class Chat extends Entity
{ {
protected $id; protected $id;
protected $type; protected $type;
protected $title; protected $title;
...@@ -81,37 +80,31 @@ class Chat extends Entity ...@@ -81,37 +80,31 @@ class Chat extends Entity
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
public function getType() public function getType()
{ {
return $this->type; return $this->type;
} }
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
public function getFirstName() public function getFirstName()
{ {
return $this->first_name; return $this->first_name;
} }
public function getLastName() public function getLastName()
{ {
return $this->last_name; return $this->last_name;
} }
public function getUsername() public function getUsername()
{ {
return $this->username; return $this->username;
} }
......
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class ChosenInlineResult extends Entity class ChosenInlineResult extends Entity
{ {
protected $result_id; protected $result_id;
protected $from; protected $from;
protected $location; protected $location;
...@@ -23,7 +22,6 @@ class ChosenInlineResult extends Entity ...@@ -23,7 +22,6 @@ class ChosenInlineResult extends Entity
public function __construct(array $data) public function __construct(array $data)
{ {
$this->result_id = isset($data['result_id']) ? $data['result_id'] : null; $this->result_id = isset($data['result_id']) ? $data['result_id'] : null;
if (empty($this->result_id)) { if (empty($this->result_id)) {
throw new TelegramException('result_id is empty!'); throw new TelegramException('result_id is empty!');
......
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class Contact extends Entity class Contact extends Entity
{ {
protected $phone_number; protected $phone_number;
protected $first_name; protected $first_name;
protected $last_name; protected $last_name;
...@@ -22,7 +21,6 @@ class Contact extends Entity ...@@ -22,7 +21,6 @@ class Contact extends Entity
public function __construct(array $data) public function __construct(array $data)
{ {
$this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null; $this->phone_number = isset($data['phone_number']) ? $data['phone_number'] : null;
if (empty($this->phone_number)) { if (empty($this->phone_number)) {
throw new TelegramException('phone_number is empty!'); throw new TelegramException('phone_number is empty!');
......
...@@ -22,7 +22,6 @@ class Document extends Entity ...@@ -22,7 +22,6 @@ class Document extends Entity
public function __construct(array $data) public function __construct(array $data)
{ {
$this->file_id = isset($data['file_id']) ? $data['file_id'] : null; $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
if (empty($this->file_id)) { if (empty($this->file_id)) {
throw new TelegramException('file_id is empty!'); throw new TelegramException('file_id is empty!');
...@@ -36,7 +35,6 @@ class Document extends Entity ...@@ -36,7 +35,6 @@ class Document extends Entity
$this->file_name = isset($data['file_name']) ? $data['file_name'] : null; $this->file_name = isset($data['file_name']) ? $data['file_name'] : null;
$this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null; $this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
$this->file_size = isset($data['file_size']) ? $data['file_size'] : null; $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
} }
public function getFileId() public function getFileId()
...@@ -46,21 +44,21 @@ class Document extends Entity ...@@ -46,21 +44,21 @@ class Document extends Entity
public function getThumb() public function getThumb()
{ {
return $this->thumb; return $this->thumb;
} }
public function getFileName() public function getFileName()
{ {
return $this->file_name; return $this->file_name;
} }
public function getMimeType() public function getMimeType()
{ {
return $this->mime_type; return $this->mime_type;
} }
public function getFileSize() public function getFileSize()
{ {
return $this->file_size; return $this->file_size;
} }
} }
...@@ -14,10 +14,8 @@ class Entity ...@@ -14,10 +14,8 @@ class Entity
{ {
protected $bot_name; protected $bot_name;
public function getBotName() public function getBotName()
{ {
return $this->bot_name; return $this->bot_name;
} }
......
...@@ -20,7 +20,6 @@ class File extends Entity ...@@ -20,7 +20,6 @@ class File extends Entity
public function __construct(array $data) public function __construct(array $data)
{ {
$this->file_id = isset($data['file_id']) ? $data['file_id'] : null; $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
if (empty($this->file_id)) { if (empty($this->file_id)) {
throw new TelegramException('file_id is empty!'); throw new TelegramException('file_id is empty!');
...@@ -29,7 +28,6 @@ class File extends Entity ...@@ -29,7 +28,6 @@ class File extends Entity
$this->file_size = isset($data['file_size']) ? $data['file_size'] : null; $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
$this->file_path = isset($data['file_path']) ? $data['file_path'] : null; $this->file_path = isset($data['file_path']) ? $data['file_path'] : null;
} }
public function getFileId() public function getFileId()
...@@ -39,11 +37,11 @@ class File extends Entity ...@@ -39,11 +37,11 @@ class File extends Entity
public function getFileSize() public function getFileSize()
{ {
return $this->file_size; return $this->file_size;
} }
public function getFilePath() public function getFilePath()
{ {
return $this->file_path; return $this->file_path;
} }
} }
...@@ -19,6 +19,9 @@ class InlineKeyboardButton extends Entity ...@@ -19,6 +19,9 @@ class InlineKeyboardButton extends Entity
protected $callback_data; protected $callback_data;
protected $switch_inline_query; protected $switch_inline_query;
/**
* @todo check if only one of 'url, callback_data, switch_inline_query' fields is set, documentation states that only one of these can be used
*/
public function __construct($data = array()) public function __construct($data = array())
{ {
$this->text = isset($data['text']) ? $data['text'] : null; $this->text = isset($data['text']) ? $data['text'] : null;
...@@ -30,12 +33,8 @@ class InlineKeyboardButton extends Entity ...@@ -30,12 +33,8 @@ class InlineKeyboardButton extends Entity
$this->callback_data = isset($data['callback_data']) ? $data['callback_data'] : null; $this->callback_data = isset($data['callback_data']) ? $data['callback_data'] : null;
$this->switch_inline_query = isset($data['switch_inline_query']) ? $data['switch_inline_query'] : null; $this->switch_inline_query = isset($data['switch_inline_query']) ? $data['switch_inline_query'] : null;
if (empty($this->url) && empty($this->callback_data) && empty($this->switch_inline_query)) { if ($this->url === '' && $this->callback_data === '' && $this->switch_inline_query === '') {
throw new TelegramException('You must use at least one of these fields: url, callback_data, switch_inline_query!'); throw new TelegramException('You must use at least one of these fields: url, callback_data, switch_inline_query!');
} }
/*
* @todo check if only one of 'url, callback_data, switch_inline_query' fields is set, documentation states that only one of these can be used
*/
} }
} }
...@@ -16,7 +16,7 @@ class InlineKeyboardMarkup extends Entity ...@@ -16,7 +16,7 @@ class InlineKeyboardMarkup extends Entity
{ {
protected $inline_keyboard; protected $inline_keyboard;
/* /**
* @todo check for InlineKeyboardButton elements * @todo check for InlineKeyboardButton elements
*/ */
public function __construct($data = array()) public function __construct($data = array())
......
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class InlineQuery extends Entity class InlineQuery extends Entity
{ {
protected $id; protected $id;
protected $from; protected $from;
protected $location; protected $location;
...@@ -23,7 +22,6 @@ class InlineQuery extends Entity ...@@ -23,7 +22,6 @@ class InlineQuery extends Entity
public function __construct(array $data) public function __construct(array $data)
{ {
$this->id = isset($data['id']) ? $data['id'] : null; $this->id = isset($data['id']) ? $data['id'] : null;
if (empty($this->id)) { if (empty($this->id)) {
throw new TelegramException('id is empty!'); throw new TelegramException('id is empty!');
...@@ -48,18 +46,22 @@ class InlineQuery extends Entity ...@@ -48,18 +46,22 @@ class InlineQuery extends Entity
{ {
return $this->id; return $this->id;
} }
public function getFrom() public function getFrom()
{ {
return $this->from; return $this->from;
} }
public function getLocation() public function getLocation()
{ {
return $this->location; return $this->location;
} }
public function getQuery() public function getQuery()
{ {
return $this->query; return $this->query;
} }
public function getOffset() public function getOffset()
{ {
return $this->offset; return $this->offset;
......
...@@ -35,8 +35,19 @@ class InlineQueryResult extends Entity ...@@ -35,8 +35,19 @@ class InlineQueryResult extends Entity
{ {
return $this->type; return $this->type;
} }
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
public function getInputMessageContent()
{
return $this->input_message_content;
}
public function getReplyMarkup()
{
return $this->reply_markup;
}
} }
...@@ -45,7 +45,6 @@ class InlineQueryResultArticle extends InlineQueryResult ...@@ -45,7 +45,6 @@ class InlineQueryResultArticle extends InlineQueryResult
$this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null; $this->thumb_url = isset($data['thumb_url']) ? $data['thumb_url'] : null;
$this->thumb_width = isset($data['thumb_width']) ? $data['thumb_width'] : null; $this->thumb_width = isset($data['thumb_width']) ? $data['thumb_width'] : null;
$this->thumb_height = isset($data['thumb_height']) ? $data['thumb_height'] : null; $this->thumb_height = isset($data['thumb_height']) ? $data['thumb_height'] : null;
} }
public function getTitle() public function getTitle()
......
<?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 InlineQueryResultCachedAudio extends InlineQueryResult
{
protected $audio_file_id;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'audio';
$this->audio_file_id = isset($data['audio_file_id']) ? $data['audio_file_id'] : null;
if (empty($this->audio_file_id)) {
throw new TelegramException('audio_file_id is empty!');
}
}
public function getAudioFileId()
{
return $this->audio_file_id;
}
}
<?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 InlineQueryResultCachedDocument extends InlineQueryResult
{
protected $document_file_id;
protected $title;
protected $description;
protected $caption;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'document';
$this->document_file_id = isset($data['document_file_id']) ? $data['document_file_id'] : null;
if (empty($this->document_file_id)) {
throw new TelegramException('document_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
public function getDocumentFileId()
{
return $this->document_file_id;
}
public function getTitle()
{
return $this->title;
}
public function getDescription()
{
return $this->description;
}
public function getCaption()
{
return $this->caption;
}
}
<?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 InlineQueryResultCachedGif extends InlineQueryResult
{
protected $gif_file_id;
protected $title;
protected $description;
protected $caption;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'gif';
$this->gif_file_id = isset($data['gif_file_id']) ? $data['gif_file_id'] : null;
if (empty($this->gif_file_id)) {
throw new TelegramException('gif_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
public function getGifFileId()
{
return $this->gif_file_id;
}
public function getTitle()
{
return $this->title;
}
public function getCaption()
{
return $this->caption;
}
}
<?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 InlineQueryResultCachedMpeg4Gif extends InlineQueryResult
{
protected $mpeg4_file_id;
protected $title;
protected $caption;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'mpeg4_gif';
$this->mpeg4_file_id = isset($data['mpeg4_file_id']) ? $data['mpeg4_file_id'] : null;
if (empty($this->mpeg4_file_id)) {
throw new TelegramException('mpeg4_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
public function getMpeg4FileId()
{
return $this->mpeg4_file_id;
}
public function getTitle()
{
return $this->title;
}
public function getCaption()
{
return $this->caption;
}
}
<?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 InlineQueryResultCachedPhoto extends InlineQueryResult
{
protected $photo_file_id;
protected $title;
protected $description;
protected $caption;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'photo';
$this->photo_file_id = isset($data['photo_file_id']) ? $data['photo_file_id'] : null;
if (empty($this->photo_file_id)) {
throw new TelegramException('photo_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
public function getPhotoFileId()
{
return $this->photo_file_id;
}
public function getTitle()
{
return $this->title;
}
public function getDescription()
{
return $this->description;
}
public function getCaption()
{
return $this->caption;
}
}
<?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 InlineQueryResultCachedSticker extends InlineQueryResult
{
protected $sticker_file_id;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'sticker';
$this->photo_file_id = isset($data['sticker_file_id']) ? $data['sticker_file_id'] : null;
if (empty($this->sticker_file_id)) {
throw new TelegramException('sticker_file_id is empty!');
}
}
public function getStickerFileId()
{
return $this->sticker_file_id;
}
}
<?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 InlineQueryResultCachedVideo extends InlineQueryResult
{
protected $video_file_id;
protected $title;
protected $description;
protected $caption;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'photo';
$this->video_file_id = isset($data['video_file_id']) ? $data['video_file_id'] : null;
if (empty($this->video_file_id)) {
throw new TelegramException('video_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
public function getVideoFileId()
{
return $this->video_file_id;
}
public function getTitle()
{
return $this->title;
}
public function getDescription()
{
return $this->description;
}
public function getCaption()
{
return $this->caption;
}
}
<?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 InlineQueryResultCachedVoice extends InlineQueryResult
{
protected $voice_file_id;
protected $title;
protected $description;
protected $caption;
public function __construct(array $data)
{
parent::__construct($data);
$this->type = 'voice';
$this->voice_file_id = isset($data['voice_file_id']) ? $data['voice_file_id'] : null;
if (empty($this->voice_file_id)) {
throw new TelegramException('voice_file_id is empty!');
}
$this->title = isset($data['title']) ? $data['title'] : null;
if (empty($this->title)) {
throw new TelegramException('title is empty!');
}
$this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null;
}
public function getVoiceFileId()
{
return $this->voice_file_id;
}
public function getTitle()
{
return $this->title;
}
public function getDescription()
{
return $this->description;
}
public function getCaption()
{
return $this->caption;
}
}
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultGif extends InlineQueryResult class InlineQueryResultGif extends InlineQueryResult
{ {
protected $gif_url; protected $gif_url;
protected $gif_width; protected $gif_width;
protected $gif_height; protected $gif_height;
...@@ -43,29 +42,33 @@ class InlineQueryResultGif extends InlineQueryResult ...@@ -43,29 +42,33 @@ class InlineQueryResultGif extends InlineQueryResult
$this->title = isset($data['title']) ? $data['title'] : null; $this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null; $this->caption = isset($data['caption']) ? $data['caption'] : null;
} }
public function getGifUrl() public function getGifUrl()
{ {
return $this->gif_url; return $this->gif_url;
} }
public function getGifWidth() public function getGifWidth()
{ {
return $this->gif_width; return $this->gif_width;
} }
public function getGifHeight() public function getGifHeight()
{ {
return $this->gif_height; return $this->gif_height;
} }
public function getThumbUrl() public function getThumbUrl()
{ {
return $this->thumb_url; return $this->thumb_url;
} }
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
public function getCaption() public function getCaption()
{ {
return $this->caption; return $this->caption;
......
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultMpeg4Gif extends InlineQueryResult class InlineQueryResultMpeg4Gif extends InlineQueryResult
{ {
protected $mpeg4_url; protected $mpeg4_url;
protected $mpeg4_width; protected $mpeg4_width;
protected $mpeg4_height; protected $mpeg4_height;
...@@ -43,29 +42,33 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult ...@@ -43,29 +42,33 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult
$this->title = isset($data['title']) ? $data['title'] : null; $this->title = isset($data['title']) ? $data['title'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null; $this->caption = isset($data['caption']) ? $data['caption'] : null;
} }
public function getMpeg4Url() public function getMpeg4Url()
{ {
return $this->mpeg4_url; return $this->mpeg4_url;
} }
public function getMpeg4Width() public function getMpeg4Width()
{ {
return $this->mpeg4_width; return $this->mpeg4_width;
} }
public function getMpeg4Height() public function getMpeg4Height()
{ {
return $this->mpeg4_height; return $this->mpeg4_height;
} }
public function getThumbUrl() public function getThumbUrl()
{ {
return $this->thumb_url; return $this->thumb_url;
} }
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
public function getCaption() public function getCaption()
{ {
return $this->caption; return $this->caption;
......
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultPhoto extends InlineQueryResult class InlineQueryResultPhoto extends InlineQueryResult
{ {
protected $photo_url; protected $photo_url;
protected $photo_width; protected $photo_width;
protected $photo_height; protected $photo_height;
...@@ -45,33 +44,38 @@ class InlineQueryResultPhoto extends InlineQueryResult ...@@ -45,33 +44,38 @@ class InlineQueryResultPhoto extends InlineQueryResult
$this->title = isset($data['title']) ? $data['title'] : null; $this->title = isset($data['title']) ? $data['title'] : null;
$this->description = isset($data['description']) ? $data['description'] : null; $this->description = isset($data['description']) ? $data['description'] : null;
$this->caption = isset($data['caption']) ? $data['caption'] : null; $this->caption = isset($data['caption']) ? $data['caption'] : null;
} }
public function getPhotoUrl() public function getPhotoUrl()
{ {
return $this->photo_url; return $this->photo_url;
} }
public function getPhotoWidth() public function getPhotoWidth()
{ {
return $this->photo_width; return $this->photo_width;
} }
public function getPhotoHeight() public function getPhotoHeight()
{ {
return $this->photo_height; return $this->photo_height;
} }
public function getThumbUrl() public function getThumbUrl()
{ {
return $this->thumb_url; return $this->thumb_url;
} }
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
public function getDescription() public function getDescription()
{ {
return $this->description; return $this->description;
} }
public function getCaption() public function getCaption()
{ {
return $this->caption; return $this->caption;
......
...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -14,7 +14,6 @@ use Longman\TelegramBot\Exception\TelegramException;
class InlineQueryResultVideo extends InlineQueryResult class InlineQueryResultVideo extends InlineQueryResult
{ {
protected $video_url; protected $video_url;
protected $mime_type; protected $mime_type;
protected $thumb_url; protected $thumb_url;
...@@ -56,34 +55,42 @@ class InlineQueryResultVideo extends InlineQueryResult ...@@ -56,34 +55,42 @@ class InlineQueryResultVideo extends InlineQueryResult
{ {
return $this->video_url; return $this->video_url;
} }
public function getMimeType() public function getMimeType()
{ {
return $this->mime_type; return $this->mime_type;
} }
public function getThumbUrl() public function getThumbUrl()
{ {
return $this->thumb_url; return $this->thumb_url;
} }
public function getTitle() public function getTitle()
{ {
return $this->title; return $this->title;
} }
public function getCaption() public function getCaption()
{ {
return $this->caption; return $this->caption;
} }
public function getVideoWidth() public function getVideoWidth()
{ {
return $this->video_width; return $this->video_width;
} }
public function getVideoHeight() public function getVideoHeight()
{ {
return $this->video_height; return $this->video_height;
} }
public function getVideoDuration() public function getVideoDuration()
{ {
return $this->video_duration; return $this->video_duration;
} }
public function getDescription() public function getDescription()
{ {
return $this->description; return $this->description;
......
...@@ -20,8 +20,6 @@ class InputContactMessageContent extends InputMessageContent ...@@ -20,8 +20,6 @@ class InputContactMessageContent extends InputMessageContent
public function __construct(array $data) public function __construct(array $data)
{ {
//parent::__construct($data);
$this->phone_number isset($data['phone_number']) ? $data['phone_number'] : null; $this->phone_number isset($data['phone_number']) ? $data['phone_number'] : null;
if (empty($this->phone_number)) { if (empty($this->phone_number)) {
throw new TelegramException('phone_number is empty!'); throw new TelegramException('phone_number is empty!');
......
...@@ -19,8 +19,6 @@ class InputLocationMessageContent extends InputMessageContent ...@@ -19,8 +19,6 @@ class InputLocationMessageContent extends InputMessageContent
public function __construct(array $data) public function __construct(array $data)
{ {
//parent::__construct($data);
$this->latitude isset($data['latitude']) ? $data['latitude'] : null; $this->latitude isset($data['latitude']) ? $data['latitude'] : null;
if (empty($this->latitude)) { if (empty($this->latitude)) {
throw new TelegramException('latitude is empty!'); throw new TelegramException('latitude is empty!');
......
...@@ -20,8 +20,6 @@ class InputTextMessageContent extends InputMessageContent ...@@ -20,8 +20,6 @@ class InputTextMessageContent extends InputMessageContent
public function __construct(array $data) public function __construct(array $data)
{ {
//parent::__construct($data);
$this->message_text isset($data['message_text']) ? $data['message_text'] : null; $this->message_text isset($data['message_text']) ? $data['message_text'] : null;
if (empty($this->message_text)) { if (empty($this->message_text)) {
throw new TelegramException('message_text is empty!'); throw new TelegramException('message_text is empty!');
......
...@@ -22,8 +22,6 @@ class InputVenueMessageContent extends InputMessageContent ...@@ -22,8 +22,6 @@ class InputVenueMessageContent extends InputMessageContent
public function __construct(array $data) public function __construct(array $data)
{ {
//parent::__construct($data);
$this->latitude isset($data['latitude']) ? $data['latitude'] : null; $this->latitude isset($data['latitude']) ? $data['latitude'] : null;
if (empty($this->latitude)) { if (empty($this->latitude)) {
throw new TelegramException('latitude is empty!'); throw new TelegramException('latitude is empty!');
......
...@@ -122,7 +122,6 @@ class Message extends Entity ...@@ -122,7 +122,6 @@ class Message extends Entity
$this->forward_from = isset($data['forward_from']) ? $data['forward_from'] : null; $this->forward_from = isset($data['forward_from']) ? $data['forward_from'] : null;
if (!empty($this->forward_from)) { if (!empty($this->forward_from)) {
$this->forward_from = new User($this->forward_from); $this->forward_from = new User($this->forward_from);
} }
$this->forward_from_chat = isset($data['forward_from_chat']) ? $data['forward_from_chat'] : null; $this->forward_from_chat = isset($data['forward_from_chat']) ? $data['forward_from_chat'] : null;
......
...@@ -17,20 +17,23 @@ class MessageEntity extends Entity ...@@ -17,20 +17,23 @@ class MessageEntity extends Entity
protected $length; protected $length;
protected $url; protected $url;
/**
* @todo check for type value from this list: https://core.telegram.org/bots/api#messageentity
*/
public function __construct(array $data) public function __construct(array $data)
{ {
$this->type = isset($data['type']) ? $data['type'] : null; $this->type = isset($data['type']) ? $data['type'] : null;
if (empty($this->type)) { // @todo check for value from this list: https://core.telegram.org/bots/api#messageentity if (empty($this->type)) {
throw new TelegramException('type is empty!'); throw new TelegramException('type is empty!');
} }
$this->offset = isset($data['offset']) ? $data['offset'] : null; $this->offset = isset($data['offset']) ? $data['offset'] : null;
if (empty($this->offset) && $this->offset != 0) { // @todo this is not an ideal solution? if ($this->offset === '') {
throw new TelegramException('offset is empty!'); throw new TelegramException('offset is empty!');
} }
$this->length = isset($data['length']) ? $data['length'] : null; $this->length = isset($data['length']) ? $data['length'] : null;
if (empty($this->length) && $this->offset != 0) { // @todo this is not an ideal solution? if ($this->length === '') {
throw new TelegramException('length is empty!'); throw new TelegramException('length is empty!');
} }
......
...@@ -21,7 +21,7 @@ class ReplyKeyboardMarkup extends Entity ...@@ -21,7 +21,7 @@ class ReplyKeyboardMarkup extends Entity
protected $one_time_keyboard; protected $one_time_keyboard;
protected $selective; protected $selective;
/* /**
* @todo check for KeyboardButton elements * @todo check for KeyboardButton elements
*/ */
public function __construct($data = array()) public function __construct($data = array())
......
...@@ -568,6 +568,12 @@ class Telegram ...@@ -568,6 +568,12 @@ class Telegram
if ($user_id === null && $this->update !== null) { if ($user_id === null && $this->update !== null) {
if (($message = $this->update->getMessage()) && ($from = $message->getFrom())) { if (($message = $this->update->getMessage()) && ($from = $message->getFrom())) {
$user_id = $from->getId(); $user_id = $from->getId();
} elseif (($inline_query = $this->update->getInlineQuery()) && ($from = $inline_query->getFrom())) {
$user_id = $from->getId();
} elseif (($callback_query = $this->update->getCallbackQuery()) && ($from = $callback_query->getFrom())) {
$user_id = $from->getId();
} elseif (($chosen_inline_result = $this->update->getChosenInlineResult()) && ($from = $chosen_inline_result->getFrom())) {
$user_id = $from->getId();
} }
} }
......
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