Commit 7c338752 authored by MBoretto's avatar MBoretto

output moved outside lib

parent d7c61bee
...@@ -36,7 +36,17 @@ try { ...@@ -36,7 +36,17 @@ try {
//$telegram->setUploadPath("../Upload"); //$telegram->setUploadPath("../Upload");
// handle telegram getUpdate request // 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) { } catch (Longman\TelegramBot\Exception\TelegramException $e) {
// log telegram errors // log telegram errors
echo $e; echo $e;
......
...@@ -29,7 +29,7 @@ class Telegram ...@@ -29,7 +29,7 @@ class Telegram
* *
* @var string * @var string
*/ */
protected $version = '0.23.0'; protected $version = '0.24.0';
/** /**
* Telegram API key * Telegram API key
...@@ -334,7 +334,7 @@ class Telegram ...@@ -334,7 +334,7 @@ class Telegram
/** /**
* Handle getUpdates method * Handle getUpdates method
* *
* @return \Longman\TelegramBot\Telegram *
*/ */
public function handleGetUpdates($limit = null, $timeout = null) public function handleGetUpdates($limit = null, $timeout = null)
...@@ -354,19 +354,17 @@ class Telegram ...@@ -354,19 +354,17 @@ class Telegram
'limit' => $limit, 'limit' => $limit,
'timeout' => $timeout 'timeout' => $timeout
]); ]);
if ($ServerResponse->isOk()) { if ($ServerResponse->isOk()) {
$results = ''; $results = '';
$n_update = count($ServerResponse->getResult()); $n_update = count($ServerResponse->getResult());
for ($a = 0; $a < $n_update; $a++) { for ($a = 0; $a < $n_update; $a++) {
$result = $this->processUpdate($ServerResponse->getResult()[$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