【发布时间】:2019-10-22 13:57:16
【问题描述】:
我目前正在开发一个简单的 slack 机器人,它将每天发布一条消息,其中包含如下所示的文本列表。
问题是列表中第二项的新行不是我添加的。就像机器人的消息以 XX 字符为上限。如果我复制机器人发送的消息并在频道中发送相同的消息,效果很好,那么就没有像下面的示例那样添加换行符。
有人知道为什么会这样吗?
机器人的消息:
• 1 day This is a rather short message
• 1 day This is a longer message that will automatically get cut
when I reach some unknown length.
• 4 days This is working due to it is a short message.
如果我复制机器人发送的文本并在同一频道中发送:
• 1 day This is a rather short message
• 1 day This is a longer message that will automatically get cut when I reach some unknown length.
• 4 days This is working due to it is a short message.
slack web 客户端是从我的应用程序发送的代码
msg = [ {'type': 'section', 'text':
{'type': 'mrkdwn', 'text': "First a greeting message"}
},
{'type': 'divider'},
{'type': 'section', 'text':
{'type': 'mrkdwn', 'text': '• 1 day This is a rather short message \n • 1 day This is a longer message that will automatically get cut when I reach some unknown length, but if I reply the same msg it will be fine \n • 4 days This is working due to it is a short message.'}
}
]
slack_client.chat_postMessage(channel=channel, blocks=msg)
【问题讨论】:
-
如果您希望人们帮助您解决问题,请将您应用的相关代码添加到问题中。
-
更新了发送到 slack web 客户端的描述。
标签: python-3.x slack slack-api