Python-用Python发送列表介绍松弛消息格式
因此,我一直在使用python和Discord的webhook,其中包含Slacks消息格式,可以在这里找到: 然而,我试图做的是有一个可以发送到slack的倍增URL,类似于: 现在,当我将所有URL添加到列表并尝试将其应用于格式设置等时:Python-用Python发送列表介绍松弛消息格式,python,slack,slack-api,Python,Slack,Slack Api,因此,我一直在使用python和Discord的webhook,其中包含Slacks消息格式,可以在这里找到: 然而,我试图做的是有一个可以发送到slack的倍增URL,类似于: 现在,当我将所有URL添加到列表并尝试将其应用于格式设置等时: { "username": "Google website", "attachments": [ { "author_name": "Google", "color": "#
{
"username": "Google website",
"attachments": [
{
"author_name": "Google",
"color": "#00ff00",
"text": "^Press the link above!",
"title": "www.google.se",
"title_link": URLLIST
}
]
}
它告诉我“必须是str,而不是列表”
我一直被困在这个问题上,因为没有关于这个问题的很好的文档,任何人都知道怎么做?我猜你会出错,因为你的
urlist
不是一个字符串
以下是两个可行的解决方案:
您可以执行多个附件,其中每个附件都是一个链接。然后title\u 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/"
}
]
}
{
"text": "<https://www.google.com|8>\n<https://www.google.com|9>\n<https://www.google.com|10>\n"
}
或者将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/"
}
]
}
{
"text": "<https://www.google.com|8>\n<https://www.google.com|9>\n<https://www.google.com|10>\n"
}
{
“文本”:“\n\n\n”
}