Libraryless. Click here for Pure Java version (706L/6K/18K).
1 | !752 |
2 | |
3 | static class Msg {
|
4 | S type, user, text, ts; |
5 | O reactions; |
6 | } |
7 | |
8 | static S data; |
9 | static new L<Msg> msgs; // Note: They're in reverse order! |
10 | |
11 | static S token = "xoxp-11444506721-15584660016-15602755169-10849bef29"; |
12 | static S channelID = "C0FH9PY8J"; // #talkingbots |
13 | static S oldest = "1449245380.000382"; // timestamp of first msg to get |
14 | |
15 | p {
|
16 | S url = "https://slack.com/api/channels.history"; |
17 | S postData = "token=" + urlencode(token) + "&channel=" + urlencode(channelID) + "&oldest=" + urlencode(oldest); |
18 | data = doPost(postData, url); |
19 | Map map = cast jsonDecode(data); |
20 | assertTrue(map.get("ok"));
|
21 | List<Map> _msgs = cast map.get("messages");
|
22 | msgs = new ArrayList<Msg>(); |
23 | for (Map msg : _msgs) {
|
24 | new Msg m; |
25 | m.type = (S) msg.get("type");
|
26 | m.user = (S) msg.get("user");
|
27 | m.text = (S) msg.get("text");
|
28 | m.ts = (S) msg.get("ts");
|
29 | m.reactions = msg.get("reactions");
|
30 | msgs.add(m); |
31 | print(structure(m)); |
32 | } |
33 | print(l(msgs) + " messages sucked from slack channel."); |
34 | } |
Began life as a copy of #1001867
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001888 |
| Snippet name: | Test channels.history on Slack 2 (reading chat contents of #talkingbots), with parsing |
| Eternal ID of this version: | #1001888/1 |
| Text MD5: | 3123b2d072ae734211b99fa3fbabaee7 |
| Transpilation MD5: | 417a69b9b4409c7506f01df45d7d2f24 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-12-04 21:34:26 |
| Source code size: | 1036 bytes / 34 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 911 / 929 |
| Referenced in: | [show references] |