// slurp whole channel at once static L<SlackMsg> multiSlurp(S channelName, S token) { ret multiSlurp(channelName, token, null, null); } // inclusive is always false // slurp a part of the channel (everything > oldest and < latest) // channelName can also by the ID (starting with "C") static L<SlackMsg> multiSlurp(S channelName, S token, S oldest, S latest) { S channelID = channelName; if (!channelName.startsWith("C")) { Map<S, S> channels = slackGetChannelIDs(token); channelName = dropPrefix("#", channelName); channelID = channels.get(channelName); } if (channelID == null) fail("Channel not found: " + channelName); int limit = 1000; L<SlackMsg> l; new L<L<SlackMsg>> all; int n = 0; // safety switch #1 - never suck more than 100.000 msgs do { l = slackSlurp(channelID, token, limit, oldest, latest, false); if (empty(l)) break; S newLatest = first(l).ts; assertNotNull(newLatest); // safety switch #2 if (latest != null) assertTrue(cmp(latest, newLatest) > 0); latest = newLatest; print("latest=" + latest); print(l(l) + " messages slurped from #" + channelName); all.add(l); } while (++n < 100); ret concatLists(reversedList(all)); }
Began life as a copy of #1002173
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
ID | Author/Program | Comment | Date |
---|---|---|---|
1202 | stefan | TODO: go forward also | 2016-01-01 22:31:27 |
Snippet ID: | #1002183 |
Snippet name: | multiSlurp - multiple Slack slurps for one channel until the job is done! |
Eternal ID of this version: | #1002183/1 |
Text MD5: | 038b0ee6de84fea2c8c8df54308bd4a1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-25 16:43:52 |
Source code size: | 1272 bytes / 38 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 873 / 1081 |
Referenced in: | [show references] |