Added object \TgBotLib\Objects\Telegram > InputTextMessageContent to represent the content of a text message to be sent as the result of an inline query.

This commit is contained in:
Netkas 2023-04-23 14:42:51 -04:00
parent 18a3c7ef6f
commit ed41bcea2f
3 changed files with 132 additions and 1 deletions

3
.idea/php.xml generated
View file

@ -9,12 +9,13 @@
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PhpAnalysisConfiguration" call_tree_analysis_depth="3" />
<component name="PhpIncludePathManager">
<include_path>
<path value="/usr/share/php" />
<path value="/etc/ncc" />
<path value="/var/ncc/packages/net.nosial.tamerlib=1.0.0" />
<path value="/var/ncc/packages/net.nosial.loglib=1.0.2" />
<path value="/var/ncc/packages/net.nosial.loglib=1.0.1" />
<path value="/var/ncc/packages/net.nosial.tempfile=1.1.0" />
</include_path>
</component>

View file

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This update accompanies the release of the [Telegram Bot API 6.7](https://core.telegram.org/bots/api#april-21-2023).
### Added
* Added object `\TgBotLib\Objects\Telegram > InputTextMessageContent` to represent the content of a text message to be sent as the result of an inline query.
## [6.6.0] - 2023-04-10

View file

@ -0,0 +1,127 @@
<?php
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram;
use TgBotLib\Interfaces\ObjectTypeInterface;
class InputTextMessageContent implements ObjectTypeInterface
{
/**
* @var string
*/
private $message_text;
/**
* @var string|null
*/
private $parse_mode;
/**
* @var MessageEntity[]|null
*/
private $entities;
/**
* @var bool
*/
private $disable_web_page_preview;
/**
* Text of the message to be sent, 1-4096 characters
*
* @return string
*/
public function getMessageText(): string
{
return $this->message_text;
}
/**
* Optional. Mode for parsing entities in the message text.
*
* @see https://core.telegram.org/bots/api#formatting-options
* @return string|null
*/
public function getParseMode(): ?string
{
return $this->parse_mode;
}
/**
* Optional. List of special entities that appear in message text, which can be specified instead of parse_mode
*
* @return MessageEntity[]|null
*/
public function getEntities(): ?array
{
return $this->entities;
}
/**
* Optional. Disables link previews for links in the sent message
*
* @return bool
*/
public function isDisableWebPagePreview(): bool
{
return $this->disable_web_page_preview;
}
/**
* Returns an array representation of the object
*
* @return array
*/
public function toArray(): array
{
$message_entities = null;
if($this->entities !== null)
{
/** @var MessageEntity $entity */
foreach($this->entities as $entity)
{
if($entity instanceof MessageEntity)
{
$message_entities[] = $entity->toArray();
}
}
}
return [
'message_text' => $this->message_text,
'parse_mode' => $this->parse_mode,
'entities' => $message_entities,
'disable_web_page_preview' => $this->disable_web_page_preview,
];
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return ObjectTypeInterface
*/
public static function fromArray(array $data): ObjectTypeInterface
{
$object = new self();
$object->message_text = $data['message_text'] ?? null;
$object->parse_mode = $data['parse_mode'] ?? null;
$object->disable_web_page_preview = (bool)$data['disable_web_page_preview'] ?? false;
if(isset($data['entities']))
{
foreach($data['entities'] as $entity)
{
$object->entities[] = MessageEntity::fromArray($entity);
}
}
return $object;
}
}