aboutsummaryrefslogtreecommitdiffstats
path: root/slack/util.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-08-26 13:44:16 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:54 +0100
commit5d1b7404d965235880813264a0a37bb3704810b4 (patch)
tree9609965ed1bcbb32242df5a353f62a051ed289e8 /slack/util.py
parent425db0016edb859c13c0e5aede03a469cfcb47ed (diff)
downloadwee-slack-5d1b7404d965235880813264a0a37bb3704810b4.tar.gz
Support rendering attachments
Diffstat (limited to 'slack/util.py')
-rw-r--r--slack/util.py9
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