python - 有没有办法更新 Slack 消息中的单个块元素?
问题描述
我正在尝试使用机器人更新 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"
}
]
}
]
)
解决方案
目前,无法更新块的部分。需要更新完整的视图。
尽管有一种方法可以保留在“输入块”中输入的数据:
Preserving input entry
Data entered or selected in input blocks can be preserved while updating views.
The new view object that you use with views.update should contain
the same input blocks and elements with identical block_id and action_id values.
推荐阅读
- python-3.7 - 将列表中的 m-repeated 数字收缩为 n-repeated (n
我想编写一个
python 3.7
函数,它有一个排序的数字列表作为输入,一个数字n
是每个整数可以重复的最大数字,并就地修改列表,以便任何重复多次的n
数字, 将被削减为n
重复,它应该在O(1)
- c++ - 为什么 C++20 格式对格式字符串没有强类型定义?
- electron - 在渲染器中使用 Electron 10 和 Requirejs 会返回错误
- email - 了解电子邮件中的 UTF-8 编码
- javascript - Nativescript playground vue.js show error message "TypeError: undefined is not an object (evaluating 'res.list.splice)"
- amazon-web-services - How to add an index to an RDS database/table after AWS Glue script imports the data therein?
- javascript - 我正在使用 fixer api 开发货币转换器 webapp
- reactjs - 如何使用 Typescript 从 mui 扩展调色板
- c# - SSIS 脚本任务获取“调用的目标已引发异常”。使用 3rd 方 dll 运行时
- c# - 应该如何在 ASP NET Core MVC 中检索数据?