Libraryless. Click here for Pure Java version (906L/7K/22K).
1 | !752 |
2 | |
3 | p {
|
4 | while true {
|
5 | L<SlackMsg> qs = getNewQuestions(); |
6 | print(l(qs) + " question(s)."); |
7 | printList(qs); |
8 | sleepSeconds(10); |
9 | } |
10 | } |
11 | |
12 | static S getNewQuestions_lastSeen; |
13 | |
14 | static L<SlackMsg> getNewQuestions() {
|
15 | L<SlackMsg> msgs = slackReadTalkingBots(150, getNewQuestions_lastSeen); |
16 | if (!msgs.isEmpty()) getNewQuestions_lastSeen = last(msgs).ts; |
17 | int i = indexOfLastBotAnswer(msgs); |
18 | if (i > 0) {
|
19 | print("Last bot answer at " + (i+1) + "/" + l(msgs) + ": " + structure(msgs.get(i)));
|
20 | msgs = subList(msgs, i+1); |
21 | } |
22 | ret msgs; |
23 | } |
24 | |
25 | static int indexOfLastBotAnswer(L<SlackMsg> msgs) {
|
26 | for (int i = l(msgs)-1; i >= 0; i--) |
27 | if (msgs.get(i).botName != null) ret i; |
28 | ret -1; |
29 | } |
Began life as a copy of #1001910
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: | #1001912 |
| Snippet name: | Bot loop test for #talkingbots |
| Eternal ID of this version: | #1001912/1 |
| Text MD5: | 2bf9aa36c47f68f1e0e0f0a21ef9aa3d |
| Transpilation MD5: | e65d537b26e82eec3d1ffdc8accb41a1 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-12-06 19:25:46 |
| Source code size: | 730 bytes / 29 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1074 / 1207 |
| Referenced in: | [show references] |