MCPcopy Index your code
hub / github.com/slackapi/python-slack-sdk / InputBlock

Class InputBlock

slack_sdk/models/blocks/blocks.py:414–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412
413
414class InputBlock(Block):
415 type = "input"
416 label_max_length = 2000
417 hint_max_length = 2000
418
419 @property
420 def attributes(self) -> Set[str]: # type: ignore[override]
421 return super().attributes.union({"label", "hint", "element", "optional", "dispatch_action"})
422
423 def __init__(
424 self,
425 *,
426 label: Union[str, dict, PlainTextObject],
427 element: Union[str, dict, InputInteractiveElement],
428 block_id: Optional[str] = None,
429 hint: Optional[Union[str, dict, PlainTextObject]] = None,
430 dispatch_action: Optional[bool] = None,
431 optional: Optional[bool] = None,
432 **others: dict,
433 ):
434 """A block that collects information from users - it can hold a plain-text input element,
435 a select menu element, a multi-select menu element, or a datepicker.
436 https://docs.slack.dev/reference/block-kit/blocks/input-block
437
438 Args:
439 label (required): A label that appears above an input element in the form of a text object
440 that must have type of plain_text. Maximum length for the text in this field is 2000 characters.
441 element (required): An plain-text input element, a checkbox element, a radio button element,
442 a select menu element, a multi-select menu element, or a datepicker.
443 block_id: A string acting as a unique identifier for a block. If not specified, one will be generated.
444 Maximum length for this field is 255 characters.
445 block_id should be unique for each message or view and each iteration of a message or view.
446 If a message or view is updated, use a new block_id.
447 hint: An optional hint that appears below an input element in a lighter grey.
448 It must be a text object with a type of plain_text.
449 Maximum length for the text in this field is 2000 characters.
450 dispatch_action: A boolean that indicates whether or not the use of elements in this block
451 should dispatch a block_actions payload. Defaults to false.
452 optional: A boolean that indicates whether the input element may be empty when a user submits the modal.
453 Defaults to false.
454 """
455 super().__init__(type=self.type, block_id=block_id)
456 show_unknown_key_warning(self, others)
457
458 self.label = TextObject.parse(label, default_type=PlainTextObject.type)
459 self.element = BlockElement.parse(element) # type: ignore[arg-type]
460 self.hint = TextObject.parse(hint, default_type=PlainTextObject.type) # type: ignore[arg-type]
461 self.dispatch_action = dispatch_action
462 self.optional = optional
463
464 @JsonValidator(f"label attribute cannot exceed {label_max_length} characters")
465 def _validate_label_length(self):
466 return self.label is None or self.label.text is None or len(self.label.text) <= self.label_max_length
467
468 @JsonValidator(f"hint attribute cannot exceed {hint_max_length} characters")
469 def _validate_hint_length(self):
470 return self.hint is None or self.hint.text is None or len(self.hint.text) <= self.label_max_length
471

Callers 9

open_modalFunction · 0.90
slack_appFunction · 0.90
test_documentMethod · 0.90
test_documentMethod · 0.90
parseMethod · 0.85

Calls

no outgoing calls

Tested by 6

test_documentMethod · 0.72
test_documentMethod · 0.72