aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2024-02-19 17:09:22 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-19 21:53:33 +0100
commitb10a3afb80b3477d9df91357b90bb949ac168f52 (patch)
tree82126e63d1853e0f9b84530586ed9aa76a51ed39
parenta2d385bbdb7d6f2c1d7c8c9bdf9548832d8965a3 (diff)
downloadwee-slack-b10a3afb80b3477d9df91357b90bb949ac168f52.tar.gz
Only reset foreground color in with_color function
The with_color helper is usually used to set only the foreground color (currently all usages), so by only reseting the foreground we keep any existing background color. This fixes the default background on the current buffer in the buflist for muted conversations.
-rw-r--r--slack/util.py2
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/test_render_attachments.py14
-rw-r--r--tests/test_render_blocks.py6
-rw-r--r--tests/test_render_reactions.py14
-rw-r--r--tests/test_unfurl.py10
6 files changed, 24 insertions, 24 deletions
diff --git a/slack/util.py b/slack/util.py
index cfe0e03..f7d16f5 100644
--- a/slack/util.py
+++ b/slack/util.py
@@ -28,7 +28,7 @@ def get_callback_name(callback: Callable[..., WeechatCallbackReturnType]) -> str
return callback_id
-def with_color(color: Optional[str], string: str, reset_color: str = "reset"):
+def with_color(color: Optional[str], string: str, reset_color: str = "default"):
if color:
return f"{weechat.color(color)}{string}{weechat.color(reset_color)}"
else:
diff --git a/tests/conftest.py b/tests/conftest.py
index cda1833..e86afaa 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -144,7 +144,7 @@ shared.standard_emojis = load_standard_emojis()
color_channel_mention = "<[color:<[config_color:channel_mention]>]>"
color_user_mention = "<[color:<[config_color:user_mention]>]>"
color_usergroup_mention = "<[color:<[config_color:usergroup_mention]>]>"
-color_reset = "<[color:reset]>"
+color_default = "<[color:default]>"
workspace_id = "T0FC8BFQR"
diff --git a/tests/test_render_attachments.py b/tests/test_render_attachments.py
index 9e47449..3718427 100644
--- a/tests/test_render_attachments.py
+++ b/tests/test_render_attachments.py
@@ -8,7 +8,7 @@ from slack.shared import shared
from slack.slack_message import SlackMessage
from tests.conftest import (
channel_public_id,
- color_reset,
+ color_default,
color_user_mention,
resolve_pending_message_item,
user_test1_id,
@@ -425,7 +425,7 @@ cases: List[Case] = [
"input_text_before": "",
"output": "\n".join(
[
- "<[color:16711680]>|<[color:reset]> Title",
+ f"<[color:16711680]>|{color_default} Title",
]
),
},
@@ -441,7 +441,7 @@ cases: List[Case] = [
"input_text_before": "",
"output": "\n".join(
[
- "<[color:16711680]>|<[color:reset]> Title",
+ f"<[color:16711680]>|{color_default} Title",
]
),
},
@@ -560,13 +560,13 @@ cases: List[Case] = [
"| text & <asd>",
"| (https://image.url/?x=<x>&z=z)",
"| field title & <asd>: field value & <asd>",
- f"| field title mention <@{user_test1_id}>: field value mention {color_user_mention}@Test_1{color_reset}",
+ f"| field title mention <@{user_test1_id}>: field value mention {color_user_mention}@Test_1{color_default}",
"| footer & <asd> | Oct 16, 2023",
"| ```",
"| block rich_text_preformatted & <asd>",
"| ```",
"| block rich_text_section & <asd> `https://block.link?x=<x>&z=z`",
- f"| {color_user_mention}@Test_1{color_reset}: <@ASD>",
+ f"| {color_user_mention}@Test_1{color_default}: <@ASD>",
]
),
},
@@ -595,7 +595,7 @@ cases: List[Case] = [
[
"| (https://from.url)",
"| Author name: text",
- "| Posted in <[color:chat_channel]>#channel1<[color:reset]> | Oct 15, 2023",
+ f"| Posted in <[color:chat_channel]>#channel1{color_default} | Oct 15, 2023",
]
),
},
@@ -625,7 +625,7 @@ cases: List[Case] = [
[
"| (https://from.url)",
"| Author name: text",
- "| From a thread in <[color:chat_channel]>#channel1<[color:reset]> | Oct 15, 2023",
+ f"| From a thread in <[color:chat_channel]>#channel1{color_default} | Oct 15, 2023",
]
),
},
diff --git a/tests/test_render_blocks.py b/tests/test_render_blocks.py
index 63e4df5..fb61199 100644
--- a/tests/test_render_blocks.py
+++ b/tests/test_render_blocks.py
@@ -7,7 +7,7 @@ import pytest
from slack.shared import shared
from slack.slack_message import SlackMessage
from tests.conftest import (
- color_reset,
+ color_default,
color_user_mention,
resolve_pending_message_item,
user_test1_id,
@@ -139,7 +139,7 @@ cases: List[Case] = [
"block code",
"more code",
"```",
- f"{color_user_mention}@Test_1{color_reset}: 😮",
+ f"{color_user_mention}@Test_1{color_default}: 😮",
],
},
{
@@ -442,7 +442,7 @@ cases: List[Case] = [
],
}
],
- "rendered": ["#FFAA00 <[color:16755200]>■<[color:reset]>"],
+ "rendered": [f"#FFAA00 <[color:16755200]>■{color_default}"],
},
]
diff --git a/tests/test_render_reactions.py b/tests/test_render_reactions.py
index dad9696..108c600 100644
--- a/tests/test_render_reactions.py
+++ b/tests/test_render_reactions.py
@@ -7,7 +7,7 @@ import pytest
from slack.shared import shared
from slack.slack_message import SlackMessage
from tests.conftest import (
- color_reset,
+ color_default,
user_test1_id,
user_test2_id,
)
@@ -31,32 +31,32 @@ color_reaction_self_suffix = "<[color:<[config_color:reaction_self_suffix]>]>"
cases: List[Case] = [
{
"reactions": [{"name": "custom", "users": [user_test2_id], "count": 1}],
- "rendered": f" {color_reaction_suffix}[:custom:1]{color_reset}",
+ "rendered": f" {color_reaction_suffix}[:custom:1]{color_default}",
"display_reaction_nicks": False,
},
{
"reactions": [{"name": "custom", "users": [user_test1_id], "count": 1}],
- "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1{color_reaction_suffix}]{color_reset}",
+ "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1{color_reaction_suffix}]{color_default}",
"display_reaction_nicks": False,
},
{
"reactions": [{"name": "custom", "users": [user_test2_id], "count": 1}],
- "rendered": f" {color_reaction_suffix}[:custom:1(Test_2)]{color_reset}",
+ "rendered": f" {color_reaction_suffix}[:custom:1(Test_2)]{color_default}",
"display_reaction_nicks": True,
},
{
"reactions": [{"name": "custom", "users": [user_test1_id], "count": 1}],
- "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1(Test_1){color_reaction_suffix}]{color_reset}",
+ "rendered": f" {color_reaction_suffix}[{color_reaction_self_suffix}:custom:1(Test_1){color_reaction_suffix}]{color_default}",
"display_reaction_nicks": True,
},
{
"reactions": [{"name": "custom", "users": [user_test2_id], "count": 2}],
- "rendered": f" {color_reaction_suffix}[:custom:2]{color_reset}",
+ "rendered": f" {color_reaction_suffix}[:custom:2]{color_default}",
"display_reaction_nicks": False,
},
{
"reactions": [{"name": "custom", "users": [user_test2_id], "count": 2}],
- "rendered": f" {color_reaction_suffix}[:custom:2(Test_2, and others)]{color_reset}",
+ "rendered": f" {color_reaction_suffix}[:custom:2(Test_2, and others)]{color_default}",
"display_reaction_nicks": True,
},
]
diff --git a/tests/test_unfurl.py b/tests/test_unfurl.py
index aeb5e5a..15c7ad1 100644
--- a/tests/test_unfurl.py
+++ b/tests/test_unfurl.py
@@ -8,7 +8,7 @@ from slack.slack_message import SlackMessage
from tests.conftest import (
channel_public_id,
color_channel_mention,
- color_reset,
+ color_default,
color_user_mention,
color_usergroup_mention,
resolve_pending_message_item,
@@ -33,19 +33,19 @@ cases: List[Case] = [
},
{
"input": "<!channel>",
- "output": f"{color_usergroup_mention}@channel{color_reset}",
+ "output": f"{color_usergroup_mention}@channel{color_default}",
},
{
"input": "<!here>",
- "output": f"{color_usergroup_mention}@here{color_reset}",
+ "output": f"{color_usergroup_mention}@here{color_default}",
},
{
"input": f"<@{user_test1_id}|@othernick>: foo",
- "output": f"{color_user_mention}@Test_1{color_reset}: foo",
+ "output": f"{color_user_mention}@Test_1{color_default}: foo",
},
{
"input": f"foo <#{channel_public_id}|otherchannel> bar",
- "output": f"foo {color_channel_mention}#channel1{color_reset} bar",
+ "output": f"foo {color_channel_mention}#channel1{color_default} bar",
},
]