slack - How might I share a message URL that renders a preview the same way Slack does?
问题描述
I'd like to include Slack message URLs in a post message (using blocks, if at all possible) in such a way that it's rendered the same way Slack would render the message URL; "Posted in #channel | Dec 11th | View message", etc.
I've tried using the Block Builder Kit to test this out. Slack will render this URL as plain text (which I guess is obvious), but verbatim: false
isn't an option for plain_text
. My options seem limited and I'm wondering if maybe I'm overlooking an alternative way to do this?
{
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": "https://mycompany.com/archives/C0H0DMAEB/p1576068001171300"
}
}
]
}
Example of what I mean showing Block Builder vs. URL paste: https://imgur.com/a/ThIuxrk
Any guidance would be greatly appreciated.
解决方案
然后你需要避免使用块,因为基于文本的链接不会自动展开。"unfurl_links": true
如果您使用 Python的chat.postMessage
slackclient,您需要传入
response = client.chat_postMessage(
channel=channel_id,
text='<https://mycompany.com/archives/C0H0DMAEB/p1576068001171300>',
unfurl_links = True,
)
assert response["ok"]
您还可以指示在遇到消息中的链接时松弛如何表现,在此处找到更多详细信息
推荐阅读
- django - 照片未在 django html 中显示
- plugins - 如何在 Aurelia 中添加插件
- php - PHP/MySQL:在一个事件上获得多个插入
- ruby-on-rails - Cloudinary 使用“未初始化的常量 Cloudinary”打破 RSpec 测试
- spartacus-storefront - 如何正确覆盖默认的 spartacus 组件
- google-sheets - 如果选中复选框,则突出显示列的公式 - Google 表格
- powershell - Powershell 不会在电子邮件 html 正文中输出“£”
- scala - Apache Spark根据列的不同值计算列值
- gcc - 用于堆栈与堆访问的 gcc 程序集
- android - RecyclerView 仅显示两个文本视图?其他不显示...项目不显示