From affe904bed4db6b47f1b98493a1499ef5fdb9051 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 7 Mar 2026 09:47:01 +0300 Subject: [PATCH 1/8] tag 1.5.1 --- src/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api.php b/src/Api.php index 8cd774d..296f8b7 100644 --- a/src/Api.php +++ b/src/Api.php @@ -48,7 +48,7 @@ use RuntimeException; */ class Api { - public const string LIBRARY_VERSION = '1.5.0'; + public const string LIBRARY_VERSION = '1.5.1'; public const string API_VERSION = '1.2.5'; From 1e48123ee3c5945388907601a491aea6806e540f Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 13 Mar 2026 20:54:05 +0300 Subject: [PATCH 2/8] Updated webhook documentation #26 --- README.md | 2 +- docs/README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b432597..c9b3ef7 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ $dispatcher->addHandler(UpdateType::BotStarted, function (BotStartedUpdate $upda ```php $api->subscribe( - url: 'https://example.com/webhook', // URL на который будут приходить хуки + url: 'https://example.com/webhook', // HTTPS URL на который будут приходить хуки secret: 'super_secret', // Секретная фраза для проверки хуков updateTypes: [ // Типы хуков которые вы хотите получать (либо ничего не указывать, чтобы получать все) diff --git a/docs/README.md b/docs/README.md index 1004d8c..430aa46 100644 --- a/docs/README.md +++ b/docs/README.md @@ -275,11 +275,11 @@ $subscriptions = $api->getSubscriptions(); Подписывает бота на получение обновлений через WebHook. После вызова этого метода бот будет получать уведомления о новых событиях в чатах на указанный URL. -Ваш сервер должен прослушивать один из следующих портов: 80, 8080, 443, 8443, 16384-32383. +Судя по обновленной [документации](https://dev.max.ru/docs-api/methods/POST/subscriptions) поддерживается только 443 порт! ```php $api->subscribe( - url: 'https://example.com/webhook', // URL на который будут приходить хуки. Должен начинаться с http(s):// + url: 'https://example.com/webhook', // HTTPS URL на который будут приходить хуки. Должен начинаться с https:// secret: 'super_secret', // Секретная фраза для проверки хуков (необязательно) updateTypes: [UpdateType::MessageCreated], // Типы хуков которые вы хотите получать (либо ничего не указывать, чтобы получать все) ); From 40742ddc60227457ce2a26374f38d6a67fb23747 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 20 Mar 2026 22:55:36 +0300 Subject: [PATCH 3/8] Removed deprecated ReplyKeyboardAttachment #27 --- src/Enums/AttachmentType.php | 1 - src/ModelFactory.php | 14 +-- .../ReplyKeyboardAttachmentRequestPayload.php | 22 ----- .../Attachments/ReplyKeyboardAttachment.php | 19 ---- .../ReplyKeyboardAttachmentRequest.php | 28 ------ tests/ModelFactoryTest.php | 22 ----- ...lyKeyboardAttachmentRequestPayloadTest.php | 99 ------------------- .../ReplyKeyboardAttachmentTest.php | 43 -------- .../ReplyKeyboardAttachmentRequestTest.php | 59 ----------- 9 files changed, 2 insertions(+), 305 deletions(-) delete mode 100644 src/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayload.php delete mode 100644 src/Models/Attachments/ReplyKeyboardAttachment.php delete mode 100644 src/Models/Attachments/Requests/ReplyKeyboardAttachmentRequest.php delete mode 100644 tests/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayloadTest.php delete mode 100644 tests/Models/Attachments/ReplyKeyboardAttachmentTest.php delete mode 100644 tests/Models/Attachments/Requests/ReplyKeyboardAttachmentRequestTest.php diff --git a/src/Enums/AttachmentType.php b/src/Enums/AttachmentType.php index 4e3d35d..af81056 100644 --- a/src/Enums/AttachmentType.php +++ b/src/Enums/AttachmentType.php @@ -13,7 +13,6 @@ enum AttachmentType: string case Sticker = 'sticker'; case Contact = 'contact'; case InlineKeyboard = 'inline_keyboard'; - case ReplyKeyboard = 'reply_keyboard'; case Location = 'location'; case Share = 'share'; case Data = 'data'; diff --git a/src/ModelFactory.php b/src/ModelFactory.php index 3e8f482..ce8a46a 100644 --- a/src/ModelFactory.php +++ b/src/ModelFactory.php @@ -29,7 +29,6 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\FileAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\InlineKeyboardAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\LocationAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\PhotoAttachment; -use BushlanovDev\MaxMessengerBot\Models\Attachments\ReplyKeyboardAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\ShareAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\StickerAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\VideoAttachment; @@ -242,14 +241,6 @@ readonly class ModelFactory public function createAttachment(array $data): AbstractAttachment { $attachmentType = AttachmentType::tryFrom($data['type'] ?? ''); - if ($attachmentType === AttachmentType::ReplyKeyboard - && isset($data['buttons']) && is_array($data['buttons'])) { - $data['buttons'] = array_map( - fn($rowOfButtons) => array_map([$this, 'createReplyButton'], $rowOfButtons), - $data['buttons'], - ); - } - if ($attachmentType === AttachmentType::InlineKeyboard && isset($data['payload']['buttons']) && is_array($data['payload']['buttons'])) { $data['payload']['buttons'] = array_map( @@ -259,8 +250,6 @@ readonly class ModelFactory } return match ($attachmentType) { - AttachmentType::Data => DataAttachment::fromArray($data), - AttachmentType::Share => ShareAttachment::fromArray($data), AttachmentType::Image => PhotoAttachment::fromArray($data), AttachmentType::Video => VideoAttachment::fromArray($data), AttachmentType::Audio => AudioAttachment::fromArray($data), @@ -268,8 +257,9 @@ readonly class ModelFactory AttachmentType::Sticker => StickerAttachment::fromArray($data), AttachmentType::Contact => ContactAttachment::fromArray($data), AttachmentType::InlineKeyboard => InlineKeyboardAttachment::fromArray($data), - AttachmentType::ReplyKeyboard => ReplyKeyboardAttachment::fromArray($data), AttachmentType::Location => LocationAttachment::fromArray($data), + AttachmentType::Share => ShareAttachment::fromArray($data), + AttachmentType::Data => DataAttachment::fromArray($data), default => throw new LogicException('Unknown or unsupported attachment type: ' . ($data['type'] ?? 'none')), }; } diff --git a/src/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayload.php b/src/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayload.php deleted file mode 100644 index ed594dd..0000000 --- a/src/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayload.php +++ /dev/null @@ -1,22 +0,0 @@ -factory->createMarkupElement(['type' => 'brand_new_unsupported_type']); } - #[Test] - public function createAttachmentCorrectlyHydratesReplyKeyboard(): void - { - $data = [ - 'type' => 'reply_keyboard', - 'buttons' => [ - [['type' => 'message', 'text' => 'Hello']], - [['type' => 'user_contact', 'text' => 'My Contact']] - ] - ]; - - $attachment = $this->factory->createAttachment($data); - - $this->assertInstanceOf(ReplyKeyboardAttachment::class, $attachment); - $this->assertCount(2, $attachment->buttons); - $this->assertInstanceOf(SendMessageButton::class, $attachment->buttons[0][0]); - $this->assertInstanceOf(SendContactButton::class, $attachment->buttons[1][0]); - $this->assertSame('My Contact', $attachment->buttons[1][0]->text); - } - #[Test] public function createReplyButtonThrowsExceptionForUnknownType(): void { diff --git a/tests/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayloadTest.php b/tests/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayloadTest.php deleted file mode 100644 index 65c90a8..0000000 --- a/tests/Models/Attachments/Payloads/ReplyKeyboardAttachmentRequestPayloadTest.php +++ /dev/null @@ -1,99 +0,0 @@ - [ - [ - [ - 'type' => 'message', - 'text' => 'Help', - 'payload' => null, - 'intent' => 'default', - ], - ], - [ - [ - 'type' => 'user_contact', - 'text' => 'Share Contact', - ], - ], - ], - 'direct' => false, - 'direct_user_id' => null, - ]; - - $this->assertEquals($expected, $payload->toArray()); - } - - #[Test] - public function toArrayWithAllParameters(): void - { - $buttons = [ - [new SendMessageButton('Confirm', 'confirm-action', Intent::Positive)], - ]; - - $payload = new ReplyKeyboardAttachmentRequestPayload( - buttons: $buttons, - direct: true, - directUserId: 987654321, - ); - - $expected = [ - 'buttons' => [ - [ - [ - 'type' => 'message', - 'text' => 'Confirm', - 'payload' => 'confirm-action', - 'intent' => 'positive', - ], - ], - ], - 'direct' => true, - 'direct_user_id' => 987654321, - ]; - - $this->assertEquals($expected, $payload->toArray()); - } - - #[Test] - public function toArrayWithEmptyButtons(): void - { - $payload = new ReplyKeyboardAttachmentRequestPayload(buttons: []); - - $expected = [ - 'buttons' => [], - 'direct' => false, - 'direct_user_id' => null, - ]; - - $this->assertEquals($expected, $payload->toArray()); - } -} diff --git a/tests/Models/Attachments/ReplyKeyboardAttachmentTest.php b/tests/Models/Attachments/ReplyKeyboardAttachmentTest.php deleted file mode 100644 index e894068..0000000 --- a/tests/Models/Attachments/ReplyKeyboardAttachmentTest.php +++ /dev/null @@ -1,43 +0,0 @@ - 'reply_keyboard', - 'buttons' => [ - [['type' => 'message', 'text' => 'Hello']], - [['type' => 'user_contact', 'text' => 'My Contact']] - ] - ]; - - $factory = new ModelFactory(); - $attachment = $factory->createAttachment($data); - - $this->assertInstanceOf(ReplyKeyboardAttachment::class, $attachment); - $this->assertCount(2, $attachment->buttons); - $this->assertInstanceOf(SendContactButton::class, $attachment->buttons[1][0]); - $this->assertSame('My Contact', $attachment->buttons[1][0]->text); - } -} diff --git a/tests/Models/Attachments/Requests/ReplyKeyboardAttachmentRequestTest.php b/tests/Models/Attachments/Requests/ReplyKeyboardAttachmentRequestTest.php deleted file mode 100644 index 9d3b788..0000000 --- a/tests/Models/Attachments/Requests/ReplyKeyboardAttachmentRequestTest.php +++ /dev/null @@ -1,59 +0,0 @@ - 'reply_keyboard', - 'payload' => [ - 'buttons' => [ - [ - [ - 'type' => 'message', - 'text' => 'Help', - 'payload' => 'help_payload', - 'intent' => 'positive', - ], - ], - [ - [ - 'type' => 'user_contact', - 'text' => 'Share Contact', - ], - ], - ], - 'direct' => true, - 'direct_user_id' => null, - ], - ]; - - $this->assertEquals($expectedArray, $request->toArray()); - } -} From 85231b09628647da766e48db36668da2ee0fc033 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 21 Mar 2026 09:44:40 +0300 Subject: [PATCH 4/8] Removed deprecated DataAttachment --- src/Enums/AttachmentType.php | 1 - src/ModelFactory.php | 2 - src/Models/Attachments/DataAttachment.php | 21 -------- tests/ModelFactoryTest.php | 24 ++------- .../Models/Attachments/DataAttachmentTest.php | 49 ------------------- 5 files changed, 5 insertions(+), 92 deletions(-) delete mode 100644 src/Models/Attachments/DataAttachment.php delete mode 100644 tests/Models/Attachments/DataAttachmentTest.php diff --git a/src/Enums/AttachmentType.php b/src/Enums/AttachmentType.php index af81056..ccc0484 100644 --- a/src/Enums/AttachmentType.php +++ b/src/Enums/AttachmentType.php @@ -15,5 +15,4 @@ enum AttachmentType: string case InlineKeyboard = 'inline_keyboard'; case Location = 'location'; case Share = 'share'; - case Data = 'data'; } diff --git a/src/ModelFactory.php b/src/ModelFactory.php index ce8a46a..9e8aa67 100644 --- a/src/ModelFactory.php +++ b/src/ModelFactory.php @@ -24,7 +24,6 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Reply\SendContactBut use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Reply\SendGeoLocationButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Reply\SendMessageButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\ContactAttachment; -use BushlanovDev\MaxMessengerBot\Models\Attachments\DataAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\FileAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\InlineKeyboardAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\LocationAttachment; @@ -259,7 +258,6 @@ readonly class ModelFactory AttachmentType::InlineKeyboard => InlineKeyboardAttachment::fromArray($data), AttachmentType::Location => LocationAttachment::fromArray($data), AttachmentType::Share => ShareAttachment::fromArray($data), - AttachmentType::Data => DataAttachment::fromArray($data), default => throw new LogicException('Unknown or unsupported attachment type: ' . ($data['type'] ?? 'none')), }; } diff --git a/src/Models/Attachments/DataAttachment.php b/src/Models/Attachments/DataAttachment.php deleted file mode 100644 index ae24be5..0000000 --- a/src/Models/Attachments/DataAttachment.php +++ /dev/null @@ -1,21 +0,0 @@ - 102, 'text' => 'Message with data attachment', 'attachments' => [ - ['type' => 'data', 'data' => 'payload_from_reply_button'], [ 'type' => 'share', 'payload' => ['url' => 'http://a.com'], @@ -613,16 +610,13 @@ final class ModelFactoryTest extends TestCase $this->assertInstanceOf(Message::class, $message); $this->assertInstanceOf(MessageBody::class, $message->body); $this->assertIsArray($attachments); - $this->assertCount(3, $attachments); + $this->assertCount(2, $attachments); - $this->assertInstanceOf(DataAttachment::class, $attachments[0]); - $this->assertSame('payload_from_reply_button', $attachments[0]->data); + $this->assertInstanceOf(ShareAttachment::class, $message->body->attachments[0]); + $this->assertSame('Test Share', $attachments[0]->title); - $this->assertInstanceOf(ShareAttachment::class, $message->body->attachments[1]); - $this->assertSame('Test Share', $attachments[1]->title); - - $this->assertInstanceOf(PhotoAttachment::class, $attachments[2]); - $this->assertSame(1, $attachments[2]->payload->photoId); + $this->assertInstanceOf(PhotoAttachment::class, $attachments[1]); + $this->assertSame(1, $attachments[1]->payload->photoId); } #[Test] @@ -747,14 +741,6 @@ final class ModelFactoryTest extends TestCase public static function attachmentTypeProvider(): array { return [ - 'Data Attachment' => [ - ['type' => 'data', 'data' => 'test_payload'], - DataAttachment::class, - function (TestCase $test, DataAttachment $attachment) { - $test->assertSame('test_payload', $attachment->data); - } - ], - 'Location Attachment' => [ ['type' => 'location', 'latitude' => 55.751244, 'longitude' => 37.618423], LocationAttachment::class, diff --git a/tests/Models/Attachments/DataAttachmentTest.php b/tests/Models/Attachments/DataAttachmentTest.php deleted file mode 100644 index f3905de..0000000 --- a/tests/Models/Attachments/DataAttachmentTest.php +++ /dev/null @@ -1,49 +0,0 @@ -assertSame(AttachmentType::Data, $attachment->type); - $this->assertSame('some_payload_from_button', $attachment->data); - - $expectedArray = [ - 'type' => 'data', - 'data' => 'some_payload_from_button', - ]; - - $this->assertEquals($expectedArray, $attachment->toArray()); - } - - #[Test] - public function canBeCreatedFromArray(): void - { - $data = [ - 'type' => 'data', - 'data' => 'payload123', - ]; - - $attachment = DataAttachment::fromArray($data); - - $this->assertInstanceOf(DataAttachment::class, $attachment); - $this->assertSame(AttachmentType::Data, $attachment->type); - $this->assertSame('payload123', $attachment->data); - } -} From dd295efc3de5354b209ff923b707103d4f08fb41 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 22 Mar 2026 09:23:35 +0300 Subject: [PATCH 5/8] tag 1.6.0 --- src/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api.php b/src/Api.php index 296f8b7..170d725 100644 --- a/src/Api.php +++ b/src/Api.php @@ -48,7 +48,7 @@ use RuntimeException; */ class Api { - public const string LIBRARY_VERSION = '1.5.1'; + public const string LIBRARY_VERSION = '1.6.0'; public const string API_VERSION = '1.2.5'; From efd62614906797a3a563198b822fab0e7970d35f Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 15 Apr 2026 22:10:15 +0300 Subject: [PATCH 6/8] Added chat admin permissions --- src/Api.php | 2 +- src/Enums/ChatAdminPermission.php | 4 ++++ tests/ApiTest.php | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Api.php b/src/Api.php index 170d725..2c84056 100644 --- a/src/Api.php +++ b/src/Api.php @@ -48,7 +48,7 @@ use RuntimeException; */ class Api { - public const string LIBRARY_VERSION = '1.6.0'; + public const string LIBRARY_VERSION = '1.6.1'; public const string API_VERSION = '1.2.5'; diff --git a/src/Enums/ChatAdminPermission.php b/src/Enums/ChatAdminPermission.php index 609d231..74cdb63 100644 --- a/src/Enums/ChatAdminPermission.php +++ b/src/Enums/ChatAdminPermission.php @@ -15,5 +15,9 @@ enum ChatAdminPermission: string case ChangeChatInfo = 'change_chat_info'; case PinMessage = 'pin_message'; case Write = 'write'; + case CanCall = 'can_call'; case EditLink = 'edit_link'; + case PostEditDeleteMessage = 'post_edit_delete_message'; + case EditMessage = 'edit_message'; + case DeleteMessage = 'delete_message'; } diff --git a/tests/ApiTest.php b/tests/ApiTest.php index c9b8536..1ae4a1e 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -1667,12 +1667,14 @@ final class ApiTest extends TestCase $admins = [ new ChatAdmin(101, [ChatAdminPermission::Write]), new ChatAdmin(202, [ChatAdminPermission::PinMessage]), + new ChatAdmin(303, [ChatAdminPermission::EditMessage, ChatAdminPermission::CanCall], 'SuperUser'), ]; $expectedBody = [ 'admins' => [ ['user_id' => 101, 'permissions' => ['write'], 'alias' => null], ['user_id' => 202, 'permissions' => ['pin_message'], 'alias' => null], + ['user_id' => 303, 'permissions' => ['edit_message', 'can_call'], 'alias' => 'SuperUser'], ], ]; $rawResponse = ['success' => true]; From 455b36ba2ae109ad238179d92dfad9a3fb678de0 Mon Sep 17 00:00:00 2001 From: szuev Date: Thu, 16 Apr 2026 13:05:58 +0300 Subject: [PATCH 7/8] add `psr/log` versions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8561291..917a574 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "psr/http-client": "^1.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0||^2.0", - "psr/log": "^3.0" + "psr/log": "^1.1||^2.0||^3.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.77", From 4fdfca53eeb6dd85214a20c065c8e5dd30a7e50e Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 17 Apr 2026 20:21:29 +0300 Subject: [PATCH 8/8] tag 1.6.2 --- src/Api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api.php b/src/Api.php index 2c84056..1417e8e 100644 --- a/src/Api.php +++ b/src/Api.php @@ -48,7 +48,7 @@ use RuntimeException; */ class Api { - public const string LIBRARY_VERSION = '1.6.1'; + public const string LIBRARY_VERSION = '1.6.2'; public const string API_VERSION = '1.2.5';