static class SlackMsg { S user, botName; // one of these is going to be set S userName; // looked up if user != null S type, text, ts; O reactions; S channelID; } static L<SlackMsg> slackReadChannel(S channelID, S token, int limit) { ret slackReadChannel(channelID, token, limit, null); } static L<SlackMsg> slackReadChannel(S channelID, S token, int limit, S oldest) { S url = "https://slack.com/api/channels.history"; S postData = "token=" + urlencode(token) + "&channel=" + urlencode(channelID) + "&count=" + limit + (oldest != null ? "&oldest=" + urlencode(oldest) : ""); S data = doPostWithTimeout(postData, url, slackSetTimeout_get()); Map map = cast jsonDecode(data); if (!isTrue(map.get("ok"))) fail(structure(map)); List<Map> _msgs = cast map.get("messages"); new L<SlackMsg> msgs; for (Map msg : reversedList(_msgs)) { new SlackMsg m; m.type = (S) msg.get("type"); m.user = (S) msg.get("user"); m.botName = (S) msg.get("username"); m.text = htmldecode((S) msg.get("text")); m.ts = (S) msg.get("ts"); m.reactions = msg.get("reactions"); m.channelID = channelID; m.userName = slackGetUserName(token, m.user); msgs.add(m); //print(structure(m)); } //print(l(msgs) + " messages sucked from slack channel."); ret msgs; }
Began life as a copy of #1001907
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: | #1001926 |
Snippet name: | slackReadChannel |
Eternal ID of this version: | #1001926/1 |
Text MD5: | dee1be7fa9d615a915fc135160347d22 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-04-18 22:42:30 |
Source code size: | 1352 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 727 / 1298 |
Referenced in: | [show references] |