Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Is it possible to put url in the message? #27

Open
walva opened this issue May 10, 2017 · 4 comments
Open

Is it possible to put url in the message? #27

walva opened this issue May 10, 2017 · 4 comments
Assignees

Comments

@walva
Copy link

walva commented May 10, 2017

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!

@DZunke
Copy link
Owner

DZunke commented May 12, 2017

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

@DZunke DZunke self-assigned this May 12, 2017
@DZunke
Copy link
Owner

DZunke commented May 12, 2017

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,
    ]
);

image

@walva
Copy link
Author

walva commented May 12, 2017

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).

@DZunke
Copy link
Owner

DZunke commented May 12, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants