diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2022-11-20 19:35:28 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | 7ad074083492e78c66e705b97699c92e5d38541a (patch) | |
tree | b455ddc72b6c7dbf69375a9063d611617da88d78 /slack/commands.py | |
parent | 9934388d03ff6cee5302383cfd231c0e559f7ffa (diff) | |
download | wee-slack-7ad074083492e78c66e705b97699c92e5d38541a.tar.gz |
Create buffers on connect
Diffstat (limited to 'slack/commands.py')
-rw-r--r-- | slack/commands.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/slack/commands.py b/slack/commands.py index bf48dda..1acf545 100644 --- a/slack/commands.py +++ b/slack/commands.py @@ -11,6 +11,7 @@ from slack.api import SlackWorkspace from slack.config import WeeChatOption from slack.log import print_error from slack.shared import shared +from slack.task import create_task from slack.util import get_callback_name, with_color commands: Dict[str, Command] = {} @@ -99,6 +100,24 @@ def command_slack(buffer: str, args: List[str], options: Dict[str, Optional[str] print("ran slack") +@weechat_command("%(slack_workspaces)") +def command_slack_connect( + buffer: str, args: List[str], options: Dict[str, Optional[str]] +): + async def connect(): + if args and args[0]: + workspace = shared.workspaces.get(args[0]) + if workspace: + await workspace.connect() + else: + print_error(f'workspace "{args[0]}" not found') + else: + for workspace in shared.workspaces.values(): + await workspace.connect() + + create_task(connect(), final=True) + + @weechat_command() def command_slack_workspace( buffer: str, args: List[str], options: Dict[str, Optional[str]] |