diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a9e5e..87fed00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/TgBotLib/Bot.php b/src/TgBotLib/Bot.php index 198319c..a0d9ec2 100644 --- a/src/TgBotLib/Bot.php +++ b/src/TgBotLib/Bot.php @@ -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. diff --git a/src/TgBotLib/Objects/Telegram/BotShortDescription.php b/src/TgBotLib/Objects/Telegram/BotShortDescription.php new file mode 100644 index 0000000..800cd10 --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/BotShortDescription.php @@ -0,0 +1,52 @@ +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; + } + } \ No newline at end of file