-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a medium support options for slack bot message
- Loading branch information
Showing
11 changed files
with
371 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from fink_utils.slack_bot.rich_text.rich_text import RichElement | ||
from fink_utils.slack_bot.rich_text.rich_section import SectionElement | ||
from enum import Enum | ||
from typing import List, Union | ||
from typing_extensions import Self | ||
|
||
|
||
class RichListStyle(Enum): | ||
BULLET = "bullet" | ||
ORDERED = "ordered" | ||
|
||
|
||
class RichList(RichElement): | ||
def __init__( | ||
self, | ||
style: RichListStyle = RichListStyle.BULLET, | ||
indent:int=None, | ||
offset:int=None, | ||
border:int=None, | ||
) -> None: | ||
""" | ||
A class representing a list | ||
Parameters | ||
---------- | ||
style : RichListStyle, optional | ||
style of the list, by default RichListStyle.BULLET | ||
indent : int, optional | ||
list indent in pixels, by default None | ||
offset : int, optional | ||
number of pixels to offset the list, by default None | ||
border : int, optional | ||
border thickness in pixels, by default None | ||
""" | ||
super().__init__() | ||
self.rich_list = { | ||
"type": "rich_text_list", | ||
"style": style.value, | ||
"elements": [], | ||
} | ||
if indent is not None: | ||
self.rich_list["indent"] = indent | ||
|
||
if offset is not None: | ||
self.rich_list["offset"] = offset | ||
|
||
if border is not None: | ||
self.rich_list["border"] = border | ||
|
||
def get_element(self): | ||
return self.rich_list | ||
|
||
def add_elements( | ||
self, elements: Union[SectionElement, List[SectionElement]] | ||
) -> Self: | ||
if type(elements) is list: | ||
self.rich_list["elements"] += [el.get_element() for el in elements] | ||
else: | ||
self.rich_list["elements"].append(elements.get_element()) | ||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from fink_utils.slack_bot.rich_text.rich_text import RichElement | ||
from typing import List, Union | ||
from typing_extensions import Self | ||
from fink_utils.slack_bot.rich_text.rich_text_element import RichTextElement | ||
|
||
|
||
class RichPreformatted(RichElement): | ||
def __init__(self, border:int=None) -> None: | ||
""" | ||
A class representing a block surrounded by a border | ||
Parameters | ||
---------- | ||
border : _type_, optional | ||
border thickness in pixels, by default None | ||
""" | ||
super().__init__() | ||
self.preform = {"type": "rich_text_preformatted", "elements": []} | ||
if border is not None: | ||
self.preform["border"] = border | ||
|
||
def get_element(self): | ||
return self.preform | ||
|
||
def add_elements( | ||
self, elements: Union[RichTextElement, List[RichTextElement]] | ||
) -> Self: | ||
if type(elements) is list: | ||
self.preform["elements"] += [el.get_element() for el in elements] | ||
else: | ||
self.preform["elements"].append(elements.get_element()) | ||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from fink_utils.slack_bot.rich_text.rich_text import RichElement | ||
from typing import List, Union | ||
from typing_extensions import Self | ||
from fink_utils.slack_bot.rich_text.rich_text_element import RichTextElement | ||
|
||
|
||
class RichQuote(RichElement): | ||
def __init__(self, border:int=None) -> None: | ||
""" | ||
A class representing a quote | ||
Parameters | ||
---------- | ||
border : int, optional | ||
border thickness in pixels, by default None | ||
""" | ||
super().__init__() | ||
self.quote = {"type": "rich_text_quote", "elements": []} | ||
if border is not None: | ||
self.quote["border"] = border | ||
|
||
def get_element(self): | ||
return self.quote | ||
|
||
def add_elements( | ||
self, elements: Union[RichTextElement, List[RichTextElement]] | ||
) -> Self: | ||
if type(elements) is list: | ||
self.quote["elements"] += [el.get_element() for el in elements] | ||
else: | ||
self.quote["elements"].append(elements.get_element()) | ||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from fink_utils.slack_bot.rich_text.rich_text import RichElement | ||
from fink_utils.slack_bot.rich_text.rich_text_element import RichTextElement | ||
from typing import List, Union | ||
from typing_extensions import Self | ||
|
||
|
||
class SectionElement(RichElement): | ||
def __init__(self) -> None: | ||
""" | ||
A class representing a section of a rich text | ||
""" | ||
super().__init__() | ||
self.section = {"type": "rich_text_section", "elements": []} | ||
|
||
def add_elements( | ||
self, elements: Union[RichTextElement, List[RichTextElement]] | ||
) -> Self: | ||
if type(elements) is list: | ||
self.section["elements"] += [el.get_element() for el in elements] | ||
else: | ||
self.section["elements"].append(elements.get_element()) | ||
return self | ||
|
||
def get_element(self) -> dict: | ||
return self.section |
Oops, something went wrong.