1
1
using Slack
2
2
3
+ mutable struct channel
4
+ is_private:: Bool
5
+ pending_connected_team_ids
6
+ topic
7
+ is_archived:: Bool
8
+ is_general:: Bool
9
+ is_mpim:: Bool
10
+ name
11
+ previous_names
12
+ num_members:: Int64
13
+ is_im:: Bool
14
+ id
15
+ created:: Int64
16
+ name_normalized
17
+ is_group:: Bool
18
+ purpose
19
+ creator
20
+ is_channel:: Bool
21
+ pending_shared
22
+ is_shared:: Bool
23
+ is_ext_shared:: Bool
24
+ shared_team_ids
25
+ is_member:: Bool
26
+ parent_conversation
27
+ is_pending_ext_shared:: Bool
28
+ is_org_shared:: Bool
29
+
30
+ end
31
+
32
+
3
33
"""
4
34
getchannels(token::String)
5
35
"""
@@ -11,6 +41,103 @@ function getchannels(token::String)
11
41
12
42
r = HTTP. get (url, [" Content-Type" => " application/json" ])
13
43
14
- return (String (r. body))
44
+ json_obj = JSON. parse (String (r. body))
45
+ channel_holder = []
46
+
47
+ for (k,v) in json_obj
48
+ if occursin (" channels" , k)
49
+ for item in v
50
+
51
+ is_private = false
52
+ pending_connected_team_ids = []
53
+ topic = []
54
+ is_archived = false
55
+ is_general = false
56
+ is_mpim = false
57
+ name = " "
58
+ previous_names = []
59
+ num_members = 0
60
+ is_im = false
61
+ id = " "
62
+ created = 0
63
+ name_normalized = " "
64
+ is_group = false
65
+ purpose = []
66
+ creator = " "
67
+ is_channel = false
68
+ pending_shared = []
69
+ is_shared = false
70
+ is_ext_shared = false
71
+ shared_team_ids = []
72
+ is_member = false
73
+ parent_conversation = []
74
+ is_pending_ext_shared = false
75
+ is_org_shared = false
76
+
77
+ for (key,value) in item
78
+ if occursin (" is_private" , key)
79
+ is_private = value
80
+ elseif occursin (" pending_connected_team_ids" , key)
81
+ pending_connected_team_ids = value
82
+ elseif occursin (" topic" , key)
83
+ topic = value
84
+ elseif occursin (" is_archived" , key)
85
+ is_archived = value
86
+ elseif occursin (" is_general" , key)
87
+ is_general = value
88
+ elseif occursin (" is_mpim" , key)
89
+ is_mpim = value
90
+ elseif occursin (" name" , key)
91
+ name = value
92
+ elseif occursin (" previous_names" , key)
93
+ previous_names = value
94
+ elseif occursin (" num_members" , key)
95
+ num_members = value
96
+ elseif occursin (" is_im" , key)
97
+ is_im = value
98
+ elseif occursin (" id" , key)
99
+ id = value
100
+ elseif occursin (" created" , key)
101
+ created = value
102
+ elseif occursin (" name_normalized" , key)
103
+ name_normalized = value
104
+ elseif occursin (" is_group" , key)
105
+ is_group = value
106
+ elseif occursin (" purpose" , key)
107
+ purpose = value
108
+ elseif occursin (" creator" , key)
109
+ creator = value
110
+ elseif occursin (" is_channel" , key)
111
+ is_channel = value
112
+ elseif occursin (" pending_shared" , key)
113
+ pending_shared = value
114
+ elseif occursin (" is_shared" , key)
115
+ is_shared = value
116
+ elseif occursin (" is_ext_shared" , key)
117
+ is_ext_shared = value
118
+ elseif occursin (" shared_team_ids" , key)
119
+ shared_team_ids = value
120
+ elseif occursin (" is_member" , key)
121
+ is_member = value
122
+ elseif occursin (" parent_conversation" , key)
123
+ parent_conversation = value
124
+ elseif occursin (" is_pending_ext_shared" , key)
125
+ is_pending_ext_shared = value
126
+ elseif occursin (" is_org_shared" , key)
127
+ is_org_shared = value
128
+ end
129
+ # println("$(key) $(value)") #DEBUG
130
+ end
131
+ new_channel = channel (is_private, pending_connected_team_ids, topic, is_archived, is_general,
132
+ is_mpim, name, previous_names, num_members, is_im, id[1 ], created, name_normalized,
133
+ is_group, purpose, creator, is_channel, pending_shared, is_shared, is_ext_shared,
134
+ shared_team_ids, is_member, parent_conversation, is_pending_ext_shared, is_org_shared)
135
+
136
+ push! (channel_holder, new_channel)
137
+ end
138
+ end
139
+ end
140
+
141
+ return (channel_holder)
15
142
16
143
end
0 commit comments