我正在尝试使用机器人更新 Slack 消息的按钮样式和文本,但我找不到有关更新单个块而不是整个数组的信息。我怎样才能只更新 res_but 元素的“文本”和“样式”,同时保留其余的消息内容?
编辑:我忘了提到我正在使用 Python3 和 Bolt 来编程
@app.action("res_but")
def resolve_toggle(ack, body, client):
ack()
resolvebutton_style = body["actions"][0]["style"]
if(resolvebutton_style == "danger"):
client.chat_update(
channel = body["channel"]["id"],
ts = body["message"]["ts"],
blocks=[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Issue:*\n{}\n*Urgency:*\n{}\n*Posted By*:\n{}\n*When:*\n<!date^{}^Posted {{date_num}} {{time_secs}}|Null Date>\n*Last Update:*\n".format(msg, urgency_val, username, posttimest_int)
}
},
{
"block_id": "issue_buttons",
"type": "actions",
"elements": [
{
"action_id": "res_but",
"type": "button",
"text": {
"type": "plain_text",
"emoji": True,
"text": "Resolved" #issue status changed to resolved
},
"style": "primary", #color changed to primary
"value": "resolve_but"
},
{
"action_id": "ogmes_but",
"type": "button",
"text": {
"type": "plain_text",
"emoji": True,
"text": "Original Message"
},
"value": "og_message"
}
]
}
]
)