Skip to content

Commit

Permalink
Merge pull request #36 from tg-bot-api/feature/35-bot-api-4-9
Browse files Browse the repository at this point in the history
Feature #35 bot api 4.9
  • Loading branch information
greenplugin authored Jun 5, 2020
2 parents 065c8eb + 56de709 commit 831c125
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 18 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
- Nothing
--->

## 1.6.0 - 2020-06-06

#### June 4, 2020
#### Bot API 4.9

### Added
- Added the new field `viaBot` to the `MessageType` class.
You can now know which bot was used to send a message.
- Supported video thumbnails for inline GIF and MPEG4 animations (Updated comments in classes).
- Supported the new basketball animation for the random dice.
Choose between different animations (dice, darts, basketball)
by specifying the emoji parameter in the `SendDiceMethod`.
Added to the class new factory method `SendDiceMethod::createWithBasketball`
and new constant `SendDiceMethod::EMOJI_BASKETBALL`.

## 1.5.1 - 2020-05-28

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[![Duplicated Lines (%)][sonar-duplicated-lines-icon]][sonar-path]
[![Security Rating][sonar-security-rating-icon]][sonar-path]

#### Supported Telegram Bot API v4.8 (April 24, 2020)
#### Supported Telegram Bot API v4.9 (June 4, 2020)

## Installation

Expand Down Expand Up @@ -146,7 +146,7 @@ If you discover any security related issues, please email [email protected] inst
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

[ico-php-v]: https://img.shields.io/travis/php-v/tg-bot-api/bot-api-base.svg?style=flat-square
[ico-bot-api]: https://img.shields.io/badge/Bot%20API-4.8-blue.svg?style=flat-square
[ico-bot-api]: https://img.shields.io/badge/Bot%20API-4.9-blue.svg?style=flat-square
[ico-version]: https://img.shields.io/packagist/v/tg-bot-api/bot-api-base.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/tg-bot-api/bot-api-base/master.svg?style=flat-square
Expand Down
14 changes: 14 additions & 0 deletions src/Method/SendDiceMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SendDiceMethod implements SendMethodAliasInterface

public const EMOJI_DICE = '🎲';
public const EMOJI_DARTS = '🎯';
public const EMOJI_BASKETBALL = '🏀';

/**
* Emoji on which the dice throw animation is based. Currently, must be one of “🎲” or “🎯”. Defauts to “🎲”.
Expand Down Expand Up @@ -77,4 +78,17 @@ public static function createWithDarts($chatId, array $data = null): SendDiceMet

return $instance;
}

/**
* @param $chatId
*
* @throws BadArgumentException
*/
public static function createWithBasketball($chatId, array $data = null): SendDiceMethod
{
$instance = static::create($chatId, $data);
$instance->emoji = self::EMOJI_BASKETBALL;

return $instance;
}
}
9 changes: 1 addition & 8 deletions src/Type/InlineQueryResult/InlineQueryResultGifType.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class InlineQueryResultGifType extends InlineQueryResultType implements HasParse
public $gifDuration;

/**
* URL of the static thumbnail for the result (jpeg or gif).
* URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
*
* @var string
*/
Expand Down Expand Up @@ -82,14 +82,7 @@ class InlineQueryResultGifType extends InlineQueryResultType implements HasParse
public $inputMessageContent;

/**
* @param string $id
* @param string $gifUrl
* @param string $thumbUrl
* @param array|null $data
*
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
*
* @return InlineQueryResultGifType
*/
public static function create(
string $id,
Expand Down
9 changes: 1 addition & 8 deletions src/Type/InlineQueryResult/InlineQueryResultMpeg4GifType.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class InlineQueryResultMpeg4GifType extends InlineQueryResultType implements Has
public $mpeg4Duration;

/**
* URL of the static thumbnail (jpeg or gif) for the result.
* URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
*
* @var string
*/
Expand Down Expand Up @@ -82,14 +82,7 @@ class InlineQueryResultMpeg4GifType extends InlineQueryResultType implements Has
public $inputMessageContent;

/**
* @param string $id
* @param string $mpeg4Url
* @param string $thumbUrl
* @param array|null $data
*
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException
*
* @return InlineQueryResultMpeg4GifType
*/
public static function create(
string $id,
Expand Down
7 changes: 7 additions & 0 deletions src/Type/MessageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ class MessageType implements HasParseModeVariableInterface
*/
public $replyToMessage;

/**
* Optional. Bot through which the message was sent.
*
* @var UserType|null
*/
public $viaBot;

/**
* Optional. Date the message was last edited in \DateTimeImmutable.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/Method/SendDiceMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ public function dataProvider(): array
]
),
],
[
$this->getApi(SendDiceMethod::EMOJI_BASKETBALL),
SendDiceMethod::createWithBasketball(
'chat_id',
[
'disableNotification' => true,
'replyToMessageId' => 1,
'replyMarkup' => $this->buildInlineMarkupObject(),
]
),
],
];
}

Expand Down

0 comments on commit 831c125

Please sign in to comment.