Major revision 2

This commit is contained in:
Mattia Mascarello
2023-02-07 01:27:52 +01:00
parent 6a005fd277
commit 88ce5972b4
919 changed files with 16257 additions and 829872 deletions

View File

@ -0,0 +1,14 @@
<?php
namespace TelegramBot\Api;
/**
* Class BadMethodCallException
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class BadMethodCallException extends Exception
{
}

View File

@ -0,0 +1,99 @@
<?php
namespace TelegramBot\Api;
/**
* Class BaseType
* Base class for Telegram Types
*
* @package TelegramBot\Api
*/
abstract class BaseType
{
/**
* Array of required data params for type
*
* @var array
*/
protected static $requiredParams = [];
/**
* Map of input data
*
* @var array
*/
protected static $map = [];
/**
* Validate input data
*
* @param array $data
*
* @return bool
*
* @throws InvalidArgumentException
*/
public static function validate($data)
{
if (count(array_intersect_key(array_flip(static::$requiredParams), $data)) === count(static::$requiredParams)) {
return true;
}
throw new InvalidArgumentException();
}
public function map($data)
{
foreach (static::$map as $key => $item) {
if (isset($data[$key]) && (!is_array($data[$key]) || (is_array($data[$key]) && !empty($data[$key])))) {
$method = 'set' . self::toCamelCase($key);
if ($item === true) {
$this->$method($data[$key]);
} else {
$this->$method($item::fromResponse($data[$key]));
}
}
}
}
protected static function toCamelCase($str)
{
return str_replace(" ", "", ucwords(str_replace("_", " ", $str)));
}
public function toJson($inner = false)
{
$output = [];
foreach (static::$map as $key => $item) {
$property = lcfirst(self::toCamelCase($key));
if (!is_null($this->$property)) {
if (is_array($this->$property)) {
$output[$key] = array_map(
function ($v) {
return is_object($v) ? $v->toJson(true) : $v;
},
$this->$property
);
} else {
$output[$key] = $item === true ? $this->$property : $this->$property->toJson(true);
}
}
}
return $inner === false ? json_encode($output) : $output;
}
public static function fromResponse($data)
{
if ($data === true) {
return true;
}
self::validate($data);
$instance = new static();
$instance->map($data);
return $instance;
}
}

1725
vendor/telegram-bot/api/src/BotApi.php vendored Normal file

File diff suppressed because it is too large Load Diff

92
vendor/telegram-bot/api/src/Botan.php vendored Normal file
View File

@ -0,0 +1,92 @@
<?php
namespace TelegramBot\Api;
use TelegramBot\Api\Types\Message;
class Botan
{
/**
* @var string Tracker url
*/
const BASE_URL = 'https://api.botan.io/track';
/**
* CURL object
*
* @var
*/
protected $curl;
/**
* Yandex AppMetrica application api_key
*
* @var string
*/
protected $token;
/**
* Botan constructor
*
* @param string $token
*
* @throws \Exception
*/
public function __construct($token)
{
if (!function_exists('curl_version')) {
throw new Exception('CURL not installed');
}
if (empty($token) || !is_string($token)) {
throw new InvalidArgumentException('Token should be a string');
}
$this->token = $token;
$this->curl = curl_init();
}
/**
* Event tracking
*
* @param \TelegramBot\Api\Types\Message $message
* @param string $eventName
*
* @throws \TelegramBot\Api\Exception
* @throws \TelegramBot\Api\HttpException
*/
public function track(Message $message, $eventName = 'Message')
{
$uid = $message->getFrom()->getId();
$options = [
CURLOPT_URL => self::BASE_URL . "?token={$this->token}&uid={$uid}&name={$eventName}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => $message->toJson(),
CURLOPT_TIMEOUT => 5,
];
curl_setopt_array($this->curl, $options);
$result = BotApi::jsonValidate(curl_exec($this->curl), true);
BotApi::curlValidate($this->curl);
if ($result['status'] !== 'accepted') {
throw new Exception('Error Processing Request');
}
}
/**
* Destructor. Close curl
*/
public function __destruct()
{
$this->curl && curl_close($this->curl);
}
}

409
vendor/telegram-bot/api/src/Client.php vendored Normal file
View File

@ -0,0 +1,409 @@
<?php
namespace TelegramBot\Api;
use Closure;
use ReflectionFunction;
use TelegramBot\Api\Events\EventCollection;
use TelegramBot\Api\Types\Update;
/**
* Class Client
*
* @package TelegramBot\Api
*/
class Client
{
/**
* RegExp for bot commands
*/
const REGEXP = '/^(?:@\w+\s)?\/([^\s@]+)(@\S+)?\s?(.*)$/';
/**
* @var \TelegramBot\Api\BotApi
*/
protected $api;
/**
* @var \TelegramBot\Api\Events\EventCollection
*/
protected $events;
/**
* Client constructor
*
* @param string $token Telegram Bot API token
* @param string|null $trackerToken Yandex AppMetrica application api_key
*/
public function __construct($token, $trackerToken = null)
{
$this->api = new BotApi($token);
$this->events = new EventCollection($trackerToken);
}
/**
* Use this method to add command. Parameters will be automatically parsed and passed to closure.
*
* @param string $name
* @param \Closure $action
*
* @return \TelegramBot\Api\Client
*/
public function command($name, Closure $action)
{
return $this->on(self::getEvent($action), self::getChecker($name));
}
public function editedMessage(Closure $action)
{
return $this->on(self::getEditedMessageEvent($action), self::getEditedMessageChecker());
}
public function callbackQuery(Closure $action)
{
return $this->on(self::getCallbackQueryEvent($action), self::getCallbackQueryChecker());
}
public function channelPost(Closure $action)
{
return $this->on(self::getChannelPostEvent($action), self::getChannelPostChecker());
}
public function editedChannelPost(Closure $action)
{
return $this->on(self::getEditedChannelPostEvent($action), self::getEditedChannelPostChecker());
}
public function inlineQuery(Closure $action)
{
return $this->on(self::getInlineQueryEvent($action), self::getInlineQueryChecker());
}
public function chosenInlineResult(Closure $action)
{
return $this->on(self::getChosenInlineResultEvent($action), self::getChosenInlineResultChecker());
}
public function shippingQuery(Closure $action)
{
return $this->on(self::getShippingQueryEvent($action), self::getShippingQueryChecker());
}
public function preCheckoutQuery(Closure $action)
{
return $this->on(self::getPreCheckoutQueryEvent($action), self::getPreCheckoutQueryChecker());
}
/**
* Use this method to add an event.
* If second closure will return true (or if you are passed null instead of closure), first one will be executed.
*
* @param \Closure $event
* @param \Closure|null $checker
*
* @return \TelegramBot\Api\Client
*/
public function on(Closure $event, Closure $checker = null)
{
$this->events->add($event, $checker);
return $this;
}
/**
* Handle updates
*
* @param Update[] $updates
*/
public function handle(array $updates)
{
foreach ($updates as $update) {
/* @var \TelegramBot\Api\Types\Update $update */
$this->events->handle($update);
}
}
/**
* Webhook handler
*
* @return array
* @throws \TelegramBot\Api\InvalidJsonException
*/
public function run()
{
if ($data = BotApi::jsonValidate($this->getRawBody(), true)) {
$this->handle([Update::fromResponse($data)]);
}
}
public function getRawBody()
{
return file_get_contents('php://input');
}
/**
* Returns event function to handling the command.
*
* @param \Closure $action
*
* @return \Closure
*/
protected static function getEvent(Closure $action)
{
return function (Update $update) use ($action) {
$message = $update->getMessage();
if (!$message) {
return true;
}
preg_match(self::REGEXP, $message->getText(), $matches);
if (isset($matches[3]) && !empty($matches[3])) {
$parameters = str_getcsv($matches[3], chr(32));
} else {
$parameters = [];
}
array_unshift($parameters, $message);
$action = new ReflectionFunction($action);
if (count($parameters) >= $action->getNumberOfRequiredParameters()) {
$action->invokeArgs($parameters);
}
return false;
};
}
protected static function getEditedMessageEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getEditedMessage()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getEditedMessage()]);
return false;
};
}
protected static function getChannelPostEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getChannelPost()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getChannelPost()]);
return false;
};
}
protected static function getCallbackQueryEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getCallbackQuery()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getCallbackQuery()]);
return false;
};
}
protected static function getEditedChannelPostEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getEditedChannelPost()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getEditedChannelPost()]);
return false;
};
}
protected static function getInlineQueryEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getInlineQuery()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getInlineQuery()]);
return false;
};
}
protected static function getChosenInlineResultEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getChosenInlineResult()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getChosenInlineResult()]);
return false;
};
}
protected static function getShippingQueryEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getShippingQuery()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getShippingQuery()]);
return false;
};
}
protected static function getPreCheckoutQueryEvent(Closure $action)
{
return function (Update $update) use ($action) {
if (!$update->getPreCheckoutQuery()) {
return true;
}
$reflectionAction = new ReflectionFunction($action);
$reflectionAction->invokeArgs([$update->getPreCheckoutQuery()]);
return false;
};
}
/**
* Returns check function to handling the command.
*
* @param string $name
*
* @return \Closure
*/
protected static function getChecker($name)
{
return function (Update $update) use ($name) {
$message = $update->getMessage();
if (is_null($message) || !strlen($message->getText())) {
return false;
}
preg_match(self::REGEXP, $message->getText(), $matches);
return !empty($matches) && $matches[1] == $name;
};
}
/**
* Returns check function to handling the edited message.
*
* @return Closure
*/
protected static function getEditedMessageChecker()
{
return function (Update $update) {
return !is_null($update->getEditedMessage());
};
}
/**
* Returns check function to handling the channel post.
*
* @return Closure
*/
protected static function getChannelPostChecker()
{
return function (Update $update) {
return !is_null($update->getChannelPost());
};
}
/**
* Returns check function to handling the callbackQuery.
*
* @return Closure
*/
protected static function getCallbackQueryChecker()
{
return function (Update $update) {
return !is_null($update->getCallbackQuery());
};
}
/**
* Returns check function to handling the edited channel post.
*
* @return Closure
*/
protected static function getEditedChannelPostChecker()
{
return function (Update $update) {
return !is_null($update->getEditedChannelPost());
};
}
/**
* Returns check function to handling the chosen inline result.
*
* @return Closure
*/
protected static function getChosenInlineResultChecker()
{
return function (Update $update) {
return !is_null($update->getChosenInlineResult());
};
}
/**
* Returns check function to handling the inline queries.
*
* @return Closure
*/
protected static function getInlineQueryChecker()
{
return function (Update $update) {
return !is_null($update->getInlineQuery());
};
}
/**
* Returns check function to handling the shipping queries.
*
* @return Closure
*/
protected static function getShippingQueryChecker()
{
return function (Update $update) {
return !is_null($update->getShippingQuery());
};
}
/**
* Returns check function to handling the pre checkout queries.
*
* @return Closure
*/
protected static function getPreCheckoutQueryChecker()
{
return function (Update $update) {
return !is_null($update->getPreCheckoutQuery());
};
}
public function __call($name, array $arguments)
{
if (method_exists($this, $name)) {
return call_user_func_array([$this, $name], $arguments);
} elseif (method_exists($this->api, $name)) {
return call_user_func_array([$this->api, $name], $arguments);
}
throw new BadMethodCallException("Method {$name} not exists");
}
}

View File

@ -0,0 +1,111 @@
<?php
namespace TelegramBot\Api\Collection;
use TelegramBot\Api\Types\InputMedia\InputMedia;
/**
* Class Collection
*/
class Collection
{
/**
* @var array
*/
protected $items = [];
/**
* @var int Max items count, if set 0 - unlimited
*/
protected $maxCount = 0;
/**
* @param CollectionItemInterface $item
* @param mixed $key
* @return void
* @throws ReachedMaxSizeException
* @throws KeyHasUseException
*/
public function addItem(CollectionItemInterface $item, $key = null)
{
if ($this->maxCount > 0 && $this->count() + 1 >= $this->maxCount) {
throw new ReachedMaxSizeException("Maximum collection items count reached. Max size: {$this->maxCount}");
}
if ($key == null) {
$this->items[] = $item;
} else {
if (isset($this->items[$key])) {
throw new KeyHasUseException("Key $key already in use.");
}
$this->items[$key] = $item;
}
}
/**
* @param $key
* @throws KeyInvalidException
* @return void
*/
public function deleteItem($key)
{
$this->checkItemKey($key);
unset($this->items[$key]);
}
/**
* @param $key
* @return InputMedia
* @return CollectionItemInterface
* @throws KeyInvalidException
*/
public function getItem($key)
{
$this->checkItemKey($key);
return $this->items[$key];
}
/**
* @return int
*/
public function count()
{
return count($this->items);
}
/**
* @param bool $inner
* @return array|string
*/
public function toJson($inner = false)
{
$output = [];
foreach ($this->items as $item) {
$output[] = $item->toJson(true);
}
return $inner === false ? json_encode($output) : $output;
}
/**
* @param int $maxCount
* @return void
*/
public function setMaxCount($maxCount)
{
$this->maxCount = $maxCount;
}
/**
* @param $key
* @throws KeyInvalidException
*/
private function checkItemKey($key)
{
if (!isset($this->items[$key])) {
throw new KeyInvalidException("Invalid key $key.");
}
}
}

View File

@ -0,0 +1,8 @@
<?php
namespace TelegramBot\Api\Collection;
interface CollectionItemInterface
{
public function toJson($inner = false);
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Collection;
use TelegramBot\Api\Exception;
/**
* Class KeyHasUseException
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class KeyHasUseException extends Exception
{
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Collection;
use TelegramBot\Api\Exception;
/**
* Class KeyInvalidException
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class KeyInvalidException extends Exception
{
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Collection;
use TelegramBot\Api\Exception;
/**
* Class ReachedMaxSizeException
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class ReachedMaxSizeException extends Exception
{
}

View File

@ -0,0 +1,75 @@
<?php
namespace TelegramBot\Api\Events;
use TelegramBot\Api\Types\Message;
use TelegramBot\Api\Types\Update;
class Event
{
/**
* @var \Closure
*/
protected $checker;
/**
* @var \Closure
*/
protected $action;
/**
* Event constructor.
*
* @param \Closure $action
* @param \Closure|null $checker
*/
public function __construct(\Closure $action, \Closure $checker)
{
$this->action = $action;
$this->checker = $checker;
}
/**
* @return \Closure
*/
public function getAction()
{
return $this->action;
}
/**
* @return \Closure|null
*/
public function getChecker()
{
return $this->checker;
}
/**
* @param \TelegramBot\Api\Types\Update
*
* @return mixed
*/
public function executeChecker(Update $message)
{
if (is_callable($this->checker)) {
return call_user_func($this->checker, $message);
}
return false;
}
/**
* @param \TelegramBot\Api\Types\Update
*
* @return mixed
*/
public function executeAction(Update $message)
{
if (is_callable($this->action)) {
return call_user_func($this->action, $message);
}
return false;
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace TelegramBot\Api\Events;
use Closure;
use ReflectionFunction;
use TelegramBot\Api\Botan;
use TelegramBot\Api\Types\Update;
class EventCollection
{
/**
* Array of events.
*
* @var array
*/
protected $events;
/**
* Botan tracker
*
* @var \TelegramBot\Api\Botan
*/
protected $tracker;
/**
* EventCollection constructor.
*
* @param string $trackerToken
*/
public function __construct($trackerToken = null)
{
if ($trackerToken) {
$this->tracker = new Botan($trackerToken);
}
}
/**
* Add new event to collection
*
* @param Closure $event
* @param Closure|null $checker
*
* @return \TelegramBot\Api\Events\EventCollection
*/
public function add(Closure $event, $checker = null)
{
$this->events[] = !is_null($checker) ? new Event($event, $checker)
: new Event($event, function () {
});
return $this;
}
/**
* @param \TelegramBot\Api\Types\Update
*/
public function handle(Update $update)
{
foreach ($this->events as $event) {
/* @var \TelegramBot\Api\Events\Event $event */
if ($event->executeChecker($update) === true) {
if (false === $event->executeAction($update)) {
if (!is_null($this->tracker)) {
$checker = new ReflectionFunction($event->getChecker());
$this->tracker->track($update->getMessage(), $checker->getStaticVariables()['name']);
}
break;
}
}
}
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace TelegramBot\Api;
/**
* Class Exception
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class Exception extends \Exception
{
}

View File

@ -0,0 +1,40 @@
<?php
namespace TelegramBot\Api;
/**
* Class HttpException
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class HttpException extends Exception
{
/**
* @var array
*/
protected $parameters = [];
/**
* HttpException constructor.
*
* @param string $message [optional] The Exception message to throw.
* @param int $code [optional] The Exception code.
* @param Exception $previous [optional] The previous throwable used for the exception chaining.
* @param array $parameters [optional] Array of parameters returned from API.
*/
public function __construct($message = '', $code = 0, Exception $previous = null, $parameters = [])
{
$this->parameters = $parameters;
parent::__construct($message, $code, $previous);
}
/**
* @return array
*/
public function getParameters()
{
return $this->parameters;
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace TelegramBot\Api;
/**
* Class InvalidArgumentException
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class InvalidArgumentException extends Exception
{
}

View File

@ -0,0 +1,14 @@
<?php
namespace TelegramBot\Api;
/**
* Class InvalidJsonException
*
* @codeCoverageIgnore
* @package TelegramBot\Api
*/
class InvalidJsonException extends Exception
{
}

View File

@ -0,0 +1,8 @@
<?php
namespace TelegramBot\Api;
interface TypeInterface
{
public static function fromResponse($data);
}

View File

@ -0,0 +1,13 @@
<?php
namespace TelegramBot\Api\Types;
abstract class ArrayOfArrayOfPhotoSize
{
public static function fromResponse($data)
{
return array_map(function ($arrayOfPhotoSize) {
return ArrayOfPhotoSize::fromResponse($arrayOfPhotoSize);
}, $data);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Types;
abstract class ArrayOfChatMemberEntity
{
public static function fromResponse($data)
{
$arrayOfChatMemberEntity = [];
foreach ($data as $chatMemberEntity) {
$arrayOfChatMemberEntity[] = ChatMember::fromResponse($chatMemberEntity);
}
return $arrayOfChatMemberEntity;
}
}

View File

@ -0,0 +1,22 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 13/04/16
* Time: 04:16
*/
namespace TelegramBot\Api\Types;
abstract class ArrayOfMessageEntity
{
public static function fromResponse($data)
{
$arrayOfMessageEntity = [];
foreach ($data as $messageEntity) {
$arrayOfMessageEntity[] = MessageEntity::fromResponse($messageEntity);
}
return $arrayOfMessageEntity;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Types;
abstract class ArrayOfMessages
{
public static function fromResponse($data)
{
$arrayOfMessages = [];
foreach ($data as $message) {
$arrayOfMessages[] = Message::fromResponse($message);
}
return $arrayOfMessages;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Types;
abstract class ArrayOfPhotoSize
{
public static function fromResponse($data)
{
$arrayOfPhotoSize = [];
foreach ($data as $photoSizeItem) {
$arrayOfPhotoSize[] = PhotoSize::fromResponse($photoSizeItem);
}
return $arrayOfPhotoSize;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Types;
abstract class ArrayOfUpdates
{
public static function fromResponse($data)
{
$arrayOfUpdates = [];
foreach ($data as $update) {
$arrayOfUpdates[] = Update::fromResponse($update);
}
return $arrayOfUpdates;
}
}

View File

@ -0,0 +1,187 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class Audio
* This object represents an audio file (voice note).
*
* @package TelegramBot\Api\Types
*/
class Audio extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['file_id', 'duration'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'file_id' => true,
'duration' => true,
'performer' => true,
'title' => true,
'mime_type' => true,
'file_size' => true
];
/**
* Unique identifier for this file
*
* @var string
*/
protected $fileId;
/**
* Photo width
*
* @var int
*/
protected $duration;
/**
* Optional. Performer of the audio as defined by sender or by audio tags
*
* @var string
*/
protected $performer;
/**
* Optional. Title of the audio as defined by sender or by audio tags
*
* @var string
*/
protected $title;
/**
* Optional. MIME type of the file as defined by sender
*
* @var string
*/
protected $mimeType;
/**
* Optional. File size
*
* @var int
*/
protected $fileSize;
/**
* @return int
*/
public function getDuration()
{
return $this->duration;
}
/**
* @param int $duration
*
* @throws InvalidArgumentException
*/
public function setDuration($duration)
{
if (is_integer($duration)) {
$this->duration = $duration;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getPerformer()
{
return $this->performer;
}
/**
* @param string $performer
*/
public function setPerformer($performer)
{
$this->performer = $performer;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string $fileId
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return int
*/
public function getFileSize()
{
return $this->fileSize;
}
/**
* @param int $fileSize
*
* @throws InvalidArgumentException
*/
public function setFileSize($fileSize)
{
if (is_integer($fileSize)) {
$this->fileSize = $fileSize;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* @param string $mimeType
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
}

View File

@ -0,0 +1,210 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
/**
* Class CallbackQuery
* This object represents an incoming callback query from a callback
* button in an inline keyboard.
* If the button that originated the query was attached to a message sent by the bot,
* the field message will be present.
* If the button was attached to a message sent via the bot (in inline mode),
* the field inline_message_id will be present.
* Exactly one of the fields data or game_short_name will be present.
*
* @package TelegramBot\Api\Types
*/
class CallbackQuery extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['id', 'from'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'id' => true,
'from' => User::class,
'message' => Message::class,
'inline_message_id' => true,
'chat_instance' => true,
'data' => true,
'game_short_name' => true
];
/**
* Unique identifier for this query
*
* @var string
*/
protected $id;
/**
* Sender
*
* @var \TelegramBot\Api\Types\User
*/
protected $from;
/**
* Optional. Message with the callback button that originated the query.
* Note that message content and message date will not be available
* if the message is too old
*
* @var \TelegramBot\Api\Types\Message
*/
protected $message;
/**
* Optional. Identifier of the message sent via the bot in inline mode,
* that originated the query.
*
* @var string
*/
protected $inlineMessageId;
/**
* Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent.
* Useful for high scores in games.
*
* @var string
*/
protected $chatInstance;
/**
* Optional. Data associated with the callback button.
* Be aware that a bad client can send arbitrary data in this field.
*
* @var string
*/
protected $data;
/**
* Optional. Short name of a Game to be returned,
* serves as the unique identifier for the game
*
* @var string
*/
protected $gameShortName;
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return User
*/
public function getFrom()
{
return $this->from;
}
/**
* @param User $from
*/
public function setFrom(User $from)
{
$this->from = $from;
}
/**
* @return Message
*/
public function getMessage()
{
return $this->message;
}
/**
* @param Message $message
*/
public function setMessage($message)
{
$this->message = $message;
}
/**
* @return string
*/
public function getInlineMessageId()
{
return $this->inlineMessageId;
}
/**
* @param string $inlineMessageId
*/
public function setInlineMessageId($inlineMessageId)
{
$this->inlineMessageId = $inlineMessageId;
}
/**
* @return string
*/
public function getChatInstance()
{
return $this->chatInstance;
}
/**
* @param string $chatInstance
*/
public function setChatInstance($chatInstance)
{
$this->chatInstance = $chatInstance;
}
/**
* @return string
*/
public function getData()
{
return $this->data;
}
/**
* @param string $data
*/
public function setData($data)
{
$this->data = $data;
}
/**
* @return string
*/
public function getGameShortName()
{
return $this->gameShortName;
}
/**
* @param string $gameShortName
*/
public function setGameShortName($gameShortName)
{
$this->gameShortName = $gameShortName;
}
}

View File

@ -0,0 +1,338 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
class Chat extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['id', 'type'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'id' => true,
'type' => true,
'title' => true,
'username' => true,
'first_name' => true,
'last_name' => true,
'all_members_are_administrators' => true,
'photo' => ChatPhoto::class,
'description' => true,
'invite_link' => true,
'pinned_message' => Message::class,
'sticker_set_name' => true,
'can_set_sticker_set' => true
];
/**
* Unique identifier for this chat, not exceeding 1e13 by absolute value
*
* @var int|string
*/
protected $id;
/**
* Type of chat, can be either “private”, “group”, “supergroup” or “channel”
*
* @var string
*/
protected $type;
/**
* Optional. Title, for channels and group chats
*
* @var string
*/
protected $title;
/**
* Optional. Username, for private chats and channels if available
*
* @var string
*/
protected $username;
/**
* Optional. First name of the other party in a private chat
*
* @var string
*/
protected $firstName;
/**
* Optional. Last name of the other party in a private chat
*
* @var string
*/
protected $lastName;
protected $allMembersAreAdministrators;
/**
* Optional. Chat photo. Returned only in getChat.
*
* @var ChatPhoto
*/
protected $photo;
/**
* Optional. Description, for supergroups and channel chats. Returned only in getChat.
*
* @var string
*/
protected $description;
/**
* Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
*
* @var string
*/
protected $inviteLink;
/**
* Optional. Pinned message, for supergroups. Returned only in getChat.
*
* @var Message
*/
protected $pinnedMessage;
/**
* Optional. For supergroups, name of group sticker set. Returned only in getChat.
*
* @var string
*/
protected $stickerSetName;
/**
* Optional. True, if the bot can change the group sticker set. Returned only in getChat.
*
* @var bool
*/
protected $canSetStickerSet;
/**
* @return int|string
*/
public function getId()
{
return $this->id;
}
/**
* @param int|string $id
*
* @throws InvalidArgumentException
*/
public function setId($id)
{
if (is_integer($id) || is_float($id) || is_string($id)) {
$this->id = $id;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* @param string $username
*/
public function setUsername($username)
{
$this->username = $username;
}
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return mixed
*/
public function getAllMembersAreAdministrators()
{
return $this->allMembersAreAdministrators;
}
/**
* @param mixed $allMembersAreAdministrators
*/
public function setAllMembersAreAdministrators($allMembersAreAdministrators)
{
$this->allMembersAreAdministrators = $allMembersAreAdministrators;
}
/**
* @return ChatPhoto
*/
public function getPhoto()
{
return $this->photo;
}
/**
* @param ChatPhoto $photo
*/
public function setPhoto($photo)
{
$this->photo = $photo;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getInviteLink()
{
return $this->inviteLink;
}
/**
* @param string $inviteLink
*/
public function setInviteLink($inviteLink)
{
$this->inviteLink = $inviteLink;
}
/**
* @return Message
*/
public function getPinnedMessage()
{
return $this->pinnedMessage;
}
/**
* @param Message $pinnedMessage
*/
public function setPinnedMessage($pinnedMessage)
{
$this->pinnedMessage = $pinnedMessage;
}
/**
* @return string
*/
public function getStickerSetName()
{
return $this->stickerSetName;
}
/**
* @param string $stickerSetName
*/
public function setStickerSetName($stickerSetName)
{
$this->stickerSetName = $stickerSetName;
}
/**
* @return bool
*/
public function isCanSetStickerSet()
{
return $this->canSetStickerSet;
}
/**
* @param bool $canSetStickerSet
*/
public function setCanSetStickerSet($canSetStickerSet)
{
$this->canSetStickerSet = $canSetStickerSet;
}
}

View File

@ -0,0 +1,412 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
class ChatMember extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['user', 'status'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'user' => User::class,
'status' => true,
'until_date' => true,
'can_be_edited' => true,
'can_change_info' => true,
'can_post_messages' => true,
'can_edit_messages' => true,
'can_delete_messages' => true,
'can_invite_users' => true,
'can_restrict_members' => true,
'can_pin_messages' => true,
'can_promote_members' => true,
'can_send_messages' => true,
'can_send_media_messages' => true,
'can_send_other_messages' => true,
'can_add_web_page_previews' => true
];
/**
* Information about the user
*
* @var User
*/
protected $user;
/**
* The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked”
*
* @var string
*/
protected $status;
/**
* Optional. Restictred and kicked only. Date when restrictions will be lifted for this user, unix time
*
* @var integer
*/
protected $untilDate;
/**
* Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user
*
* @var bool
*/
protected $canBeEdited;
/**
* Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings
*
* @var bool
*/
protected $canChangeInfo;
/**
* Optional. Administrators only. True, if the administrator can post in the channel, channels only
*
* @var bool
*/
protected $canPostMessages;
/**
* Optional. Administrators only. True, if the administrator can edit messages of other users, channels only
*
* @var bool
*/
protected $canEditMessages;
/**
* Optional. Administrators only. True, if the administrator can delete messages of other users
*
* @var bool
*/
protected $canDeleteMessages;
/**
* Optional. Administrators only. True, if the administrator can invite new users to the chat
*
* @var bool
*/
protected $canInviteUsers;
/**
* Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members
*
* @var bool
*/
protected $canRestrictMembers;
/**
* Optional. Administrators only. True, if the administrator can pin messages, supergroups only
*
* @var bool
*/
protected $canPinMessages;
/**
* Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own
* privileges or demote administrators that he has promoted, directly or indirectly
* (promoted by administrators that were appointed by the user)
*
* @var bool
*/
protected $canPromoteMembers;
/**
* Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues
*
* @var bool
*/
protected $canSendMessages;
/**
* Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes
* and voice notes, implies can_send_messages
*
* @var bool
*/
protected $canSendMediaMessages;
/**
* Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots,
* implies can_send_media_messages
*
* @var bool
*/
protected $canSendOtherMessages;
/**
* Optional. Restricted only. True, if user may add web page previews to his messages,
* implies can_send_media_messages
*
* @var bool
*/
protected $canAddWebPagePreviews;
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* @param User $user
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* @param string $status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
* @return int
*/
public function getUntilDate()
{
return $this->untilDate;
}
/**
* @param int $untilDate
*/
public function setUntilDate($untilDate)
{
$this->untilDate = $untilDate;
}
/**
* @return bool
*/
public function getCanBeEdited()
{
return $this->canBeEdited;
}
/**
* @param bool $canBeEdited
*/
public function setCanBeEdited($canBeEdited)
{
$this->canBeEdited = $canBeEdited;
}
/**
* @return bool
*/
public function getCanChangeInfo()
{
return $this->canChangeInfo;
}
/**
* @param bool $canChangeInfo
*/
public function setCanChangeInfo($canChangeInfo)
{
$this->canChangeInfo = $canChangeInfo;
}
/**
* @return bool
*/
public function getCanPostMessages()
{
return $this->canPostMessages;
}
/**
* @param bool $canPostMessages
*/
public function setCanPostMessages($canPostMessages)
{
$this->canPostMessages = $canPostMessages;
}
/**
* @return bool
*/
public function getCanEditMessages()
{
return $this->canEditMessages;
}
/**
* @param bool $canEditMessages
*/
public function setCanEditMessages($canEditMessages)
{
$this->canEditMessages = $canEditMessages;
}
/**
* @return bool
*/
public function getCanDeleteMessages()
{
return $this->canDeleteMessages;
}
/**
* @param bool $canDeleteMessages
*/
public function setCanDeleteMessages($canDeleteMessages)
{
$this->canDeleteMessages = $canDeleteMessages;
}
/**
* @return bool
*/
public function getCanInviteUsers()
{
return $this->canInviteUsers;
}
/**
* @param bool $canInviteUsers
*/
public function setCanInviteUsers($canInviteUsers)
{
$this->canInviteUsers = $canInviteUsers;
}
/**
* @return bool
*/
public function getCanRestrictMembers()
{
return $this->canRestrictMembers;
}
/**
* @param bool $canRestrictMembers
*/
public function setCanRestrictMembers($canRestrictMembers)
{
$this->canRestrictMembers = $canRestrictMembers;
}
/**
* @return bool
*/
public function getCanPinMessages()
{
return $this->canPinMessages;
}
/**
* @param bool $canPinMessages
*/
public function setCanPinMessages($canPinMessages)
{
$this->canPinMessages = $canPinMessages;
}
/**
* @return bool
*/
public function getCanPromoteMembers()
{
return $this->canPromoteMembers;
}
/**
* @param bool $canPromoteMembers
*/
public function setCanPromoteMembers($canPromoteMembers)
{
$this->canPromoteMembers = $canPromoteMembers;
}
/**
* @return bool
*/
public function getCanSendMessages()
{
return $this->canSendMessages;
}
/**
* @param bool $canSendMessages
*/
public function setCanSendMessages($canSendMessages)
{
$this->canSendMessages = $canSendMessages;
}
/**
* @return bool
*/
public function getCanSendMediaMessages()
{
return $this->canSendMediaMessages;
}
/**
* @param bool $canSendMediaMessages
*/
public function setCanSendMediaMessages($canSendMediaMessages)
{
$this->canSendMediaMessages = $canSendMediaMessages;
}
/**
* @return bool
*/
public function getCanSendOtherMessages()
{
return $this->canSendOtherMessages;
}
/**
* @param bool $canSendOtherMessages
*/
public function setCanSendOtherMessages($canSendOtherMessages)
{
$this->canSendOtherMessages = $canSendOtherMessages;
}
/**
* @return bool
*/
public function getCanAddWebPagePreviews()
{
return $this->canAddWebPagePreviews;
}
/**
* @param bool $canAddWebPagePreviews
*/
public function setCanAddWebPagePreviews($canAddWebPagePreviews)
{
$this->canAddWebPagePreviews = $canAddWebPagePreviews;
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
class ChatPhoto extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['small_file_id', 'big_file_id'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'small_file_id' => true,
'big_file_id' => true,
];
/**
* Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download.
*
* @var string
*/
protected $smallFileId;
/**
* Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.
*
* @var string
*/
protected $bigFileId;
/**
* @return string
*/
public function getSmallFileId()
{
return $this->smallFileId;
}
/**
* @param string $smallFileId
*/
public function setSmallFileId($smallFileId)
{
$this->smallFileId = $smallFileId;
}
/**
* @return string
*/
public function getBigFileId()
{
return $this->bigFileId;
}
/**
* @param string $bigFileId
*/
public function setBigFileId($bigFileId)
{
$this->bigFileId = $bigFileId;
}
}

View File

@ -0,0 +1,126 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\TypeInterface;
/**
* Class Contact
* This object represents a sticker.
*
* @package TelegramBot\Api\Types
*/
class Contact extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['phone_number', 'first_name'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'phone_number' => true,
'first_name' => true,
'last_name' => true,
'user_id' => true
];
/**
* Contact's phone number
*
* @var string
*/
protected $phoneNumber;
/**
* Contact's first name
*
* @var string
*/
protected $firstName;
/**
* Optional. Contact's last name
*
* @var string
*/
protected $lastName;
/**
* Optional. Contact's user identifier in Telegram
*
* @var int
*/
protected $userId;
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return string
*/
public function getPhoneNumber()
{
return $this->phoneNumber;
}
/**
* @param string $phoneNumber
*/
public function setPhoneNumber($phoneNumber)
{
$this->phoneNumber = $phoneNumber;
}
/**
* @return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* @param int $userId
*/
public function setUserId($userId)
{
$this->userId = $userId;
}
}

View File

@ -0,0 +1,158 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class Document
* This object represents a general file (as opposed to photos and audio files).
* Telegram users can send files of any type of up to 1.5 GB in size.
*
* @package TelegramBot\Api\Types
*/
class Document extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'file_id' => true,
'thumb' => PhotoSize::class,
'file_name' => true,
'mime_type' => true,
'file_size' => true
];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['file_id'];
/**
* Unique identifier for this file
*
* @var string
*/
protected $fileId;
/**
* Document thumbnail as defined by sender
*
* @var PhotoSize
*/
protected $thumb;
/**
* Optional. Original filename as defined by sender
*
* @var string
*/
protected $fileName;
/**
* Optional. MIME type of the file as defined by sender
*
* @var string
*/
protected $mimeType;
/**
* Optional. File size
*
* @var int
*/
protected $fileSize;
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string $fileId
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return string
*/
public function getFileName()
{
return $this->fileName;
}
/**
* @param string $fileName
*/
public function setFileName($fileName)
{
$this->fileName = $fileName;
}
/**
* @return int
*/
public function getFileSize()
{
return $this->fileSize;
}
/**
* @param int $fileSize
*
* @throws InvalidArgumentException
*/
public function setFileSize($fileSize)
{
if (is_integer($fileSize)) {
$this->fileSize = $fileSize;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* @param string $mimeType
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return PhotoSize
*/
public function getThumb()
{
return $this->thumb;
}
/**
* @param PhotoSize $thumb
*/
public function setThumb(PhotoSize $thumb)
{
$this->thumb = $thumb;
}
}

View File

@ -0,0 +1,112 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class File
* This object represents a file ready to be downloaded.
* The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>.
* It is guaranteed that the link will be valid for at least 1 hour.
* When the link expires, a new one can be requested by calling getFile.
*
* @package TelegramBot\Api\Types
*/
class File extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['file_id'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'file_id' => true,
'file_size' => true,
'file_path' => true
];
/**
* Unique identifier for this file
*
* @var string
*/
protected $fileId;
/**
* Optional. File size, if known
*
* @var int
*/
protected $fileSize;
/**
* Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
*
* @var string
*/
protected $filePath;
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string $fileId
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return int
*/
public function getFileSize()
{
return $this->fileSize;
}
/**
* @param int $fileSize
*
* @throws InvalidArgumentException
*/
public function setFileSize($fileSize)
{
if (is_integer($fileSize)) {
$this->fileSize = $fileSize;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getFilePath()
{
return $this->filePath;
}
/**
* @param string $filePath
*/
public function setFilePath($filePath)
{
$this->filePath = $filePath;
}
}

View File

@ -0,0 +1,88 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
/**
* Class ForceReply
* Upon receiving a message with this object, Telegram clients will display a reply interface to the user
* (act as if the user has selected the bots message and tapped Reply').This can be extremely useful
* if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
*
* @package TelegramBot\Api\Types
*/
class ForceReply extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['force_reply'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'force_reply' => true,
'selective' => true
];
/**
* Shows reply interface to the user, as if they manually selected the bots message and tapped Reply'
*
* @var bool
*/
protected $forceReply;
/**
* Optional. Use this parameter if you want to show the keyboard to specific users only.
* Targets:
* 1) users that are @mentioned in the text of the Message object;
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
*
* @var bool
*/
protected $selective;
public function __construct($forceReply = true, $selective = null)
{
$this->forceReply = $forceReply;
$this->selective = $selective;
}
/**
* @return boolean
*/
public function isForceReply()
{
return $this->forceReply;
}
/**
* @param boolean $forceReply
*/
public function setForceReply($forceReply)
{
$this->forceReply = $forceReply;
}
/**
* @return boolean
*/
public function isSelective()
{
return $this->selective;
}
/**
* @param boolean $selective
*/
public function setSelective($selective)
{
$this->selective = $selective;
}
}

View File

@ -0,0 +1,153 @@
<?php
namespace TelegramBot\Api\Types\Inline;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Types\Location;
use TelegramBot\Api\Types\User;
/**
* Class ChosenInlineResult
* This object represents a result of an inline query that was chosen by the user and sent to their chat partner.
*
* @package TelegramBot\Api\Types
*/
class ChosenInlineResult extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['result_id', 'from', 'query'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'result_id' => true,
'from' => User::class,
'location' => Location::class,
'inline_message_id' => true,
'query' => true,
];
/**
* The unique identifier for the result that was chosen.
*
* @var string
*/
protected $resultId;
/**
* The user that chose the result.
*
* @var User
*/
protected $from;
/**
* Optional. Sender location, only for bots that require user location
*
* @var Location
*/
protected $location;
/**
* Optional. Identifier of the sent inline message.
* Available only if there is an inline keyboard attached to the message.
* Will be also received in callback queries and can be used to edit the message.
*
* @var string
*/
protected $inlineMessageId;
/**
* The query that was used to obtain the result.
*
* @var string
*/
protected $query;
/**
* @return string
*/
public function getResultId()
{
return $this->resultId;
}
/**
* @param string $resultId
*/
public function setResultId($resultId)
{
$this->resultId = $resultId;
}
/**
* @return User
*/
public function getFrom()
{
return $this->from;
}
/**
* @param User $from
*/
public function setFrom(User $from)
{
$this->from = $from;
}
/**
* @return Location
*/
public function getLocation()
{
return $this->location;
}
/**
* @param Location $location
*/
public function setLocation($location)
{
$this->location = $location;
}
/**
* @return string
*/
public function getInlineMessageId()
{
return $this->inlineMessageId;
}
/**
* @param string $inlineMessageId
*/
public function setInlineMessageId($inlineMessageId)
{
$this->inlineMessageId = $inlineMessageId;
}
/**
* @return string
*/
public function getQuery()
{
return $this->query;
}
/**
* @param string $query
*/
public function setQuery($query)
{
$this->query = $query;
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Created by PhpStorm.
* User: YaroslavMolchan
* Date: 16/03/17
* Time: 22:15
*/
namespace TelegramBot\Api\Types\Inline;
use TelegramBot\Api\BaseType;
class InlineKeyboardMarkup extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['inline_keyboard'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'inline_keyboard' => true,
];
/**
* Array of button rows, each represented by an Array of InlineKeyboardButton objects
* Array of Array of InlineKeyboardButton
*
* @var array
*/
protected $inlineKeyboard;
/**
* @param array $inlineKeyboard
*/
public function __construct($inlineKeyboard)
{
$this->inlineKeyboard = $inlineKeyboard;
}
/**
* @return array
*/
public function getInlineKeyboard()
{
return $this->inlineKeyboard;
}
/**
* @param array $inlineKeyboard
*/
public function setInlineKeyboard($inlineKeyboard)
{
$this->inlineKeyboard = $inlineKeyboard;
}
}

View File

@ -0,0 +1,153 @@
<?php
namespace TelegramBot\Api\Types\Inline;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Types\Location;
use TelegramBot\Api\Types\User;
/**
* Class InlineQuery
* This object represents an incoming inline query.
* When the user sends an empty query, your bot could return some default or trending results.
*
* @package TelegramBot\Api\Types
*/
class InlineQuery extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['id', 'from', 'query', 'offset'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'id' => true,
'from' => User::class,
'location' => Location::class,
'query' => true,
'offset' => true,
];
/**
* Unique identifier for this query
*
* @var string
*/
protected $id;
/**
* Sender
*
* @var User
*/
protected $from;
/**
* Optional. Sender location, only for bots that request user location
*
* @var Location
*/
protected $location;
/**
* Text of the query
*
* @var string
*/
protected $query;
/**
* Offset of the results to be returned, can be controlled by the bot
*
* @var string
*/
protected $offset;
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return User
*/
public function getFrom()
{
return $this->from;
}
/**
* @param User $from
*/
public function setFrom(User $from)
{
$this->from = $from;
}
/**
* @return Location
*/
public function getLocation()
{
return $this->location;
}
/**
* @param Location $location
*/
public function setLocation($location)
{
$this->location = $location;
}
/**
* @return string
*/
public function getQuery()
{
return $this->query;
}
/**
* @param string $query
*/
public function setQuery($query)
{
$this->query = $query;
}
/**
* @return string
*/
public function getOffset()
{
return $this->offset;
}
/**
* @param string $offset
*/
public function setOffset($offset)
{
$this->offset = $offset;
}
}

View File

@ -0,0 +1,16 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 14/04/16
* Time: 04:05
*/
namespace TelegramBot\Api\Types\Inline;
use TelegramBot\Api\BaseType;
class InputMessageContent extends BaseType
{
}

View File

@ -0,0 +1,126 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 14/04/16
* Time: 16:01
*/
namespace TelegramBot\Api\Types\Inline\InputMessageContent;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\TypeInterface;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Contact
*
* @see https://core.telegram.org/bots/api#inputcontactmessagecontent
* Represents the content of a contact message to be sent as the result of an inline query.
*
* @package TelegramBot\Api\Types\Inline
*/
class Contact extends InputMessageContent implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['phone_number', 'first_name'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'phone_number' => true,
'first_name' => true,
'last_name' => true,
];
/**
* Contact's phone number
*
* @var string
*/
protected $phoneNumber;
/**
* Contact's first name
*
* @var string
*/
protected $firstName;
/**
* Optional. Contact's last name
*
* @var string
*/
protected $lastName;
/**
* Contact constructor.
*
* @param string $phoneNumber
* @param string $firstName
* @param string|null $lastName
*/
public function __construct($phoneNumber, $firstName, $lastName = null)
{
$this->phoneNumber = $phoneNumber;
$this->firstName = $firstName;
$this->lastName = $lastName;
}
/**
* @return string
*/
public function getPhoneNumber()
{
return $this->phoneNumber;
}
/**
* @param string $phoneNumber
*/
public function setPhoneNumber($phoneNumber)
{
$this->phoneNumber = $phoneNumber;
}
/**
* @return mixed
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param mixed $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
}

View File

@ -0,0 +1,97 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 14/04/16
* Time: 15:41
*/
namespace TelegramBot\Api\Types\Inline\InputMessageContent;
use TelegramBot\Api\TypeInterface;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Location
* @see https://core.telegram.org/bots/api#inputlocationmessagecontent
* Represents the content of a location message to be sent as the result of an inline query.
*
* @package TelegramBot\Api\Types\Inline
*/
class Location extends InputMessageContent implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['latitude', 'longitude'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'latitude' => true,
'longitude' => true
];
/**
* Latitude of the location in degrees
*
* @var float
*/
protected $latitude;
/**
* Longitude of the location in degrees
*
* @var float
*/
protected $longitude;
/**
* Location constructor.
* @param float $latitude
* @param float $longitude
*/
public function __construct($latitude, $longitude)
{
$this->latitude = $latitude;
$this->longitude = $longitude;
}
/**
* @return float
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* @param float $latitude
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
/**
* @return float
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* @param float $longitude
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 14/04/16
* Time: 14:41
*/
namespace TelegramBot\Api\Types\Inline\InputMessageContent;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\TypeInterface;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Text
* @see https://core.telegram.org/bots/api#inputtextmessagecontent
* Represents the content of a text message to be sent as the result of an inline query.
*
* @package TelegramBot\Api\Types\Inline\InputMessageContent
*/
class Text extends InputMessageContent implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['message_text'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'message_text' => true,
'parse_mode' => true,
'disable_web_page_preview' => true,
];
/**
* Text of the message to be sent, 1-4096 characters
*
* @var string
*/
protected $messageText;
/**
* Optional. Send Markdown or HTML,
* if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
*
* @var string
*/
protected $parseMode;
/**
* Optional. Disables link previews for links in the sent message
*
* @var bool
*/
protected $disableWebPagePreview;
/**
* Text constructor.
* @param string $messageText
* @param string $parseMode
* @param bool $disableWebPagePreview
*/
public function __construct($messageText, $parseMode = null, $disableWebPagePreview = false)
{
$this->messageText = $messageText;
$this->parseMode = $parseMode;
$this->disableWebPagePreview = $disableWebPagePreview;
}
/**
* @return string
*/
public function getMessageText()
{
return $this->messageText;
}
/**
* @param string $messageText
*/
public function setMessageText($messageText)
{
$this->messageText = $messageText;
}
/**
* @return string
*/
public function getParseMode()
{
return $this->parseMode;
}
/**
* @param string $parseMode
*/
public function setParseMode($parseMode)
{
$this->parseMode = $parseMode;
}
/**
* @return boolean
*/
public function isDisableWebPagePreview()
{
return $this->disableWebPagePreview;
}
/**
* @param boolean $disableWebPagePreview
*/
public function setDisableWebPagePreview($disableWebPagePreview)
{
$this->disableWebPagePreview = $disableWebPagePreview;
}
}

View File

@ -0,0 +1,175 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 14/04/16
* Time: 15:45
*/
namespace TelegramBot\Api\Types\Inline\InputMessageContent;
use TelegramBot\Api\TypeInterface;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Venue
* @see https://core.telegram.org/bots/api#inputvenuemessagecontent
* Represents the content of a venue message to be sent as the result of an inline query.
*
* @package TelegramBot\Api\Types\Inline
*/
class Venue extends InputMessageContent implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['latitude', 'longitude', 'title', 'address'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'latitude' => true,
'longitude' => true,
'title' => true,
'address' => true,
'foursquare_id' => true
];
/**
* Latitude of the venue in degrees
*
* @var float
*/
protected $latitude;
/**
* Longitude of the venue in degrees
*
* @var float
*/
protected $longitude;
/**
* Name of the venue
*
* @var string
*/
protected $title;
/**
* Address of the venue
*
* @var string
*/
protected $address;
/**
* Optional. Foursquare identifier of the venue, if known
*
* @var string
*/
protected $foursquareId;
/**
* Venue constructor.
* @param float $latitude
* @param float $longitude
* @param string $title
* @param string $address
* @param string $foursquareId
*/
public function __construct($latitude, $longitude, $title, $address, $foursquareId = null)
{
$this->latitude = $latitude;
$this->longitude = $longitude;
$this->title = $title;
$this->address = $address;
$this->foursquareId = $foursquareId;
}
/**
* @return float
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* @param float $latitude
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
/**
* @return float
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* @param float $longitude
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @param string $address
*/
public function setAddress($address)
{
$this->address = $address;
}
/**
* @return string
*/
public function getFoursquareId()
{
return $this->foursquareId;
}
/**
* @param string $foursquareId
*/
public function setFoursquareId($foursquareId)
{
$this->foursquareId = $foursquareId;
}
}

View File

@ -0,0 +1,147 @@
<?php
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class AbstractInlineQueryResult
* Abstract class for representing one result of an inline query
*
* @package TelegramBot\Api\Types
*/
class AbstractInlineQueryResult extends BaseType
{
/**
* Type of the result, must be one of: article, photo, gif, mpeg4_gif, video
*
* @var string
*/
protected $type;
/**
* Unique identifier for this result, 1-64 bytes
*
* @var string
*/
protected $id;
/**
* Title for the result
*
* @var string
*/
protected $title;
/**
* Content of the message to be sent instead of the file
*
* @var InputMessageContent
*/
protected $inputMessageContent;
/**
* Optional. Inline keyboard attached to the message
*
* @var InlineKeyboardMarkup
*/
protected $replyMarkup;
/**
* AbstractInlineQueryResult constructor.
*
* @param string $id
* @param string $title
* @param InputMessageContent|null $inputMessageContent
* @param InlineKeyboardMarkup|null $replyMarkup
*/
public function __construct($id, $title, $inputMessageContent = null, $replyMarkup = null)
{
$this->id = $id;
$this->title = $title;
$this->inputMessageContent = $inputMessageContent;
$this->replyMarkup = $replyMarkup;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return InputMessageContent
*/
public function getInputMessageContent()
{
return $this->inputMessageContent;
}
/**
* @param InputMessageContent $inputMessageContent
*/
public function setInputMessageContent($inputMessageContent)
{
$this->inputMessageContent = $inputMessageContent;
}
/**
* @return InlineKeyboardMarkup
*/
public function getReplyMarkup()
{
return $this->replyMarkup;
}
/**
* @param InlineKeyboardMarkup $replyMarkup
*/
public function setReplyMarkup($replyMarkup)
{
$this->replyMarkup = $replyMarkup;
}
}

View File

@ -0,0 +1,217 @@
<?php
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class InlineQueryResultArticle
* Represents a link to an article or web page.
*
* @package TelegramBot\Api\Types\Inline
*/
class Article extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'title', 'input_message_content'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'title' => true,
'input_message_content' => InputMessageContent::class,
'reply_markup' => InlineKeyboardMarkup::class,
'url' => true,
'hide_url' => true,
'description' => true,
'thumb_url' => true,
'thumb_width' => true,
'thumb_height' => true,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'article';
/**
* Optional. URL of the result
*
* @var string
*/
protected $url;
/**
* Optional. Pass True, if you don't want the URL to be shown in the message
*
* @var bool
*/
protected $hideUrl;
/**
* Optional. Short description of the result
*
* @var string
*/
protected $description;
/**
* Optional. Url of the thumbnail for the result
*
* @var string
*/
protected $thumbUrl;
/**
* Optional. Thumbnail width
*
* @var int
*/
protected $thumbWidth;
/**
* Optional. Thumbnail height
*
* @var int
*/
protected $thumbHeight;
/**
* InlineQueryResultArticle constructor.
*
* @param string $id
* @param string $title
* @param string|null $description
* @param string|null $thumbUrl
* @param int|null $thumbWidth
* @param int|null $thumbHeight
* @param InputMessageContent $inputMessageContent
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
*/
public function __construct(
$id,
$title,
$description = null,
$thumbUrl = null,
$thumbWidth = null,
$thumbHeight = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->description = $description;
$this->thumbUrl = $thumbUrl;
$this->thumbWidth = $thumbWidth;
$this->thumbHeight = $thumbHeight;
}
/**
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* @param string $url
*/
public function setUrl($url)
{
$this->url = $url;
}
/**
* @return boolean
*/
public function isHideUrl()
{
return $this->hideUrl;
}
/**
* @param boolean $hideUrl
*/
public function setHideUrl($hideUrl)
{
$this->hideUrl = $hideUrl;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param string $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return int
*/
public function getThumbWidth()
{
return $this->thumbWidth;
}
/**
* @param int $thumbWidth
*/
public function setThumbWidth($thumbWidth)
{
$this->thumbWidth = $thumbWidth;
}
/**
* @return int
*/
public function getThumbHeight()
{
return $this->thumbHeight;
}
/**
* @param int $thumbHeight
*/
public function setThumbHeight($thumbHeight)
{
$this->thumbHeight = $thumbHeight;
}
}

View File

@ -0,0 +1,152 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 14/04/16
* Time: 16:53
*/
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Audio
*
* @see https://core.telegram.org/bots/api#inlinequeryresultaudio
* Represents a link to an mp3 audio file. By default, this audio file will be sent by the user.
* Alternatively, you can use InputMessageContent to send a message with the specified content instead of the audio.
*
* Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
*
* @package TelegramBot\Api\Types\Inline\QueryResult
*/
class Audio extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'audio_url', 'title'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'audio_url' => true,
'title' => true,
'performer' => true,
'audio_duration' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'audio';
/**
* A valid URL for the audio file
*
* @var string
*/
protected $audioUrl;
/**
* Optional. Performer
*
* @var string
*/
protected $performer;
/**
* Optional. Audio duration in seconds
*
* @var int
*/
protected $audioDuration;
/**
* Audio constructor.
*
* @param string $id
* @param string $audioUrl
* @param string $title
* @param string|null $performer
* @param int|null $audioDuration
* @param InputMessageContent|null $inputMessageContent
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
*/
public function __construct(
$id,
$audioUrl,
$title,
$performer = null,
$audioDuration = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->audioUrl = $audioUrl;
$this->performer = $performer;
$this->audioDuration = $audioDuration;
}
/**
* @return string
*/
public function getAudioUrl()
{
return $this->audioUrl;
}
/**
* @param string $audioUrl
*/
public function setAudioUrl($audioUrl)
{
$this->audioUrl = $audioUrl;
}
/**
* @return string
*/
public function getPerformer()
{
return $this->performer;
}
/**
* @param string $performer
*/
public function setPerformer($performer)
{
$this->performer = $performer;
}
/**
* @return int
*/
public function getAudioDuration()
{
return $this->audioDuration;
}
/**
* @param int $audioDuration
*/
public function setAudioDuration($audioDuration)
{
$this->audioDuration = $audioDuration;
}
}

View File

@ -0,0 +1,220 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 14/04/16
* Time: 03:58
*/
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
class Contact extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'phone_number', 'first_name'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'phone_number' => true,
'first_name' => true,
'last_name' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
'thumb_url' => true,
'thumb_width' => true,
'thumb_height' => true,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'contact';
/**
* Contact's phone number
*
* @var string
*/
protected $phoneNumber;
/**
* Contact's first name
*
* @var string
*/
protected $firstName;
/**
* Optional. Contact's last name
*
* @var string
*/
protected $lastName;
/**
* Optional. Url of the thumbnail for the result
*
* @var string
*/
protected $thumbUrl;
/**
* Optional. Thumbnail width
*
* @var int
*/
protected $thumbWidth;
/**
* Optional. Thumbnail height
*
* @var int
*/
protected $thumbHeight;
/**
* Contact constructor.
*
* @param string $id
* @param string $phoneNumber
* @param string $firstName
* @param string $lastName
* @param string $thumbUrl
* @param int $thumbWidth
* @param int $thumbHeight
* @param InputMessageContent|null $inputMessageContent
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
*/
public function __construct(
$id,
$phoneNumber,
$firstName,
$lastName = null,
$thumbUrl = null,
$thumbWidth = null,
$thumbHeight = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, null, $inputMessageContent, $inlineKeyboardMarkup);
$this->phoneNumber = $phoneNumber;
$this->firstName = $firstName;
$this->lastName = $lastName;
$this->thumbUrl = $thumbUrl;
$this->thumbWidth = $thumbWidth;
$this->thumbHeight = $thumbHeight;
}
/**
* @return string
*/
public function getPhoneNumber()
{
return $this->phoneNumber;
}
/**
* @param string $phoneNumber
*/
public function setPhoneNumber($phoneNumber)
{
$this->phoneNumber = $phoneNumber;
}
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return string
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param string $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return int
*/
public function getThumbWidth()
{
return $this->thumbWidth;
}
/**
* @param int $thumbWidth
*/
public function setThumbWidth($thumbWidth)
{
$this->thumbWidth = $thumbWidth;
}
/**
* @return int
*/
public function getThumbHeight()
{
return $this->thumbHeight;
}
/**
* @param int $thumbHeight
*/
public function setThumbHeight($thumbHeight)
{
$this->thumbHeight = $thumbHeight;
}
}

View File

@ -0,0 +1,197 @@
<?php
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class InlineQueryResultGif
* Represents a link to an animated GIF file.
* By default, this animated GIF file will be sent by the user with optional caption.
* Alternatively, you can provide InputMessageContent to send it instead of the animation.
*
* @package TelegramBot\Api\Types\Inline
*/
class Gif extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'gif_url', 'thumb_url'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'gif_url' => true,
'gif_width' => true,
'gif_height' => true,
'thumb_url' => true,
'title' => true,
'caption' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'gif';
/**
* A valid URL for the GIF file. File size must not exceed 1MB
*
* @var string
*/
protected $gifUrl;
/**
* Optional. Width of the GIF
*
* @var int
*/
protected $gifWidth;
/**
* Optional. Height of the GIF
*
* @var int
*/
protected $gifHeight;
/**
* URL of the static thumbnail for the result (jpeg or gif)
*
* @var string
*/
protected $thumbUrl;
/**
* Optional. Caption of the GIF file to be sent, 0-200 characters
*
* @var string
*/
protected $caption;
/**
* InlineQueryResultGif constructor.
*
* @param string $id
* @param string $gifUrl
* @param string $thumbUrl
* @param int|null $gifWidth
* @param int|null $gifHeight
* @param string|null $title
* @param string|null $caption
* @param InputMessageContent $inputMessageContent
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
*/
public function __construct(
$id,
$gifUrl,
$thumbUrl = null,
$title = null,
$caption = null,
$gifWidth = null,
$gifHeight = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->gifUrl = $gifUrl;
$this->thumbUrl = is_null($thumbUrl) ? $gifUrl : $thumbUrl;
$this->gifWidth = $gifWidth;
$this->gifHeight = $gifHeight;
$this->caption = $caption;
}
/**
* @return string
*/
public function getGifUrl()
{
return $this->gifUrl;
}
/**
* @param string $gifUrl
*/
public function setGifUrl($gifUrl)
{
$this->gifUrl = $gifUrl;
}
/**
* @return int
*/
public function getGifWidth()
{
return $this->gifWidth;
}
/**
* @param int $gifWidth
*/
public function setGifWidth($gifWidth)
{
$this->gifWidth = $gifWidth;
}
/**
* @return int
*/
public function getGifHeight()
{
return $this->gifHeight;
}
/**
* @param int $gifHeight
*/
public function setGifHeight($gifHeight)
{
$this->gifHeight = $gifHeight;
}
/**
* @return string
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param string $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption($caption)
{
$this->caption = $caption;
}
}

View File

@ -0,0 +1,206 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 18/04/16
* Time: 04:00
*/
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Location
*
* @see https://core.telegram.org/bots/api#inlinequeryresultlocation
* Represents a location on a map. By default, the location will be sent by the user.
* Alternatively, you can use InputMessageContent to send a message with the specified content instead of the location.
*
* Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
*
* @package TelegramBot\Api\Types\Inline\QueryResult
*/
class Location extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'latitude', 'longitude', 'title'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'latitude' => true,
'longitude' => true,
'title' => true,
'thumb_url' => true,
'thumb_width' => true,
'thumb_height' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'location';
/**
* Location latitude in degrees
*
* @var float
*/
protected $latitude;
/**
* Location longitude in degrees
*
* @var float
*/
protected $longitude;
/**
* Optional. Url of the thumbnail for the result
*
* @var string
*/
protected $thumbUrl;
/**
* Optional. Thumbnail width
*
* @var int
*/
protected $thumbWidth;
/**
* Optional. Thumbnail height
*
* @var int
*/
protected $thumbHeight;
/**
* Voice constructor
*
* @param string $id
* @param float $latitude
* @param float $longitude
* @param string $title
* @param string $thumbUrl
* @param int $thumbWidth
* @param int $thumbHeight
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
* @param InputMessageContent|null $inputMessageContent
*/
public function __construct(
$id,
$latitude,
$longitude,
$title,
$thumbUrl = null,
$thumbWidth = null,
$thumbHeight = null,
$inlineKeyboardMarkup = null,
$inputMessageContent = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->latitude = $latitude;
$this->longitude = $longitude;
$this->thumbUrl = $thumbUrl;
$this->thumbWidth = $thumbWidth;
$this->thumbHeight = $thumbHeight;
}
/**
* @return float
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* @param float $latitude
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
/**
* @return float
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* @param float $longitude
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
/**
* @return string
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param string $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return int
*/
public function getThumbWidth()
{
return $this->thumbWidth;
}
/**
* @param int $thumbWidth
*/
public function setThumbWidth($thumbWidth)
{
$this->thumbWidth = $thumbWidth;
}
/**
* @return int
*/
public function getThumbHeight()
{
return $this->thumbHeight;
}
/**
* @param int $thumbHeight
*/
public function setThumbHeight($thumbHeight)
{
$this->thumbHeight = $thumbHeight;
}
}

View File

@ -0,0 +1,198 @@
<?php
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class InlineQueryResultMpeg4Gif
* Represents a link to a video animation (H.264/MPEG-4 AVC video without sound).
* By default, this animated MPEG-4 file will be sent by the user with optional caption.
* Alternatively, you can provide message_text to send it instead of the animation.
*
* @package TelegramBot\Api\Types\Inline
*/
class Mpeg4Gif extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'mpeg4_url', 'thumb_url'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'mpeg4_url' => true,
'mpeg4_width' => true,
'mpeg4_height' => true,
'thumb_url' => true,
'title' => true,
'caption' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'mpeg4_gif';
/**
* A valid URL for the MP4 file. File size must not exceed 1MB
*
* @var string
*/
protected $mpeg4Url;
/**
* Optional. Video width
*
* @var int
*/
protected $mpeg4Width;
/**
* Optional. Video height
*
* @var int
*/
protected $mpeg4Height;
/**
* URL of the static thumbnail (jpeg or gif) for the result
*
* @var string
*/
protected $thumbUrl;
/**
* Optional. Caption of the MPEG-4 file to be sent, 0-200 characters
*
* @var string
*/
protected $caption;
/**
* InlineQueryResultMpeg4Gif constructor.
*
* @param string $id
* @param string $mpeg4Url
* @param string $thumbUrl
* @param int|null $mpeg4Width
* @param int|null $mpeg4Height
* @param string|null $caption
* @param string|null $title
* @param InputMessageContent $inputMessageContent
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
*/
public function __construct(
$id,
$mpeg4Url,
$thumbUrl,
$title = null,
$caption = null,
$mpeg4Width = null,
$mpeg4Height = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->mpeg4Url = $mpeg4Url;
$this->thumbUrl = $thumbUrl;
$this->mpeg4Width = $mpeg4Width;
$this->mpeg4Height = $mpeg4Height;
$this->caption = $caption;
}
/**
* @return string
*/
public function getMpeg4Url()
{
return $this->mpeg4Url;
}
/**
* @param string $mpeg4Url
*/
public function setMpeg4Url($mpeg4Url)
{
$this->mpeg4Url = $mpeg4Url;
}
/**
* @return int
*/
public function getMpeg4Width()
{
return $this->mpeg4Width;
}
/**
* @param int $mpeg4Width
*/
public function setMpeg4Width($mpeg4Width)
{
$this->mpeg4Width = $mpeg4Width;
}
/**
* @return int
*/
public function getMpeg4Height()
{
return $this->mpeg4Height;
}
/**
* @param int $mpeg4Height
*/
public function setMpeg4Height($mpeg4Height)
{
$this->mpeg4Height = $mpeg4Height;
}
/**
* @return string
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param string $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption($caption)
{
$this->caption = $caption;
}
}

View File

@ -0,0 +1,224 @@
<?php
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class InlineQueryResultPhoto
* Represents a link to a photo. By default, this photo will be sent by the user with optional caption.
* Alternatively, you can provide message_text to send it instead of photo.
*
* @package TelegramBot\Api\Types\Inline
*/
class Photo extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'photo_url', 'thumb_url'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'photo_url' => true,
'thumb_url' => true,
'photo_width' => true,
'photo_height' => true,
'title' => true,
'description' => true,
'caption' => true,
'input_message_content' => InputMessageContent::class,
'reply_markup' => InlineKeyboardMarkup::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'photo';
/**
* A valid URL of the photo. Photo size must not exceed 5MB
*
* @var string
*/
protected $photoUrl;
/**
* Optional. Width of the photo
*
* @var int
*/
protected $photoWidth;
/**
* Optional. Height of the photo
*
* @var int
*/
protected $photoHeight;
/**
* URL of the thumbnail for the photo
*
* @var
*/
protected $thumbUrl;
/**
* Optional. Short description of the result
*
* @var string
*/
protected $description;
/**
* Optional. Caption of the photo to be sent, 0-200 characters
*
* @var string
*/
protected $caption;
/**
* InlineQueryResultPhoto constructor.
*
* @param string $id
* @param string $photoUrl
* @param string $thumbUrl
* @param int|null $photoWidth
* @param int|null $photoHeight
* @param string|null $title
* @param string|null $description
* @param string|null $caption
* @param InputMessageContent|null $inputMessageContent
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
*/
public function __construct(
$id,
$photoUrl,
$thumbUrl,
$photoWidth = null,
$photoHeight = null,
$title = null,
$description = null,
$caption = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->photoUrl = $photoUrl;
$this->thumbUrl = $thumbUrl;
$this->photoWidth = $photoWidth;
$this->photoHeight = $photoHeight;
$this->description = $description;
$this->caption = $caption;
}
/**
* @return string
*/
public function getPhotoUrl()
{
return $this->photoUrl;
}
/**
* @param string $photoUrl
*/
public function setPhotoUrl($photoUrl)
{
$this->photoUrl = $photoUrl;
}
/**
* @return int
*/
public function getPhotoWidth()
{
return $this->photoWidth;
}
/**
* @param int $photoWidth
*/
public function setPhotoWidth($photoWidth)
{
$this->photoWidth = $photoWidth;
}
/**
* @return int
*/
public function getPhotoHeight()
{
return $this->photoHeight;
}
/**
* @param int $photoHeight
*/
public function setPhotoHeight($photoHeight)
{
$this->photoHeight = $photoHeight;
}
/**
* @return mixed
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param mixed $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption($caption)
{
$this->caption = $caption;
}
}

View File

@ -0,0 +1,260 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 18/04/16
* Time: 04:19
*/
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Venue
*
* @see https://core.telegram.org/bots/api#inlinequeryresultvenue
* Represents a venue. By default, the venue will be sent by the user.
* Alternatively, you can use InputMessageContent to send a message with the specified content instead of the venue.
*
* Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
*
* @package TelegramBot\Api\Types\Inline\QueryResult
*/
class Venue extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'latitude', 'longitude', 'title', 'address'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'latitude' => true,
'longitude' => true,
'title' => true,
'address' => true,
'foursquare_id' => true,
'thumb_url' => true,
'thumb_width' => true,
'thumb_height' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'venue';
/**
* Latitude of the venue location in degrees
*
* @var float
*/
protected $latitude;
/**
* Longitude of the venue location in degrees
*
* @var float
*/
protected $longitude;
/**
* Optional. Thumbnail width
*
* @var string
*/
protected $address;
/**
* Optional. Url of the thumbnail for the result
*
* @var string
*/
protected $thumbUrl;
/**
* Optional. Thumbnail width
*
* @var int
*/
protected $thumbWidth;
/**
* Optional. Thumbnail height
*
* @var int
*/
protected $thumbHeight;
/**
* Optional. Foursquare identifier of the venue if known
*
* @var int
*/
protected $foursquareId;
/**
* Voice constructor
*
* @param string $id
* @param float $latitude
* @param float $longitude
* @param string $title
* @param string $address
* @param string $thumbUrl
* @param int $thumbWidth
* @param int $thumbHeight
* @param string $foursquareId
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
* @param InputMessageContent|null $inputMessageContent
*/
public function __construct(
$id,
$latitude,
$longitude,
$title,
$address,
$thumbUrl = null,
$thumbWidth = null,
$thumbHeight = null,
$foursquareId = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->latitude = $latitude;
$this->longitude = $longitude;
$this->address = $address;
$this->thumbUrl = $thumbUrl;
$this->thumbWidth = $thumbWidth;
$this->thumbHeight = $thumbHeight;
$this->foursquareId = $foursquareId;
}
/**
* @return float
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* @param float $latitude
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
/**
* @return float
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* @param float $longitude
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @param string $address
*/
public function setAddress($address)
{
$this->address = $address;
}
/**
* @return int
*/
public function getFoursquareId()
{
return $this->foursquareId;
}
/**
* @param int $foursquareId
*/
public function setFoursquareId($foursquareId)
{
$this->foursquareId = $foursquareId;
}
/**
* @return string
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param string $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return int
*/
public function getThumbWidth()
{
return $this->thumbWidth;
}
/**
* @param int $thumbWidth
*/
public function setThumbWidth($thumbWidth)
{
$this->thumbWidth = $thumbWidth;
}
/**
* @return int
*/
public function getThumbHeight()
{
return $this->thumbHeight;
}
/**
* @param int $thumbHeight
*/
public function setThumbHeight($thumbHeight)
{
$this->thumbHeight = $thumbHeight;
}
}

View File

@ -0,0 +1,278 @@
<?php
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class InlineQueryResultVideo
* Represents link to a page containing an embedded video player or a video file.
*
* @package TelegramBot\Api\Types\Inline
*/
class Video extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'video_url', 'mime_type', 'thumb_url', 'title'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'video_url' => true,
'mime_type' => true,
'thumb_url' => true,
'title' => true,
'caption' => true,
'description' => true,
'video_width' => true,
'video_height' => true,
'video_duration' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'video';
/**
* A valid URL for the embedded video player or video file
*
* @var string
*/
protected $videoUrl;
/**
* Mime type of the content of video url, “text/html” or “video/mp4”
*
* @var string
*/
protected $mimeType;
/**
* Optional. Video width
*
* @var int
*/
protected $videoWidth;
/**
* Optional. Video height
*
* @var int
*/
protected $videoHeight;
/**
* Optional. Video duration in seconds
*
* @var int
*/
protected $videoDuration;
/**
* URL of the thumbnail (jpeg only) for the video
*
* @var string
*/
protected $thumbUrl;
/**
* Optional. Short description of the result
*
* @var string
*/
protected $caption;
/**
* Optional. Short description of the result
*
* @var string
*/
protected $description;
/**
* Video constructor
*
* @param string $id
* @param string $videoUrl
* @param string $thumbUrl
* @param string $mimeType
* @param string $title
* @param string|null $caption
* @param string|null $description
* @param int|null $videoWidth
* @param int|null $videoHeight
* @param int|null $videoDuration
* @param InputMessageContent|null $inputMessageContent
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
*/
public function __construct(
$id,
$videoUrl,
$thumbUrl,
$mimeType,
$title,
$caption = null,
$description = null,
$videoWidth = null,
$videoHeight = null,
$videoDuration = null,
$inputMessageContent = null,
$inlineKeyboardMarkup = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->videoUrl = $videoUrl;
$this->thumbUrl = $thumbUrl;
$this->caption = $caption;
$this->description = $description;
$this->mimeType = $mimeType;
$this->videoWidth = $videoWidth;
$this->videoHeight = $videoHeight;
$this->videoDuration = $videoDuration;
}
/**
* @return string
*/
public function getVideoUrl()
{
return $this->videoUrl;
}
/**
* @param string $videoUrl
*/
public function setVideoUrl($videoUrl)
{
$this->videoUrl = $videoUrl;
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* @param string $mimeType
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return int
*/
public function getVideoWidth()
{
return $this->videoWidth;
}
/**
* @param int $videoWidth
*/
public function setVideoWidth($videoWidth)
{
$this->videoWidth = $videoWidth;
}
/**
* @return int
*/
public function getVideoHeight()
{
return $this->videoHeight;
}
/**
* @param int $videoHeight
*/
public function setVideoHeight($videoHeight)
{
$this->videoHeight = $videoHeight;
}
/**
* @return int
*/
public function getVideoDuration()
{
return $this->videoDuration;
}
/**
* @param int $videoDuration
*/
public function setVideoDuration($videoDuration)
{
$this->videoDuration = $videoDuration;
}
/**
* @return mixed
*/
public function getThumbUrl()
{
return $this->thumbUrl;
}
/**
* @param mixed $thumbUrl
*/
public function setThumbUrl($thumbUrl)
{
$this->thumbUrl = $thumbUrl;
}
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption($caption)
{
$this->caption = $caption;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
}

View File

@ -0,0 +1,128 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 17/04/16
* Time: 02:12
*/
namespace TelegramBot\Api\Types\Inline\QueryResult;
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup;
use TelegramBot\Api\Types\Inline\InputMessageContent;
/**
* Class Voice
*
* @see https://core.telegram.org/bots/api#inlinequeryresultvoice
* Represents a link to an mp3 audio file. By default, this audio file will be sent by the user.
* Alternatively, you can use InputMessageContent to send a message with the specified content instead of the audio.
*
* Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
*
* @package TelegramBot\Api\Types\Inline\QueryResult
*/
class Voice extends AbstractInlineQueryResult
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'id', 'voice_url', 'title'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'id' => true,
'voice_url' => true,
'title' => true,
'voice_duration' => true,
'reply_markup' => InlineKeyboardMarkup::class,
'input_message_content' => InputMessageContent::class,
];
/**
* {@inheritdoc}
*
* @var string
*/
protected $type = 'voice';
/**
* A valid URL for the audio file
*
* @var string
*/
protected $voiceUrl;
/**
* Optional. Audio duration in seconds
*
* @var int
*/
protected $voiceDuration;
/**
* Voice constructor
*
* @param string $id
* @param string $voiceUrl
* @param string $title
* @param int|null $voiceDuration
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup
* @param InputMessageContent|null $inputMessageContent
*/
public function __construct(
$id,
$voiceUrl,
$title,
$voiceDuration = null,
$inlineKeyboardMarkup = null,
$inputMessageContent = null
) {
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup);
$this->voiceUrl = $voiceUrl;
$this->voiceDuration = $voiceDuration;
$this->replyMarkup = $inlineKeyboardMarkup;
$this->inputMessageContent = $inputMessageContent;
}
/**
* @return string
*/
public function getVoiceUrl()
{
return $this->voiceUrl;
}
/**
* @param string $voiceUrl
*/
public function setVoiceUrl($voiceUrl)
{
$this->voiceUrl = $voiceUrl;
}
/**
* @return int
*/
public function getVoiceDuration()
{
return $this->voiceDuration;
}
/**
* @param int $voiceDuration
*/
public function setVoiceDuration($voiceDuration)
{
$this->voiceDuration = $voiceDuration;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace TelegramBot\Api\Types\InputMedia;
use TelegramBot\Api\Collection\Collection;
/**
* Class ArrayOfInputMedia
*
* @package TelegramBot\Api
*/
class ArrayOfInputMedia extends Collection
{
protected $maxCount = 10;
}

View File

@ -0,0 +1,129 @@
<?php
namespace TelegramBot\Api\Types\InputMedia;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Collection\CollectionItemInterface;
/**
* Class InputMedia
* This object represents the content of a media message to be sent.
*
* @package TelegramBot\Api
*/
class InputMedia extends BaseType implements CollectionItemInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'media'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'media' => true,
'caption' => true,
'parse_mode' => true,
];
/**
* Type of the result.
*
* @var string
*/
protected $type;
/**
* File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended),
* pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>"
* to upload a new one using multipart/form-data under <file_attach_name> name.
*
* @var string
*/
protected $media;
/**
* Optional. Caption of the photo to be sent, 0-200 characters.
*
* @var string
*/
protected $caption;
/**
* Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic,
* fixed-width text or inline URLs in the media caption.
*
* @var string
*/
protected $parseMode;
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getMedia()
{
return $this->media;
}
/**
* @param string $media
*/
public function setMedia($media)
{
$this->media = $media;
}
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption($caption)
{
$this->caption = $caption;
}
/**
* @return string
*/
public function getParseMode()
{
return $this->parseMode;
}
/**
* @param string $parseMode
*/
public function setParseMode($parseMode)
{
$this->parseMode = $parseMode;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace TelegramBot\Api\Types\InputMedia;
/**
* Class InputMediaPhoto
* Represents a photo to be sent.
*
* @package TelegramBot\Api
*/
class InputMediaPhoto extends InputMedia
{
/**
* InputMediaPhoto constructor.
*
* @param string $media
* @param null $caption
* @param null $parseMode
*/
public function __construct($media, $caption = null, $parseMode = null)
{
$this->type = 'photo';
$this->media = $media;
$this->caption = $caption;
$this->parseMode = $parseMode;
}
}

View File

@ -0,0 +1,150 @@
<?php
namespace TelegramBot\Api\Types\InputMedia;
/**
* Class InputMediaVideo
* Represents a video to be sent.
*
* @package TelegramBot\Api
*/
class InputMediaVideo extends InputMedia
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'media' => true,
'caption' => true,
'parse_mode' => true,
'width' => true,
'height' => true,
'duration' => true,
'supports_streaming' => true
];
/**
* Optional. Video width.
*
* @var string
*/
protected $width;
/**
* Optional. Video height.
*
* @var string
*/
protected $height;
/**
* Optional. Video duration.
*
* @var string
*/
protected $duration;
/**
* Optional. Pass True, if the uploaded video is suitable for streaming.
*
* @var bool
*/
protected $supportsStreaming;
/**
* InputMediaVideo constructor.
*
* @param string $media
* @param null $caption
* @param null $parseMode
* @param null $width
* @param null $height
* @param null $duration
* @param bool $supportsStreaming
*/
public function __construct(
$media,
$caption = null,
$parseMode = null,
$width = null,
$height = null,
$duration = null,
$supportsStreaming = false
) {
$this->type = 'video';
$this->media = $media;
$this->caption = $caption;
$this->parseMode = $parseMode;
$this->width = $width;
$this->height = $height;
$this->duration = $duration;
$this->supportsStreaming = $supportsStreaming;
}
/**
* @return string
*/
public function getWidth()
{
return $this->width;
}
/**
* @param string $width
*/
public function setWidth($width)
{
$this->width = $width;
}
/**
* @return string
*/
public function getHeight()
{
return $this->height;
}
/**
* @param string $height
*/
public function setHeight($height)
{
$this->height = $height;
}
/**
* @return string
*/
public function getDuration()
{
return $this->duration;
}
/**
* @param string $duration
*/
public function setDuration($duration)
{
$this->duration = $duration;
}
/**
* @return bool
*/
public function getSupportsStreaming()
{
return $this->supportsStreaming;
}
/**
* @param bool $supportsStreaming
*/
public function setSupportsStreaming($supportsStreaming)
{
$this->supportsStreaming = $supportsStreaming;
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class Location
* This object represents a point on the map.
*
* @package TelegramBot\Api\Types
*/
class Location extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['latitude', 'longitude'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'latitude' => true,
'longitude' => true
];
/**
* Longitude as defined by sender
*
* @var float
*/
protected $longitude;
/**
* Latitude as defined by sender
*
* @var float
*/
protected $latitude;
/**
* @return float
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* @param float $latitude
*
* @throws InvalidArgumentException
*/
public function setLatitude($latitude)
{
if (is_float($latitude)) {
$this->latitude = $latitude;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return float
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* @param float $longitude
*
* @throws InvalidArgumentException
*/
public function setLongitude($longitude)
{
if (is_float($longitude)) {
$this->longitude = $longitude;
} else {
throw new InvalidArgumentException();
}
}
}

View File

@ -0,0 +1,920 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
use TelegramBot\Api\Types\Payments\Invoice;
use TelegramBot\Api\Types\Payments\SuccessfulPayment;
class Message extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['message_id', 'date', 'chat'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'message_id' => true,
'from' => User::class,
'date' => true,
'chat' => Chat::class,
'forward_from' => User::class,
'forward_date' => true,
'reply_to_message' => Message::class,
'text' => true,
'entities' => ArrayOfMessageEntity::class,
'caption_entities' => ArrayOfMessageEntity::class,
'audio' => Audio::class,
'document' => Document::class,
'photo' => ArrayOfPhotoSize::class,
'sticker' => Sticker::class,
'video' => Video::class,
'voice' => Voice::class,
'caption' => true,
'contact' => Contact::class,
'location' => Location::class,
'venue' => Venue::class,
'new_chat_member' => User::class,
'left_chat_member' => User::class,
'new_chat_title' => true,
'new_chat_photo' => ArrayOfPhotoSize::class,
'delete_chat_photo' => true,
'group_chat_created' => true,
'supergroup_chat_created' => true,
'channel_chat_created' => true,
'migrate_to_chat_id' => true,
'migrate_from_chat_id' => true,
'pinned_message' => Message::class,
'invoice' => Invoice::class,
'successful_payment' => SuccessfulPayment::class,
'forward_signature' => true,
'author_signature' => true,
'connected_website' => true
];
/**
* Unique message identifier
*
* @var int
*/
protected $messageId;
/**
* Optional. Sender name. Can be empty for messages sent to channels
*
* @var \TelegramBot\Api\Types\User
*/
protected $from;
/**
* Date the message was sent in Unix time
*
* @var int
*/
protected $date;
/**
* Conversation the message belongs to — user in case of a private message, GroupChat in case of a group
*
* @var \TelegramBot\Api\Types\Chat
*/
protected $chat;
/**
* Optional. For forwarded messages, sender of the original message
*
* @var \TelegramBot\Api\Types\User
*/
protected $forwardFrom;
/**
* Optional. For forwarded messages, date the original message was sent in Unix time
*
* @var int
*/
protected $forwardDate;
/**
* Optional. For replies, the original message. Note that the Message object in this field will not contain further
* reply_to_message fields even if it itself is a reply.
*
* @var \TelegramBot\Api\Types\Message
*/
protected $replyToMessage;
/**
* Optional. For text messages, the actual UTF-8 text of the message
*
* @var string
*/
protected $text;
/**
* Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.
* array of \TelegramBot\Api\Types\MessageEntity
*
* @var array
*/
protected $entities;
/**
* Optional. Message is an audio file, information about the file
*
* @var \TelegramBot\Api\Types\Audio
*/
protected $audio;
/**
* Optional. Message is a general file, information about the file
*
* @var \TelegramBot\Api\Types\Document
*/
protected $document;
/**
* Optional. Message is a photo, available sizes of the photo
* array of \TelegramBot\Api\Types\Photo
*
* @var array
*/
protected $photo;
/**
* Optional. Message is a sticker, information about the sticker
*
* @var \TelegramBot\Api\Types\Sticker
*/
protected $sticker;
/**
* Optional. Message is a video, information about the video
*
* @var \TelegramBot\Api\Types\Video
*/
protected $video;
/**
* Optional. Message is a voice message, information about the file
*
* @var \TelegramBot\Api\Types\Voice
*/
protected $voice;
/**
* Optional. Message is a shared contact, information about the contact
*
* @var \TelegramBot\Api\Types\Contact
*/
protected $contact;
/**
* Optional. Message is a shared location, information about the location
*
* @var \TelegramBot\Api\Types\Location
*/
protected $location;
/**
* Optional. Message is a venue, information about the venue
*
* @var \TelegramBot\Api\Types\Venue
*/
protected $venue;
/**
* Optional. A new member was added to the group, information about them (this member may be bot itself)
*
* @var \TelegramBot\Api\Types\User
*/
protected $newChatMember;
/**
* Optional. A member was removed from the group, information about them (this member may be bot itself)
*
* @var \TelegramBot\Api\Types\User
*/
protected $leftChatMember;
/**
* Optional. A group title was changed to this value
*
* @var string
*/
protected $newChatTitle;
/**
* Optional. A group photo was change to this value
*
* @var mixed
*/
protected $newChatPhoto;
/**
* Optional. Informs that the group photo was deleted
*
* @var bool
*/
protected $deleteChatPhoto;
/**
* Optional. Informs that the group has been created
*
* @var bool
*/
protected $groupChatCreated;
/**
* Optional. Text description of the video (usually empty)
*
* @var string
*/
protected $caption;
/**
* Optional. Service message: the supergroup has been created
*
* @var bool
*/
protected $supergroupChatCreated;
/**
* Optional. Service message: the channel has been created
*
* @var bool
*/
protected $channelChatCreated;
/**
* Optional. The group has been migrated to a supergroup with the specified identifier,
* not exceeding 1e13 by absolute value
*
* @var int
*/
protected $migrateToChatId;
/**
* Optional. The supergroup has been migrated from a group with the specified identifier,
* not exceeding 1e13 by absolute value
*
* @var int
*/
protected $migrateFromChatId;
/**
* Optional. Specified message was pinned.Note that the Message object in this field
* will not contain further reply_to_message fields even if it is itself a reply.
*
* @var Message
*/
protected $pinnedMessage;
/**
* Optional. Message is an invoice for a payment, information about the invoice.
*
* @var Invoice
*/
protected $invoice;
/**
* Optional. Message is a service message about a successful payment, information about the payment.
*
* @var SuccessfulPayment
*/
protected $successfulPayment;
/**
* Optional. For messages forwarded from channels, signature of the post author if present
*
* @var string
*/
protected $forwardSignature;
/**
* Optional. Signature of the post author for messages in channels
*
* @var string
*/
protected $authorSignature;
/**
* Optional. For messages with a caption, special entities like usernames,
* URLs, bot commands, etc. that appear in the caption
*
* @var ArrayOfMessageEntity
*/
protected $captionEntities;
/**
* Optional. The domain name of the website on which the user has logged in.
*
* @var string
*/
protected $connectedWebsite;
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption($caption)
{
$this->caption = $caption;
}
/**
* @return Audio
*/
public function getAudio()
{
return $this->audio;
}
/**
* @param Audio $audio
*/
public function setAudio(Audio $audio)
{
$this->audio = $audio;
}
/**
* @return Chat
*/
public function getChat()
{
return $this->chat;
}
/**
* @param Chat $chat
*/
public function setChat(Chat $chat)
{
$this->chat = $chat;
}
/**
* @return Contact
*/
public function getContact()
{
return $this->contact;
}
/**
* @param Contact $contact
*/
public function setContact(Contact $contact)
{
$this->contact = $contact;
}
/**
* @return int
*/
public function getDate()
{
return $this->date;
}
/**
* @param int $date
*
* @throws InvalidArgumentException
*/
public function setDate($date)
{
if (is_integer($date)) {
$this->date = $date;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return boolean
*/
public function isDeleteChatPhoto()
{
return $this->deleteChatPhoto;
}
/**
* @param boolean $deleteChatPhoto
*/
public function setDeleteChatPhoto($deleteChatPhoto)
{
$this->deleteChatPhoto = (bool)$deleteChatPhoto;
}
/**
* @return Document
*/
public function getDocument()
{
return $this->document;
}
/**
* @param Document $document
*/
public function setDocument($document)
{
$this->document = $document;
}
/**
* @return int
*/
public function getForwardDate()
{
return $this->forwardDate;
}
/**
* @param int $forwardDate
*
* @throws InvalidArgumentException
*/
public function setForwardDate($forwardDate)
{
if (is_integer($forwardDate)) {
$this->forwardDate = $forwardDate;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return User
*/
public function getForwardFrom()
{
return $this->forwardFrom;
}
/**
* @param User $forwardFrom
*/
public function setForwardFrom(User $forwardFrom)
{
$this->forwardFrom = $forwardFrom;
}
/**
* @return boolean
*/
public function isGroupChatCreated()
{
return $this->groupChatCreated;
}
/**
* @param boolean $groupChatCreated
*/
public function setGroupChatCreated($groupChatCreated)
{
$this->groupChatCreated = (bool)$groupChatCreated;
}
/**
* @return User
*/
public function getLeftChatMember()
{
return $this->leftChatMember;
}
/**
* @param User $leftChatMember
*/
public function setLeftChatMember($leftChatMember)
{
$this->leftChatMember = $leftChatMember;
}
/**
* @return Location
*/
public function getLocation()
{
return $this->location;
}
/**
* @param Location $location
*/
public function setLocation(Location $location)
{
$this->location = $location;
}
/**
* @return Venue
*/
public function getVenue()
{
return $this->venue;
}
/**
* @param Venue $venue
*/
public function setVenue($venue)
{
$this->venue = $venue;
}
/**
* @return int
*/
public function getMessageId()
{
return $this->messageId;
}
/**
* @param int $messageId
*
* @throws InvalidArgumentException
*/
public function setMessageId($messageId)
{
if (is_integer($messageId) || is_float($messageId)) {
$this->messageId = $messageId;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return User
*/
public function getNewChatMember()
{
return $this->newChatMember;
}
/**
* @param User $newChatMember
*/
public function setNewChatMember($newChatMember)
{
$this->newChatMember = $newChatMember;
}
/**
* @return array
*/
public function getNewChatPhoto()
{
return $this->newChatPhoto;
}
/**
* @param array $newChatPhoto
*/
public function setNewChatPhoto($newChatPhoto)
{
$this->newChatPhoto = $newChatPhoto;
}
/**
* @return string
*/
public function getNewChatTitle()
{
return $this->newChatTitle;
}
/**
* @param string $newChatTitle
*/
public function setNewChatTitle($newChatTitle)
{
$this->newChatTitle = $newChatTitle;
}
/**
* @return array
*/
public function getPhoto()
{
return $this->photo;
}
/**
* @param array $photo
*/
public function setPhoto(array $photo)
{
$this->photo = $photo;
}
/**
* @return Message
*/
public function getReplyToMessage()
{
return $this->replyToMessage;
}
/**
* @param Message $replyToMessage
*/
public function setReplyToMessage(Message $replyToMessage)
{
$this->replyToMessage = $replyToMessage;
}
/**
* @return Sticker
*/
public function getSticker()
{
return $this->sticker;
}
/**
* @param Sticker $sticker
*/
public function setSticker(Sticker $sticker)
{
$this->sticker = $sticker;
}
/**
* @return string
*/
public function getText()
{
return $this->text;
}
/**
* @param string $text
*/
public function setText($text)
{
$this->text = $text;
}
/**
* @return array
*/
public function getEntities()
{
return $this->entities;
}
/**
* @param array $entities
*/
public function setEntities($entities)
{
$this->entities = $entities;
}
/**
* @return User
*/
public function getFrom()
{
return $this->from;
}
/**
* @param User $from
*/
public function setFrom(User $from)
{
$this->from = $from;
}
/**
* @return Video
*/
public function getVideo()
{
return $this->video;
}
/**
* @param Video $video
*/
public function setVideo(Video $video)
{
$this->video = $video;
}
/**
* @return Voice
*/
public function getVoice()
{
return $this->voice;
}
/**
* @param Voice $voice
*/
public function setVoice($voice)
{
$this->voice = $voice;
}
/**
* @param boolean $supergroupChatCreated
*/
public function setSupergroupChatCreated($supergroupChatCreated)
{
$this->supergroupChatCreated = $supergroupChatCreated;
}
/**
* @return boolean
*/
public function isSupergroupChatCreated()
{
return $this->supergroupChatCreated;
}
/**
* @param boolean $channelChatCreated
*/
public function setChannelChatCreated($channelChatCreated)
{
$this->channelChatCreated = $channelChatCreated;
}
/**
* @return boolean
*/
public function isChannelChatCreated()
{
return $this->channelChatCreated;
}
/**
* @param int $migrateToChatId
*/
public function setMigrateToChatId($migrateToChatId)
{
$this->migrateToChatId = $migrateToChatId;
}
/**
* @return int
*/
public function getMigrateToChatId()
{
return $this->migrateToChatId;
}
/**
* @param int $migrateFromChatId
*/
public function setMigrateFromChatId($migrateFromChatId)
{
$this->migrateFromChatId = $migrateFromChatId;
}
/**
* @return int
*/
public function getMigrateFromChatId()
{
return $this->migrateFromChatId;
}
/**
* @return Message
*/
public function getPinnedMessage()
{
return $this->pinnedMessage;
}
/**
* @param Message $pinnedMessage
*/
public function setPinnedMessage($pinnedMessage)
{
$this->pinnedMessage = $pinnedMessage;
}
/**
* @author MY
* @return Invoice
*/
public function getInvoice()
{
return $this->invoice;
}
/**
* @author MY
* @param Invoice $invoice
*/
public function setInvoice($invoice)
{
$this->invoice = $invoice;
}
/**
* @author MY
* @return SuccessfulPayment
*/
public function getSuccessfulPayment()
{
return $this->successfulPayment;
}
/**
* @author MY
* @param SuccessfulPayment $successfulPayment
*/
public function setSuccessfulPayment($successfulPayment)
{
$this->successfulPayment = $successfulPayment;
}
/**
* @return string
*/
public function getForwardSignature()
{
return $this->forwardSignature;
}
/**
* @param string $forwardSignature
*/
public function setForwardSignature($forwardSignature)
{
$this->forwardSignature = $forwardSignature;
}
/**
* @return string
*/
public function getAuthorSignature()
{
return $this->authorSignature;
}
/**
* @param string $authorSignature
*/
public function setAuthorSignature($authorSignature)
{
$this->authorSignature = $authorSignature;
}
/**
* @return ArrayOfMessageEntity
*/
public function getCaptionEntities()
{
return $this->captionEntities;
}
/**
* @param ArrayOfMessageEntity $captionEntities
*/
public function setCaptionEntities($captionEntities)
{
$this->captionEntities = $captionEntities;
}
/**
* @return string
*/
public function getConnectedWebsite()
{
return $this->connectedWebsite;
}
/**
* @param string $connectedWebsite
*/
public function setConnectedWebsite($connectedWebsite)
{
$this->connectedWebsite = $connectedWebsite;
}
}

View File

@ -0,0 +1,140 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 13/04/16
* Time: 04:10
*/
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\TypeInterface;
class MessageEntity extends BaseType implements TypeInterface
{
const TYPE_MENTION = 'mentin';
const TYPE_HASHTAG = 'hashtag';
const TYPE_BOT_COMMAND = 'bot_command';
const TYPE_URL = 'url';
const TYPE_EMAIL = 'email';
const TYPE_BOLD = 'bold';
const TYPE_ITALIC = 'italic';
const TYPE_CODE = 'code';
const TYPE_PRE = 'pre';
const TYPE_TEXT_LINK = 'text_link';
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['type', 'offset', 'length'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'type' => true,
'offset' => true,
'length' => true,
'url' => true,
];
/**
* Type of the entity.
* One of mention (@username), hashtag, bot_command, url, email, bold (bold text),
* italic (italic text), code (monowidth string),pre (monowidth block), text_link (for clickable text URLs)
*
* @var string
*/
protected $type;
/**
* Offset in UTF-16 code units to the start of the entity
*
* @var int
*/
protected $offset;
/**
* Length of the entity in UTF-16 code units
*
* @var int
*/
protected $length;
/**
* Optional. For “text_link” only, url that will be opened after user taps on the text
*
* @var string
*/
protected $url;
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @param string $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return int
*/
public function getOffset()
{
return $this->offset;
}
/**
* @param int $offset
*/
public function setOffset($offset)
{
$this->offset = $offset;
}
/**
* @return int
*/
public function getLength()
{
return $this->length;
}
/**
* @param int $length
*/
public function setLength($length)
{
$this->length = $length;
}
/**
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* @param string $url
*/
public function setUrl($url)
{
$this->url = $url;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace TelegramBot\Api\Types\Payments;
abstract class ArrayOfLabeledPrice
{
public static function fromResponse($data)
{
$arrayOfLabeledPrice = [];
foreach ($data as $labeledPrice) {
$arrayOfLabeledPrice[] = LabeledPrice::fromResponse($labeledPrice);
}
return $arrayOfLabeledPrice;
}
}

View File

@ -0,0 +1,155 @@
<?php
namespace TelegramBot\Api\Types\Payments;
use TelegramBot\Api\BaseType;
/**
* Class Invoice
* This object contains basic information about an invoice.
*
* @package TelegramBot\Api\Types\Payments
*/
class Invoice extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['title', 'description', 'start_parameter', 'currency', 'total_amount'];
/**
* @var array
*/
static protected $map = [
'title' => true,
'description' => true,
'start_parameter' => true,
'currency' => true,
'total_amount' => true,
];
/**
* Product name
*
* @var string
*/
protected $title;
/**
* Product description
*
* @var string
*/
protected $description;
/**
* Unique bot deep-linking parameter that can be used to generate this invoice
*
* @var string
*/
protected $startParameter;
/**
* Three-letter ISO 4217 currency code
*
* @var string
*/
protected $currency;
/**
* Total price in the smallest units of the currency
*
* @var integer
*/
protected $totalAmount;
/**
* @author MY
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @author MY
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @author MY
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @author MY
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @author MY
* @return string
*/
public function getStartParameter()
{
return $this->startParameter;
}
/**
* @author MY
* @param string $startParameter
*/
public function setStartParameter($startParameter)
{
$this->startParameter = $startParameter;
}
/**
* @author MY
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @author MY
* @param string $currency
*/
public function setCurrency($currency)
{
$this->currency = $currency;
}
/**
* @author MY
* @return int
*/
public function getTotalAmount()
{
return $this->totalAmount;
}
/**
* @author MY
* @param int $totalAmount
*/
public function setTotalAmount($totalAmount)
{
$this->totalAmount = $totalAmount;
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace TelegramBot\Api\Types\Payments;
use TelegramBot\Api\BaseType;
/**
* Class LabeledPrice
* This object represents a portion of the price for goods or services.
*
* @package TelegramBot\Api\Types\Payments
*/
class LabeledPrice extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['label', 'amount'];
/**
* @var array
*/
static protected $map = [
'label' => true,
'amount' => true
];
/**
* Portion label
*
* @var string
*/
protected $label;
/**
* Price of the product in the smallest units of the currency (integer, not float/double).
*
* @var int
*/
protected $amount;
/**
* @return string
*/
public function getLabel()
{
return $this->label;
}
/**
* @param string $label
*/
public function setLabel($label)
{
$this->label = $label;
}
/**
* @return int
*/
public function getAmount()
{
return $this->amount;
}
/**
* @param int $amount
*/
public function setAmount($amount)
{
$this->amount = $amount;
}
}

View File

@ -0,0 +1,129 @@
<?php
namespace TelegramBot\Api\Types\Payments;
use TelegramBot\Api\BaseType;
/**
* Class OrderInfo
* This object represents information about an order.
*
* @package TelegramBot\Api\Types\Payments
*/
class OrderInfo extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = [];
/**
* @var array
*/
static protected $map = [
'name' => true,
'phone_number' => true,
'email' => true,
'shipping_address' => ShippingAddress::class
];
/**
* Optional. User name
*
* @var string
*/
protected $name;
/**
* Optional. User's phone number
*
* @var string
*/
protected $phoneNumber;
/**
* Optional. User email
*
* @var string
*/
protected $email;
/**
* Optional. User shipping address
*
* @var ShippingAddress
*/
protected $shippingAddress;
/**
* @author MY
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @author MY
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @author MY
* @return string
*/
public function getPhoneNumber()
{
return $this->phoneNumber;
}
/**
* @author MY
* @param string $phoneNumber
*/
public function setPhoneNumber($phoneNumber)
{
$this->phoneNumber = $phoneNumber;
}
/**
* @author MY
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @author MY
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @author MY
* @return ShippingAddress
*/
public function getShippingAddress()
{
return $this->shippingAddress;
}
/**
* @author MY
* @param ShippingAddress $shippingAddress
*/
public function setShippingAddress($shippingAddress)
{
$this->shippingAddress = $shippingAddress;
}
}

View File

@ -0,0 +1,104 @@
<?php
namespace TelegramBot\Api\Types\Payments\Query;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Types\Payments\ArrayOfLabeledPrice;
/**
* Class AnswerPreCheckoutQuery
* Use this method to respond to such pre-checkout queries.
*
* @package TelegramBot\Api\Types\Payments\Query
*/
class AnswerPreCheckoutQuery extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['pre_checkout_query_id', 'ok'];
/**
* @var array
*/
static protected $map = [
'pre_checkout_query_id' => true,
'ok' => true,
'error_message' => true,
];
/**
* Unique identifier for the query to be answered
*
* @var string
*/
protected $preCheckoutQueryId;
/**
* Specify True if everything is alright
*
* @var bool
*/
protected $ok;
/**
* Error message in human readable form that explains the reason for failure to proceed with the checkout
*
* @var string
*/
protected $errorMessage;
/**
* @author MY
* @return true
*/
public function getOk()
{
return $this->ok;
}
/**
* @author MY
* @param true $ok
*/
public function setOk($ok)
{
$this->ok = $ok;
}
/**
* @author MY
* @return string
*/
public function getErrorMessage()
{
return $this->errorMessage;
}
/**
* @author MY
* @param string $errorMessage
*/
public function setErrorMessage($errorMessage)
{
$this->errorMessage = $errorMessage;
}
/**
* @author MY
* @return string
*/
public function getPreCheckoutQueryId()
{
return $this->preCheckoutQueryId;
}
/**
* @author MY
* @param string $preCheckoutQueryId
*/
public function setPreCheckoutQueryId($preCheckoutQueryId)
{
$this->preCheckoutQueryId = $preCheckoutQueryId;
}
}

View File

@ -0,0 +1,132 @@
<?php
namespace TelegramBot\Api\Types\Payments\Query;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Types\Payments\ArrayOfLabeledPrice;
/**
* Class AnswerShippingQuery
* If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
* the Bot API will send an Update with a shipping_query field to the bot
*
* @package TelegramBot\Api\Types\Payments\Query
*/
class AnswerShippingQuery extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['shipping_query_id', 'ok'];
/**
* @var array
*/
static protected $map = [
'shipping_query_id' => true,
'ok' => true,
'shipping_options' => ArrayOfLabeledPrice::class,
'error_message' => true,
];
/**
* Unique identifier for the query to be answered
*
* @var string
*/
protected $shippingQueryId;
/**
* Specify True if delivery to the specified address is possible and False if there are any problems
*
* @var true
*/
protected $ok;
/**
* Required if ok is True. A JSON-serialized array of available shipping options.
*
* @var array
*/
protected $shippingOptions;
/**
* Required if ok is False. Error message in human readable form that explains why it is impossible to complete
* the order
*
* @var string
*/
protected $errorMessage;
/**
* @author MY
* @return string
*/
public function getShippingQueryId()
{
return $this->shippingQueryId;
}
/**
* @author MY
* @param string $shippingQueryId
*/
public function setShippingQueryId($shippingQueryId)
{
$this->shippingQueryId = $shippingQueryId;
}
/**
* @author MY
* @return bool
*/
public function getOk()
{
return $this->ok;
}
/**
* @author MY
* @param true $ok
*/
public function setOk($ok)
{
$this->ok = $ok;
}
/**
* @author MY
* @return array
*/
public function getShippingOptions()
{
return $this->shippingOptions;
}
/**
* @author MY
* @param array $shippingOptions
*/
public function setShippingOptions($shippingOptions)
{
$this->shippingOptions = $shippingOptions;
}
/**
* @author MY
* @return string
*/
public function getErrorMessage()
{
return $this->errorMessage;
}
/**
* @author MY
* @param string $errorMessage
*/
public function setErrorMessage($errorMessage)
{
$this->errorMessage = $errorMessage;
}
}

View File

@ -0,0 +1,211 @@
<?php
namespace TelegramBot\Api\Types\Payments\Query;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Types\Payments\ArrayOfLabeledPrice;
use TelegramBot\Api\Types\Payments\OrderInfo;
use TelegramBot\Api\Types\Payments\ShippingAddress;
use TelegramBot\Api\Types\User;
/**
* Class PreCheckoutQuery
* This object contains information about an incoming pre-checkout query.
*
* @package TelegramBot\Api\Types\Payments\Query
*/
class PreCheckoutQuery extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['id', 'from', 'currency', 'total_amount', 'invoice_payload'];
/**
* @var array
*/
static protected $map = [
'id' => true,
'from' => User::class,
'currency' => true,
'total_amount' => true,
'invoice_payload' => true,
'shipping_option_id' => true,
'order_info' => OrderInfo::class
];
/**
* Unique query identifier
*
* @var string
*/
protected $id;
/**
* User who sent the query
*
* @var User
*/
protected $from;
/**
* Three-letter ISO 4217 currency code
*
* @var string
*/
protected $currency;
/**
* Total price in the smallest units of the currency
*
* @var integer
*/
protected $totalAmount;
/**
* Bot specified invoice payload
*
* @var string
*/
protected $invoicePayload;
/**
* Optional. Identifier of the shipping option chosen by the user
*
* @var string
*/
protected $shippingOptionId;
/**
* Optional. Order info provided by the user
*
* @var OrderInfo
*/
protected $orderInfo;
/**
* @author MY
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @author MY
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @author MY
* @return User
*/
public function getFrom()
{
return $this->from;
}
/**
* @author MY
* @param User $from
*/
public function setFrom($from)
{
$this->from = $from;
}
/**
* @author MY
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @author MY
* @param string $currency
*/
public function setCurrency($currency)
{
$this->currency = $currency;
}
/**
* @author MY
* @return int
*/
public function getTotalAmount()
{
return $this->totalAmount;
}
/**
* @author MY
* @param int $totalAmount
*/
public function setTotalAmount($totalAmount)
{
$this->totalAmount = $totalAmount;
}
/**
* @author MY
* @return mixed
*/
public function getInvoicePayload()
{
return $this->invoicePayload;
}
/**
* @author MY
* @param mixed $invoicePayload
*/
public function setInvoicePayload($invoicePayload)
{
$this->invoicePayload = $invoicePayload;
}
/**
* @author MY
* @return string
*/
public function getShippingOptionId()
{
return $this->shippingOptionId;
}
/**
* @author MY
* @param string $shippingOptionId
*/
public function setShippingOptionId($shippingOptionId)
{
$this->shippingOptionId = $shippingOptionId;
}
/**
* @author MY
* @return OrderInfo
*/
public function getOrderInfo()
{
return $this->orderInfo;
}
/**
* @author MY
* @param OrderInfo $orderInfo
*/
public function setOrderInfo($orderInfo)
{
$this->orderInfo = $orderInfo;
}
}

View File

@ -0,0 +1,134 @@
<?php
namespace TelegramBot\Api\Types\Payments\Query;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\Types\Payments\ArrayOfLabeledPrice;
use TelegramBot\Api\Types\Payments\ShippingAddress;
use TelegramBot\Api\Types\User;
/**
* Class ShippingQuery
* This object contains information about an incoming shipping query.
*
* @package TelegramBot\Api\Types\Payments\Query
*/
class ShippingQuery extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['id', 'from', 'invoice_payload', 'shipping_address'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'id' => true,
'from' => User::class,
'invoice_payload' => true,
'shipping_address' => ShippingAddress::class
];
/**
* Unique query identifier
*
* @var string
*/
protected $id;
/**
* User who sent the query
*
* @var User
*/
protected $from;
/**
* Bot specified invoice payload
*
* @var string
*/
protected $invoicePayload;
/**
* User specified shipping address
*
* @var ShippingAddress
*/
protected $shippingAddress;
/**
* @author MY
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @author MY
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @author MY
* @return User
*/
public function getFrom()
{
return $this->from;
}
/**
* @author MY
* @param User $from
*/
public function setFrom($from)
{
$this->from = $from;
}
/**
* @author MY
* @return string
*/
public function getInvoicePayload()
{
return $this->invoicePayload;
}
/**
* @author MY
* @param string $invoicePayload
*/
public function setInvoicePayload($invoicePayload)
{
$this->invoicePayload = $invoicePayload;
}
/**
* @author MY
* @return ShippingAddress
*/
public function getShippingAddress()
{
return $this->shippingAddress;
}
/**
* @author MY
* @param ShippingAddress $shippingAddress
*/
public function setShippingAddress($shippingAddress)
{
$this->shippingAddress = $shippingAddress;
}
}

View File

@ -0,0 +1,181 @@
<?php
namespace TelegramBot\Api\Types\Payments;
use TelegramBot\Api\BaseType;
/**
* Class ShippingAddress
* This object represents a shipping address.
*
* @package TelegramBot\Api\Types\Payments
*/
class ShippingAddress extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['country_code', 'state', 'city', 'street_line1', 'street_line2', 'post_code'];
/**
* @var array
*/
static protected $map = [
'country_code' => true,
'state' => true,
'city' => true,
'street_line1' => true,
'street_line2' => true,
'post_code' => true,
];
/**
* ISO 3166-1 alpha-2 country code
*
* @var string
*/
protected $countryCode;
/**
* State, if applicable
*
* @var string
*/
protected $state;
/**
* City
*
* @var string
*/
protected $city;
/**
* First line for the address
*
* @var string
*/
protected $streetLine1;
/**
* Second line for the address
*
* @var integer
*/
protected $streetLine2;
/**
* Address post code
*
* @var integer
*/
protected $postCode;
/**
* @author MY
* @return string
*/
public function getCountryCode()
{
return $this->countryCode;
}
/**
* @author MY
* @param string $countryCode
*/
public function setCountryCode($countryCode)
{
$this->countryCode = $countryCode;
}
/**
* @author MY
* @return string
*/
public function getState()
{
return $this->state;
}
/**
* @author MY
* @param string $state
*/
public function setState($state)
{
$this->state = $state;
}
/**
* @author MY
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* @author MY
* @param string $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @author MY
* @return string
*/
public function getStreetLine1()
{
return $this->streetLine1;
}
/**
* @author MY
* @param string $streetLine1
*/
public function setStreetLine1($streetLine1)
{
$this->streetLine1 = $streetLine1;
}
/**
* @author MY
* @return int
*/
public function getStreetLine2()
{
return $this->streetLine2;
}
/**
* @author MY
* @param int $streetLine2
*/
public function setStreetLine2($streetLine2)
{
$this->streetLine2 = $streetLine2;
}
/**
* @author MY
* @return int
*/
public function getPostCode()
{
return $this->postCode;
}
/**
* @author MY
* @param int $postCode
*/
public function setPostCode($postCode)
{
$this->postCode = $postCode;
}
}

View File

@ -0,0 +1,103 @@
<?php
namespace TelegramBot\Api\Types\Payments;
use TelegramBot\Api\BaseType;
/**
* Class ShippingOption
* This object represents one shipping option.
*
* @package TelegramBot\Api\Types\Payments
*/
class ShippingOption extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = ['id', 'title', 'prices'];
/**
* @var array
*/
static protected $map = [
'id' => true,
'title' => true,
'prices' => ArrayOfLabeledPrice::class
];
/**
* Shipping option identifier
*
* @var string
*/
protected $id;
/**
* Option title
*
* @var string
*/
protected $title;
/**
* List of price portions
*
* @var array
*/
protected $prices;
/**
* @author MY
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @author MY
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @author MY
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @author MY
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @author MY
* @return array
*/
public function getPrices()
{
return $this->prices;
}
/**
* @author MY
* @param array $prices
*/
public function setPrices($prices)
{
$this->prices = $prices;
}
}

View File

@ -0,0 +1,213 @@
<?php
namespace TelegramBot\Api\Types\Payments;
use TelegramBot\Api\BaseType;
/**
* Class SuccessfulPayment
* This object contains basic information about a successful payment.
*
* @package TelegramBot\Api\Types\Payments
*/
class SuccessfulPayment extends BaseType
{
/**
* @var array
*/
static protected $requiredParams = [
'currency',
'total_amount',
'invoice_payload',
'telegram_payment_charge_id',
'provider_payment_charge_id'
];
/**
* @var array
*/
static protected $map = [
'currency' => true,
'total_amount' => true,
'invoice_payload' => true,
'shipping_option_id' => true,
'order_info' => OrderInfo::class,
'telegram_payment_charge_id' => true,
'provider_payment_charge_id' => true
];
/**
* Three-letter ISO 4217 currency code
*
* @var string
*/
protected $currency;
/**
* Total price in the smallest units of the currency
*
* @var integer
*/
protected $totalAmount;
/**
* Bot specified invoice payload
*
* @var array
*/
protected $invoicePayload;
/**
* Optional. Identifier of the shipping option chosen by the user
*
* @var string
*/
protected $shippingOptionId;
/**
* Optional. Order info provided by the user
*
* @var OrderInfo
*/
protected $orderInfo;
/**
* Telegram payment identifier
*
* @var string
*/
protected $telegramPaymentChargeId;
/**
* Provider payment identifier
*
* @var string
*/
protected $providerPaymentChargeId;
/**
* @author MY
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @author MY
* @param string $currency
*/
public function setCurrency($currency)
{
$this->currency = $currency;
}
/**
* @author MY
* @return int
*/
public function getTotalAmount()
{
return $this->totalAmount;
}
/**
* @author MY
* @param int $totalAmount
*/
public function setTotalAmount($totalAmount)
{
$this->totalAmount = $totalAmount;
}
/**
* @author MY
* @return array
*/
public function getInvoicePayload()
{
return $this->invoicePayload;
}
/**
* @author MY
* @param array $invoicePayload
*/
public function setInvoicePayload($invoicePayload)
{
$this->invoicePayload = $invoicePayload;
}
/**
* @author MY
* @return string
*/
public function getShippingOptionId()
{
return $this->shippingOptionId;
}
/**
* @author MY
* @param string $shippingOptionId
*/
public function setShippingOptionId($shippingOptionId)
{
$this->shippingOptionId = $shippingOptionId;
}
/**
* @author MY
* @return string
*/
public function getTelegramPaymentChargeId()
{
return $this->telegramPaymentChargeId;
}
/**
* @author MY
* @param string $telegramPaymentChargeId
*/
public function setTelegramPaymentChargeId($telegramPaymentChargeId)
{
$this->telegramPaymentChargeId = $telegramPaymentChargeId;
}
/**
* @author MY
* @return mixed
*/
public function getProviderPaymentChargeId()
{
return $this->providerPaymentChargeId;
}
/**
* @author MY
* @param mixed $providerPaymentChargeId
*/
public function setProviderPaymentChargeId($providerPaymentChargeId)
{
$this->providerPaymentChargeId = $providerPaymentChargeId;
}
/**
* @author MY
* @return OrderInfo
*/
public function getOrderInfo()
{
return $this->orderInfo;
}
/**
* @author MY
* @param OrderInfo $orderInfo
*/
public function setOrderInfo($orderInfo)
{
$this->orderInfo = $orderInfo;
}
}

View File

@ -0,0 +1,145 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class PhotoSize
* This object represents one size of a photo or a file / sticker thumbnail.
*
* @package TelegramBot\Api\Types
*/
class PhotoSize extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['file_id', 'width', 'height'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'file_id' => true,
'width' => true,
'height' => true,
'file_size' => true,
];
/**
* Unique identifier for this file
*
* @var string
*/
protected $fileId;
/**
* Photo width
*
* @var int
*/
protected $width;
/**
* Photo height
*
* @var int
*/
protected $height;
/**
* Optional. File size
*
* @var int
*/
protected $fileSize;
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string $fileId
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return int
*/
public function getFileSize()
{
return $this->fileSize;
}
/**
* @param int $fileSize
*
* @throws InvalidArgumentException
*/
public function setFileSize($fileSize)
{
if (is_integer($fileSize)) {
$this->fileSize = $fileSize;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return int
*/
public function getHeight()
{
return $this->height;
}
/**
* @param int $height
*
* @throws InvalidArgumentException
*/
public function setHeight($height)
{
if (is_integer($height)) {
$this->height = $height;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return int
*/
public function getWidth()
{
return $this->width;
}
/**
* @param int $width
*
* @throws InvalidArgumentException
*/
public function setWidth($width)
{
if (is_integer($width)) {
$this->width = $width;
} else {
throw new InvalidArgumentException();
}
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
/**
* Class ReplyKeyboardHide
* Upon receiving a message with this object, Telegram clients will hide the current custom keyboard
* and display the default letter-keyboard. By default, custom keyboards are displayed
* until a new keyboard is sent by a bot. An exception is made for one-time keyboards
* that are hidden immediately after the user presses a button (see \TelegramBot\Api\Types\ReplyKeyboardMarkup).
*
* @package TelegramBot\Api\Types
*/
class ReplyKeyboardHide extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['hide_keyboard'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'hide_keyboard' => true,
'selective' => true
];
/**
* Requests clients to hide the custom keyboard
*
* @var bool
*/
protected $hideKeyboard;
/**
* Optional. Use this parameter if you want to show the keyboard to specific users only.
* Targets:
* 1) users that are @mentioned in the text of the Message object;
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
*
* @var bool
*/
protected $selective;
public function __construct($hideKeyboard = true, $selective = null)
{
$this->hideKeyboard = $hideKeyboard;
$this->selective = $selective;
}
/**
* @return boolean
*/
public function isHideKeyboard()
{
return $this->hideKeyboard;
}
/**
* @param boolean $hideKeyboard
*/
public function setHideKeyboard($hideKeyboard)
{
$this->hideKeyboard = $hideKeyboard;
}
/**
* @return boolean
*/
public function isSelective()
{
return $this->selective;
}
/**
* @param boolean $selective
*/
public function setSelective($selective)
{
$this->selective = $selective;
}
}

View File

@ -0,0 +1,139 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
/**
* Class ReplyKeyboardMarkup
* This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).
*
* @package TelegramBot\Api\Types
*/
class ReplyKeyboardMarkup extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['keyboard'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'keyboard' => true,
'one_time_keyboard' => true,
'resize_keyboard' => true,
'selective' => true
];
/**
* Array of button rows, each represented by an Array of Strings
* Array of Array of String
*
* @var array
*/
protected $keyboard;
/**
* Optional. Requests clients to resize the keyboard vertically for optimal fit
* (e.g., make the keyboard smaller if there are just two rows of buttons).
* Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
*
* @var bool
*/
protected $resizeKeyboard;
/**
* Optional. Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
*
* @var bool
*/
protected $oneTimeKeyboard;
/**
* Optional. Use this parameter if you want to show the keyboard to specific users only.
* Targets:
* 1) users that are @mentioned in the text of the Message object;
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
*
* @var bool
*/
protected $selective;
public function __construct($keyboard, $oneTimeKeyboard = null, $resizeKeyboard = null, $selective = null)
{
$this->keyboard = $keyboard;
$this->oneTimeKeyboard = $oneTimeKeyboard;
$this->resizeKeyboard = $resizeKeyboard;
$this->selective = $selective;
}
/**
* @return array
*/
public function getKeyboard()
{
return $this->keyboard;
}
/**
* @param array $keyboard
*/
public function setKeyboard($keyboard)
{
$this->keyboard = $keyboard;
}
/**
* @return boolean
*/
public function isOneTimeKeyboard()
{
return $this->oneTimeKeyboard;
}
/**
* @param boolean $oneTimeKeyboard
*/
public function setOneTimeKeyboard($oneTimeKeyboard)
{
$this->oneTimeKeyboard = $oneTimeKeyboard;
}
/**
* @return boolean
*/
public function isResizeKeyboard()
{
return $this->resizeKeyboard;
}
/**
* @param boolean $resizeKeyboard
*/
public function setResizeKeyboard($resizeKeyboard)
{
$this->resizeKeyboard = $resizeKeyboard;
}
/**
* @return boolean
*/
public function isSelective()
{
return $this->selective;
}
/**
* @param boolean $selective
*/
public function setSelective($selective)
{
$this->selective = $selective;
}
}

View File

@ -0,0 +1,88 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
/**
* Class ReplyKeyboardRemove
* Upon receiving a message with this object,
* Telegram clients will remove the current custom keyboard and display the default letter-keyboard.
*
* @package TelegramBot\Api\Types
*/
class ReplyKeyboardRemove extends BaseType
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['remove_keyboard'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'remove_keyboard' => true,
'selective' => true
];
/**
* Requests clients to remove the custom keyboard (user will not be able to summon this keyboard;
* if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)
*
* @var bool
*/
protected $removeKeyboard;
/**
* Optional. Use this parameter if you want to remove the keyboard for specific users only.
* Targets:
* 1) users that are @mentioned in the text of the Message object;
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
*
* @var bool
*/
protected $selective;
public function __construct($remove_keyboard = true, $selective = false)
{
$this->removeKeyboard = $remove_keyboard;
$this->selective = $selective;
}
/**
* @return bool
*/
public function getRemoveKeyboard()
{
return $this->removeKeyboard;
}
/**
* @param bool $remove_keyboard
*/
public function setRemoveKeyboard($remove_keyboard)
{
$this->removeKeyboard = $remove_keyboard;
}
/**
* @return bool
*/
public function getSelective()
{
return $this->selective;
}
/**
* @param bool $selective
*/
public function setSelective($selective)
{
$this->selective = $selective;
}
}

View File

@ -0,0 +1,169 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class Sticker
* This object represents a sticker.
*
* @package TelegramBot\Api\Types
*/
class Sticker extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['file_id', 'width', 'height'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'file_id' => true,
'width' => true,
'height' => true,
'thumb' => PhotoSize::class,
'file_size' => true,
];
/**
* Unique identifier for this file
*
* @var string
*/
protected $fileId;
/**
* Sticker width
*
* @var int
*/
protected $width;
/**
* Sticker height
*
* @var int
*/
protected $height;
/**
* Document thumbnail as defined by sender
*
* @var PhotoSize
*/
protected $thumb;
/**
* Optional. File size
*
* @var int
*/
protected $fileSize;
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string $fileId
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return int
*/
public function getFileSize()
{
return $this->fileSize;
}
/**
* @param int $fileSize
*
* @throws InvalidArgumentException
*/
public function setFileSize($fileSize)
{
if (is_integer($fileSize)) {
$this->fileSize = $fileSize;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return int
*/
public function getHeight()
{
return $this->height;
}
/**
* @param int $height
*
* @throws InvalidArgumentException
*/
public function setHeight($height)
{
if (is_integer($height)) {
$this->height = $height;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return PhotoSize
*/
public function getThumb()
{
return $this->thumb;
}
/**
* @param PhotoSize $thumb
*/
public function setThumb(PhotoSize $thumb)
{
$this->thumb = $thumb;
}
/**
* @return int
*/
public function getWidth()
{
return $this->width;
}
/**
* @param int $width
*
* @throws InvalidArgumentException
*/
public function setWidth($width)
{
if (is_integer($width)) {
$this->width = $width;
} else {
throw new InvalidArgumentException();
}
}
}

View File

@ -0,0 +1,282 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\TypeInterface;
use TelegramBot\Api\Types\Inline\ChosenInlineResult;
use TelegramBot\Api\Types\Inline\InlineQuery;
use TelegramBot\Api\Types\Payments\Query\PreCheckoutQuery;
use TelegramBot\Api\Types\Payments\Query\ShippingQuery;
/**
* Class Update
* This object represents an incoming update.
* Only one of the optional parameters can be present in any given update.
*
* @package TelegramBot\Api\Types
*/
class Update extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['update_id'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'update_id' => true,
'message' => Message::class,
'edited_message' => Message::class,
'channel_post' => Message::class,
'edited_channel_post' => Message::class,
'inline_query' => InlineQuery::class,
'chosen_inline_result' => ChosenInlineResult::class,
'callback_query' => CallbackQuery::class,
'shipping_query' => ShippingQuery::class,
'pre_checkout_query' => PreCheckoutQuery::class,
];
/**
* The updates unique identifier.
* Update identifiers start from a certain positive number and increase sequentially.
* This ID becomes especially handy if youre using Webhooks, since it allows you to ignore repeated updates or
* to restore the correct update sequence, should they get out of order.
*
* @var integer
*/
protected $updateId;
/**
* Optional. New incoming message of any kind — text, photo, sticker, etc.
*
* @var Message
*/
protected $message;
/**
* Optional. New version of a message that is known to the bot and was edited
*
* @var Message
*/
protected $editedMessage;
/**
* Optional. New incoming channel post of any kind — text, photo, sticker, etc.
*
* @var Message
*/
protected $channelPost;
/**
* Optional. New version of a channel post that is known to the bot and was edited
*
* @var Message
*/
protected $editedChannelPost;
/**
* Optional. New incoming inline query
*
* @var \TelegramBot\Api\Types\Inline\InlineQuery
*/
protected $inlineQuery;
/**
* Optional. The result of a inline query that was chosen by a user and sent to their chat partner
*
* @var \TelegramBot\Api\Types\Inline\ChosenInlineResult
*/
protected $chosenInlineResult;
/**
* Optional. New incoming callback query
*
* @var \TelegramBot\Api\Types\CallbackQuery
*/
protected $callbackQuery;
/**
* Optional. New incoming shipping query. Only for invoices with flexible price
*
* @var ShippingQuery
*/
protected $shippingQuery;
/**
* Optional. New incoming pre-checkout query. Contains full information about checkout
*
* @var PreCheckoutQuery
*/
protected $preCheckoutQuery;
/**
* @return int
*/
public function getUpdateId()
{
return $this->updateId;
}
/**
* @param int $updateId
*/
public function setUpdateId($updateId)
{
$this->updateId = $updateId;
}
/**
* @return Message
*/
public function getMessage()
{
return $this->message;
}
/**
* @param Message $message
*/
public function setMessage(Message $message)
{
$this->message = $message;
}
/**
* @return Message
*/
public function getEditedMessage()
{
return $this->editedMessage;
}
/**
* @param Message $editedMessage
*/
public function setEditedMessage($editedMessage)
{
$this->editedMessage = $editedMessage;
}
/**
* @return Message
*/
public function getChannelPost()
{
return $this->channelPost;
}
/**
* @param Message $channelPost
*/
public function setChannelPost($channelPost)
{
$this->channelPost = $channelPost;
}
/**
* @return Message
*/
public function getEditedChannelPost()
{
return $this->editedChannelPost;
}
/**
* @param Message $editedChannelPost
*/
public function setEditedChannelPost($editedChannelPost)
{
$this->editedChannelPost = $editedChannelPost;
}
/**
* @return InlineQuery
*/
public function getInlineQuery()
{
return $this->inlineQuery;
}
/**
* @param InlineQuery $inlineQuery
*/
public function setInlineQuery($inlineQuery)
{
$this->inlineQuery = $inlineQuery;
}
/**
* @return ChosenInlineResult
*/
public function getChosenInlineResult()
{
return $this->chosenInlineResult;
}
/**
* @param ChosenInlineResult $chosenInlineResult
*/
public function setChosenInlineResult($chosenInlineResult)
{
$this->chosenInlineResult = $chosenInlineResult;
}
/**
* @return CallbackQuery
*/
public function getCallbackQuery()
{
return $this->callbackQuery;
}
/**
* @param CallbackQuery $callbackQuery
*/
public function setCallbackQuery($callbackQuery)
{
$this->callbackQuery = $callbackQuery;
}
/**
* @author MY
* @return ShippingQuery
*/
public function getShippingQuery()
{
return $this->shippingQuery;
}
/**
* @author MY
* @param ShippingQuery $shippingQuery
*/
public function setShippingQuery($shippingQuery)
{
$this->shippingQuery = $shippingQuery;
}
/**
* @author MY
* @return PreCheckoutQuery
*/
public function getPreCheckoutQuery()
{
return $this->preCheckoutQuery;
}
/**
* @author MY
* @param PreCheckoutQuery $preCheckoutQuery
*/
public function setPreCheckoutQuery($preCheckoutQuery)
{
$this->preCheckoutQuery = $preCheckoutQuery;
}
}

View File

@ -0,0 +1,181 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class User
* This object represents a Telegram user or bot.
*
* @package TelegramBot\Api\Types
*/
class User extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['id', 'first_name'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'id' => true,
'first_name' => true,
'last_name' => true,
'username' => true,
'language_code' => true,
'is_bot' => true
];
/**
* Unique identifier for this user or bot
*
* @var int
*/
protected $id;
/**
* Users or bots first name
*
* @var string
*/
protected $firstName;
/**
* Optional. Users or bots last name
*
* @var string
*/
protected $lastName;
/**
* Optional. Users or bots username
*
* @var string
*/
protected $username;
/**
* Optional. IETF language tag of the user's language
*
* @var string
*/
protected $languageCode;
/**
* True, if this user is a bot
*
* @var bool
*/
protected $isBot;
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*
* @throws InvalidArgumentException
*/
public function setId($id)
{
if (is_integer($id) || is_float($id)) {
$this->id = $id;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* @param string $username
*/
public function setUsername($username)
{
$this->username = $username;
}
/**
* @return string
*/
public function getLanguageCode()
{
return $this->languageCode;
}
/**
* @param string $languageCode
*/
public function setLanguageCode($languageCode)
{
$this->languageCode = $languageCode;
}
/**
* @return bool
*/
public function isBot()
{
return $this->isBot;
}
/**
* @param bool $isBot
*/
public function setIsBot($isBot)
{
$this->isBot = $isBot;
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class UserProfilePhotos
* This object represent a user's profile pictures.
*
* @package TelegramBot\Api\Types
*/
class UserProfilePhotos extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['total_count', 'photos'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'total_count' => true,
'photos' => ArrayOfArrayOfPhotoSize::class,
];
/**
* Total number of profile pictures the target user has
*
* @var Integer
*/
protected $totalCount;
/**
* Requested profile pictures (in up to 4 sizes each).
* Array of Array of \TelegramBot\Api\Types\PhotoSize
*
* @var array
*/
protected $photos;
/**
* @return array
*/
public function getPhotos()
{
return $this->photos;
}
/**
* @param array $photos
*/
public function setPhotos($photos)
{
$this->photos = $photos;
}
/**
* @return int
*/
public function getTotalCount()
{
return $this->totalCount;
}
/**
* @param int $totalCount
*
* @throws InvalidArgumentException
*/
public function setTotalCount($totalCount)
{
if (is_integer($totalCount)) {
$this->totalCount = $totalCount;
} else {
throw new InvalidArgumentException();
}
}
}

View File

@ -0,0 +1,132 @@
<?php
/**
* Created by PhpStorm.
* User: iGusev
* Date: 13/04/16
* Time: 13:55
*/
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\TypeInterface;
/**
* Class Venue
* This object represents a venue
*
* @package TelegramBot\Api\Types
*/
class Venue extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['location', 'title', 'address'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'location' => Location::class,
'title' => true,
'address' => true,
'foursquare_id' => true,
];
/**
* Venue location
*
* @var Location
*/
protected $location;
/**
* Name of the venue
*
* @var string
*/
protected $title;
/**
* Address of the venue
*
* @var string
*/
protected $address;
/**
* Optional. Foursquare identifier of the venue
*
* @var string
*/
protected $foursquareId;
/**
* @return Location
*/
public function getLocation()
{
return $this->location;
}
/**
* @param Location $location
*/
public function setLocation($location)
{
$this->location = $location;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* @param string $address
*/
public function setAddress($address)
{
$this->address = $address;
}
/**
* @return string
*/
public function getFoursquareId()
{
return $this->foursquareId;
}
/**
* @param string $foursquareId
*/
public function setFoursquareId($foursquareId)
{
$this->foursquareId = $foursquareId;
}
}

View File

@ -0,0 +1,224 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class Video
* This object represents a video file.
*
* @package TelegramBot\Api\Types
*/
class Video extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['file_id', 'width', 'height', 'duration'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'file_id' => true,
'width' => true,
'height' => true,
'duration' => true,
'thumb' => PhotoSize::class,
'mime_type' => true,
'file_size' => true
];
/**
* Unique identifier for this file
*
* @var string
*/
protected $fileId;
/**
* Video width as defined by sender
*
* @var int
*/
protected $width;
/**
* Video height as defined by sender
*
* @var int
*/
protected $height;
/**
* Duration of the video in seconds as defined by sender
*
* @var int
*/
protected $duration;
/**
* Video thumbnail
*
* @var PhotoSize
*/
protected $thumb;
/**
* Optional. Mime type of a file as defined by sender
*
* @var string
*/
protected $mimeType;
/**
* Optional. File size
*
* @var int
*/
protected $fileSize;
/**
* @return int
*/
public function getDuration()
{
return $this->duration;
}
/**
* @param int $duration
*
* @throws InvalidArgumentException
*/
public function setDuration($duration)
{
if (is_integer($duration)) {
$this->duration = $duration;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string $fileId
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return int
*/
public function getFileSize()
{
return $this->fileSize;
}
/**
* @param int $fileSize
*
* @throws InvalidArgumentException
*/
public function setFileSize($fileSize)
{
if (is_integer($fileSize)) {
$this->fileSize = $fileSize;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return int
*/
public function getHeight()
{
return $this->height;
}
/**
* @param int $height
*
* @throws InvalidArgumentException
*/
public function setHeight($height)
{
if (is_integer($height)) {
$this->height = $height;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* @param string $mimeType
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return PhotoSize
*/
public function getThumb()
{
return $this->thumb;
}
/**
* @param PhotoSize $thumb
*/
public function setThumb(PhotoSize $thumb)
{
$this->thumb = $thumb;
}
/**
* @return int
*/
public function getWidth()
{
return $this->width;
}
/**
* @param int $width
*
* @throws InvalidArgumentException
*/
public function setWidth($width)
{
if (is_integer($width)) {
$this->width = $width;
} else {
throw new InvalidArgumentException();
}
}
}

View File

@ -0,0 +1,139 @@
<?php
namespace TelegramBot\Api\Types;
use TelegramBot\Api\BaseType;
use TelegramBot\Api\InvalidArgumentException;
use TelegramBot\Api\TypeInterface;
/**
* Class Voice
* This object represents a voice note.
*
* @package TelegramBot\Api\Types
*/
class Voice extends BaseType implements TypeInterface
{
/**
* {@inheritdoc}
*
* @var array
*/
static protected $requiredParams = ['file_id', 'duration'];
/**
* {@inheritdoc}
*
* @var array
*/
static protected $map = [
'file_id' => true,
'duration' => true,
'mime_type' => true,
'file_size' => true
];
/**
* Unique identifier for this file
*
* @var string
*/
protected $fileId;
/**
* Duration of the audio in seconds as defined by sender
*
* @var int
*/
protected $duration;
/**
* Optional. MIME type of the file as defined by sender
*
* @var string
*/
protected $mimeType;
/**
* Optional. File size
*
* @var int
*/
protected $fileSize;
/**
* @return string
*/
public function getFileId()
{
return $this->fileId;
}
/**
* @param string $fileId
*/
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
/**
* @return int
*/
public function getDuration()
{
return $this->duration;
}
/**
* @param int $duration
*
* @throws InvalidArgumentException
*/
public function setDuration($duration)
{
if (is_integer($duration)) {
$this->duration = $duration;
} else {
throw new InvalidArgumentException();
}
}
/**
* @return string
*/
public function getMimeType()
{
return $this->mimeType;
}
/**
* @param string $mimeType
*/
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return int
*/
public function getFileSize()
{
return $this->fileSize;
}
/**
* @param int $fileSize
*
* @throws InvalidArgumentException
*/
public function setFileSize($fileSize)
{
if (is_integer($fileSize)) {
$this->fileSize = $fileSize;
} else {
throw new InvalidArgumentException();
}
}
}