Python - 在 Python 中发送列表介绍 Slack 消息格式
Python - Send a list intro Slack message formatting in Python
所以我一直在研究 python 和 Discord 的带有 Slacks 消息格式的 webhook,可以在这里找到:Slack message formatting
但是我想要做的是有一个乘法 URL 可以发送到类似的松弛:
现在,当我将所有 URL 添加到列表中并尝试将其应用于格式等时:
{
"username": "Google website",
"attachments": [
{
"author_name": "Google",
"color": "#00ff00",
"text": "^Press the link above!",
"title": "www.google.se",
"title_link": URLLIST
}
]
}
它告诉我 "Must be str, not a list"
我一直坚持这个,因为没有关于这个的很好的文档,任何人都知道如何做到这一点?
我猜你遇到了错误,因为你的 URLLIST
不是字符串。
这里有两个可行的解决方案:
要么你做多个附件,每个附件都是一个link。那么 title_link
必须是 URL 字符串,而不是列表。
示例:
{
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/"
},
{
"fallback": "Required plain-text summary of the attachment.",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/"
},
{
"fallback": "Required plain-text summary of the attachment.",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/"
}
]
}
或者您只是将 URL 列表分解为文本字符串(我会这样做)。那么你甚至不需要附件。
示例:
{
"text": "<https://www.google.com|8>\n<https://www.google.com|9>\n<https://www.google.com|10>\n"
}
所以我一直在研究 python 和 Discord 的带有 Slacks 消息格式的 webhook,可以在这里找到:Slack message formatting
但是我想要做的是有一个乘法 URL 可以发送到类似的松弛:
现在,当我将所有 URL 添加到列表中并尝试将其应用于格式等时:
{
"username": "Google website",
"attachments": [
{
"author_name": "Google",
"color": "#00ff00",
"text": "^Press the link above!",
"title": "www.google.se",
"title_link": URLLIST
}
]
}
它告诉我 "Must be str, not a list"
我一直坚持这个,因为没有关于这个的很好的文档,任何人都知道如何做到这一点?
我猜你遇到了错误,因为你的 URLLIST
不是字符串。
这里有两个可行的解决方案:
要么你做多个附件,每个附件都是一个link。那么 title_link
必须是 URL 字符串,而不是列表。
示例:
{
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/"
},
{
"fallback": "Required plain-text summary of the attachment.",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/"
},
{
"fallback": "Required plain-text summary of the attachment.",
"title": "Slack API Documentation",
"title_link": "https://api.slack.com/"
}
]
}
或者您只是将 URL 列表分解为文本字符串(我会这样做)。那么你甚至不需要附件。
示例:
{
"text": "<https://www.google.com|8>\n<https://www.google.com|9>\n<https://www.google.com|10>\n"
}