Skip to content

Commit 545e002

Browse files
committed
Added the class MenuButton and the methods setChatMenuButton and getChatMenuButton for managing the behavior of the bot's menu button in private chats.
1 parent 5c9fd8b commit 545e002

File tree

5 files changed

+146
-66
lines changed

5 files changed

+146
-66
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\MenuButton;
4+
5+
use Longman\TelegramBot\Entities\Entity;
6+
7+
abstract class MenuButton extends Entity
8+
{
9+
10+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\MenuButton;
4+
5+
/**
6+
* Represents a menu button, which opens the bot's list of commands.
7+
*/
8+
class MenuButtonCommands extends MenuButton
9+
{
10+
public function __construct(array $data)
11+
{
12+
$data['type'] = 'commands';
13+
parent::__construct($data);
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\MenuButton;
4+
5+
/**
6+
* Describes that no specific value for the menu button was set.
7+
*/
8+
class MenuButtonDefault extends MenuButton
9+
{
10+
public function __construct(array $data)
11+
{
12+
$data['type'] = 'default';
13+
parent::__construct($data);
14+
}
15+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\MenuButton;
4+
5+
use Longman\TelegramBot\Entities\WebAppInfo;
6+
7+
/**
8+
* Represents a menu button, which launches a Web App.
9+
*
10+
* @method string getText() Text on the button
11+
* @method WebAppInfo getWebApp() Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery.
12+
*
13+
* @method $this setText(string $text) Text on the button
14+
* @method $this setWebApp(WebAppInfo $web_app) Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery.
15+
*/
16+
class MenuButtonWebApp extends MenuButton
17+
{
18+
public function __construct(array $data)
19+
{
20+
$data['type'] = 'web_app';
21+
parent::__construct($data);
22+
}
23+
24+
protected function subEntities(): array
25+
{
26+
return [
27+
'web_app' => WebAppInfo::class,
28+
];
29+
}
30+
31+
32+
}

0 commit comments

Comments
 (0)