Пример #1
0
 /**
  * @param MessageReceivedEvent $event
  */
 public function handleMessageEvent(MessageReceivedEvent $event)
 {
     $message = $event->getMessage();
     if (strpos($message['text'], 'bot: hi') === 0) {
         $this->client->postMessage(['channel' => $event->getChannel(), 'text' => 'Hi <@' . $message['user'] . '>']);
     }
 }
Пример #2
0
 /**
  * @param $event
  */
 public function handleMessageEvent(MessageReceivedEvent $event)
 {
     $message = $event->getMessage();
     $date = new DateTime();
     if (isset($message['ts'])) {
         $date->setTimeStamp($message['ts']);
     }
     $username = isset($message['user_id']) ? $this->userService->getUserName($message['user_id']) : '*** me ***';
     $text = '[' . $date->format('Y-m-d H:i:s') . '] ' . '[' . $username . '] ' . $message['text'];
     $this->logger->info($text);
 }