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 28
28
include (" send.jl" )
29
29
export
30
30
sendtoslack,
31
- sendattachmenttoslack
31
+ sendattachmenttoslack,
32
+ sendfiletoslack
32
33
33
34
include (" channel.jl" )
34
35
export
Original file line number Diff line number Diff line change @@ -43,3 +43,27 @@ function sendattachmenttoslack(data, user_endpoint::String)
43
43
44
44
return (String (r. body))
45
45
end
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