我如何分享一条消息 URL 以与 Slack 相同的方式呈现预览?
How might I share a message URL that renders a preview the same way Slack does?
我想在 post 消息中包含 Slack 消息 URLs(如果可能的话,使用块),其呈现方式与 Slack 呈现的方式相同留言URL; "Posted in #channel | Dec 11th | View message",等等
我尝试使用 Block Builder Kit 对此进行测试。 Slack 会将此 URL 呈现为纯文本(我想这很明显),但 verbatim: false
不是 plain_text
的选项。我的选择似乎有限,我想知道我是否忽略了另一种方法来做到这一点?
{
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": "https://mycompany.com/archives/C0H0DMAEB/p1576068001171300"
}
}
]
}
我的意思是显示 Block Builder 与 URL 粘贴的示例:https://imgur.com/a/ThIuxrk
任何指导将不胜感激。
然后您需要避免使用块,因为基于文本的链接不会自动展开。你需要在 chat.postMessage
中传递 "unfurl_links": true
所以如果你使用 Python 的 slackclient 就像我的情况一样它会如下
response = client.chat_postMessage(
channel=channel_id,
text='<https://mycompany.com/archives/C0H0DMAEB/p1576068001171300>',
unfurl_links = True,
)
assert response["ok"]
您还可以指示 slack 在遇到消息中的链接时如何表现查找更多详细信息here
我想在 post 消息中包含 Slack 消息 URLs(如果可能的话,使用块),其呈现方式与 Slack 呈现的方式相同留言URL; "Posted in #channel | Dec 11th | View message",等等
我尝试使用 Block Builder Kit 对此进行测试。 Slack 会将此 URL 呈现为纯文本(我想这很明显),但 verbatim: false
不是 plain_text
的选项。我的选择似乎有限,我想知道我是否忽略了另一种方法来做到这一点?
{
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": "https://mycompany.com/archives/C0H0DMAEB/p1576068001171300"
}
}
]
}
我的意思是显示 Block Builder 与 URL 粘贴的示例:https://imgur.com/a/ThIuxrk
任何指导将不胜感激。
然后您需要避免使用块,因为基于文本的链接不会自动展开。你需要在 chat.postMessage
中传递 "unfurl_links": true
所以如果你使用 Python 的 slackclient 就像我的情况一样它会如下
response = client.chat_postMessage(
channel=channel_id,
text='<https://mycompany.com/archives/C0H0DMAEB/p1576068001171300>',
unfurl_links = True,
)
assert response["ok"]
您还可以指示 slack 在遇到消息中的链接时如何表现查找更多详细信息here