diff options
-rw-r--r-- | docs/Commands.md | 8 | ||||
-rw-r--r-- | wee_slack.py | 31 |
2 files changed, 39 insertions, 0 deletions
diff --git a/docs/Commands.md b/docs/Commands.md index 5770503..bb78359 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -33,6 +33,14 @@ Sets your status as 'back'. List the channels in the current team. +### create + +``` +/slack create [-private] <channel_name> +``` + +Create a public or private channel. + ### distracting ``` diff --git a/wee_slack.py b/wee_slack.py index 77b861e..dbbccc5 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -3191,6 +3191,13 @@ def handle_usersprofileset(json, eventrouter, team, channel, metadata): w.prnt('', 'ERROR: Failed to set profile: {}'.format(json['error'])) +def handle_conversationscreate(json, eventrouter, team, channel, metadata): + metadata = json["wee_slack_request_metadata"] + if not json['ok']: + name = metadata.post_data["name"] + print_error("Couldn't create channel {}: {}".format(name, json['error'])) + + def handle_conversationsinvite(json, eventrouter, team, channel, metadata): nicks = ', '.join(metadata['nicks']) if json['ok']: @@ -4523,6 +4530,30 @@ def join_query_command_cb(data, current_buffer, args): @slack_buffer_required @utf8_decode +def command_create(data, current_buffer, args): + """ + /slack create [-private] <channel_name> + Create a public or private channel. + """ + team = EVENTROUTER.weechat_controller.buffers[current_buffer].team + + parts = args.split(None, 1) + if parts[0] == "-private": + args = parts[1] + private = True + else: + private = False + + post_data = {"name": args, "is_private": private} + s = SlackRequest(team, "conversations.create", post_data) + EVENTROUTER.receive(s) + return w.WEECHAT_RC_OK_EAT + +command_create.completion = '-private' + + +@slack_buffer_required +@utf8_decode def command_showmuted(data, current_buffer, args): """ /slack showmuted |