| 580 | |
| 581 | |
| 582 | class MarkdownBlock(Block): |
| 583 | type = "markdown" |
| 584 | text_max_length = 12000 |
| 585 | |
| 586 | @property |
| 587 | def attributes(self) -> Set[str]: # type: ignore[override] |
| 588 | return super().attributes.union({"text"}) |
| 589 | |
| 590 | def __init__( |
| 591 | self, |
| 592 | *, |
| 593 | text: str, |
| 594 | block_id: Optional[str] = None, |
| 595 | **others: dict, |
| 596 | ): |
| 597 | """Displays formatted markdown. |
| 598 | https://docs.slack.dev/reference/block-kit/blocks/markdown-block/ |
| 599 | |
| 600 | Args: |
| 601 | block_id: A string acting as a unique identifier for a block. If not specified, one will be generated. |
| 602 | Maximum length for this field is 255 characters. |
| 603 | block_id should be unique for each message and each iteration of a message. |
| 604 | If a message is updated, use a new block_id. |
| 605 | text (required): The standard markdown-formatted text. Limit 12,000 characters max. |
| 606 | """ |
| 607 | super().__init__(type=self.type, block_id=block_id) |
| 608 | show_unknown_key_warning(self, others) |
| 609 | |
| 610 | self.text = text |
| 611 | |
| 612 | @JsonValidator("text attribute must be specified") |
| 613 | def _validate_text(self): |
| 614 | return self.text != "" |
| 615 | |
| 616 | @JsonValidator(f"text attribute cannot exceed {text_max_length} characters") |
| 617 | def _validate_alt_text_length(self): |
| 618 | return len(self.text) <= self.text_max_length |
| 619 | |
| 620 | |
| 621 | class VideoBlock(Block): |
no outgoing calls