Skip to content

Commit ed35363

Browse files
committed
Polling
1 parent b9eac52 commit ed35363

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/Telegram.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace PhpTelegramBot\Core;
44

55
use PhpTelegramBot\Core\Entities\Factory;
6+
use PhpTelegramBot\Core\Entities\Update;
67
use PhpTelegramBot\Core\Exceptions\NotYetImplementedException;
78
use PhpTelegramBot\Core\Exceptions\TelegramException;
89
use PhpTelegramBot\Core\Methods\AnswersInlineQueries;
@@ -78,18 +79,30 @@ protected function makeResultObject(mixed $result, string|array|null $returnType
7879
return new $returnType($result);
7980
}
8081

81-
public function handleGetUpdates()
82+
public function handleGetUpdates(int $pollingInterval = 30, ?array $allowedUpdates = null)
8283
{
83-
throw new NotYetImplementedException();
84+
$offset = null;
85+
while (true) {
86+
$updates = $this->getUpdates([
87+
'offset' => $offset,
88+
'timeout' => 30,
89+
'allowed_updates' => $allowedUpdates,
90+
]);
91+
92+
foreach ($updates as $update) {
93+
$this->processUpdate($update);
94+
$offset = $update->getUpdateId() + 1;
95+
}
96+
}
8497
}
8598

8699
public function handle()
87100
{
88101
throw new NotYetImplementedException();
89102
}
90103

91-
protected function processUpdate()
104+
protected function processUpdate(Update $update)
92105
{
93-
throw new NotYetImplementedException();
106+
//
94107
}
95108
}

0 commit comments

Comments
 (0)