コード例 #1
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 public function processAction(ActionDto $dto)
 {
     $this->dtoData = $dto->getData();
     $recipient = $dto->get('recipient');
     $this->recipientId = $this->slackFacade->getUserIdByName(str_replace('@', '', $recipient));
     $messages = $dto->get('messages');
     // 1. Send "before" message
     $beforeMessage = Ar::get($messages, 'before');
     if (null !== $beforeMessage) {
         $this->slackFacade->getSlackApi()->chatPostMessage($this->recipientId, $beforeMessage);
     }
     // 2. Register timed message handler
     $this->handlerId = uniqid();
     $start = time();
     $finish = $start + $this->getTimeoutSize($dto->get('timeout'));
     $this->coreProcessor->addTimedMessageHandler($this->handlerId, [$this, 'checker'], [$this, 'handler'], $start, $finish);
 }
コード例 #2
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 public function processAction(ActionDto $dto)
 {
     $recipients = preg_split('/\\s*,\\s*/', $dto->get('recipients'));
     if (0 === count($recipients)) {
         return;
     }
     $recipientIds = [];
     foreach ($recipients as $recipient) {
         if ($recipient !== null) {
             $recipientIds[] = $this->slackFacade->getRecipientIdByName($recipient);
         }
     }
     if (0 === count($recipientIds)) {
         return;
     }
     $message = $dto->getMessage();
     $message = $this->substituteVariables($message);
     $dto->setData(array_merge($dto->getData(), ['message' => $message]));
     $this->outputManager->sendMessage($dto);
 }