Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/daemon/bot/PhabricatorBot.php
Show All 17 Lines | final class PhabricatorBot extends PhabricatorDaemon { | ||||
protected function run() { | protected function run() { | ||||
$argv = $this->getArgv(); | $argv = $this->getArgv(); | ||||
if (count($argv) !== 1) { | if (count($argv) !== 1) { | ||||
throw new Exception('usage: PhabricatorBot <json_config_file>'); | throw new Exception('usage: PhabricatorBot <json_config_file>'); | ||||
} | } | ||||
$json_raw = Filesystem::readFile($argv[0]); | $json_raw = Filesystem::readFile($argv[0]); | ||||
$config = json_decode($json_raw, true); | try { | ||||
if (!is_array($config)) { | $config = phutil_json_decode($json_raw); | ||||
throw new Exception("File '{$argv[0]}' is not valid JSON!"); | } catch (PhutilJSONParserException $ex) { | ||||
throw new PhutilProxyException( | |||||
pht("File '%s' is not valid JSON!", $argv[0]), | |||||
$ex); | |||||
} | } | ||||
$nick = idx($config, 'nick', 'phabot'); | $nick = idx($config, 'nick', 'phabot'); | ||||
$handlers = idx($config, 'handlers', array()); | $handlers = idx($config, 'handlers', array()); | ||||
$protocol_adapter_class = idx( | $protocol_adapter_class = idx( | ||||
$config, | $config, | ||||
'protocol-adapter', | 'protocol-adapter', | ||||
'PhabricatorIRCProtocolAdapter'); | 'PhabricatorIRCProtocolAdapter'); | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |