Commit 7a34308d authored by Jack'lul's avatar Jack'lul

Require an optional parameter to work without a database

parent 80a67904
...@@ -318,16 +318,27 @@ class Telegram ...@@ -318,16 +318,27 @@ class Telegram
* *
* @param int|null $limit * @param int|null $limit
* @param int|null $timeout * @param int|null $timeout
* @param bool $no_database
* *
* @return \Longman\TelegramBot\Entities\ServerResponse * @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function handleGetUpdates($limit = null, $timeout = null) public function handleGetUpdates($limit = null, $timeout = null, $no_database = false)
{ {
if (empty($this->bot_username)) { if (empty($this->bot_username)) {
throw new TelegramException('Bot Username is not defined!'); throw new TelegramException('Bot Username is not defined!');
} }
if (!DB::isDbConnected() && !$no_database) {
return new ServerResponse(
[
'ok' => false,
'description' => 'getUpdates needs MySQL connection!',
],
$this->bot_username
);
}
//Take custom input into account. //Take custom input into account.
if ($custom_input = $this->getCustomInput()) { if ($custom_input = $this->getCustomInput()) {
$response = new ServerResponse(json_decode($custom_input, true), $this->bot_username); $response = new ServerResponse(json_decode($custom_input, true), $this->bot_username);
......
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