/** * Send the message. * * The parameters can be `($text, $markdown, $notification)`, and the $text and * the $notification can be `null` that does not modify the exist field. * The parameters can also be * `($text, $attachment_text, $attachment_title, $attachment_images, $attachment_color)`. * * @param mixed * @return bool */ public function send() { if (!$this->client) { return false; } if ($count = func_num_args()) { $firstArg = func_get_arg(0); if (1 === $count && (is_array($firstArg) || is_object($firstArg))) { return $this->client->sendMessage($firstArg); } if (!is_null($firstArg)) { $this->setText($firstArg); } if ($count > 1 && is_bool(func_get_arg(1))) { $this->setMarkdown(func_get_arg(1)); if ($count > 2 && !is_null(func_get_arg(2))) { $this->setNotification(func_get_arg(2)); } } elseif ($count > 1) { call_user_func_array([$this, 'addAttachment'], array_slice(func_get_args(), 1)); } } return $this->client->sendMessage($this); }
/** * Create a new message. * * @param \ElfSundae\BearyChat\Client|null $client */ public function __construct(Client $client = null) { if ($this->client = $client) { $this->configureDefaults($client->getMessageDefaults()); } }