SlackBundle
SlackBundle copied to clipboard
Is it possible to put url in the message?
Hello everyone!
I'm struggling tonight by trying to put a link within the message. I try to follow this documentation and it doesn't work. I thought that it was the HTTP method the problem so I changed GET to POST and I have the same result.
Regarding slack documentation, it shoud work like this.
Here is my code:
$identity = new \DZunke\SlackBundle\Slack\Messaging\Identity();
$identity->setUsername($sender->getFullName());
$identity->setIconUrl($avatar);
$this->slack->send(Actions::ACTION_POST_MESSAGE,
[
'identity' => $identity,
'channel' => "system",
'text' => "HEY <http://google.be|google>",
'icon_url' => $avatar,
'unfurl_links' => 0,
'parse' => 'full',
]);
With also this additional method:
public function send($action, array $parameter = [])
{
try {
if (isset($parameter["channel"]) AND $this->env != "prod") {
$parameter["channel"] = "#debug";
}
$this->originalSlackClient->send($action, $parameter);
} catch (\Exception $e) {
$context = $parameter;
if (isset($context['identity'])) unset($context['identity']);
$this->logger->error("Failed to send message to slack", $context);
}
}
`
And finally here is my configuration:
d_zunke_slack:
token: "ZZZ"
use_http_post: true
identities:
spartan: ~`
Could someone give me an example of message containing link in order to have an example?
Thank you in advance and thanks a lot for this bundle!
Hey,
thanks for the Issue. I can confirm it is not working but i must take a look on it. I can surely say that there is no encoding implemented that could destroy the url.
Greets
Hey,
i am still investigating but it'll work with this code:
$client->send(
\DZunke\SlackBundle\Slack\Client\Actions::ACTION_POST_MESSAGE,
[
'identity' => $identity,
'channel' => '#slack-testing',
'text' => 'HEY <http://google.be|google>',
'parse' => 'none',
'unfurl_links' => 0,
]
);
Thank you for your feedback, I will have a look this weekend. I wonder if there a parameter in my slack account that could disable that (I honestly don't believe in this because other bot are able to push links).
Yeah. I think it is sth. at the slack api that were good in early times but has changed over time. I'd found the same issues on div. slack libraries in ruby, python and hubot.
will have a look again, too.