diff options
Diffstat (limited to 'slack')
-rw-r--r-- | slack/api.py | 4 | ||||
-rw-r--r-- | slack/commands.py | 4 | ||||
-rw-r--r-- | slack/config.py | 7 | ||||
-rw-r--r-- | slack/init.py | 25 |
4 files changed, 29 insertions, 11 deletions
diff --git a/slack/api.py b/slack/api.py index 9d6ac24..66cd687 100644 --- a/slack/api.py +++ b/slack/api.py @@ -73,7 +73,7 @@ class SlackWorkspace: self.name = name self.config = shared.config.create_workspace_config(self.name) self.api = SlackApi(self) - self.connected = False + self.is_connected = False self.nick = "TODO" # Maybe make private, so you have to use get_user? Maybe make get_user a getter, though don't know if that's a problem since it's async self.users: Dict[str, SlackUser] = {} @@ -101,6 +101,8 @@ class SlackWorkspace: # print(rtm_connect) # print([c["name"] for c in user_channels]) + self.is_connected = True + weechat.bar_item_update("input_text") async def get_user(self, id: str) -> SlackUser: if id in self.users: diff --git a/slack/commands.py b/slack/commands.py index 1acf545..c9c62ee 100644 --- a/slack/commands.py +++ b/slack/commands.py @@ -77,7 +77,7 @@ def list_workspaces(workspace_name: Optional[str] = None, detailed_list: bool = def display_workspace(workspace: SlackWorkspace, detailed_list: bool): - if workspace.connected: + if workspace.is_connected: weechat.prnt( "", f" * " @@ -193,7 +193,7 @@ def command_slack_workspace_del( if not workspace: print_error(f'workspace "{name}" not found for "workspace del" command') return - if workspace.connected: + if workspace.is_connected: print_error( f'you can not delete server "{name}" because you are connected to it. Try "/slack disconnect {name}" first.' ) diff --git a/slack/config.py b/slack/config.py index 8ee1e1c..6150ff7 100644 --- a/slack/config.py +++ b/slack/config.py @@ -158,6 +158,13 @@ class SlackConfigSectionColor: def __init__(self, weechat_config: WeeChatConfig): self._section = WeeChatSection(weechat_config, "color") + self.disconnected = WeeChatOption( + self._section, + "disconnected", + "text color for the disconnected text", + WeeChatColor("red"), + ) + self.loading = WeeChatOption( self._section, "loading", diff --git a/slack/init.py b/slack/init.py index a4c97be..68da138 100644 --- a/slack/init.py +++ b/slack/init.py @@ -28,18 +28,27 @@ def signal_buffer_switch_cb(data: str, signal: str, buffer_pointer: str) -> int: def modifier_input_text_display_with_cursor_cb( data: str, modifier: str, buffer_pointer: str, string: str ) -> str: + prefix = "" conversation = get_conversation_from_buffer_pointer(buffer_pointer) - if conversation and conversation.is_loading: + if conversation: input_delim_color = weechat.config_string( weechat.config_get("weechat.bar.input.color_delim") ) - return ( - f"{with_color(input_delim_color, '[')}" - f"{with_color(shared.config.color.loading.value, 'loading')}" - f"{with_color(input_delim_color, ']')}" - f" {string}" - ) - return string + input_delim_start = with_color(input_delim_color, "[") + input_delim_end = with_color(input_delim_color, "]") + if not conversation.workspace.is_connected: + prefix += ( + f"{input_delim_start}" + f"{with_color(shared.config.color.disconnected.value, 'disconnected')}" + f"{input_delim_end} " + ) + if conversation.is_loading: + prefix += ( + f"{input_delim_start}" + f"{with_color(shared.config.color.loading.value, 'loading')}" + f"{input_delim_end} " + ) + return prefix + string async def init(): |