Add custom_input for getUpdates method.

parent 41cfa0b6
......@@ -10,6 +10,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated
### Removed
### Fixed
- Take `custom_input` into account when using getUpdates method (mainly for testing).
### Security
## [0.44.1] - 2017-04-25
......
......@@ -334,20 +334,25 @@ class Telegram
);
}
//DB Query
$last_update = DB::selectTelegramUpdate(1);
$last_update = reset($last_update);
//Take custom input into account.
if ($custom_input = $this->getCustomInput()) {
$response = new ServerResponse(json_decode($custom_input, true), $this->bot_username);
} else {
//DB Query
$last_update = DB::selectTelegramUpdate(1);
$last_update = reset($last_update);
//As explained in the telegram bot api documentation
$offset = isset($last_update['id']) ? $last_update['id'] + 1 : null;
//As explained in the telegram bot api documentation
$offset = isset($last_update['id']) ? $last_update['id'] + 1 : null;
$response = Request::getUpdates(
[
'offset' => $offset,
'limit' => $limit,
'timeout' => $timeout,
]
);
$response = Request::getUpdates(
[
'offset' => $offset,
'limit' => $limit,
'timeout' => $timeout,
]
);
}
if ($response->isOk()) {
//Process all updates
......@@ -890,7 +895,7 @@ class Telegram
/**
* Enable requests limiter
*
* @param array $options
* @param array $options
*
* @return \Longman\TelegramBot\Telegram
*/
......@@ -914,7 +919,7 @@ class Telegram
throw new TelegramException('No command(s) provided!');
}
$this->run_commands = true;
$this->run_commands = true;
$this->botan_enabled = false; // Force disable Botan.io integration, we don't want to track self-executed commands!
$result = Request::getMe()->getResult();
......@@ -943,8 +948,8 @@ class Telegram
],
'date' => time(),
'chat' => [
'id' => $bot_id,
'type' => 'private',
'id' => $bot_id,
'type' => 'private',
],
'text' => $command,
],
......
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