问题描述
背景
我正在尝试使用 slack bolt jdk 以及以下依赖项:
// Slack bolt SDK
implementation("com.slack.api:bolt:1.8.1")
implementation("com.slack.api:bolt-servlet:1.8.1")
implementation("com.slack.api:bolt-jetty:1.8.1")
implementation("com.slack.api:slack-api-model-kotlin-extension:1.8.1")
implementation("com.slack.api:slack-api-client-kotlin-extension:1.8.1")
我想要达到的目标(在 slack 中)
我目前得到的(松弛)
到目前为止我尝试过的
fun SlashCommandContext.sendSectionAndAck(
message: String,): Response {
slack.methods(bottoken).chatPostMessage { req ->
req
.channel(channelId)
.blocks {
section {
markdownText(message)
}
}
}
return ack()
}
似乎 Markdown 的格式几乎正确。页眉和页脚都按预期加粗,但由于某种原因,项目符号列表的格式不正确。我也试过用 *
替换 -
没有任何运气。
val input = """
*Some header text in bold*
- item
- another item
*Some footer text also in bold*
"""
sendSectionAndAck(input)
我做错了什么?
解决方法
最简单的解决方法是在文本中使用'•'字符本身。
Slack 还使用以下作为块套件消息的一部分来反映要点:
"text": "• test","blocks": [
{
"type": "rich_text","block_id": "erY","elements": [
{
"type": "rich_text_list","elements": [
{
"type": "rich_text_section","elements": [
{
"type": "text","text": "test"
}
]
}
],"style": "bullet","indent": 0
}
]
}
另一个参考:
https://superuser.com/questions/1282510/how-do-i-make-a-bullet-point-in-a-slack-message