如何让SLACK API BLOCK套件占据整个SLACK窗口的宽度?套件、宽度、窗口、SLACK

2023-09-03 13:28:29 作者:离癸

我正在为一些自动通知创建一个Slackbot,我收到了一个请求,要让通知占据整个松弛窗口的宽度,这样看起来干净多了。我发现似乎有一个特定的宽度,积木似乎占据,并不会水平延伸超过该点。我想知道是否有解决办法来删除似乎正在发生的最大宽度

Current implementation: Seems to have a maximum width that isn't specified

如何用 Python 打造一个简单的聊天机器人

Ideally it would end up looking like this

我使用类似以下内容作为格式化块:

{
    "type": "section",
    "text": {
        "type": "mrkdwn",
        "text": "Testing if a longer message will force the update box to be wider Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
    },
    "accessory": {
        "type": "button",
        "text": {
            "type": "plain_text",
            "text": "Button",
            "emoji": true
        },
        "value": "click_me_123"
    }
}

这是数据块工具包/SLACK API的限制吗?或者有什么方法可以取消此宽度限制吗?

Block Kit Builder site if anyone wants to play with formatting

推荐答案

松弛似乎有一种称为rich_text的块类型,该类型没有特别详细的文档记录,它确实填满了松弛消息面板的宽度。

{
  "blocks": [
    {
      "type": "rich_text",
      "elements": [
        {
          "type": "rich_text_preformatted",
          "elements": [
            {
              "type": "text",
              "text": "+---------+---------+---------+---------+---------+---------+---------+---------+

| column1 | column2 | column3 | column4 | column5 | column6 | column7 | column8 |

+---------+---------+---------+---------+---------+---------+---------+---------+

| row1c1  | row1c2  | row1c3  | row1c4  | row1c5  | row1c6  | row1c7  | row1c8  |

+---------+---------+---------+---------+---------+---------+---------+---------+"
            }
          ]
        }
      ]
    }
  ]
}