Is it possible to stop links from unfurling when they're coming from hubot? It can be a bit of a nuisance!
Any thoughts on this?
I'd also love to have this option.
I've asked Slack support about setting this by default for bot users. They thought it was a good idea, but would have impact on existing bots.
Over in https://github.com/slackhq/hubot-slack/pull/236 I've done some changes to make all messages use chat.postMessage. If that's accepted, I could see adding an option to setting unfurl_links to false when posting.
Hi,
I've wrote an ugly patch to disable all media and links unfurling for my hubot slack messages by switching as @technicalpickles from channel.send to @custommessage and then hardcode inside custommessage that all messages have unfurling disabled for media & links.
It's ugly but does the trick while a better solution gets implemented.
--- slack.coffee.backup 2016-03-17 16:59:32.545057497 +0000
+++ slack.coffee 2016-03-17 17:06:48.483552643 +0000
@@ -238,7 +238,7 @@
@robot.logger.debug "Sending to #{envelope.room}: #{msg}"
if msg.length <= SlackBot.MAX_MESSAGE_LENGTH
- channel.send msg
+ @customMessage channel: envelope.room, text: msg
# If message is greater than MAX_MESSAGE_LENGTH, split it into multiple messages
else
@@ -299,6 +299,8 @@
msg.attachments = data.attachments || data.content
msg.attachments = [msg.attachments] unless Array.isArray msg.attachments
+ msg.unfurl_links = false
+ msg.unfurl_media = false
msg.text = data.text
This is on the right path. Going forward in v4, we can add support for unfurl_links and unfurl_media in channel.send so that the right thing happens automatically. @johnagan what do you think?
We really need this. It's aggravating when the link posted is unfurled and takes up more than 50% of vertical view space. Then when you remove the unfurl'ed portion by clicking the X, it marks your URL as _(edited)_....
@nitrocode I believe you can just include unfurl_links: false and/or unfurl_media: false to your message object to prevent this.
Since v4, I believe we can now disable link unfurling on a message by message basis.
message =
text: "http://www.bbc.co.uk/news/business-38359640"
unfurl_links: false
msg.send message
I tested this briefly and it seems to have the desired effect.
EDIT: Looks like @johnagan got there first!
@johnagan @pearswj thanks guys! What I was hoping for was something like a backslash escape command to stop unfurling on a message basis... e.g.
Hey channel, check out this great link \https://hackernoon.com/we-reverse-engineered-16k-apps-heres-what-we-found-51bdf3b456bb#.ngd3kysva
The code provided is still useful because I think I may be able to construct a slack addon that provides a backslash before a url to stop unfurling.
Hi,
to me the right setting is this one:
message =
text: "http://www.bbc.co.uk/news/business-38359640"
unfurl_links: false
unful_media: false
msg.send message
Most helpful comment
@johnagan @pearswj thanks guys! What I was hoping for was something like a backslash escape command to stop unfurling on a message basis... e.g.
The code provided is still useful because I think I may be able to construct a slack addon that provides a backslash before a url to stop unfurling.