diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2022-11-19 23:16:33 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | 02d98fc22539bfec6e96e24722aa178ab3bf618d (patch) | |
tree | 8a3b25f6e237b2984277979eab446ec78a547175 /slack | |
parent | 734e76aea266632643f4c5df49b8ab34ffc403d0 (diff) | |
download | wee-slack-02d98fc22539bfec6e96e24722aa178ab3bf618d.tar.gz |
Add workspace rename and del commands
Diffstat (limited to 'slack')
-rw-r--r-- | slack/commands.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/slack/commands.py b/slack/commands.py index 39e5c67..a54337e 100644 --- a/slack/commands.py +++ b/slack/commands.py @@ -143,6 +143,48 @@ def command_slack_workspace_add( ) +@weechat_command(min_args=2) +def command_slack_workspace_rename( + buffer: str, args: List[str], options: Dict[str, Optional[str]] +): + old_name = args[0] + new_name = args[1] + workspace = shared.workspaces.get(old_name) + if not workspace: + print_error(f'workspace "{old_name}" not found for "workspace rename" command') + return + workspace.name = new_name + shared.workspaces[new_name] = workspace + del shared.workspaces[old_name] + weechat.prnt( + "", + f"server {with_color('chat_server', old_name)} has been renamed to {with_color('chat_server', new_name)}", + ) + # TODO: Rename buffers and config + + +@weechat_command(min_args=1) +def command_slack_workspace_del( + buffer: str, args: List[str], options: Dict[str, Optional[str]] +): + name = args[0] + workspace = shared.workspaces.get(name) + if not workspace: + print_error(f'workspace "{name}" not found for "workspace del" command') + return + if workspace.connected: + print_error( + f'you can not delete server "{name}" because you are connected to it. Try "/slack disconnect {name}" first.' + ) + return + # TODO: Delete config + del shared.workspaces[name] + weechat.prnt( + "", + f"server {with_color('chat_server', name)} has been deleted", + ) + + def command_cb(data: str, buffer: str, args: str) -> int: args_parts = re.finditer("[^ ]+", args) cmd = data |