Ejemplo n.º 1
0
 /**
  * Application constructor.
  * @param $argv array CLI arguments
  */
 public function __construct($argv)
 {
     $this->config = new Config(new Parser(), new FileLoader());
     $this->argParser = new ArgvParser($argv);
     $configFile = $this->argParser->get('config');
     if (file_exists($configFile) && is_readable($configFile)) {
         $this->config->loadData($configFile);
     }
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pidFile = $this->config->getEntry($this->config->getEntry('server.pidfile'));
     if (file_exists($pidFile)) {
         $pid = file_get_contents($pidFile);
         if (Posix::isPidActive($pid)) {
             echo 'Slackbot server is running';
         } else {
             echo 'Slackbot server is not running';
         }
     } else {
         echo 'Slackbot server is not running';
     }
 }
Ejemplo n.º 3
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $pidFile = $this->config->getEntry($this->config->getEntry('server.rtmpidfile'));
     if (file_exists($pidFile)) {
         $pid = file_get_contents($pidFile);
         if (Posix::isPidActive($pid)) {
             posix_kill($pid, SIGINT);
             echo 'RTM listener stopped';
         } else {
             echo 'RTM listener is not running';
         }
         unlink($pidFile);
     } else {
         echo 'RTM listener is not running';
     }
 }
 /**
  * @param RequestHandlerInterface $handler
  * @param RequestDto $dto
  * @return bool
  */
 public function shouldExecute(RequestHandlerInterface $handler, RequestDto $dto)
 {
     $section = $this->config->getSection('custom');
     if (empty($section)) {
         return true;
     }
     $dtoChannel = $dto->getChannel();
     if (null === $dtoChannel) {
         return true;
     }
     $handlerId = $handler->getId();
     $handlerConfig = $this->config->getEntry('custom.' . $handlerId);
     if (empty($handlerConfig)) {
         return false;
     }
     $dtoChannelType = $dtoChannel[0];
     if ('D' === $dtoChannelType) {
         return Ar::get($handlerConfig, 'dm') ?: true;
     }
     if ('C' === $dtoChannelType) {
         $dtoChannelInfo = $this->slackApi->channelsInfo($dtoChannel);
         $dtoChannelName = '#' . Ar::get($dtoChannelInfo, 'channel.name');
     } else {
         $dtoChannelInfo = $this->slackApi->groupsInfo($dtoChannel);
         $dtoChannelName = Ar::get($dtoChannelInfo, 'group.name');
     }
     $defaultBehavior = $this->config->getEntry('custom.' . $handlerId . '.default');
     $handlerChannels = $this->config->getEntry('custom.' . $handlerId . '.channels');
     if (empty($handlerChannels)) {
         return 'allow' === $defaultBehavior ? true : false;
     }
     $handlerChannelConfig = $this->config->getSectionFromArray('custom.' . $handlerId . '.channels', 'name=' . $dtoChannelName);
     if (empty($handlerChannelConfig)) {
         return 'allow' === $defaultBehavior ? true : false;
     }
     $this->params = Ar::get($handlerChannelConfig, 'params') ?: [];
     return true;
 }
Ejemplo n.º 5
0
 /**
  * @return string
  */
 private function getServerUrl()
 {
     $host = $this->config->getEntry('server.host') ?: 'localhost';
     $port = $this->config->getEntry('server.port') ?: '8888';
     return sprintf('http://%s:%s/process/message/', $host, $port);
 }
Ejemplo n.º 6
0
 /** @test */
 public function shouldReturnFalseOnNonExistentSectionEntry()
 {
     $config = new Config($this->parserMock, $this->loader);
     $config->loadData('tests/data/config-test.yml');
     $this->assertEquals(null, $config->getEntry('non-existent-section.path'));
 }