Skip to content

Commit f66d276

Browse files
author
Anonymous
committed
Adding in inital groundwork for Message History and threads
1 parent b366acf commit f66d276

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
/Manifest.toml
33
/dev/
4+
/.vscode

src/Slack.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ include("history.jl")
1717
export
1818
getchannelhistory
1919

20-
# include("utils.jl")
21-
# export
22-
# convert_HTTP_Response_To_JSON
20+
include("threads.jl")
21+
export
22+
getthreads
2323

2424
end # module

src/history.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ function getchannelhistory(token::String, channelid::String)
1717
if occursin("messages", k)
1818
for item in v
1919
for (key,value) in item
20-
print(key, " ", value)
21-
#TODO Make a Messages Struct and then add the message info to the object.
20+
if key == "client_msg_id"
21+
println("client_msg_id: $(value)")
22+
elseif key == "text"
23+
println("text: $(value)")
24+
end
2225
end
2326
end
2427
end

src/threads.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
getthreads(token::String)
3+
Takes in the Slack App Auth token, channel ID, and Time Signature of the parent message.
4+
5+
https://api.slack.com/methods/conversations.replies#arg_ts
6+
"""
7+
function getthreads(token::String, channelid::String, ts::String)
8+
HTTP.setuseragent!("HTTP.jl")
9+
10+
url = "https://slack.com/api/conversations.replies?token=$(token)&channel=$(channelid)&ts=$(ts)&limit=50"
11+
12+
r = HTTP.get(url, ["Content-Type" => "application/json"])
13+
14+
json_obj = JSON.parse(String(r.body))
15+
message_holder = []
16+
for (k,v) in json_obj
17+
if occursin("messages", k)
18+
for item in v
19+
for (key,value) in item
20+
if key == "text"
21+
println(value)
22+
elseif key == "user"
23+
println("User with ID $(value) said:")
24+
end
25+
end
26+
end
27+
end
28+
end
29+
30+
end

0 commit comments

Comments
 (0)