Skip to content

Commit da7fb4d

Browse files
committed
Added msg property to default updates
1 parent acfadc0 commit da7fb4d

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

docs/01-updates.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ $updates = $bot->updates(true);
3636
```
3737

3838
Here's a list of the currently available general updates:
39+
* [`msg`](https://core.telegram.org/bots/api#message): The sent message.
3940
* [`user`](https://core.telegram.org/bots/api#user): The user that performed the action.
4041
* [`chat`](https://core.telegram.org/bots/api#chat): The chat where the action was performed.

src/Telegram/Updates.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ public function __construct(?object $data, bool $enableDefaultUpdates = false){
3636
if($enableDefaultUpdates){
3737

3838
foreach($data->result ?? [$data] as &$upd){
39-
$upd->user = $upd->message->from ??
40-
$upd->message->sender_chat ??
41-
$upd->edited_message->from ??
39+
$upd->msg = $upd->message ??
40+
$upd->edited_message ??
41+
$upd->channel_post ??
42+
$upd->edited_channel_post ??
43+
null;
44+
45+
$upd->user = $upd->msg->from ??
46+
$upd->msg->sender_chat ??
4247
$upd->inline_query->from ??
4348
$upd->chosen_inline_result->from ??
4449
$upd->callback_query->from ??
@@ -48,10 +53,7 @@ public function __construct(?object $data, bool $enableDefaultUpdates = false){
4853
$upd->chat_join_request->from ??
4954
null;
5055

51-
$upd->chat = $upd->message->chat ??
52-
$upd->edited_message->chat ??
53-
$upd->channel_post->chat ??
54-
$upd->edited_channel_post->chat ??
56+
$upd->chat = $upd->mgs->chat ??
5557
$upd->callback_query->message->chat ??
5658
$upd->my_chat_member->chat ??
5759
$upd->chat_member->chat ??

0 commit comments

Comments
 (0)