aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-07-09 20:43:32 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2020-07-09 20:44:46 +0200
commit1c927f75ff4f77394838c3a74fd15343388d5d54 (patch)
tree3d6b00a883b2cce643c31154c8e363e6c7a26ff8 /wee_slack.py
parent13b93fa12d1a964a6677d23032fd398b8732a03d (diff)
downloadwee-slack-1c927f75ff4f77394838c3a74fd15343388d5d54.tar.gz
Support creating channels
Add command /slack create to create a channel. Currently doesn't switch to the channel after it's created, even when switch_buffer_on_join is true, that is a todo for later. Fixes #415
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py31
1 files changed, 31 insertions, 0 deletions
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