Skip to content

Commit 3c6da8e

Browse files
committed
Added MessageButton & ChatAdminPermission::EditLink & alias in ChatAdmin & participants in Chat & first_name in BotPatch
1 parent cbb4cbc commit 3c6da8e

15 files changed

Lines changed: 83 additions & 5 deletions

File tree

docs/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4656,4 +4656,4 @@
46564656
}
46574657
}
46584658
}
4659-
}
4659+
}

src/Enums/ChatAdminPermission.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ enum ChatAdminPermission: string
1515
case ChangeChatInfo = 'change_chat_info';
1616
case PinMessage = 'pin_message';
1717
case Write = 'write';
18+
case EditLink = 'edit_link';
1819
}

src/ModelFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\CallbackButton;
1616
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\ChatButton;
1717
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\LinkButton;
18+
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\MessageButton;
1819
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\OpenAppButton;
1920
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\RequestContactButton;
2021
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\RequestGeoLocationButton;
@@ -311,6 +312,7 @@ public function createInlineButton(array $data): AbstractInlineButton
311312
InlineButtonType::RequestGeoLocation => RequestGeoLocationButton::fromArray($data),
312313
InlineButtonType::Chat => ChatButton::fromArray($data),
313314
InlineButtonType::OpenApp => OpenAppButton::fromArray($data),
315+
InlineButtonType::Message => MessageButton::fromArray($data),
314316
default => throw new LogicException(
315317
'Unknown or unsupported inline button type: ' . ($data['type'] ?? 'none')
316318
),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline;
6+
7+
use BushlanovDev\MaxMessengerBot\Enums\InlineButtonType;
8+
9+
/**
10+
* Button send text in chat from user.
11+
*/
12+
final readonly class MessageButton extends AbstractInlineButton
13+
{
14+
/**
15+
* @param string $text Text sending in chat from user.
16+
*/
17+
public function __construct(string $text)
18+
{
19+
parent::__construct(InlineButtonType::Message, $text);
20+
}
21+
}

src/Models/BotPatch.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
/**
1010
* Represents the data to patch for a bot. Instantiate with named arguments.
1111
*
12-
* Example: new BotPatch(name: 'New Bot Name', description: null);
12+
* Example: new BotPatch(first_name: 'New Bot Name', description: null);
1313
*
14-
* @property-read string|null $name
14+
* @property-read string|null $first_name
15+
* @property-read string|null $last_name
1516
* @property-read string|null $description
1617
* @property-read BotCommand[]|null $commands
1718
* @property-read PhotoAttachmentRequestPayload|null $photo
19+
* @property-read string|null $name @deprecated Use first_name
1820
*/
1921
final readonly class BotPatch extends AbstractPatchModel
2022
{

src/Models/Chat.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @param int|null $messagesCount Messages count in chat. Only for group chats and channels. Not available for dialogs.
2929
* @param string|null $chatMessageId Identifier of message that contains `chat` button initialized chat.
3030
* @param Message|null $pinnedMessage Pinned message in chat or channel. Returned only when single chat is requested.
31+
* @param array<string, int>|null $participants List of participants in chat. Returned only when single chat is requested.
3132
*/
3233
public function __construct(
3334
public int $chatId,
@@ -45,6 +46,7 @@ public function __construct(
4546
public ?int $messagesCount,
4647
public ?string $chatMessageId,
4748
public ?Message $pinnedMessage,
49+
public ?array $participants,
4850
) {
4951
}
5052
}

src/Models/ChatAdmin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
/**
1616
* @param int $userId The identifier of the user to be made an admin.
1717
* @param ChatAdminPermission[] $permissions The list of permissions to grant to the user.
18+
* @param string|null $alias Alias of the user.
1819
*/
1920
public function __construct(
2021
public int $userId,
2122
#[ArrayOf(ChatAdminPermission::class)]
2223
public array $permissions,
24+
public ?string $alias = null,
2325
) {
2426
}
2527
}

src/Models/ChatMember.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @param bool $isAdmin True if this member is an administrator of the chat.
2828
* @param int $joinTime The time the user joined the chat.
2929
* @param ChatAdminPermission[]|null $permissions A list of permissions if the member is an admin, otherwise null.
30+
* @param string|null $alias Alias of the user.
3031
*/
3132
public function __construct(
3233
public int $userId,
@@ -44,6 +45,7 @@ public function __construct(
4445
public int $joinTime,
4546
#[ArrayOf(ChatAdminPermission::class)]
4647
public ?array $permissions,
48+
public ?string $alias,
4749
) {
4850
}
4951
}

tests/ApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,8 +1671,8 @@ public function postAdminsCallsClientWithCorrectBody(): void
16711671

16721672
$expectedBody = [
16731673
'admins' => [
1674-
['user_id' => 101, 'permissions' => ['write']],
1675-
['user_id' => 202, 'permissions' => ['pin_message']],
1674+
['user_id' => 101, 'permissions' => ['write'], 'alias' => null],
1675+
['user_id' => 202, 'permissions' => ['pin_message'], 'alias' => null],
16761676
],
16771677
];
16781678
$rawResponse = ['success' => true];

tests/ModelFactoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ public function createChatMember()
458458
'is_admin' => true,
459459
'join_time' => 1678000000,
460460
'permissions' => ['pin_message', 'write'],
461+
'alias' => null,
461462
];
462463

463464
$chatMember = $this->factory->createChatMember($rawData);

0 commit comments

Comments
 (0)