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