Libraryless. Click here for Pure Java version (1711L/12K/39K).
1 | !752 |
2 | |
3 | static S channelID = "C0FH9PY8J"; // relp, #talkingbots |
4 | static S token; |
5 | |
6 | static PersistentLog<SlackMsg> msgs; |
7 | |
8 | static new Map<S, S> lastSeenByChannel; |
9 | |
10 | p { |
11 | if (token == null) |
12 | token = loadSecretTextFileMandatory("#1001889", "relp-slack-botstuff-token").trim(); |
13 | |
14 | msgs = new PersistentLog<SlackMsg>("msgs"); |
15 | for (SlackMsg msg : msgs) { |
16 | S s = lastSeenByChannel.get(msg); |
17 | if (s == null || msg.ts.compareTo(s) > 0) |
18 | lastSeenByChannel.put(channelID, msg.ts); |
19 | } |
20 | |
21 | while true { |
22 | pcall { |
23 | int limit = 1000; |
24 | L<SlackMsg> newMsgs = slackReadChannel(channelID, token, limit, |
25 | lastSeenByChannel.get(channelID)); |
26 | msgs.addAll(newMsgs); |
27 | if (!newMsgs.isEmpty()) { |
28 | print(l(newMsgs) + " new messages in " + channelID + "."); |
29 | lastSeenByChannel.put(channelID, last(newMsgs).ts); |
30 | } |
31 | } |
32 | sleepSeconds(5); |
33 | } |
34 | } |
Began life as a copy of #1001915
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: | #1001979 |
Snippet name: | Old Slack Slurper (sucks Slack channels & stores them) |
Eternal ID of this version: | #1001979/1 |
Text MD5: | 60dc0d1ebf4f16cd94afee7e22d60c8b |
Transpilation MD5: | 74908f4c2d37793d05404aceb88160cf |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-23 21:17:07 |
Source code size: | 918 bytes / 34 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 622 / 878 |
Referenced in: | [show references] |