Added the ability to get the current bot short description in the given language as the class [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription) using the method \TgBotLib\Bot > getMyShortDescription() see [getMyShortDescription](https://core.telegram.org/bots/api#getmyshortdescription) for more information.

This commit is contained in:
Netkas 2023-04-06 13:47:53 -04:00
parent 5c1bb7c936
commit 38012104ae
3 changed files with 73 additions and 0 deletions

View file

@ -16,6 +16,8 @@ This update accompanies the release of the [Telegram Bot API 6.6](https://core.t
using the method `\TgBotLib\Bot > getMyDescription()` see [getMyDescription](https://core.telegram.org/bots/api#getmydescription) for more information.
* Added the ability to set different bot short descriptions for different user languages using the method `\TgBotLib\Bot > setMyShortDescription()`
see [setMyShortDescription](https://core.telegram.org/bots/api#setmyshortdescription) for more information.
* Added the ability to get the current bot short description in the given language as the class [BotShortDescription](https://core.telegram.org/bots/api#botshortdescription)
using the method `\TgBotLib\Bot > getMyShortDescription()` see [getMyShortDescription](https://core.telegram.org/bots/api#getmyshortdescription) for more information.
### Changed
* Removed unused `__destruct()` method from `\TgBotLib\Bot`

View file

@ -17,6 +17,7 @@
use TgBotLib\Interfaces\ObjectTypeInterface;
use TgBotLib\Objects\Telegram\BotCommandScope;
use TgBotLib\Objects\Telegram\BotDescription;
use TgBotLib\Objects\Telegram\BotShortDescription;
use TgBotLib\Objects\Telegram\Chat;
use TgBotLib\Objects\Telegram\ChatAdministratorRights;
use TgBotLib\Objects\Telegram\ChatInviteLink;
@ -2197,6 +2198,24 @@
return true;
}
/**
* Use this method to get the current bot short description for the given user language.
* Returns BotShortDescription on success.
*
* @param string|null $language_code A two-letter ISO 639-1 language code or an empty string
* @param array $options Optional parameters
* @return BotShortDescription
* @throws TelegramException
* @link https://core.telegram.org/bots/api#getmyshortdescription
* @noinspection PhpUnused
*/
public function getMyShortDescription(?string $language_code=null, array $options=[]): BotShortDescription
{
return BotShortDescription::fromArray($this->sendRequest('getMyShortDescription', array_merge([
'language_code' => $language_code
], $options)));
}
/**
* Use this method to change the bot's menu button in a private chat, or the default menu button.
* Returns True on success.

View file

@ -0,0 +1,52 @@
<?php
/** @noinspection PhpMissingFieldTypeInspection */
namespace TgBotLib\Objects\Telegram;
use TgBotLib\Interfaces\ObjectTypeInterface;
class BotShortDescription implements ObjectTypeInterface
{
/**
* @var string
*/
private $short_description;
/**
* The bot's short description
*
* @return string
*/
public function getShortDescription(): string
{
return $this->short_description;
}
/**
* Returns an array representation of the object
*
* @return array
*/
public function toArray(): array
{
return [
'short_description' => $this->short_description,
];
}
/**
* Constructs object from an array representation
*
* @param array $data
* @return BotShortDescription
*/
public static function fromArray(array $data): self
{
$object = new self();
$object->short_description = $data['short_description'];
return $object;
}
}