Skip to content

Commit 37cf05e

Browse files
authored
Merge pull request #765 from jacklul/fix
Do not process duplicated updates, prevent stopping the script
2 parents f7cac58 + aff7628 commit 37cf05e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/DB.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,6 @@ public static function insertRequest(Update $update)
492492
$update_id = $update->getUpdateId();
493493
$update_type = $update->getUpdateType();
494494

495-
if (count(self::selectTelegramUpdate(1, $update_id)) === 1) {
496-
throw new TelegramException('Duplicate update received!');
497-
}
498-
499495
// @todo Make this simpler: if ($message = $update->getMessage()) ...
500496
if ($update_type === 'message') {
501497
$message = $update->getMessage();

src/Telegram.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,12 @@ public function processUpdate(Update $update)
457457
//This is necessary to "require" all the necessary command files!
458458
$this->getCommandsList();
459459

460+
//Make sure we don't try to process update that was already processed
461+
if (count(DB::selectTelegramUpdate(1, $this->update->getUpdateId())) === 1) {
462+
TelegramLog::debug('Duplicate update received, processing aborted!');
463+
return Request::emptyResponse();
464+
}
465+
460466
DB::insertRequest($this->update);
461467

462468
return $this->executeCommand($command);

0 commit comments

Comments
 (0)