Added object \TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultAudio
, see [InlineQueryResultAudio](https://core.telegram.org/bots/api#inlinequeryresultaudio) for more information.
https://git.n64.cc/nosial/libs/tgbot/-/issues/3
This commit is contained in:
parent
41c1d0fc4c
commit
b1db812097
2 changed files with 234 additions and 0 deletions
|
@ -24,6 +24,7 @@ input objects for methods that require input objects.
|
|||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultMpeg4Gif`, see [InlineQueryResultMpeg4Gif](https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif) for more information.
|
||||
* Added field `via_chat_folder_invite_link` to `\TgBotLib\Objects\Telegram\ChatMemberUpdated` to represent the invite link, which was used by the user to join the chat; for joining by invite link events only.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultVideo`, see [InlineQueryResultVideo](https://core.telegram.org/bots/api#inlinequeryresultvideo) for more information.
|
||||
* Added object `\TgBotLib\Objects\Telegram\InlineQueryResult\InlineQueryResultAudio`, see [InlineQueryResultAudio](https://core.telegram.org/bots/api#inlinequeryresultaudio) for more information.
|
||||
|
||||
### Changed
|
||||
* Refactored InputMessageContent types to its own namespace so InputMessageContent can always return the correct InputMessageContent object type when calling `fromArray()`
|
||||
|
|
|
@ -0,0 +1,233 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\Telegram\InlineQueryResult;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Telegram\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputContactMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\Telegram\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\Telegram\MessageEntity;
|
||||
|
||||
class InlineQueryResultAudio implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $audio_url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $title;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $parse_mode;
|
||||
|
||||
/**
|
||||
* @var MessageEntity[]|null
|
||||
*/
|
||||
private $caption_entities;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $performer;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $audio_duration;
|
||||
|
||||
/**
|
||||
* @var InlineKeyboardMarkup|null
|
||||
*/
|
||||
private $reply_markup;
|
||||
|
||||
/**
|
||||
* @var InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
private $input_message_content;
|
||||
|
||||
/**
|
||||
* Type of the result, must be audio
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier for this result, 1-64 bytes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A valid URL for the audio file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAudioUrl(): string
|
||||
{
|
||||
return $this->audio_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Caption, 0-1024 characters after entities parsing
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCaption(): ?string
|
||||
{
|
||||
return $this->caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Mode for parsing entities in the audio caption. See formatting options for more details.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getParseMode(): ?string
|
||||
{
|
||||
return $this->parse_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode
|
||||
*
|
||||
* @return MessageEntity[]|null
|
||||
*/
|
||||
public function getCaptionEntities(): ?array
|
||||
{
|
||||
return $this->caption_entities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Performer
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPerformer(): ?string
|
||||
{
|
||||
return $this->performer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Audio duration in seconds
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getAudioDuration(): ?int
|
||||
{
|
||||
return $this->audio_duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Inline keyboard attached to the message
|
||||
*
|
||||
* @return InlineKeyboardMarkup|null
|
||||
*/
|
||||
public function getReplyMarkup(): ?InlineKeyboardMarkup
|
||||
{
|
||||
return $this->reply_markup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Content of the message to be sent instead of the audio
|
||||
*
|
||||
* @return InputContactMessageContent|InputInvoiceMessageContent|InputLocationMessageContent|InputTextMessageContent|InputVenueMessageContent|null
|
||||
*/
|
||||
public function getInputMessageContent(): InputVenueMessageContent|InputTextMessageContent|InputContactMessageContent|InputLocationMessageContent|InputInvoiceMessageContent|null
|
||||
{
|
||||
return $this->input_message_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'id' => $this->id,
|
||||
'audio_url' => $this->audio_url,
|
||||
'title' => $this->title,
|
||||
'caption' => $this->caption,
|
||||
'parse_mode' => $this->parse_mode,
|
||||
'caption_entities' => ($this->caption_entities) ? array_map(function (MessageEntity $messageEntity) {
|
||||
return $messageEntity->toArray();
|
||||
}, $this->caption_entities) : null,
|
||||
'performer' => $this->performer,
|
||||
'audio_duration' => $this->audio_duration,
|
||||
'reply_markup' => ($this->reply_markup) ? $this->reply_markup->toArray() : null,
|
||||
'input_message_content' => $this->input_message_content,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return ObjectTypeInterface
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->type = $data['type'] ?? null;
|
||||
$object->id = $data['id'] ?? null;
|
||||
$object->audio_url = $data['audio_url'] ?? null;
|
||||
$object->title = $data['title'] ?? null;
|
||||
$object->caption = $data['caption'] ?? null;
|
||||
$object->parse_mode = $data['parse_mode'] ?? null;
|
||||
$object->caption_entities = ($data['caption_entities']) ? array_map(function (array $messageEntity) {
|
||||
return MessageEntity::fromArray($messageEntity);
|
||||
}, $data['caption_entities']) : null;
|
||||
$object->performer = $data['performer'] ?? null;
|
||||
$object->audio_duration = $data['audio_duration'] ?? null;
|
||||
$object->reply_markup = ($data['reply_markup']) ? InlineKeyboardMarkup::fromArray($data['reply_markup']) : null;
|
||||
$object->input_message_content = $data['input_message_content'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue