Skip to content

Commit ee9dcd2

Browse files
committed
Fix Webhook Duplicate updates
1 parent 76f9666 commit ee9dcd2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/TelegramBot.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ protected function OnUpdate(\stdClass $update) : bool
9292
if ($this->Settings->AutoHandleDuplicateUpdates)
9393
{
9494
# Sooner than two weeks, Check the ID
95-
if ($this->Settings->LastUpdateDate > strtotime('-2 weeks'))
95+
if ($this->Settings->LastUpdateDate > strtotime('-1 week'))
9696
{
9797
# Check if update is in the write order
98-
if ($this->Settings->LastUpdateID == $update->update_id - 1 || $this->Settings->LastUpdateID == -1)
98+
if ($this->Settings->LastUpdateID < $update->update_id || $this->Settings->LastUpdateID == -1)
9999
{
100100
$this->Settings->LastUpdateID = $update->update_id;
101101
$this->Settings->LastUpdateDate = time();
@@ -111,7 +111,7 @@ protected function OnUpdate(\stdClass $update) : bool
111111
# Otherwise, Don't check the ID, Take it as it is
112112
else
113113
{
114-
$this->Settings->LastUpdateID = $update->update_id;
114+
$this->Settings->LastUpdateID = max($this->Settings->LastUpdateID, $update->update_id);
115115
$this->Settings->LastUpdateDate = time();
116116
}
117117
}

0 commit comments

Comments
 (0)