jclg / php-slack-bot

Slack bot user written in PHP
MIT License
169 stars 61 forks source link

Sending links #21

Open kpaxman opened 7 years ago

kpaxman commented 7 years ago

In theory, I should be able to send links using the format <http://example.com|Name of site> which is supposed to turn into a hyperlink with my chosen text to the provided URL. (See https://api.slack.com/docs/message-formatting - which is linked from the RTM API docs page under "formatting messages".)

In practice, this is displaying exactly as is. It seems that the string is getting encoded somewhere (e.g. < becomes &lt;), but I can't for the life of me find what's doing this in your source. Any tips on tracking this down and/or bypassing it?

jclg commented 7 years ago

Yes, there is a problem with the documentation about this. Please see https://github.com/slackhq/slack-api-docs/issues/32

You can only use http://example.com to send a link with RTM.

In https://api.slack.com/rtm

The RTM API only supports posting simple messages formatted using our default message formatting mode. It does not support attachments or other message formatting modes. To post a more complex message as a user clients can call the chat.postMessage Web API method with as_user set to true.

So I think you can bypass this by using the chat.postMessage Web API in order to format your message properly.

kpaxman commented 7 years ago

What would I have to do to use the chat.postMessage Web API within your application? Or would this mean looking elsewhere?