Slack bolt python use metadata when using blocks in say() function - Stack Overflow

I have this block of code which is responsible for selecting the namespace:@appmand("enable_work

I have this block of code which is responsible for selecting the namespace:

@appmand("/enable_worker")
def enable_worker(ack, body, say):
    ack()
    blocks = [
              {
                "type": "section",
                "block_id": "section678",
                "text": {
                  "type": "mrkdwn",
                  "text": ":one: Select the environment you want to setup:"
                },
                "accessory": {
                  "action_id": "environment_selector",
                  "type": "static_select",
                  "placeholder": {
                    "type": "plain_text",
                    "text": "Select an environment"
                  },
                  "options": []
                }
              }
            ]
    services = get_services()
    for namespace, service in services.items():
        ns_data = {
            "text": {
                "type": "plain_text",
                "text": f"{namespace}"
            },
            "value": f"{namespace}"
        }
        blocks[0]["accessory"]["options"].append(ns_data)
    say(blocks=blocks)

And this handler for environment_selector:

@app.action("environment_selector")
def environment_selector(ack, body, say):
    ack()
    workers_in_ns = get_services(body["actions"][0]["selected_option"]["value"])
    workers = workers_in_ns[body["actions"][0]["selected_option"]["value"]]
    blocks = [
              {
                "type": "section",
                "block_id": "section678",
                "text": {
                  "type": "mrkdwn",
                  "text": ":two: Select the worker in this environment you want to update:"
                },
                "accessory": {
                  "action_id": "worker_selector",
                  "type": "static_select",
                  "placeholder": {
                    "type": "plain_text",
                    "text": "Select a worker"
                  },
                  "options": []
                }
              }
            ]
    for worker in workers:
        w_data = {
            "text": {
                "type": "plain_text",
                "text": f"{worker[0]}"
            },
            "value": f"{worker[0]}"
        }
        blocks[0]["accessory"]["options"].append(w_data)
    say(blocks=blocks, metadata={"namespace": body["actions"][0]["selected_option"]["value"]})

And I want to pass the namespace to the handler of worker_selector:

@app.action("worker_selector")
def worker_selector(ack, body, say):
    ack()
    print(body)

But the output of body here has no element metadata, how can I pass this variable to the handler?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744228751a4564139.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信