Skip to content

Commit

Permalink
Bot API 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
luzrain committed May 5, 2024
1 parent e61bca3 commit 0d800dd
Show file tree
Hide file tree
Showing 51 changed files with 691 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PHP Wrapper for Telegram Bot API

[![Bot Api 7.1](https://img.shields.io/badge/Bot%20API-7.1-0088cc.svg?style=flat)](https://core.telegram.org/bots/api-changelog#february-16-2024)
[![Bot Api 7.2](https://img.shields.io/badge/Bot%20API-7.2-0088cc.svg?style=flat)](https://core.telegram.org/bots/api-changelog#march-31-2024)
[![PHP >=8.2](https://img.shields.io/badge/PHP->=8.2-777bb3.svg?style=flat)](https://www.php.net/releases/8.2/en.php)
[![Tests Status](https://img.shields.io/github/actions/workflow/status/luzrain/telegram-bot-api/tests.yaml?branch=master)](../../actions/workflows/tests.yaml)

Expand Down
21 changes: 21 additions & 0 deletions src/Event/BusinessConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Event;

use Luzrain\TelegramBotApi\Event;
use Luzrain\TelegramBotApi\Type;

final class BusinessConnection extends Event
{
public function executeChecker(Type\Update $update): bool
{
return $update->businessConnection !== null;
}

public function executeCallback(Type\Update $update): mixed
{
return $this->callback($update->businessConnection);
}
}
21 changes: 21 additions & 0 deletions src/Event/BusinessMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Event;

use Luzrain\TelegramBotApi\Event;
use Luzrain\TelegramBotApi\Type;

final class BusinessMessage extends Event
{
public function executeChecker(Type\Update $update): bool
{
return $update->businessMessage !== null;
}

public function executeCallback(Type\Update $update): mixed
{
return $this->callback($update->businessMessage);
}
}
21 changes: 21 additions & 0 deletions src/Event/DeletedBusinessMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Event;

use Luzrain\TelegramBotApi\Event;
use Luzrain\TelegramBotApi\Type;

final class DeletedBusinessMessage extends Event
{
public function executeChecker(Type\Update $update): bool
{
return $update->deletedBusinessMessages !== null;
}

public function executeCallback(Type\Update $update): mixed
{
return $this->callback($update->deletedBusinessMessages);
}
}
21 changes: 21 additions & 0 deletions src/Event/EditedBusinessMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Event;

use Luzrain\TelegramBotApi\Event;
use Luzrain\TelegramBotApi\Type;

final class EditedBusinessMessage extends Event
{
public function executeChecker(Type\Update $update): bool
{
return $update->editedBusinessMessage !== null;
}

public function executeCallback(Type\Update $update): mixed
{
return $this->callback($update->editedBusinessMessage);
}
}
2 changes: 1 addition & 1 deletion src/Method/AnswerInlineQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
/**
* A JSON-serialized array of results for the inline query
*
* @var InlineQueryResult[]
* @var list<InlineQueryResult>
*/
protected array $results,

Expand Down
4 changes: 2 additions & 2 deletions src/Method/CreateInvoiceLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(
/**
* Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
*
* @var LabeledPrice[]
* @var list<LabeledPrice>
*/
protected array $prices,

Expand All @@ -66,7 +66,7 @@ public function __construct(
* At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive,
* passed in a strictly increased order and must not exceed max_tip_amount.
*
* @var int[]|null
* @var list<int>|null
*/
protected array|null $suggestedTipAmounts = null,

Expand Down
7 changes: 1 addition & 6 deletions src/Method/CreateNewStickerSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,10 @@ public function __construct(
/**
* A JSON-serialized list of 1-50 initial stickers to be added to the sticker set
*
* @var InputSticker[]
* @var list<InputSticker>
*/
protected array $stickers,

/**
* Format of stickers in the set, must be one of "static", "animated", "video"
*/
protected string $stickerFormat,

/**
* Type of stickers in the set, pass "regular", "mask", or "custom_emoji". By default, a regular sticker set is created.
*/
Expand Down
28 changes: 28 additions & 0 deletions src/Method/GetBusinessConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Method;

use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type\BusinessConnection;

/**
* Use this method to get information about the connection of the bot with a business account.
* Returns a BusinessConnection object on success.
*
* @extends Method<BusinessConnection>
*/
final class GetBusinessConnection extends Method
{
protected static string $methodName = 'getBusinessConnection';
protected static string $responseClass = BusinessConnection::class;

public function __construct(
/**
* Unique identifier of the business connection
*/
protected string $businessConnectionId,
) {
}
}
2 changes: 1 addition & 1 deletion src/Method/GetCustomEmojiStickers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
/**
* List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
*
* @var string[]
* @var list<string>
*/
protected array $customEmojiIds,
) {
Expand Down
44 changes: 44 additions & 0 deletions src/Method/ReplaceStickerInSet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Luzrain\TelegramBotApi\Method;

use Luzrain\TelegramBotApi\Method;
use Luzrain\TelegramBotApi\Type\InputSticker;

/**
* Use this method to replace an existing sticker in a sticker set with a new one.
* The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet.
* Returns True on success.
*
* @extends Method<true>
*/
final class ReplaceStickerInSet extends Method
{
protected static string $methodName = 'replaceStickerInSet';

public function __construct(
/**
* User identifier of the sticker set owner
*/
protected int $userId,

/**
* Sticker set name
*/
protected string $name,

/**
* File identifier of the replaced sticker
*/
protected string $oldSticker,

/**
* A JSON-serialized object with information about the added sticker.
* If exactly the same sticker had already been added to the set, then the set remains unchanged.
*/
protected InputSticker $sticker,
) {
}
}
8 changes: 7 additions & 1 deletion src/Method/SendAnimation.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public function __construct(
*/
protected InputFile|string $animation,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand Down Expand Up @@ -101,7 +106,8 @@ public function __construct(

/**
* Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard,
* instructions to remove reply keyboard or to force a reply from the user.
* instructions to remove a reply keyboard or to force a reply from the user.
* Not supported for messages sent on behalf of a business account.
*/
protected InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null,
) {
Expand Down
8 changes: 7 additions & 1 deletion src/Method/SendAudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function __construct(
*/
protected InputFile|string $audio,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand Down Expand Up @@ -98,7 +103,8 @@ public function __construct(

/**
* Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard,
* instructions to remove reply keyboard or to force a reply from the user.
* instructions to remove a reply keyboard or to force a reply from the user.
* Not supported for messages sent on behalf of a business account.
*/
protected InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null,
) {
Expand Down
5 changes: 5 additions & 0 deletions src/Method/SendChatAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function __construct(
*/
protected string $action,

/**
* Unique identifier of the business connection on behalf of which the action will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread; supergroups only
*/
Expand Down
8 changes: 7 additions & 1 deletion src/Method/SendContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function __construct(
*/
protected string $firstName,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand Down Expand Up @@ -70,7 +75,8 @@ public function __construct(

/**
* Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard,
* instructions to remove reply keyboard or to force a reply from the user.
* instructions to remove a reply keyboard or to force a reply from the user.
* Not supported for messages sent on behalf of a business account.
*/
protected InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null,
) {
Expand Down
8 changes: 7 additions & 1 deletion src/Method/SendDice.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function __construct(
*/
protected int|string $chatId,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand Down Expand Up @@ -58,7 +63,8 @@ public function __construct(

/**
* Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard,
* instructions to remove reply keyboard or to force a reply from the user.
* instructions to remove a reply keyboard or to force a reply from the user.
* Not supported for messages sent on behalf of a business account.
*/
protected InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null,
) {
Expand Down
8 changes: 7 additions & 1 deletion src/Method/SendDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public function __construct(
*/
protected InputFile|string $document,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand Down Expand Up @@ -86,7 +91,8 @@ public function __construct(

/**
* Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard,
* instructions to remove reply keyboard or to force a reply from the user.
* instructions to remove a reply keyboard or to force a reply from the user.
* Not supported for messages sent on behalf of a business account.
*/
protected InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null,
) {
Expand Down
6 changes: 6 additions & 0 deletions src/Method/SendGame.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public function __construct(
*/
protected string $gameShortName,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand All @@ -53,6 +58,7 @@ public function __construct(
/**
* A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown.
* If not empty, the first button must launch the game.
* Not supported for messages sent on behalf of a business account.
*/
protected InlineKeyboardMarkup|null $replyMarkup = null,
) {
Expand Down
8 changes: 7 additions & 1 deletion src/Method/SendLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function __construct(
*/
protected float $longitude,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand Down Expand Up @@ -81,7 +86,8 @@ public function __construct(

/**
* Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard,
* instructions to remove reply keyboard or to force a reply from the user.
* instructions to remove a reply keyboard or to force a reply from the user.
* Not supported for messages sent on behalf of a business account.
*/
protected InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null,
) {
Expand Down
5 changes: 5 additions & 0 deletions src/Method/SendMediaGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function __construct(
*/
protected array $media,

/**
* Unique identifier of the business connection on behalf of which the message will be sent
*/
protected string|null $businessConnectionId = null,

/**
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
*/
Expand Down
Loading

0 comments on commit 0d800dd

Please sign in to comment.