Skip to content

Commit ca3e4b1

Browse files
committed
Fixed webhook errors
1 parent 42c5ef2 commit ca3e4b1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

examples/echobot-webhook.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
$update = $bot->updates();
1010

11-
if($update->ok ?? false){
12-
$update = $update->result;
11+
if(isset($update->update_id)){
1312

1413
if(isset($update->message)){
1514
$bot->copyMessage([

src/Telegram/Updates.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ class Updates{
1010

1111
public function __construct(?object $data){
1212
if($data !== NULL){
13-
$this->lastUpdateID = end($data->result)->update_id ?? null;
13+
14+
if(isset($data->result))
15+
$this->lastUpdateID = end($data->result ?? [])->update_id ?? null;
16+
else
17+
$this->lastUpdateID = null;
18+
19+
1420
foreach($data as $key => $value)
1521
$this->$key = $value;
1622
}

0 commit comments

Comments
 (0)