// slurp whole channel at once static L 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 multiSlurp(S channelName, S token, S oldest, S latest) { S channelID = channelName; if (!channelName.startsWith("C")) { Map channels = slackGetChannelIDs(token); channelName = dropPrefix("#", channelName); channelID = channels.get(channelName); } if (channelID == null) fail("Channel not found: " + channelName); int limit = 1000; L l; new L> 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)); }