Skip to content

Commit 17b75d7

Browse files
committed
feat: add plan block
1 parent 6073ffe commit 17b75d7

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎slack_sdk/models/blocks/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
ImageBlock,
7272
InputBlock,
7373
MarkdownBlock,
74+
PlanBlock,
7475
RichTextBlock,
7576
SectionBlock,
7677
TableBlock,
@@ -138,6 +139,7 @@
138139
"ImageBlock",
139140
"InputBlock",
140141
"MarkdownBlock",
142+
"PlanBlock",
141143
"SectionBlock",
142144
"TableBlock",
143145
"TaskCardBlock",

‎slack_sdk/models/blocks/blocks.py‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def parse(cls, block: Union[dict, "Block"]) -> Optional["Block"]:
100100
return TableBlock(**block)
101101
elif type == TaskCardBlock.type:
102102
return TaskCardBlock(**block)
103+
elif type == PlanBlock.type:
104+
return PlanBlock(**block)
103105
else:
104106
cls.logger.warning(f"Unknown block detected and skipped ({block})")
105107
return None
@@ -823,3 +825,46 @@ def __init__(
823825
@JsonValidator("status must be an expected value (pending, in_progress, complete, or error)")
824826
def _validate_rows(self):
825827
return self.status in ["pending", "in_progress", "complete", "error"]
828+
829+
830+
class PlanBlock(Block):
831+
type = "plan"
832+
833+
@property
834+
def attributes(self) -> Set[str]: # type: ignore[override]
835+
return super().attributes.union(
836+
{
837+
"plan_id",
838+
"title",
839+
"tasks",
840+
}
841+
)
842+
843+
def __init__(
844+
self,
845+
*,
846+
plan_id: str,
847+
title: str,
848+
tasks: Optional[Sequence[Union[Dict, TaskCardBlock]]] = None,
849+
block_id: Optional[str] = None,
850+
**others: dict,
851+
):
852+
"""A collection of related tasks.
853+
https://docs.slack.dev/reference/block-kit/blocks/plan-block/
854+
855+
Args:
856+
block_id: A string acting as a unique identifier for a block. If not specified, one will be generated.
857+
Maximum length for this field is 255 characters.
858+
block_id should be unique for each message and each iteration of a message.
859+
If a message is updated, use a new block_id.
860+
plan_id (required): ID for the plan (May be removed / made optional, feel free to pass in a random UUID
861+
for now)
862+
title (required): Title of the plan in plain text
863+
tasks: Details of the task in the form of a single "rich_text" entity.
864+
"""
865+
super().__init__(type=self.type, block_id=block_id)
866+
show_unknown_key_warning(self, others)
867+
868+
self.plan_id = plan_id
869+
self.title = title
870+
self.tasks = tasks

0 commit comments

Comments
 (0)