Overview
  • Namespace
  • Class

Namespaces

  • Slack
    • Message

Classes

  • Slack\ApiClient
  • Slack\Bot
  • Slack\Channel
  • Slack\ClientObject
  • Slack\DataObject
  • Slack\DirectMessageChannel
  • Slack\Group
  • Slack\Message\Attachment
  • Slack\Message\AttachmentBuilder
  • Slack\Message\AttachmentField
  • Slack\Message\Message
  • Slack\Message\MessageBuilder
  • Slack\Payload
  • Slack\RealTimeClient
  • Slack\Team
  • Slack\User

Interfaces

  • Slack\ChannelInterface
  • Slack\Exception

Exceptions

  • Slack\ApiException
  • Slack\ConnectionException
  • Slack\UserNotFoundException
 1 <?php
 2 namespace Slack\Message;
 3 
 4 use Slack\ClientObject;
 5 
 6 /**
 7  * Represents a chat message and its data.
 8  */
 9 class Message extends ClientObject
10 {
11     /**
12      * Gets the message text.
13      *
14      * @return string
15      */
16     public function getText()
17     {
18         return $this->data['text'];
19     }
20 
21     /**
22      * Checks if Markdown is enabled for the message text.
23      *
24      * @return bool
25      */
26     public function isMarkdownEnabled()
27     {
28         return isset($this->data['mrkdwn']) ? $this->data['mrkdwn'] == true : true;
29     }
30 
31     /**
32      * Checks if the message has attachments.
33      *
34      * @return bool True if the message has attachments, otherwise false.
35      */
36     public function hasAttachments()
37     {
38         return isset($this->data['attachments']) && count($this->data['attachments']) > 0;
39     }
40 
41     /**
42      * Gets all message attachments.
43      *
44      * @return Attachment[]
45      */
46     public function getAttachments()
47     {
48         return isset($this->data['attachments']) ? $this->data['attachments'] : [];
49     }
50 
51     /**
52      * Gets the channel the message is in.
53      *
54      * @return \React\Promise\PromiseInterface
55      */
56     public function getChannel()
57     {
58         return $this->client->getChannelById($this->data['channel']);
59     }
60 
61     /**
62      * Gets the user that sent the message.
63      *
64      * @return \React\Promise\PromiseInterface
65      */
66     public function getUser()
67     {
68         return $this->client->getUserById($this->data['user']);
69     }
70 
71     /**
72      * {@inheritDoc}
73      */
74     public function jsonUnserialize(array $data)
75     {
76         if (!isset($this->data['attachments'])) {
77             return;
78         }
79 
80         for ($i = 0; $i < count($this->data['attachments']); $i++) {
81             $this->data['attachments'][$i] = Attachment::fromData($this->data['attachments'][$i]);
82         }
83     }
84 }
85 
API documentation generated by ApiGen