Commit fe721e02 authored by Jack'lul's avatar Jack'lul

Require user to manually enable non-DB mode using seperated method

parent 7a34308d
......@@ -137,6 +137,13 @@ class Telegram
*/
protected $run_commands = false;
/**
* Is running getUpdates without DB enabled
*
* @var bool
*/
protected $getupdates_without_database = false;
/**
* Last update ID
* Only used when running getUpdates without a database
......@@ -318,22 +325,21 @@ class Telegram
*
* @param int|null $limit
* @param int|null $timeout
* @param bool $no_database
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function handleGetUpdates($limit = null, $timeout = null, $no_database = false)
public function handleGetUpdates($limit = null, $timeout = null)
{
if (empty($this->bot_username)) {
throw new TelegramException('Bot Username is not defined!');
}
if (!DB::isDbConnected() && !$no_database) {
if (!DB::isDbConnected() && !$this->getupdates_without_database) {
return new ServerResponse(
[
'ok' => false,
'description' => 'getUpdates needs MySQL connection!',
'description' => 'getUpdates needs MySQL connection! (This can be overridden - see documentation)',
],
$this->bot_username
);
......@@ -984,4 +990,14 @@ class Telegram
{
return $this->run_commands;
}
/**
* Switch to enable running getUpdates without a database
*
* @param bool $enable
*/
public function useGetUpdatesWithoutDatabase($enable = true)
{
$this->getupdates_without_database = $enable;
}
}
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