diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-08-26 13:44:16 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 5d1b7404d965235880813264a0a37bb3704810b4 (patch) | |
tree | 9609965ed1bcbb32242df5a353f62a051ed289e8 /slack/util.py | |
parent | 425db0016edb859c13c0e5aede03a469cfcb47ed (diff) | |
download | wee-slack-5d1b7404d965235880813264a0a37bb3704810b4.tar.gz |
Support rendering attachments
Diffstat (limited to 'slack/util.py')
-rw-r--r-- | slack/util.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/slack/util.py b/slack/util.py index e216576..647ee02 100644 --- a/slack/util.py +++ b/slack/util.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Callable +from typing import Callable, Optional import weechat @@ -13,5 +13,8 @@ def get_callback_name(callback: Callable[..., WeechatCallbackReturnType]) -> str return callback_id -def with_color(color: str, string: str, reset_color: str = "reset"): - return f"{weechat.color(color)}{string}{weechat.color(reset_color)}" +def with_color(color: Optional[str], string: str, reset_color: str = "reset"): + if color: + return f"{weechat.color(color)}{string}{weechat.color(reset_color)}" + else: + return string |