空白 - 松弛(webhook)

white spaces - slack (webhook)

似乎没有选项 post 一条包含 table 的消息到 slack。我正在尝试使用文本格式构建 table。在下面的示例中,文本未对齐,因为第一行包含文本 ROW1,第二行包含文本 ROW。有没有办法在 ROW 之后添加白色 space 以对齐此文本?

{"text" : "ROW1\t\t\t\tCOL1\nROW\t\t\t\tCOL2"}

一般来说,您可以使用 Slack 的 message builder 来测试消息的呈现。

话虽这么说,但我认为您不能简单地向右 "push" 个空格,您可以使用竖线符号 like this :

"text": "ROW1|\t\t\t\tCOL1\nROW   |\t\t\t\tCOL2"

另一种可能性,稍作改动,就是使用带字段的附件 like this

"attachments": [
        {
            "fields": [
                {
                    "title": "Col1",
                    "value": "text1",
                    "short": true
                },
                {
                    "title": "Col2",
                    "value": "text2",
                    "short": true
                }
            ]
        }
    ]