Commit 7c338752 authored by MBoretto's avatar MBoretto

output moved outside lib

parent d7c61bee
......@@ -36,7 +36,17 @@ try {
//$telegram->setUploadPath("../Upload");
// handle telegram getUpdate request
$telegram->handleGetUpdates();
$ServerResponse = $telegram->handleGetUpdates();
if ($ServerResponse->isOk()) {
$n_update = count($ServerResponse->getResult());
print(date('Y-m-d H:i:s', time()).' - Processed '.$n_update." updates\n");
} else {
print(date('Y-m-d H:i:s', time())." - Fail fetch updates\n");
echo $ServerResponse->printError()."\n";
}
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// log telegram errors
echo $e;
......
......@@ -29,7 +29,7 @@ class Telegram
*
* @var string
*/
protected $version = '0.23.0';
protected $version = '0.24.0';
/**
* Telegram API key
......@@ -334,7 +334,7 @@ class Telegram
/**
* Handle getUpdates method
*
* @return \Longman\TelegramBot\Telegram
*
*/
public function handleGetUpdates($limit = null, $timeout = null)
......@@ -354,19 +354,17 @@ class Telegram
'limit' => $limit,
'timeout' => $timeout
]);
if ($ServerResponse->isOk()) {
$results = '';
$n_update = count($ServerResponse->getResult());
for ($a = 0; $a < $n_update; $a++) {
$result = $this->processUpdate($ServerResponse->getResult()[$a]);
}
print(date('Y-m-d H:i:s', time()).' - Processed '.$a." updates\n");
} else {
print(date('Y-m-d H:i:s', time())." - Fail fetch updates\n");
echo $ServerResponse->printError()."\n";
}
//return $results
return $ServerResponse;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment