aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2017-02-21 17:06:00 -0800
committerRyan Huber <rhuber@gmail.com>2017-02-21 17:06:00 -0800
commit1b5fcb47332b40906424c2cdb04db263e7ebbaa4 (patch)
treec96ab502e6249ee70ad7b0e8e672e54cda51db2c
parent3b22dd58211294833dd6e0ca6ae770cfccf5c62e (diff)
downloadwee-slack-1b5fcb47332b40906424c2cdb04db263e7ebbaa4.tar.gz
file upload returns
-rw-r--r--wee_slack.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 96b974b..62a9916 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2656,6 +2656,19 @@ def command_nodistractions(data, current_buffer, args):
# save_distracting_channels()
@slack_buffer_required
+def command_upload(data, current_buffer, args):
+ channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer)
+ url = 'https://slack.com/api/files.upload'
+ fname = args.split(' ', 1)
+ file_path = os.path.expanduser(fname[1])
+ team = EVENTROUTER.weechat_controller.buffers[current_buffer].team
+ if ' ' in file_path:
+ file_path = file_path.replace(' ', '\ ')
+
+ command = 'curl -F file=@{} -F channels={} -F token={} {}'.format(file_path, channel.identifier, team.token, url)
+ w.hook_process(command, config.slack_timeout, '', '')
+
+@slack_buffer_required
def label_command_cb(data, current_buffer, args):
channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer)
if channel and channel.type == 'thread':