PHP Class Maknz\Slack\Message

Datei anzeigen Open project: maknz/slack Class Usage Examples

Protected Properties

Property Type Description
$allow_markdown boolean Whether the message text should be interpreted in Slack's Markdown-like language.
$attachments array An array of attachments to send.
$channel string The channel the message should be sent to.
$client Client Reference to the Slack client responsible for sending the message.
$icon string The URL to the icon to use.
$iconType enum The type of icon we are using.
$markdown_in_attachments array The attachment fields which should be formatted with Slack's Markdown-like language.
$text string The text to send with the message.
$username string The username the message should be sent as.

Public Methods

Method Description
__construct ( Client $client ) : void Instantiate a new Message.
attach ( mixed $attachment ) Add an attachment to the message.
clearAttachments ( ) Remove all attachments for the message.
disableMarkdown ( ) : void Disable Markdown formatting for the message.
enableMarkdown ( ) : void Enable Markdown formatting for the message.
from ( string $username ) Change the name of the user the post will be made as.
getAllowMarkdown ( ) : boolean Get whether message text should be formatted with Slack's Markdown-like language.
getAttachments ( ) : array Get the attachments for the message.
getChannel ( ) : string Get the channel we will post to.
getIcon ( ) : string Get the icon (either URL or emoji) we will post as.
getIconType ( ) : string Get the icon type being used, if an icon is set.
getMarkdownInAttachments ( ) : array Get the attachment fields which should be formatted in Slack's Markdown-like language.
getText ( ) : string Get the message text.
getUsername ( ) : string Get the username we will post as.
send ( string $text = null ) : void Send the message.
setAllowMarkdown ( boolean $value ) : void Set whether message text should be formatted with Slack's Markdown-like language.
setAttachments ( array $attachments ) Set the attachments for the message.
setChannel ( string $channel ) Set the channel we will post to.
setIcon ( string $icon ) Set the icon (either URL or emoji) we will post as.
setMarkdownInAttachments ( array $fields ) : void Set the attachment fields which should be formatted in Slack's Markdown-like language.
setText ( string $text ) Set the message text.
setUsername ( string $username ) Set the username we will post as.
to ( string $channel ) Change the channel the post will be made to.
withIcon ( string $icon ) Chainable method for setting the icon.

Method Details

__construct() public method

Instantiate a new Message.
public __construct ( Client $client ) : void
$client Client
return void

attach() public method

Add an attachment to the message.
public attach ( mixed $attachment )
$attachment mixed

clearAttachments() public method

Remove all attachments for the message.
public clearAttachments ( )

disableMarkdown() public method

Disable Markdown formatting for the message.
public disableMarkdown ( ) : void
return void

enableMarkdown() public method

Enable Markdown formatting for the message.
public enableMarkdown ( ) : void
return void

from() public method

Change the name of the user the post will be made as.
public from ( string $username )
$username string

getAllowMarkdown() public method

Get whether message text should be formatted with Slack's Markdown-like language.
public getAllowMarkdown ( ) : boolean
return boolean

getAttachments() public method

Get the attachments for the message.
public getAttachments ( ) : array
return array

getChannel() public method

Get the channel we will post to.
public getChannel ( ) : string
return string

getIcon() public method

Get the icon (either URL or emoji) we will post as.
public getIcon ( ) : string
return string

getIconType() public method

Get the icon type being used, if an icon is set.
public getIconType ( ) : string
return string

getMarkdownInAttachments() public method

Get the attachment fields which should be formatted in Slack's Markdown-like language.
public getMarkdownInAttachments ( ) : array
return array

getText() public method

Get the message text.
public getText ( ) : string
return string

getUsername() public method

Get the username we will post as.
public getUsername ( ) : string
return string

send() public method

Send the message.
public send ( string $text = null ) : void
$text string The text to send
return void

setAllowMarkdown() public method

Set whether message text should be formatted with Slack's Markdown-like language.
public setAllowMarkdown ( boolean $value ) : void
$value boolean
return void

setAttachments() public method

Set the attachments for the message.
public setAttachments ( array $attachments )
$attachments array

setChannel() public method

Set the channel we will post to.
public setChannel ( string $channel )
$channel string

setIcon() public method

Set the icon (either URL or emoji) we will post as.
public setIcon ( string $icon )
$icon string

setMarkdownInAttachments() public method

Set the attachment fields which should be formatted in Slack's Markdown-like language.
public setMarkdownInAttachments ( array $fields ) : void
$fields array
return void

setText() public method

Set the message text.
public setText ( string $text )
$text string

setUsername() public method

Set the username we will post as.
public setUsername ( string $username )
$username string

to() public method

Change the channel the post will be made to.
public to ( string $channel )
$channel string

withIcon() public method

Chainable method for setting the icon.
public withIcon ( string $icon )
$icon string

Property Details

$allow_markdown protected_oe property

Whether the message text should be interpreted in Slack's Markdown-like language.
protected bool $allow_markdown
return boolean

$attachments protected_oe property

An array of attachments to send.
protected array $attachments
return array

$channel protected_oe property

The channel the message should be sent to.
protected string $channel
return string

$client protected_oe property

Reference to the Slack client responsible for sending the message.
protected Client,Maknz\Slack $client
return Client

$icon protected_oe property

The URL to the icon to use.
protected string $icon
return string

$iconType protected_oe property

The type of icon we are using.
protected enum $iconType
return enum

$markdown_in_attachments protected_oe property

The attachment fields which should be formatted with Slack's Markdown-like language.
protected array $markdown_in_attachments
return array

$text protected_oe property

The text to send with the message.
protected string $text
return string

$username protected_oe property

The username the message should be sent as.
protected string $username
return string