Add custom_input for getUpdates method.

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