Added the ability to get the current bot description in the given language as the class [BotDescription](https://core.telegram.org/bots/api#botdescription) using the method \TgBotLib\Bot > getMyDescription()
This commit is contained in:
parent
7252854c44
commit
ccd910938b
3 changed files with 72 additions and 0 deletions
|
@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
* Added the ability to set different bot descriptions for different user languages using the method `\TgBotLib\Bot > setMyDescription()`
|
||||
* Added the ability to get the current bot description in the given language as the class [BotDescription](https://core.telegram.org/bots/api#botdescription)
|
||||
using the method `\TgBotLib\Bot > getMyDescription()`
|
||||
|
||||
### Changed
|
||||
* Removed unused `__destruct()` method from `\TgBotLib\Bot`
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
use TgBotLib\Interfaces\EventInterface;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Telegram\BotCommandScope;
|
||||
use TgBotLib\Objects\Telegram\BotDescription;
|
||||
use TgBotLib\Objects\Telegram\Chat;
|
||||
use TgBotLib\Objects\Telegram\ChatAdministratorRights;
|
||||
use TgBotLib\Objects\Telegram\ChatInviteLink;
|
||||
|
@ -2156,6 +2157,22 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to get the current bot description for the given user language.
|
||||
* Returns BotDescription on success.
|
||||
*
|
||||
* @param string|null $language_code
|
||||
* @param array $options
|
||||
* @return BotDescription
|
||||
* @throws TelegramException
|
||||
*/
|
||||
public function getMyDescription(?string $language_code=null, array $options=[]): BotDescription
|
||||
{
|
||||
return BotDescription::fromArray($this->sendRequest('getMyDescription', 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.
|
||||
|
|
53
src/TgBotLib/Objects/Telegram/BotDescription.php
Normal file
53
src/TgBotLib/Objects/Telegram/BotDescription.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace TgBotLib\Objects\Telegram;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class BotDescription implements ObjectTypeInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* The bot's short description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'description' => $this->description,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $data
|
||||
* @return BotDescription
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->description = $data['description'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue