Ejemplo n.º 1
0
 function it_sends_room_notification(Client $client, Message $message)
 {
     $request = array("color" => "gray", "message" => "This is a test!!", 'notify' => false, 'message_format' => 'html');
     $message->toJson()->shouldBeCalled()->willReturn($request);
     $client->post("/v2/room/123456/notification", $request)->shouldBeCalled();
     $this->sendRoomNotification(123456, $message);
 }
Ejemplo n.º 2
0
 /**
  * send a message to a room
  * @param  string $room
  * @param  string $content
  * @return null
  */
 public function sendRoomMessage($room = null, $content = null)
 {
     $client = $this->setupClient();
     $roomApi = new RoomAPI($client);
     $message = new Message();
     if ($room !== null && $content !== null) {
         $message->setMessage($content);
         $message->setColor('green');
         $message->setNotify(true);
         $roomApi->sendRoomNotification($room, $message);
     }
 }
Ejemplo n.º 3
0
 /**
  * Method which actually sends a message to Gitter
  * @param  Message $message
  * @return void
  */
 public function send($message)
 {
     $color = 'gray';
     if ($message->getColor() !== null) {
         $color = $this->parseColor($message->getColor());
     }
     $content = $message->getMessage();
     if ($message->getAuthor() !== null) {
         $content = '@' . $message->getAuthor()->username . ' ' . $content;
     }
     $content = $this->parseLinksInMessage($content, $message->getLinksToParse());
     $this->message->setColor($color);
     $this->message->setNotify(true);
     $this->message->setMessage($content);
     $this->api->sendRoomNotification($this->settings->get('notify.hipchat.room'), $this->message);
 }
Ejemplo n.º 4
0
 /**
  * Send a room a notification
  * More info: https://www.hipchat.com/docs/apiv2/method/send_room_notification
  *
  * @param string $id The id or name of the room
  * @param Message $message The message to be sent
  *
  * @return void
  */
 public function sendRoomNotification($id, Message $message)
 {
     $this->client->post("/v2/room/{$id}/notification", $message->toJson());
 }
Ejemplo n.º 5
0
 /**
  * @param Client             $client
  * @param MessageInterface   $message
  * @param RecipientInterface $recipient
  */
 private function sendRoomNotification(Client $client, MessageInterface $message, RecipientInterface $recipient)
 {
     $hcMessage = new Message();
     $hcMessage->setMessage($message->hipchat_message);
     $hcMessage->setColor(isset($message->hipchat_color) ? $message->hipchat_color : $this->getMessageColor());
     $hcMessage->setMessageFormat(isset($message->hipchat_format) ? $message->hipchat_format : $this->getMessageFormat());
     $hcMessage->setNotify(isset($message->hipchat_notify) ? $message->hipchat_notify : $this->getMessageNotify());
     $roomApi = new RoomAPI($client);
     $roomApi->sendRoomNotification($recipient->hipchat_room, $hcMessage);
 }