简体   繁体   English

松弛块复选框

[英]Slack Block checkboxes

i'am using slack block in a channel using python and webhook.我在使用 python 和 webhook 的频道中使用 slack 块。 Messages are sent and arrived perfectly, the messages contains text and also checkboxes.消息完美发送和到达,消息包含文本和复选框。 When user check a checkbox only that user can see the checked checboxes and not all other user in the channel.当用户选中一个复选框时,只有该用户可以看到选中的复选框,而不是频道中的所有其他用户。 Is it possible for all users to see the selected checkbox?所有用户都可以看到选中的复选框吗?

Thank you谢谢

This is my code for build the这是我构建的代码

checkbox = []
            checkbox.append({
            "type": "input",
            "element": {
                "type": "checkboxes",
                "options": [
                    {
                        "text": {
                            "type": "plain_text",
                            "text": "Caricati {} {} di {}".format(
                                r.qta_caricata, r.articolo.um_elementare,
                                r.articolo.as_id),
                            "emoji": True
                        },
                        "value": "value-0"
                    }
                ],
                "action_id": "checkboxes-action"
            },
            "label": {
                "type": "plain_text",
                "text": " ",
                "emoji": True
            }
        })
    slack_data = {
        "username": usr,
        "icon_emoji": icon_emoji,
        "text": preview,
        "blocks": checkbox
    }
byte_length = str(sys.getsizeof(slack_data))
headers = {'Content-Type': "application/json",
           'Content-Length': byte_length}
response = requests.post(wh_url, data=json.dumps(slack_data),
                         headers=headers)

Understanding the problem理解问题
When user makes changes to the message, those changes are at Client Side , and hence does not reflect on other users view.当用户对消息进行更改时,这些更改位于Client Side因此不会反映其他用户的视图。

Solution解决方案
Capture the client's interactivity (check/uncheck of the checkbox), and update the message using Slack APIs from server side.捕获客户端的交互性(选中/取消选中复选框),并使用服务器端的 Slack API 更新消息。

In your given scenario, you are using web-hooks for posting messages.在您给定的场景中,您正在使用网络挂钩来发布消息。
Web-hooks are used for one-way communication and therefore, the event of user checking/unchecking the box can't be captured and can't be updated . Web-hook 用于单向通信,因此无法捕获用户选中/取消选中该框的事件,也无法更新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM