Commit 1513e971 authored by Marco Boretto's avatar Marco Boretto Committed by GitHub

Merge pull request #236 from MBoretto/develop

various
parents ea01d341 edd902d6
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
namespace Longman\TelegramBot; namespace Longman\TelegramBot;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Exception\TelegramException; use Longman\TelegramBot\Exception\TelegramException;
/** /**
...@@ -33,8 +32,10 @@ class BotanDB extends DB ...@@ -33,8 +32,10 @@ class BotanDB extends DB
* *
* @param $user_id * @param $user_id
* @param $url * @param $url
* @return bool|string *
* @throws TelegramException * @throws TelegramException
*
* @return bool|string
*/ */
public static function selectShortUrl($user_id, $url) public static function selectShortUrl($user_id, $url)
{ {
...@@ -65,8 +66,10 @@ class BotanDB extends DB ...@@ -65,8 +66,10 @@ class BotanDB extends DB
* @param $user_id * @param $user_id
* @param $url * @param $url
* @param $short_url * @param $short_url
* @return bool *
* @throws TelegramException * @throws TelegramException
*
* @return bool
*/ */
public static function insertShortUrl($user_id, $url, $short_url) public static function insertShortUrl($user_id, $url, $short_url)
{ {
......
...@@ -33,7 +33,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -33,7 +33,7 @@ class SendtochannelCommand extends AdminCommand
/** /**
* Conversation Object * Conversation Object
* *
* @var Longman\TelegramBot\Conversation * @var \Longman\TelegramBot\Conversation
*/ */
protected $conversation; protected $conversation;
...@@ -128,7 +128,6 @@ class SendtochannelCommand extends AdminCommand ...@@ -128,7 +128,6 @@ class SendtochannelCommand extends AdminCommand
$this->conversation->notes['last_message_id'] = $message->getMessageId(); $this->conversation->notes['last_message_id'] = $message->getMessageId();
$this->conversation->notes['message'] = $message->reflect(); $this->conversation->notes['message'] = $message->reflect();
$this->conversation->notes['message_type'] = $type; $this->conversation->notes['message_type'] = $type;
// no break // no break
case 2: case 2:
if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || !($text == 'Yes' || $text == 'No')) { if ($this->conversation->notes['last_message_id'] == $message->getMessageId() || !($text == 'Yes' || $text == 'No')) {
...@@ -258,7 +257,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -258,7 +257,7 @@ class SendtochannelCommand extends AdminCommand
/** /**
* Publish a message to a channel and return success or failure message * Publish a message to a channel and return success or failure message
* *
* @param Entities\Message $message * @param \Longman\TelegramBot\Entities\Message $message
* @param int $channel * @param int $channel
* @param string|null $caption * @param string|null $caption
* *
...@@ -292,10 +291,10 @@ class SendtochannelCommand extends AdminCommand ...@@ -292,10 +291,10 @@ class SendtochannelCommand extends AdminCommand
* @todo This method will be moved at an higher level maybe in AdminCommand or Command * @todo This method will be moved at an higher level maybe in AdminCommand or Command
* @todo Looking for a more significative name * @todo Looking for a more significative name
* *
* @param Entities\Message $message * @param \Longman\TelegramBot\Entities\Message $message
* @param array $data * @param array $data
* *
* @return Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
*/ */
protected function sendBack(Message $message, array $data) protected function sendBack(Message $message, array $data)
{ {
......
...@@ -13,9 +13,7 @@ namespace Longman\TelegramBot\Commands; ...@@ -13,9 +13,7 @@ namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\DB; use Longman\TelegramBot\DB;
use Longman\TelegramBot\Request; use Longman\TelegramBot\Request;
use Longman\TelegramBot\Telegram; use Longman\TelegramBot\Telegram;
use Longman\TelegramBot\Entities\Chat;
use Longman\TelegramBot\Entities\Update; use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Entities\User;
/** /**
* Abstract Command Class * Abstract Command Class
...@@ -32,14 +30,14 @@ abstract class Command ...@@ -32,14 +30,14 @@ abstract class Command
/** /**
* Update object * Update object
* *
* @var Entities\Update * @var \Longman\TelegramBot\Entities\Update
*/ */
protected $update; protected $update;
/** /**
* Message object * Message object
* *
* @var Entities\Message * @var \Longman\TelegramBot\Entities\Message
*/ */
protected $message; protected $message;
...@@ -96,7 +94,7 @@ abstract class Command ...@@ -96,7 +94,7 @@ abstract class Command
* Constructor * Constructor
* *
* @param Telegram $telegram * @param Telegram $telegram
* @param Entities\Update $update * @param \Longman\TelegramBot\Entities\Update $update
*/ */
public function __construct(Telegram $telegram, Update $update = null) public function __construct(Telegram $telegram, Update $update = null)
{ {
...@@ -108,7 +106,7 @@ abstract class Command ...@@ -108,7 +106,7 @@ abstract class Command
/** /**
* Set update object * Set update object
* *
* @param Entities\Update $update * @param \Longman\TelegramBot\Entities\Update $update
* @return Command * @return Command
*/ */
public function setUpdate(Update $update = null) public function setUpdate(Update $update = null)
...@@ -123,7 +121,7 @@ abstract class Command ...@@ -123,7 +121,7 @@ abstract class Command
/** /**
* Pre-execute command * Pre-execute command
* *
* @return Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
*/ */
public function preExecute() public function preExecute()
{ {
...@@ -136,14 +134,14 @@ abstract class Command ...@@ -136,14 +134,14 @@ abstract class Command
/** /**
* Execute command * Execute command
* *
* @return Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
*/ */
abstract public function execute(); abstract public function execute();
/** /**
* Execution if MySQL is required but not available * Execution if MySQL is required but not available
* *
* @return Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
*/ */
public function executeNoDb() public function executeNoDb()
{ {
...@@ -162,7 +160,7 @@ abstract class Command ...@@ -162,7 +160,7 @@ abstract class Command
/** /**
* Get update object * Get update object
* *
* @return Entities\Update * @return \Longman\TelegramBot\Entities\Update
*/ */
public function getUpdate() public function getUpdate()
{ {
...@@ -172,7 +170,7 @@ abstract class Command ...@@ -172,7 +170,7 @@ abstract class Command
/** /**
* Get message object * Get message object
* *
* @return Entities\Message * @return \Longman\TelegramBot\Entities\Message
*/ */
public function getMessage() public function getMessage()
{ {
......
...@@ -68,7 +68,7 @@ class CancelCommand extends UserCommand ...@@ -68,7 +68,7 @@ class CancelCommand extends UserCommand
* *
* @param string $text * @param string $text
* *
* @return Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
*/ */
private function hideKeyboard($text) private function hideKeyboard($text)
{ {
......
...@@ -202,7 +202,7 @@ class DateCommand extends UserCommand ...@@ -202,7 +202,7 @@ class DateCommand extends UserCommand
if (empty($location)) { if (empty($location)) {
$text = 'You must specify location in format: /date <city>'; $text = 'You must specify location in format: /date <city>';
} else { } else {
$text = $this->getformattedDate($location); $text = $this->getFormattedDate($location);
} }
$data = [ $data = [
......
...@@ -35,7 +35,7 @@ class SurveyCommand extends UserCommand ...@@ -35,7 +35,7 @@ class SurveyCommand extends UserCommand
/** /**
* Conversation Object * Conversation Object
* *
* @var Longman\TelegramBot\Conversation * @var \Longman\TelegramBot\Conversation
*/ */
protected $conversation; protected $conversation;
...@@ -57,7 +57,6 @@ class SurveyCommand extends UserCommand ...@@ -57,7 +57,6 @@ class SurveyCommand extends UserCommand
$data = []; $data = [];
if ($chat->isGroupChat() || $chat->isSuperGroup()) { if ($chat->isGroupChat() || $chat->isSuperGroup()) {
//reply to message id is applied by default //reply to message id is applied by default
$data['reply_to_message_id'] = $message_id;
//Force reply is applied by default to so can work with privacy on //Force reply is applied by default to so can work with privacy on
$data['reply_markup'] = new ForceReply([ 'selective' => true]); $data['reply_markup'] = new ForceReply([ 'selective' => true]);
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
namespace Longman\TelegramBot; namespace Longman\TelegramBot;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Exception\TelegramException; use Longman\TelegramBot\Exception\TelegramException;
/** /**
...@@ -49,7 +48,6 @@ class ConversationDB extends DB ...@@ -49,7 +48,6 @@ class ConversationDB extends DB
$query .= 'AND `chat_id` = :chat_id '; $query .= 'AND `chat_id` = :chat_id ';
$query .= 'AND `user_id` = :user_id '; $query .= 'AND `user_id` = :user_id ';
$tokens = [':chat_id' => $chat_id, ':user_id' => $user_id];
if (!is_null($limit)) { if (!is_null($limit)) {
$query .= ' LIMIT :limit'; $query .= ' LIMIT :limit';
} }
......
...@@ -199,7 +199,7 @@ class DB ...@@ -199,7 +199,7 @@ class DB
$sth_select_telegram_update->bindParam(':limit', $limit, \PDO::PARAM_INT); $sth_select_telegram_update->bindParam(':limit', $limit, \PDO::PARAM_INT);
$sth_select_telegram_update->execute(); $sth_select_telegram_update->execute();
$results = $sth_select_telegram_update->fetchAll(\PDO::FETCH_ASSOC); $results = $sth_select_telegram_update->fetchAll(\PDO::FETCH_ASSOC);
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
...@@ -234,7 +234,7 @@ class DB ...@@ -234,7 +234,7 @@ class DB
$sth->bindParam(':limit', $limit, \PDO::PARAM_INT); $sth->bindParam(':limit', $limit, \PDO::PARAM_INT);
$sth->execute(); $sth->execute();
$results = $sth->fetchAll(\PDO::FETCH_ASSOC); $results = $sth->fetchAll(\PDO::FETCH_ASSOC);
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
...@@ -299,7 +299,7 @@ class DB ...@@ -299,7 +299,7 @@ class DB
$sth_insert_telegram_update->bindParam(':edited_message_id', $edited_message_id, \PDO::PARAM_INT); $sth_insert_telegram_update->bindParam(':edited_message_id', $edited_message_id, \PDO::PARAM_INT);
return $sth_insert_telegram_update->execute(); return $sth_insert_telegram_update->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -344,7 +344,7 @@ class DB ...@@ -344,7 +344,7 @@ class DB
$sth1->bindParam(':date', $date, \PDO::PARAM_STR); $sth1->bindParam(':date', $date, \PDO::PARAM_STR);
$status = $sth1->execute(); $status = $sth1->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
...@@ -364,7 +364,7 @@ class DB ...@@ -364,7 +364,7 @@ class DB
$sth3->bindParam(':chat_id', $chat_id, \PDO::PARAM_INT); $sth3->bindParam(':chat_id', $chat_id, \PDO::PARAM_INT);
$status = $sth3->execute(); $status = $sth3->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -418,7 +418,7 @@ class DB ...@@ -418,7 +418,7 @@ class DB
$sth2->bindParam(':date', $date, \PDO::PARAM_STR); $sth2->bindParam(':date', $date, \PDO::PARAM_STR);
return $sth2->execute(); return $sth2->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -523,7 +523,7 @@ class DB ...@@ -523,7 +523,7 @@ class DB
$sth_insert_inline_query->bindParam(':created_at', $date, \PDO::PARAM_STR); $sth_insert_inline_query->bindParam(':created_at', $date, \PDO::PARAM_STR);
return $sth_insert_inline_query->execute(); return $sth_insert_inline_query->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -574,7 +574,7 @@ class DB ...@@ -574,7 +574,7 @@ class DB
$sth_insert_chosen_inline_result->bindParam(':created_at', $date, \PDO::PARAM_STR); $sth_insert_chosen_inline_result->bindParam(':created_at', $date, \PDO::PARAM_STR);
return $sth_insert_chosen_inline_result->execute(); return $sth_insert_chosen_inline_result->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -644,7 +644,7 @@ class DB ...@@ -644,7 +644,7 @@ class DB
$sth_insert_callback_query->bindParam(':created_at', $date, \PDO::PARAM_STR); $sth_insert_callback_query->bindParam(':created_at', $date, \PDO::PARAM_STR);
return $sth_insert_callback_query->execute(); return $sth_insert_callback_query->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -685,18 +685,15 @@ class DB ...@@ -685,18 +685,15 @@ class DB
//Insert user and the relation with the chat //Insert user and the relation with the chat
self::insertUser($from, $date, $chat); self::insertUser($from, $date, $chat);
//Forwarded object
if ($forward_from || $forward_from_chat) {
$forward_date = self::getTimestamp($message->getForwardDate());
}
//Insert the forwarded message user in users table //Insert the forwarded message user in users table
if (is_object($forward_from)) { if (is_object($forward_from)) {
$forward_date = self::getTimestamp($message->getForwardDate());
self::insertUser($forward_from, $forward_date); self::insertUser($forward_from, $forward_date);
$forward_from = $forward_from->getId(); $forward_from = $forward_from->getId();
} }
if (is_object($forward_from_chat)) { if (is_object($forward_from_chat)) {
$forward_date = self::getTimestamp($message->getForwardDate());
self::insertChat($forward_from_chat, $forward_date); self::insertChat($forward_from_chat, $forward_date);
$forward_from_chat = $forward_from_chat->getId(); $forward_from_chat = $forward_from_chat->getId();
} }
...@@ -841,7 +838,7 @@ class DB ...@@ -841,7 +838,7 @@ class DB
$sth->bindParam(':pinned_message', $pinned_message, \PDO::PARAM_INT); $sth->bindParam(':pinned_message', $pinned_message, \PDO::PARAM_INT);
return $sth->execute(); return $sth->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -911,7 +908,7 @@ class DB ...@@ -911,7 +908,7 @@ class DB
$sth->bindParam(':caption', $caption, \PDO::PARAM_STR); $sth->bindParam(':caption', $caption, \PDO::PARAM_STR);
return $sth->execute(); return $sth->execute();
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
} }
...@@ -1027,7 +1024,7 @@ class DB ...@@ -1027,7 +1024,7 @@ class DB
$sth->execute($tokens); $sth->execute($tokens);
$result = $sth->fetchAll(\PDO::FETCH_ASSOC); $result = $sth->fetchAll(\PDO::FETCH_ASSOC);
} catch (PDOException $e) { } catch (\PDOException $e) {
throw new TelegramException($e->getMessage()); throw new TelegramException($e->getMessage());
} }
......
...@@ -21,6 +21,11 @@ class Audio extends Entity ...@@ -21,6 +21,11 @@ class Audio extends Entity
protected $mime_type; protected $mime_type;
protected $file_size; protected $file_size;
/**
* Audio constructor.
*
* @param array $data
*/
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;
......
...@@ -20,6 +20,11 @@ class CallbackQuery extends Entity ...@@ -20,6 +20,11 @@ class CallbackQuery extends Entity
protected $inline_message_id; protected $inline_message_id;
protected $data; protected $data;
/**
* CallbackQuery constructor.
*
* @param array $data
*/
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;
......
...@@ -21,6 +21,11 @@ class Chat extends Entity ...@@ -21,6 +21,11 @@ class Chat extends Entity
protected $first_name; protected $first_name;
protected $last_name; protected $last_name;
/**
* Chat constructor.
*
* @param array $data
*/
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;
......
...@@ -15,6 +15,11 @@ class ChatMember extends Entity ...@@ -15,6 +15,11 @@ class ChatMember extends Entity
protected $user; protected $user;
protected $status; protected $status;
/**
* ChatMember constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
$this->user = isset($data['user']) ? $data['user'] : null; $this->user = isset($data['user']) ? $data['user'] : null;
......
...@@ -20,6 +20,11 @@ class ChosenInlineResult extends Entity ...@@ -20,6 +20,11 @@ class ChosenInlineResult extends Entity
protected $inline_message_id; protected $inline_message_id;
protected $query; protected $query;
/**
* ChosenInlineResult constructor.
*
* @param array $data
*/
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;
......
...@@ -19,6 +19,11 @@ class Contact extends Entity ...@@ -19,6 +19,11 @@ class Contact extends Entity
protected $last_name; protected $last_name;
protected $user_id; protected $user_id;
/**
* Contact constructor.
*
* @param array $data
*/
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;
......
...@@ -20,6 +20,11 @@ class Document extends Entity ...@@ -20,6 +20,11 @@ class Document extends Entity
protected $mime_type; protected $mime_type;
protected $file_size; protected $file_size;
/**
* Document constructor.
*
* @param array $data
*/
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;
......
...@@ -18,6 +18,11 @@ class File extends Entity ...@@ -18,6 +18,11 @@ class File extends Entity
protected $file_size; protected $file_size;
protected $file_path; protected $file_path;
/**
* File constructor.
*
* @param array $data
*/
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;
......
...@@ -19,6 +19,11 @@ class ForceReply extends Entity ...@@ -19,6 +19,11 @@ class ForceReply extends Entity
protected $force_reply; protected $force_reply;
protected $selective; protected $selective;
/**
* ForceReply constructor.
*
* @param array|null $data
*/
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->force_reply = true; $this->force_reply = true;
......
...@@ -19,8 +19,13 @@ class InlineKeyboardButton extends Entity ...@@ -19,8 +19,13 @@ class InlineKeyboardButton extends Entity
protected $callback_data; protected $callback_data;
protected $switch_inline_query; protected $switch_inline_query;
/** /**
* InlineKeyboardButton constructor.
*
* @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 * @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
*
* @param array $data
*/ */
public function __construct($data = array()) public function __construct($data = array())
{ {
......
...@@ -16,6 +16,11 @@ class InlineKeyboardMarkup extends Entity ...@@ -16,6 +16,11 @@ class InlineKeyboardMarkup extends Entity
{ {
protected $inline_keyboard; protected $inline_keyboard;
/**
* InlineKeyboardMarkup constructor.
*
* @param array $data
*/
public function __construct($data = array()) public function __construct($data = array())
{ {
if (isset($data['inline_keyboard'])) { if (isset($data['inline_keyboard'])) {
......
...@@ -20,6 +20,11 @@ class InlineQuery extends Entity ...@@ -20,6 +20,11 @@ class InlineQuery extends Entity
protected $query; protected $query;
protected $offset; protected $offset;
/**
* InlineQuery constructor.
*
* @param array $data
*/
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;
......
...@@ -19,6 +19,11 @@ class InlineQueryResult extends Entity ...@@ -19,6 +19,11 @@ class InlineQueryResult extends Entity
protected $input_message_content; protected $input_message_content;
protected $reply_markup; protected $reply_markup;
/**
* InlineQueryResult constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
$this->type = null; $this->type = null;
......
...@@ -23,6 +23,11 @@ class InlineQueryResultArticle extends InlineQueryResult ...@@ -23,6 +23,11 @@ class InlineQueryResultArticle extends InlineQueryResult
protected $thumb_width; protected $thumb_width;
protected $thumb_height; protected $thumb_height;
/**
* InlineQueryResultArticle constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -19,6 +19,11 @@ class InlineQueryResultAudio extends InlineQueryResult ...@@ -19,6 +19,11 @@ class InlineQueryResultAudio extends InlineQueryResult
protected $performer; protected $performer;
protected $audio_duration; protected $audio_duration;
/**
* InlineQueryResultAudio constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -16,6 +16,11 @@ class InlineQueryResultCachedAudio extends InlineQueryResult ...@@ -16,6 +16,11 @@ class InlineQueryResultCachedAudio extends InlineQueryResult
{ {
protected $audio_file_id; protected $audio_file_id;
/**
* InlineQueryResultCachedAudio constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -19,6 +19,11 @@ class InlineQueryResultCachedDocument extends InlineQueryResult ...@@ -19,6 +19,11 @@ class InlineQueryResultCachedDocument extends InlineQueryResult
protected $description; protected $description;
protected $caption; protected $caption;
/**
* InlineQueryResultCachedDocument constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -19,6 +19,11 @@ class InlineQueryResultCachedGif extends InlineQueryResult ...@@ -19,6 +19,11 @@ class InlineQueryResultCachedGif extends InlineQueryResult
protected $description; protected $description;
protected $caption; protected $caption;
/**
* InlineQueryResultCachedGif constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -18,6 +18,11 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult ...@@ -18,6 +18,11 @@ class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult
protected $title; protected $title;
protected $caption; protected $caption;
/**
* InlineQueryResultCachedMpeg4Gif constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -19,6 +19,11 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult ...@@ -19,6 +19,11 @@ class InlineQueryResultCachedPhoto extends InlineQueryResult
protected $description; protected $description;
protected $caption; protected $caption;
/**
* InlineQueryResultCachedPhoto constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -16,6 +16,11 @@ class InlineQueryResultCachedSticker extends InlineQueryResult ...@@ -16,6 +16,11 @@ class InlineQueryResultCachedSticker extends InlineQueryResult
{ {
protected $sticker_file_id; protected $sticker_file_id;
/**
* InlineQueryResultCachedSticker constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -19,6 +19,11 @@ class InlineQueryResultCachedVideo extends InlineQueryResult ...@@ -19,6 +19,11 @@ class InlineQueryResultCachedVideo extends InlineQueryResult
protected $description; protected $description;
protected $caption; protected $caption;
/**
* InlineQueryResultCachedVideo constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -19,6 +19,11 @@ class InlineQueryResultCachedVoice extends InlineQueryResult ...@@ -19,6 +19,11 @@ class InlineQueryResultCachedVoice extends InlineQueryResult
protected $description; protected $description;
protected $caption; protected $caption;
/**
* InlineQueryResultCachedVoice constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -21,6 +21,11 @@ class InlineQueryResultContact extends InlineQueryResult ...@@ -21,6 +21,11 @@ class InlineQueryResultContact extends InlineQueryResult
protected $thumb_width; protected $thumb_width;
protected $thumb_height; protected $thumb_height;
/**
* InlineQueryResultContact constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -23,6 +23,11 @@ class InlineQueryResultDocument extends InlineQueryResult ...@@ -23,6 +23,11 @@ class InlineQueryResultDocument extends InlineQueryResult
protected $thumb_width; protected $thumb_width;
protected $thumb_height; protected $thumb_height;
/**
* InlineQueryResultDocument constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -21,6 +21,11 @@ class InlineQueryResultGif extends InlineQueryResult ...@@ -21,6 +21,11 @@ class InlineQueryResultGif extends InlineQueryResult
protected $title; protected $title;
protected $caption; protected $caption;
/**
* InlineQueryResultGif constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -21,6 +21,11 @@ class InlineQueryResultLocation extends InlineQueryResult ...@@ -21,6 +21,11 @@ class InlineQueryResultLocation extends InlineQueryResult
protected $thumb_width; protected $thumb_width;
protected $thumb_height; protected $thumb_height;
/**
* InlineQueryResultLocation constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -21,6 +21,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult ...@@ -21,6 +21,11 @@ class InlineQueryResultMpeg4Gif extends InlineQueryResult
protected $title; protected $title;
protected $caption; protected $caption;
/**
* InlineQueryResultMpeg4Gif constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -22,6 +22,11 @@ class InlineQueryResultPhoto extends InlineQueryResult ...@@ -22,6 +22,11 @@ class InlineQueryResultPhoto extends InlineQueryResult
protected $description; protected $description;
protected $caption; protected $caption;
/**
* InlineQueryResultPhoto constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -23,6 +23,11 @@ class InlineQueryResultVenue extends InlineQueryResult ...@@ -23,6 +23,11 @@ class InlineQueryResultVenue extends InlineQueryResult
protected $thumb_width; protected $thumb_width;
protected $thumb_height; protected $thumb_height;
/**
* InlineQueryResultVenue constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -24,6 +24,11 @@ class InlineQueryResultVideo extends InlineQueryResult ...@@ -24,6 +24,11 @@ class InlineQueryResultVideo extends InlineQueryResult
protected $video_duration; protected $video_duration;
protected $description; protected $description;
/**
* InlineQueryResultVideo constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -18,6 +18,11 @@ class InlineQueryResultVoice extends InlineQueryResult ...@@ -18,6 +18,11 @@ class InlineQueryResultVoice extends InlineQueryResult
protected $title; protected $title;
protected $voice_duration; protected $voice_duration;
/**
* InlineQueryResultVoice constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
parent::__construct($data); parent::__construct($data);
......
...@@ -18,6 +18,11 @@ class InputContactMessageContent extends InputMessageContent ...@@ -18,6 +18,11 @@ class InputContactMessageContent extends InputMessageContent
protected $first_name; protected $first_name;
protected $last_name; protected $last_name;
/**
* InputContactMessageContent constructor.
*
* @param array $data
*/
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;
......
...@@ -17,6 +17,11 @@ class InputLocationMessageContent extends InputMessageContent ...@@ -17,6 +17,11 @@ class InputLocationMessageContent extends InputMessageContent
protected $latitude; protected $latitude;
protected $longitude; protected $longitude;
/**
* InputLocationMessageContent constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
$this->latitude = isset($data['latitude']) ? $data['latitude'] : null; $this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
......
...@@ -18,6 +18,11 @@ class InputTextMessageContent extends InputMessageContent ...@@ -18,6 +18,11 @@ class InputTextMessageContent extends InputMessageContent
protected $parse_mode; protected $parse_mode;
protected $disable_web_page_preview; protected $disable_web_page_preview;
/**
* InputTextMessageContent constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
$this->message_text = isset($data['message_text']) ? $data['message_text'] : null; $this->message_text = isset($data['message_text']) ? $data['message_text'] : null;
......
...@@ -20,6 +20,11 @@ class InputVenueMessageContent extends InputMessageContent ...@@ -20,6 +20,11 @@ class InputVenueMessageContent extends InputMessageContent
protected $address; protected $address;
protected $foursquare_id; protected $foursquare_id;
/**
* InputVenueMessageContent constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
$this->latitude = isset($data['latitude']) ? $data['latitude'] : null; $this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
......
...@@ -18,6 +18,11 @@ class KeyboardButton extends Entity ...@@ -18,6 +18,11 @@ class KeyboardButton extends Entity
protected $request_contact; protected $request_contact;
protected $request_location; protected $request_location;
/**
* KeyboardButton constructor.
*
* @param array $data
*/
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;
......
...@@ -18,6 +18,11 @@ class Location extends Entity ...@@ -18,6 +18,11 @@ class Location extends Entity
protected $longitude; protected $longitude;
protected $latitude; protected $latitude;
/**
* Location constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
......
...@@ -82,6 +82,12 @@ class Message extends Entity ...@@ -82,6 +82,12 @@ class Message extends Entity
private $type; private $type;
/**
* Message constructor.
*
* @param array $data
* @param $bot_name
*/
public function __construct(array $data, $bot_name) public function __construct(array $data, $bot_name)
{ {
...@@ -334,6 +340,11 @@ class Message extends Entity ...@@ -334,6 +340,11 @@ class Message extends Entity
return $this->message_id; return $this->message_id;
} }
/**
* Get User object related to the message
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getFrom() public function getFrom()
{ {
return $this->from; return $this->from;
...@@ -344,16 +355,31 @@ class Message extends Entity ...@@ -344,16 +355,31 @@ class Message extends Entity
return $this->date; return $this->date;
} }
/**
* Get User object related to the message
*
* @return \Longman\TelegramBot\Entities\Chat
*/
public function getChat() public function getChat()
{ {
return $this->chat; return $this->chat;
} }
/**
* Get User object related to the forwarded message
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getForwardFrom() public function getForwardFrom()
{ {
return $this->forward_from; return $this->forward_from;
} }
/**
* Get User object related to the message
*
* @return \Longman\TelegramBot\Entities\Chat
*/
public function getForwardFromChat() public function getForwardFromChat()
{ {
return $this->forward_from_chat; return $this->forward_from_chat;
...@@ -388,30 +414,48 @@ class Message extends Entity ...@@ -388,30 +414,48 @@ class Message extends Entity
return $text; return $text;
} }
/**
* @return \Longman\TelegramBot\Entities\Audio
*/
public function getAudio() public function getAudio()
{ {
return $this->audio; return $this->audio;
} }
/**
* @return \Longman\TelegramBot\Entities\Document
*/
public function getDocument() public function getDocument()
{ {
return $this->document; return $this->document;
} }
/**
* @return array
*/
public function getPhoto() public function getPhoto()
{ {
return $this->photo; return $this->photo;
} }
/**
* @return \Longman\TelegramBot\Entities\Sticker
*/
public function getSticker() public function getSticker()
{ {
return $this->sticker; return $this->sticker;
} }
/**
* @return \Longman\TelegramBot\Entities\Video
*/
public function getVideo() public function getVideo()
{ {
return $this->video; return $this->video;
} }
/**
* @return \Longman\TelegramBot\Entities\Voice
*/
public function getVoice() public function getVoice()
{ {
return $this->voice; return $this->voice;
...@@ -422,11 +466,17 @@ class Message extends Entity ...@@ -422,11 +466,17 @@ class Message extends Entity
return $this->caption; return $this->caption;
} }
/**
* @return \Longman\TelegramBot\Entities\Contact
*/
public function getContact() public function getContact()
{ {
return $this->contact; return $this->contact;
} }
/**
* @return \Longman\TelegramBot\Entities\Location
*/
public function getLocation() public function getLocation()
{ {
return $this->location; return $this->location;
...@@ -446,12 +496,21 @@ class Message extends Entity ...@@ -446,12 +496,21 @@ class Message extends Entity
{ {
return $this->left_chat_member; return $this->left_chat_member;
} }
/**
* Get User object related to the new member
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getNewChatMember() public function getNewChatMember()
{ {
return $this->new_chat_member; return $this->new_chat_member;
} }
/**
* Get User object related to the left member
*
* @return \Longman\TelegramBot\Entities\User
*/
public function getLeftChatMember() public function getLeftChatMember()
{ {
return $this->left_chat_member; return $this->left_chat_member;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
namespace Longman\TelegramBot\Entities; namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class MessageEntity extends Entity class MessageEntity extends Entity
{ {
protected $type; protected $type;
...@@ -19,7 +21,11 @@ class MessageEntity extends Entity ...@@ -19,7 +21,11 @@ class MessageEntity extends Entity
protected $user; protected $user;
/** /**
* MessageEntity constructor.
*
* @todo check for type value from this list: https://core.telegram.org/bots/api#messageentity * @todo check for type value from this list: https://core.telegram.org/bots/api#messageentity
*
* @param array $data
*/ */
public function __construct(array $data) public function __construct(array $data)
{ {
......
...@@ -18,8 +18,12 @@ class PhotoSize extends Entity ...@@ -18,8 +18,12 @@ class PhotoSize extends Entity
protected $width; protected $width;
protected $height; protected $height;
protected $file_size; protected $file_size;
/**
* PhotoSize constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
......
...@@ -12,13 +12,16 @@ ...@@ -12,13 +12,16 @@
namespace Longman\TelegramBot\Entities; namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class ReplyKeyboardHide extends Entity class ReplyKeyboardHide extends Entity
{ {
protected $hide_keyboard; protected $hide_keyboard;
protected $selective; protected $selective;
/**
* ReplyKeyboardHide constructor.
*
* @param array|null $data
*/
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->hide_keyboard = true; $this->hide_keyboard = true;
......
...@@ -21,6 +21,11 @@ class ReplyKeyboardMarkup extends Entity ...@@ -21,6 +21,11 @@ class ReplyKeyboardMarkup extends Entity
protected $one_time_keyboard; protected $one_time_keyboard;
protected $selective; protected $selective;
/**
* ReplyKeyboardMarkup constructor.
*
* @param array $data
*/
public function __construct($data = array()) public function __construct($data = array())
{ {
if (isset($data['keyboard'])) { if (isset($data['keyboard'])) {
......
...@@ -10,11 +10,15 @@ ...@@ -10,11 +10,15 @@
namespace Longman\TelegramBot\Entities; namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class ReplyToMessage extends Message class ReplyToMessage extends Message
{ {
/**
* ReplyToMessage constructor.
*
* @param array $data
* @param $bot_name
*/
public function __construct(array $data, $bot_name) public function __construct(array $data, $bot_name)
{ {
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
namespace Longman\TelegramBot\Entities; namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Exception\TelegramException;
class ServerResponse extends Entity class ServerResponse extends Entity
{ {
protected $ok; protected $ok;
...@@ -19,6 +17,12 @@ class ServerResponse extends Entity ...@@ -19,6 +17,12 @@ class ServerResponse extends Entity
protected $error_code; protected $error_code;
protected $description; protected $description;
/**
* ServerResponse constructor.
*
* @param array $data
* @param $bot_name
*/
public function __construct(array $data, $bot_name) public function __construct(array $data, $bot_name)
{ {
if (isset($data['ok']) & isset($data['result'])) { if (isset($data['ok']) & isset($data['result'])) {
......
...@@ -21,6 +21,11 @@ class Sticker extends Entity ...@@ -21,6 +21,11 @@ class Sticker extends Entity
protected $emoji; protected $emoji;
protected $file_size; protected $file_size;
/**
* Sticker constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
......
...@@ -24,6 +24,12 @@ class Update extends Entity ...@@ -24,6 +24,12 @@ class Update extends Entity
private $update_type; private $update_type;
/**
* Update constructor.
*
* @param array $data
* @param $bot_name
*/
public function __construct(array $data, $bot_name) public function __construct(array $data, $bot_name)
{ {
......
...@@ -20,6 +20,11 @@ class User extends Entity ...@@ -20,6 +20,11 @@ class User extends Entity
protected $last_name; protected $last_name;
protected $username; protected $username;
/**
* User constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
......
...@@ -18,6 +18,11 @@ class UserProfilePhotos extends Entity ...@@ -18,6 +18,11 @@ class UserProfilePhotos extends Entity
protected $total_count; protected $total_count;
protected $photos; protected $photos;
/**
* UserProfilePhotos constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
......
...@@ -21,6 +21,11 @@ class Venue extends Entity ...@@ -21,6 +21,11 @@ class Venue extends Entity
protected $address; protected $address;
protected $foursquare_id; protected $foursquare_id;
/**
* Venue constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
$this->location = isset($data['location']) ? $data['location'] : null; $this->location = isset($data['location']) ? $data['location'] : null;
......
...@@ -22,6 +22,11 @@ class Video extends Entity ...@@ -22,6 +22,11 @@ class Video extends Entity
protected $mime_type; protected $mime_type;
protected $file_size; protected $file_size;
/**
* Video constructor.
*
* @param array $data
*/
public function __construct(array $data) public function __construct(array $data)
{ {
......
...@@ -19,10 +19,13 @@ class Voice extends Entity ...@@ -19,10 +19,13 @@ class Voice extends Entity
protected $mime_type; protected $mime_type;
protected $file_size; protected $file_size;
/**
* Voice constructor.
*
* @param array $data
*/
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!');
...@@ -35,7 +38,6 @@ class Voice extends Entity ...@@ -35,7 +38,6 @@ class Voice extends Entity
$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()
......
...@@ -239,7 +239,7 @@ class Request ...@@ -239,7 +239,7 @@ class Request
* *
* @param string $file * @param string $file
* *
* @return CURLFile * @return \CURLFile
*/ */
protected static function encodeFile($file) protected static function encodeFile($file)
{ {
...@@ -308,7 +308,7 @@ class Request ...@@ -308,7 +308,7 @@ class Request
$string_len_utf8 = mb_strlen($text, 'UTF-8'); $string_len_utf8 = mb_strlen($text, 'UTF-8');
if ($string_len_utf8 > 4096) { if ($string_len_utf8 > 4096) {
$data['text'] = mb_substr($text, 0, 4096); $data['text'] = mb_substr($text, 0, 4096);
$result = self::send('sendMessage', $data); self::send('sendMessage', $data);
$data['text'] = mb_substr($text, 4096, $string_len_utf8); $data['text'] = mb_substr($text, 4096, $string_len_utf8);
return self::sendMessage($data); return self::sendMessage($data);
} }
......
...@@ -171,7 +171,7 @@ class Telegram ...@@ -171,7 +171,7 @@ class Telegram
/** /**
* Initialize Database external connection * Initialize Database external connection
* *
* @param PDO $external_pdo_connection PDO database object * @param /PDO $external_pdo_connection PDO database object
* @param string $table_prefix * @param string $table_prefix
*/ */
public function enableExternalMysql($external_pdo_connection, $table_prefix = null) public function enableExternalMysql($external_pdo_connection, $table_prefix = null)
...@@ -230,7 +230,7 @@ class Telegram ...@@ -230,7 +230,7 @@ class Telegram
* *
* @param string $command * @param string $command
* *
* @return Entities\Command|null * @return \Longman\TelegramBot\Commands\Command|null
*/ */
public function getCommandObject($command) public function getCommandObject($command)
{ {
...@@ -445,8 +445,13 @@ class Telegram ...@@ -445,8 +445,13 @@ class Telegram
return $this->last_command_response; return $this->last_command_response;
} }
/** /**
* @todo Complete DocBlock * Sanitize Command
*
* @param string $command
*
* @return string
*/ */
protected function sanitizeCommand($command) protected function sanitizeCommand($command)
{ {
......
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