Skip to content

Commit 4ddcfbb

Browse files
Update send.jl
1 parent fa2e3b8 commit 4ddcfbb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/send.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,25 @@ function sendtoslack(data::String, user_endpoint::String)
2121

2222
return (String(r.body))
2323
end
24+
25+
"""
26+
sendattachmenttoslack(data::String, user_endpoint::String)
27+
Takes in a string of data and the endpoint url and returns the HTTP response.
28+
The response will be "ok" if the request is sent successfully.
29+
"""
30+
function sendattachmenttoslack(data::String, user_endpoint::String)
31+
HTTP.setuseragent!("HTTP.jl")
32+
33+
34+
params = Dict("$(data)")
35+
base_url = "https://hooks.slack.com"
36+
37+
endpoint = user_endpoint
38+
url = base_url * endpoint
39+
40+
r = HTTP.post(url,
41+
["Content-Type" => "application/json"],
42+
JSON.json(params))
43+
44+
return (String(r.body))
45+
end

0 commit comments

Comments
 (0)