Skip to content

Commit 5c9fd8b

Browse files
committed
Added the class WebAppData and the field web_app_data to the class Message.
1 parent 7ca60aa commit 5c9fd8b

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/Entities/Message.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
* @method VoiceChatStarted getVoiceChatStarted() Optional. Service message: voice chat started
8080
* @method VoiceChatEnded getVoiceChatEnded() Optional. Service message: voice chat ended
8181
* @method VoiceChatParticipantsInvited getVoiceChatParticipantsInvited() Optional. Service message: new participants invited to a voice chat
82+
* @method WebAppData getWebAppData() Optional. Service message: data sent by a Web App
8283
* @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.
8384
*/
8485
class Message extends Entity
@@ -125,6 +126,7 @@ protected function subEntities(): array
125126
'voice_chat_started' => VoiceChatStarted::class,
126127
'voice_chat_ended' => VoiceChatEnded::class,
127128
'voice_chat_participants_invited' => VoiceChatParticipantsInvited::class,
129+
'web_app_data' => WebAppData::class,
128130
'reply_markup' => InlineKeyboard::class,
129131
];
130132
}
@@ -141,7 +143,7 @@ public function getFullCommand(): ?string
141143
return null;
142144
}
143145

144-
$no_EOL = strtok($text, PHP_EOL);
146+
$no_EOL = strtok($text, PHP_EOL);
145147
$no_space = strtok($text, ' ');
146148

147149
//try to understand which separator \n or space divide /command from text
@@ -167,7 +169,7 @@ public function getCommand(): ?string
167169

168170
//check if command is followed by bot username
169171
$split_cmd = explode('@', $full_command);
170-
if (!isset($split_cmd[1])) {
172+
if (! isset($split_cmd[1])) {
171173
//command is not followed by name
172174
return $full_command;
173175
}
@@ -183,7 +185,7 @@ public function getCommand(): ?string
183185
/**
184186
* For text messages, the actual UTF-8 text of the message, 0-4096 characters.
185187
*
186-
* @param bool $without_cmd
188+
* @param bool $without_cmd
187189
*
188190
* @return string|null
189191
*/
@@ -260,6 +262,7 @@ public function getType(): string
260262
'voice_chat_started',
261263
'voice_chat_ended',
262264
'voice_chat_participants_invited',
265+
'web_app_data',
263266
'reply_markup',
264267
];
265268

src/Entities/WebAppData.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities;
4+
5+
/**
6+
* Class WebAppData
7+
* Contains data sent from a Web App to the bot.
8+
*
9+
* @property string $data The data. Be aware that a bad client can send arbitrary data in this field.
10+
* @property string $button_text Text of the web_app keyboard button, from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field.
11+
*
12+
* @method string getData() The data. Be aware that a bad client can send arbitrary data in this field.
13+
* @method string getButtonText() Text of the web_app keyboard button, from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field.
14+
*
15+
* @method $this setData(string $data) The data. Be aware that a bad client can send arbitrary data in this field.
16+
* @method $this setButtonText(string $button_text) Text of the web_app keyboard button, from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field.
17+
*/
18+
class WebAppData extends Entity
19+
{
20+
21+
}

0 commit comments

Comments
 (0)