File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 2828include (" send.jl" )
2929export
3030 sendtoslack,
31- sendattachmenttoslack
31+ sendattachmenttoslack,
32+ sendfiletoslack
3233
3334include (" channel.jl" )
3435export
Original file line number Diff line number Diff line change @@ -43,3 +43,27 @@ function sendattachmenttoslack(data, user_endpoint::String)
4343
4444 return (String (r. body))
4545end
46+
47+ """
48+ sendfiletoslack(filepath, message, channel, token)
49+
50+ Sends a file with a message to the specified channel.
51+ https://api.slack.com/methods/files.upload
52+ """
53+ function sendfiletoslack (filepath, message, channel, token)
54+ HTTP. setuseragent! (" HTTP.jl" )
55+
56+
57+ url = " https://slack.com/api/files.upload"
58+ headers = Dict (" Authorization" => " Bearer $token " )
59+ data = Dict (
60+ " file" => open (filepath),
61+ " initial_comment" => message,
62+ " channels" => channel
63+ )
64+ body = HTTP. Form (data)
65+
66+ r = HTTP. post (url, headers, body)
67+
68+ return (String (r. body))
69+ end
You can’t perform that action at this time.
0 commit comments