Skip to content

Commit 2b899e7

Browse files
committed
Fix webhook receive
1 parent 0a50044 commit 2b899e7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/TelegramBot.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,20 @@ public function OnWebhookUpdate() : bool
139139
$Update = json_decode(file_get_contents('php://input'));
140140
if (empty($Update))
141141
{
142+
error_log("Empty update");
142143
http_response_code(400);
143144
return false;
144145
}
145146

146147
if ($this->Settings->AutoHandleDuplicateUpdates)
147148
{
148149
# If sooner than 2 weeks
149-
if ($this->Settings->LastUpdateDate < strtotime('-2 week'))
150+
if ($this->Settings->LastUpdateDate > strtotime('-2 week'))
150151
{
151152
if ($this->Settings->LastUpdateID >= $Update->update_id)
152153
{
153154
// This update is fake or duplicate by ID
155+
error_log("Last update ID ({$this->Settings->LastUpdateID}) >= Receieved update ID ({$Update->update_id})");
154156
http_response_code(400);
155157
return false;
156158
}
@@ -165,6 +167,7 @@ public function OnWebhookUpdate() : bool
165167
if ($_GET['token_hash'] != hash($this->HashingMethod, $this->Token))
166168
{
167169
# Fake update
170+
error_log("Unauthorized, Received token_hash={$_GET['token_hash']}");
168171
http_response_code(401);
169172
return false;
170173
}

0 commit comments

Comments
 (0)