Commit 4fbb6a56 authored by Armando Lüscher's avatar Armando Lüscher

Add failsafe if Generic command can't be found, to prevent an infinite loop.

Set default log verbosity on object creation to prevent potentially overwriting the value when calling setLogRequests().
parent d2c1fffd
......@@ -100,7 +100,7 @@ class Telegram
*
* @var int
*/
protected $log_verbosity;
protected $log_verbosity = 1;
/**
* MySQL integration
......@@ -260,8 +260,6 @@ class Telegram
public function setLogRequests($log_requests)
{
$this->log_requests = $log_requests;
//Set default log verbosity
$this->log_verbosity = 1;
return $this;
}
......@@ -485,6 +483,11 @@ class Telegram
$command_obj = $this->getCommandObject($command);
if (!$command_obj || !$command_obj->isEnabled()) {
//Failsafe in case the Generic command can't be found
if ($command === 'Generic') {
throw new TelegramException('Generic command missing!');
}
//Handle a generic command or non existing one
$this->last_command_response = $this->executeCommand('Generic');
} else {
......
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