diff --git a/src/infrastructure/daemon/bot/adapter/PhabricatorBaseProtocolAdapter.php b/src/infrastructure/daemon/bot/adapter/PhabricatorBaseProtocolAdapter.php index 55cb90ebd1..3d7c980f26 100644 --- a/src/infrastructure/daemon/bot/adapter/PhabricatorBaseProtocolAdapter.php +++ b/src/infrastructure/daemon/bot/adapter/PhabricatorBaseProtocolAdapter.php @@ -4,13 +4,18 @@ * Defines the api for protocol adapters for @{class:PhabricatorBot} */ abstract class PhabricatorBaseProtocolAdapter { - protected $config; + + private $config; public function setConfig($config) { $this->config = $config; return $this; } + public function getConfig($key, $default = null) { + return idx($this->config, $key, $default); + } + /** * Performs any connection logic necessary for the protocol */ diff --git a/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php b/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php index b2e88e2c63..b567a42d1f 100644 --- a/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php +++ b/src/infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php @@ -1,7 +1,7 @@ server = idx($this->config, 'server'); - $this->authtoken = idx($this->config, 'authtoken'); - $ssl = idx($this->config, 'ssl', false); - $rooms = idx($this->config, 'join'); + $this->server = $this->getConfig('server'); + $this->authtoken = $this->getConfig('authtoken'); + $ssl = $this->getConfig('ssl', false); + $rooms = $this->getConfig('join'); // First, join the room if (!$rooms) { diff --git a/src/infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php b/src/infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php index f2d34db246..2d799ed4cd 100644 --- a/src/infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php +++ b/src/infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php @@ -1,7 +1,7 @@ 'MESSAGE'); public function connect() { - $nick = idx($this->config, 'nick', 'phabot'); - $server = idx($this->config, 'server'); - $port = idx($this->config, 'port', 6667); - $pass = idx($this->config, 'pass'); - $ssl = idx($this->config, 'ssl', false); - $user = idx($this->config, 'user', $nick); + $nick = $this->getConfig('nick', 'phabot'); + $server = $this->getConfig('server'); + $port = $this->getConfig('port', 6667); + $pass = $this->getConfig('pass'); + $ssl = $this->getConfig('ssl', false); + $user = $this->getConfig('user', $nick); if (!preg_match('/^[A-Za-z0-9_`[{}^|\]\\-]+$/', $nick)) { throw new Exception( diff --git a/src/infrastructure/daemon/bot/handler/PhabricatorBotHandler.php b/src/infrastructure/daemon/bot/handler/PhabricatorBotHandler.php index bf32d01cb6..025cc51a1e 100644 --- a/src/infrastructure/daemon/bot/handler/PhabricatorBotHandler.php +++ b/src/infrastructure/daemon/bot/handler/PhabricatorBotHandler.php @@ -39,7 +39,7 @@ abstract class PhabricatorBotHandler { return; } - public function replyTo($original_message, $body) { + public function replyTo(PhabricatorBotMessage $original_message, $body) { if ($original_message->getCommand() != 'MESSAGE') { throw new Exception( "Handler is trying to reply to something which is not a message!");