slack-message-blocks-simplified


Nameslack-message-blocks-simplified JSON
Version 0.0.7 PyPI version JSON
download
home_pageNone
SummaryA small package that is used to create blocks in Slack messaging app
upload_time2024-12-05 20:01:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseCopyright (c) 2018 The Python Packaging Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords slack
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

- # Slack Message Blocks Simplified Package
- ## Overview
  
  **slack_message_blocks_simplified** is a Python package that simplifies the process of creating and sending rich, structured messages to Slack channels using blocks. The package provides various classes to help you build and manage these blocks and interact with Slack's API efficiently.
- ## Installation
  ```
  pip install slack-message-blocks-simplified
  ```
- ### Prerequisites
- **Python Version**: Ensure you are using Python 3.12 or higher.
- **Dependencies**:
	- `slack_sdk` (version 3.31.0)
	- `dataclasses` (built-in for Python 3.7+)
- ## Usage
- ### Importing the Package
  
  ```
  from slack_message_blocks_simplified import  DividerBlock, HeaderBlock, ContextBlock, SectionBlock, SectionTextElement, SectionTextType, SectionAccessory, ImageBlock, RichTextBlock, SlackBlock, SlackClient
  ```
- # Initialize the Slack client and Slack Block
  ```
  slack_client = SlackClient(bot_token="xoxb-your-slack-token")
  slack_message = SlackBlock(client=slack_client)
  ```
- # Create a message
  ```
  header = HeaderBlock(title="Welcome to the Channel!")
  divider = DividerBlock()
  section = SectionBlock()
  section.change_text_element(
      element = SectionTextElement(
          SectionTextType.mrkdwn,
          "This is a *section* with some _rich text_."
      )
  )
  section.change_text_accessory(
      accessory = SectionAccessory(
          image_url= "https://example.com/image.png",
          alt_text= "Example Image"
      )
  )
  ```
- # Upload file
  ```
  slack_message.upload_file("C:/path/to/file.extension", "file.extension")
  ```
- # Post the message to a channel
  ```
  slack_message.add_blocks([header, divider, section])
  slack_message.post_message_block(channel_id="C1234567890")
  ```
- # Final code
  ```
  from slack_message_blocks_simplified import DividerBlock, HeaderBlock, ContextBlock, SectionBlock, SectionTextElement, SectionTextType, SectionAccessory, ImageBlock, RichTextBlock, SlackBlock, SlackClient
 
  slack_client = SlackClient(bot_token="xoxb-your-slack-token")
  slack_message = SlackBlock(client=slack_client)
  
  header = HeaderBlock(title="Welcome to the Channel!")
  divider = DividerBlock()
  section = SectionBlock()
  section.change_text_element(
      element = SectionTextElement(
          SectionTextType.mrkdwn,
          "This is a *section* with some _rich text_."
      )
  )
  section.change_text_accessory(
      accessory = SectionAccessory(
          image_url= "https://example.com/image.png",
          alt_text= "Example Image"
      )
  )
  
  slack_message.upload_file("C:/path/to/file.extension", "file.extension")
  
  slack_message.add_blocks([header, divider, section])
  slack_message.post_message_block(channel_id="C1234567890")
  ```




# Classes and Methods

## 1. DividerBlock
Represents a Slack divider block, used to create visual separators.

### Methods:

- **`value()`**:

  **Description**: Retrieves the structure of the divider block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary with the type set to "divider".

## 2. HeaderBlock
Represents a Slack header block, used to display a title.

### Attributes:

- `title (str | None)`: The text of the header title.

### Methods:

- **`reset_value()`**:

  **Description**: Resets the header title to `None`.  
  **Args**: None.

- **`append(title: str)`**:

  **Description**: Appends text to the existing header title.  
  **Args**:  
  - `title (str)`: Text to append to the current title.

- **`value()`**:

  **Description**: Retrieves the structure of the header block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary containing the header type and its text.

## 3. ContextBlock
Represents a Slack context block, used to display context or additional information.

### Attributes:

- `elements (list[ContextSubBlock])`: A list of elements in the context block.

### Methods:

- **`reset_value()`**:

  **Description**: Clears all elements from the context block.  
  **Args**: None.

- **`add_context_sub_blocks(context_sub_block: list[ContextSubBlock])`**:

  **Description**: Adds sub-blocks to the context block.  
  **Args**:  
  - `context_sub_block (list[ContextSubBlock])`: The sub-blocks to add.

- **`value()`**:

  **Description**: Retrieves the structure of the context block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary containing the context type and its elements.

## 4. SectionBlock
Represents a Slack section block, used to display text and optional accessories.

### Attributes:

- `element (SectionTextElement | None)`: The main content of the section.
- `accessory (SectionAccessory | None)`: An optional accessory for the section.

### Methods:

- **`reset_value()`**:

  **Description**: Resets the section content and accessory to `None`.  
  **Args**: None.

- **`change_text_element(element: SectionTextElement)`**:

  **Description**: Updates the content of the section.  
  **Args**:  
  - `element (SectionTextElement)`: The new text element for the section.

- **`change_text_accessory(accessory: SectionAccessory)`**:

  **Description**: Updates the accessory of the section.  
  **Args**:  
  - `accessory (SectionAccessory)`: The new accessory for the section.

- **`value()`**:

  **Description**: Retrieves the structure of the section block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary containing the section type, text, and optional accessory.  
  **Raises**:  
  - `ValueError`: If the `element` attribute is `None`.

## 5. ImageBlock
Represents a Slack image block, used to display an image with optional title and alternative text.

### Attributes:

- `image_url (str | None)`: The URL of the image.
- `title (str | None)`: The title of the image block (optional).
- `alt_text (str | None)`: The alternative text for the image.
- `is_markdown (bool)`: Indicates whether the title is in Markdown format.

### Methods:

- **`reset_value()`**:

  **Description**: Resets all properties of the image block to their default state.  
  **Args**: None.

- **`change_values(image_url: str | None = None, title: str | None = None, alt_text: str | None = None, is_markdown: bool | None = None)`**:

  **Description**: Updates the properties of the image block.  
  **Args**:  
  - `image_url (str | None)`: The new URL of the image.  
  - `title (str | None)`: The new title for the image block.  
  - `alt_text (str | None)`: The new alternative text for the image.  
  - `is_markdown (bool | None)`: Whether the title should be in Markdown format.

- **`value()`**:

  **Description**: Retrieves the structure of the image block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary containing the image block details.  
  **Raises**:  
  - `ValueError`: If the `image_url` attribute is `None`.

## 6. RichTextBlock
Represents a Slack rich text block, used for more complex formatting and layout.

### Attributes:

- `sections (list[RichTextList | RichTextSection])`: A list of rich text sections and lists.

### Methods:

- **`reset_value()`**:

  **Description**: Clears all sections from the rich text block.  
  **Args**: None.

- **`add_sections_and_lists(elements: list[RichTextList | RichTextSection])`**:

  **Description**: Adds sections and lists to the rich text block.  
  **Args**:  
  - `elements (list[RichTextList | RichTextSection])`: A list of rich text sections and lists to add.

- **`value()`**:

  **Description**: Retrieves the structure of the rich text block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary containing the rich text block details.

## 7. SlackBlock
Represents a message block to be sent via Slack, which includes text, rich blocks, and files.

### Attributes:

- `client (SlackClient)`: The Slack client used for API communication.
- `text (str)`: The main text content of the message.
- `blocks (list[dict[str, Any]])`: A list of structured blocks for the message.
- `files (list[str])`: A list of file URLs to be attached to the message.

### Methods:

- **`add_blocks(blocks: list[BaseBlock])`**:

  **Description**: Adds multiple structured blocks to the Slack message.  
  **Args**:  
  - `blocks (list[BaseBlock])`: A list of block objects to add.

- **`upload_file(file_path: str, filename: str | None = None)`**:

  **Description**: Uploads a file to Slack and stores its permalink.  
  **Args**:  
  - `file_path (str)`: The local path of the file to upload.  
  - `filename (str | None)`: An optional custom filename for the uploaded file.

- **`add_message(new_text: str)`**:

  **Description**: Appends additional text to the current message.  
  **Args**:  
  - `new_text (str)`: The text to append to the existing message.

- **`change_message(new_text: str)`**:

  **Description**: Replaces the existing message text with new content.  
  **Args**:  
  - `new_text (str)`: The new text that will replace the current message content.

- **`reset_message()`**:

  **Description**: Clears the message text.  
  **Args**: None.

- **`post_message_block(channel_id: str)`**:

  **Description**: Sends the message block to a specified Slack channel.  
  **Args**:  
  - `channel_id (str)`: The ID of the Slack channel where the message will be posted.

# Additional Classes

## 1. BaseBlock
Base class for Slack blocks, providing a template for implementing different types of Slack blocks.

### Methods:

- **`reset_value()`**:

  **Description**: Resets the value of the block to its default state.  
  **Raises**:  
  - `NotImplementedError`: If the method is not implemented by subclasses.

- **`value()`**:

  **Description**: Retrieves the dictionary representation of the block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary representation of the block.  
  **Raises**:  
  - `NotImplementedError`: If the method is not implemented by subclasses.

## 2. ContextSubBlock
Represents a context sub-block for Slack messages.

### Attributes:

- `type (ContextSubBlockType)`: The type of the context block (e.g., text or image).  
- `text (str | None)`: Text content for the block, if applicable.  
- `image_url (str | None)`: Image URL for the block, if applicable.  
- `alt_text (str | None)`: Alternate text for the image, if applicable.

### Methods:

- **`value()`**:

  **Description**: Retrieves the dictionary representation of the context sub-block.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary with the context block's type and elements.  
  **Raises**:  
  - `ValueError`: If required attributes for the block type are missing.

## 3. RichTextElement
Represents a rich text element within a Slack block.

### Attributes:

- `type (RichTextElementType)`: The type of the rich text element (e.g., text, emoji, link).  
- `text (str | None)`: Text content of the element, if applicable.  
- `styles (list[RichTextElementStyle] | None)`: A list of styles applied to the element, if applicable.  
- `name (str | None)`: Name for emoji elements, if applicable.  
- `url (str | None)`: URL for link elements, if applicable.

### Methods:

- **`value()`**:

  **Description**: Retrieves the dictionary representation of the rich text element.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary with the element's type and attributes.  
  **Raises**:  
  - `ValueError`: If required attributes for the element type are missing.

## 4. RichTextSection
Represents a rich text section containing multiple rich text elements.

### Attributes:

- `type (RichTextSectionType)`: The type of the rich text section.  
- `elements (list[RichTextElement])`: A list of rich text elements in this section.

### Methods:

- **`add_rich_text_elements(rich_text_element: list[RichTextElement])`**:

  **Description**: Adds rich text elements to the section.  
  **Args**:  
  - `rich_text_element (list[RichTextElement])`: A list of rich text elements to add.

- **`value()`**:

  **Description**: Retrieves the dictionary representation of the rich text section.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary with the section's type and elements.

## 5. RichTextList
Represents a list of rich text sections in a Slack block.

### Attributes:

- `type (RichTextListType)`: The style of the list (e.g., numbered, bulleted).  
- `elements (list[RichTextSection])`: A list of rich text sections in this list.

### Methods:

- **`add_rich_text_sections(rich_text_sections: list[RichTextSection])`**:

  **Description**: Adds rich text sections to the list.  
  **Args**:  
  - `rich_text_sections (list[RichTextSection])`: A list of rich text sections to add.  
  **Raises**:  
  - `ValueError`: If any section does not match the type required for the list.

- **`value()`**:

  **Description**: Retrieves the dictionary representation of the rich text list.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary with the list's type, style, and elements.

## 6. SectionTextElement
Represents a text element within a section block.

### Attributes:

- `type (SectionTextType)`: The type of text (e.g., plain_text or mrkdwn).  
- `text (str)`: The content of the text.

### Methods:

- **`value()`**:

  **Description**: Retrieves the dictionary representation of the section text element.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary with the text element's type and content.

## 7. SectionAccessory
Represents an accessory for a section block, such as an image.

### Attributes:

- `image_url (str)`: The URL of the image.  
- `alt_text (str)`: Alternate text for the image.

### Methods:

- **`value()`**:

  **Description**: Retrieves the dictionary representation of the section accessory.  
  **Returns**:  
  - `dict[str, Any]`: A dictionary with the accessory's type, image URL, and alternate text.

## 8. SlackClient
A client for interacting with Slack's API.

### Attributes:

- `bot_token (str)`: The token used for authenticating the bot with Slack's API. To get this token you must have a [Slack app](https://api.slack.com/docs/apps) created and it requires the following OAuth Scopes: 
`chat:write`, `files:write`

### Methods:

- **`post_message_block(channel_id: str, blocks: Any | None, text: str = "")`**:

  **Description**: Posts a message with optional blocks to a specific Slack channel.  
  **Args**:  
  - `channel_id`: The ID of the Slack channel where the message will be posted.  
  - `blocks`: A list of blocks (formatted sections) to include in the message. Can be `None`.  
  - `text`: The plain text content of the message.

- **`upload(file: str | bytes | IOBase | None, filename: str | None)`**:

  **Description**: Uploads a file to Slack, optionally with a specified filename.  
  **Args**:  
  - `file`: The file to upload. It can be a path to a file, bytes, or an IO stream.  
  - `filename`: The name to use for the file in Slack. If `None`, Slack determines the name automatically.
---

If you'd like to contribute to this project, please fork the repository and submit a pull request. All contributions are welcome!

## License

This project is licensed under the MIT License.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "slack-message-blocks-simplified",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "Slack",
    "author": null,
    "author_email": "Serge Celestin Taveras <sergecelestint@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/fd/c4/db4cc34c50b1a4fa6c02c2b1685ccd30ebfa7817eb28e31f84a261672b1b/slack_message_blocks_simplified-0.0.7.tar.gz",
    "platform": null,
    "description": "\n\n- # Slack Message Blocks Simplified Package\n- ## Overview\n  \n  **slack_message_blocks_simplified** is a Python package that simplifies the process of creating and sending rich, structured messages to Slack channels using blocks. The package provides various classes to help you build and manage these blocks and interact with Slack's API efficiently.\n- ## Installation\n  ```\n  pip install slack-message-blocks-simplified\n  ```\n- ### Prerequisites\n- **Python Version**: Ensure you are using Python 3.12 or higher.\n- **Dependencies**:\n\t- `slack_sdk` (version 3.31.0)\n\t- `dataclasses` (built-in for Python 3.7+)\n- ## Usage\n- ### Importing the Package\n  \n  ```\n  from slack_message_blocks_simplified import  DividerBlock, HeaderBlock, ContextBlock, SectionBlock, SectionTextElement, SectionTextType, SectionAccessory, ImageBlock, RichTextBlock, SlackBlock, SlackClient\n  ```\n- # Initialize the Slack client and Slack Block\n  ```\n  slack_client = SlackClient(bot_token=\"xoxb-your-slack-token\")\n  slack_message = SlackBlock(client=slack_client)\n  ```\n- # Create a message\n  ```\n  header = HeaderBlock(title=\"Welcome to the Channel!\")\n  divider = DividerBlock()\n  section = SectionBlock()\n  section.change_text_element(\n      element = SectionTextElement(\n          SectionTextType.mrkdwn,\n          \"This is a *section* with some _rich text_.\"\n      )\n  )\n  section.change_text_accessory(\n      accessory = SectionAccessory(\n          image_url= \"https://example.com/image.png\",\n          alt_text= \"Example Image\"\n      )\n  )\n  ```\n- # Upload file\n  ```\n  slack_message.upload_file(\"C:/path/to/file.extension\", \"file.extension\")\n  ```\n- # Post the message to a channel\n  ```\n  slack_message.add_blocks([header, divider, section])\n  slack_message.post_message_block(channel_id=\"C1234567890\")\n  ```\n- # Final code\n  ```\n  from slack_message_blocks_simplified import DividerBlock, HeaderBlock, ContextBlock, SectionBlock, SectionTextElement, SectionTextType, SectionAccessory, ImageBlock, RichTextBlock, SlackBlock, SlackClient\n \n  slack_client = SlackClient(bot_token=\"xoxb-your-slack-token\")\n  slack_message = SlackBlock(client=slack_client)\n  \n  header = HeaderBlock(title=\"Welcome to the Channel!\")\n  divider = DividerBlock()\n  section = SectionBlock()\n  section.change_text_element(\n      element = SectionTextElement(\n          SectionTextType.mrkdwn,\n          \"This is a *section* with some _rich text_.\"\n      )\n  )\n  section.change_text_accessory(\n      accessory = SectionAccessory(\n          image_url= \"https://example.com/image.png\",\n          alt_text= \"Example Image\"\n      )\n  )\n  \n  slack_message.upload_file(\"C:/path/to/file.extension\", \"file.extension\")\n  \n  slack_message.add_blocks([header, divider, section])\n  slack_message.post_message_block(channel_id=\"C1234567890\")\n  ```\n\n\n\n\n# Classes and Methods\n\n## 1. DividerBlock\nRepresents a Slack divider block, used to create visual separators.\n\n### Methods:\n\n- **`value()`**:\n\n  **Description**: Retrieves the structure of the divider block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary with the type set to \"divider\".\n\n## 2. HeaderBlock\nRepresents a Slack header block, used to display a title.\n\n### Attributes:\n\n- `title (str | None)`: The text of the header title.\n\n### Methods:\n\n- **`reset_value()`**:\n\n  **Description**: Resets the header title to `None`.  \n  **Args**: None.\n\n- **`append(title: str)`**:\n\n  **Description**: Appends text to the existing header title.  \n  **Args**:  \n  - `title (str)`: Text to append to the current title.\n\n- **`value()`**:\n\n  **Description**: Retrieves the structure of the header block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary containing the header type and its text.\n\n## 3. ContextBlock\nRepresents a Slack context block, used to display context or additional information.\n\n### Attributes:\n\n- `elements (list[ContextSubBlock])`: A list of elements in the context block.\n\n### Methods:\n\n- **`reset_value()`**:\n\n  **Description**: Clears all elements from the context block.  \n  **Args**: None.\n\n- **`add_context_sub_blocks(context_sub_block: list[ContextSubBlock])`**:\n\n  **Description**: Adds sub-blocks to the context block.  \n  **Args**:  \n  - `context_sub_block (list[ContextSubBlock])`: The sub-blocks to add.\n\n- **`value()`**:\n\n  **Description**: Retrieves the structure of the context block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary containing the context type and its elements.\n\n## 4. SectionBlock\nRepresents a Slack section block, used to display text and optional accessories.\n\n### Attributes:\n\n- `element (SectionTextElement | None)`: The main content of the section.\n- `accessory (SectionAccessory | None)`: An optional accessory for the section.\n\n### Methods:\n\n- **`reset_value()`**:\n\n  **Description**: Resets the section content and accessory to `None`.  \n  **Args**: None.\n\n- **`change_text_element(element: SectionTextElement)`**:\n\n  **Description**: Updates the content of the section.  \n  **Args**:  \n  - `element (SectionTextElement)`: The new text element for the section.\n\n- **`change_text_accessory(accessory: SectionAccessory)`**:\n\n  **Description**: Updates the accessory of the section.  \n  **Args**:  \n  - `accessory (SectionAccessory)`: The new accessory for the section.\n\n- **`value()`**:\n\n  **Description**: Retrieves the structure of the section block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary containing the section type, text, and optional accessory.  \n  **Raises**:  \n  - `ValueError`: If the `element` attribute is `None`.\n\n## 5. ImageBlock\nRepresents a Slack image block, used to display an image with optional title and alternative text.\n\n### Attributes:\n\n- `image_url (str | None)`: The URL of the image.\n- `title (str | None)`: The title of the image block (optional).\n- `alt_text (str | None)`: The alternative text for the image.\n- `is_markdown (bool)`: Indicates whether the title is in Markdown format.\n\n### Methods:\n\n- **`reset_value()`**:\n\n  **Description**: Resets all properties of the image block to their default state.  \n  **Args**: None.\n\n- **`change_values(image_url: str | None = None, title: str | None = None, alt_text: str | None = None, is_markdown: bool | None = None)`**:\n\n  **Description**: Updates the properties of the image block.  \n  **Args**:  \n  - `image_url (str | None)`: The new URL of the image.  \n  - `title (str | None)`: The new title for the image block.  \n  - `alt_text (str | None)`: The new alternative text for the image.  \n  - `is_markdown (bool | None)`: Whether the title should be in Markdown format.\n\n- **`value()`**:\n\n  **Description**: Retrieves the structure of the image block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary containing the image block details.  \n  **Raises**:  \n  - `ValueError`: If the `image_url` attribute is `None`.\n\n## 6. RichTextBlock\nRepresents a Slack rich text block, used for more complex formatting and layout.\n\n### Attributes:\n\n- `sections (list[RichTextList | RichTextSection])`: A list of rich text sections and lists.\n\n### Methods:\n\n- **`reset_value()`**:\n\n  **Description**: Clears all sections from the rich text block.  \n  **Args**: None.\n\n- **`add_sections_and_lists(elements: list[RichTextList | RichTextSection])`**:\n\n  **Description**: Adds sections and lists to the rich text block.  \n  **Args**:  \n  - `elements (list[RichTextList | RichTextSection])`: A list of rich text sections and lists to add.\n\n- **`value()`**:\n\n  **Description**: Retrieves the structure of the rich text block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary containing the rich text block details.\n\n## 7. SlackBlock\nRepresents a message block to be sent via Slack, which includes text, rich blocks, and files.\n\n### Attributes:\n\n- `client (SlackClient)`: The Slack client used for API communication.\n- `text (str)`: The main text content of the message.\n- `blocks (list[dict[str, Any]])`: A list of structured blocks for the message.\n- `files (list[str])`: A list of file URLs to be attached to the message.\n\n### Methods:\n\n- **`add_blocks(blocks: list[BaseBlock])`**:\n\n  **Description**: Adds multiple structured blocks to the Slack message.  \n  **Args**:  \n  - `blocks (list[BaseBlock])`: A list of block objects to add.\n\n- **`upload_file(file_path: str, filename: str | None = None)`**:\n\n  **Description**: Uploads a file to Slack and stores its permalink.  \n  **Args**:  \n  - `file_path (str)`: The local path of the file to upload.  \n  - `filename (str | None)`: An optional custom filename for the uploaded file.\n\n- **`add_message(new_text: str)`**:\n\n  **Description**: Appends additional text to the current message.  \n  **Args**:  \n  - `new_text (str)`: The text to append to the existing message.\n\n- **`change_message(new_text: str)`**:\n\n  **Description**: Replaces the existing message text with new content.  \n  **Args**:  \n  - `new_text (str)`: The new text that will replace the current message content.\n\n- **`reset_message()`**:\n\n  **Description**: Clears the message text.  \n  **Args**: None.\n\n- **`post_message_block(channel_id: str)`**:\n\n  **Description**: Sends the message block to a specified Slack channel.  \n  **Args**:  \n  - `channel_id (str)`: The ID of the Slack channel where the message will be posted.\n\n# Additional Classes\n\n## 1. BaseBlock\nBase class for Slack blocks, providing a template for implementing different types of Slack blocks.\n\n### Methods:\n\n- **`reset_value()`**:\n\n  **Description**: Resets the value of the block to its default state.  \n  **Raises**:  \n  - `NotImplementedError`: If the method is not implemented by subclasses.\n\n- **`value()`**:\n\n  **Description**: Retrieves the dictionary representation of the block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary representation of the block.  \n  **Raises**:  \n  - `NotImplementedError`: If the method is not implemented by subclasses.\n\n## 2. ContextSubBlock\nRepresents a context sub-block for Slack messages.\n\n### Attributes:\n\n- `type (ContextSubBlockType)`: The type of the context block (e.g., text or image).  \n- `text (str | None)`: Text content for the block, if applicable.  \n- `image_url (str | None)`: Image URL for the block, if applicable.  \n- `alt_text (str | None)`: Alternate text for the image, if applicable.\n\n### Methods:\n\n- **`value()`**:\n\n  **Description**: Retrieves the dictionary representation of the context sub-block.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary with the context block's type and elements.  \n  **Raises**:  \n  - `ValueError`: If required attributes for the block type are missing.\n\n## 3. RichTextElement\nRepresents a rich text element within a Slack block.\n\n### Attributes:\n\n- `type (RichTextElementType)`: The type of the rich text element (e.g., text, emoji, link).  \n- `text (str | None)`: Text content of the element, if applicable.  \n- `styles (list[RichTextElementStyle] | None)`: A list of styles applied to the element, if applicable.  \n- `name (str | None)`: Name for emoji elements, if applicable.  \n- `url (str | None)`: URL for link elements, if applicable.\n\n### Methods:\n\n- **`value()`**:\n\n  **Description**: Retrieves the dictionary representation of the rich text element.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary with the element's type and attributes.  \n  **Raises**:  \n  - `ValueError`: If required attributes for the element type are missing.\n\n## 4. RichTextSection\nRepresents a rich text section containing multiple rich text elements.\n\n### Attributes:\n\n- `type (RichTextSectionType)`: The type of the rich text section.  \n- `elements (list[RichTextElement])`: A list of rich text elements in this section.\n\n### Methods:\n\n- **`add_rich_text_elements(rich_text_element: list[RichTextElement])`**:\n\n  **Description**: Adds rich text elements to the section.  \n  **Args**:  \n  - `rich_text_element (list[RichTextElement])`: A list of rich text elements to add.\n\n- **`value()`**:\n\n  **Description**: Retrieves the dictionary representation of the rich text section.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary with the section's type and elements.\n\n## 5. RichTextList\nRepresents a list of rich text sections in a Slack block.\n\n### Attributes:\n\n- `type (RichTextListType)`: The style of the list (e.g., numbered, bulleted).  \n- `elements (list[RichTextSection])`: A list of rich text sections in this list.\n\n### Methods:\n\n- **`add_rich_text_sections(rich_text_sections: list[RichTextSection])`**:\n\n  **Description**: Adds rich text sections to the list.  \n  **Args**:  \n  - `rich_text_sections (list[RichTextSection])`: A list of rich text sections to add.  \n  **Raises**:  \n  - `ValueError`: If any section does not match the type required for the list.\n\n- **`value()`**:\n\n  **Description**: Retrieves the dictionary representation of the rich text list.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary with the list's type, style, and elements.\n\n## 6. SectionTextElement\nRepresents a text element within a section block.\n\n### Attributes:\n\n- `type (SectionTextType)`: The type of text (e.g., plain_text or mrkdwn).  \n- `text (str)`: The content of the text.\n\n### Methods:\n\n- **`value()`**:\n\n  **Description**: Retrieves the dictionary representation of the section text element.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary with the text element's type and content.\n\n## 7. SectionAccessory\nRepresents an accessory for a section block, such as an image.\n\n### Attributes:\n\n- `image_url (str)`: The URL of the image.  \n- `alt_text (str)`: Alternate text for the image.\n\n### Methods:\n\n- **`value()`**:\n\n  **Description**: Retrieves the dictionary representation of the section accessory.  \n  **Returns**:  \n  - `dict[str, Any]`: A dictionary with the accessory's type, image URL, and alternate text.\n\n## 8. SlackClient\nA client for interacting with Slack's API.\n\n### Attributes:\n\n- `bot_token (str)`: The token used for authenticating the bot with Slack's API. To get this token you must have a [Slack app](https://api.slack.com/docs/apps) created and it requires the following OAuth Scopes: \n`chat:write`, `files:write`\n\n### Methods:\n\n- **`post_message_block(channel_id: str, blocks: Any | None, text: str = \"\")`**:\n\n  **Description**: Posts a message with optional blocks to a specific Slack channel.  \n  **Args**:  \n  - `channel_id`: The ID of the Slack channel where the message will be posted.  \n  - `blocks`: A list of blocks (formatted sections) to include in the message. Can be `None`.  \n  - `text`: The plain text content of the message.\n\n- **`upload(file: str | bytes | IOBase | None, filename: str | None)`**:\n\n  **Description**: Uploads a file to Slack, optionally with a specified filename.  \n  **Args**:  \n  - `file`: The file to upload. It can be a path to a file, bytes, or an IO stream.  \n  - `filename`: The name to use for the file in Slack. If `None`, Slack determines the name automatically.\n---\n\nIf you'd like to contribute to this project, please fork the repository and submit a pull request. All contributions are welcome!\n\n## License\n\nThis project is licensed under the MIT License.",
    "bugtrack_url": null,
    "license": "Copyright (c) 2018 The Python Packaging Authority  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A small package that is used to create blocks in Slack messaging app",
    "version": "0.0.7",
    "project_urls": {
        "Github": "https://github.com/Sirgogo95/slack-message-blocks-simplified.git"
    },
    "split_keywords": [
        "slack"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "34d668a7f41ecd1bbb665dfa5e63a7c94f52f4081463e8818feedf17d6257e77",
                "md5": "92ac95f6a7dbabe33455caea973d727e",
                "sha256": "5a295f8c9f610a9a9f0c2db9a713622df85b0024fd1d87f3889461668a1d6a87"
            },
            "downloads": -1,
            "filename": "slack_message_blocks_simplified-0.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "92ac95f6a7dbabe33455caea973d727e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 12628,
            "upload_time": "2024-12-05T20:01:32",
            "upload_time_iso_8601": "2024-12-05T20:01:32.834259Z",
            "url": "https://files.pythonhosted.org/packages/34/d6/68a7f41ecd1bbb665dfa5e63a7c94f52f4081463e8818feedf17d6257e77/slack_message_blocks_simplified-0.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdc4db4cc34c50b1a4fa6c02c2b1685ccd30ebfa7817eb28e31f84a261672b1b",
                "md5": "d217847b436cc4e36ade2b4123da7294",
                "sha256": "371eae7a53e0ae6b7e9bcc765eff78bbd130a1b57a26ac823cb33d692790a6f5"
            },
            "downloads": -1,
            "filename": "slack_message_blocks_simplified-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "d217847b436cc4e36ade2b4123da7294",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 10856,
            "upload_time": "2024-12-05T20:01:33",
            "upload_time_iso_8601": "2024-12-05T20:01:33.759362Z",
            "url": "https://files.pythonhosted.org/packages/fd/c4/db4cc34c50b1a4fa6c02c2b1685ccd30ebfa7817eb28e31f84a261672b1b/slack_message_blocks_simplified-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-05 20:01:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Sirgogo95",
    "github_project": "slack-message-blocks-simplified",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "slack-message-blocks-simplified"
}
        
Elapsed time: 2.06528s