1 | static class SlackMsg { |
2 | S user, botName; // one of these is going to be set |
3 | S userName; // looked up if user != null |
4 | S type, text, ts; |
5 | O reactions; |
6 | S channelID; |
7 | } |
8 | |
9 | static L<SlackMsg> slackSlurp(S channelID, S token, int limit, S oldest, S latest, boolean inclusive) { |
10 | S url = "https://slack.com/api/channels.history"; |
11 | Map postData = litmap( |
12 | "token", token, |
13 | "channel", channelID, |
14 | "count", limit, |
15 | "oldest", oldest, |
16 | "latest", latest, |
17 | "inclusive", inclusive ? 1 : 0); |
18 | S data = doPost(postData, url); |
19 | Map map = cast jsonDecode(data); |
20 | assertTrue(map.get("ok")); |
21 | List<Map> _msgs = cast map.get("messages"); |
22 | new L<SlackMsg> msgs; |
23 | for (Map msg : reversedList(_msgs)) { |
24 | new SlackMsg m; |
25 | m.type = (S) msg.get("type"); |
26 | m.user = (S) msg.get("user"); |
27 | m.botName = (S) msg.get("username"); |
28 | m.text = htmldecode((S) msg.get("text")); |
29 | m.ts = (S) msg.get("ts"); |
30 | m.reactions = msg.get("reactions"); |
31 | m.channelID = channelID; |
32 | m.userName = slackGetUserName(token, m.user); |
33 | msgs.add(m); |
34 | //print(structure(m)); |
35 | } |
36 | //print(l(msgs) + " messages sucked from slack channel."); |
37 | ret msgs; |
38 | } |
Began life as a copy of #1001926
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002169 |
Snippet name: | slackSlurp |
Eternal ID of this version: | #1002169/1 |
Text MD5: | 494d365315abd1efa7121d9d0c82aedb |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-23 04:36:27 |
Source code size: | 1195 bytes / 38 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 643 / 919 |
Referenced in: | [show references] |