!752 p { while true { L qs = getNewQuestions(); print(l(qs) + " question(s)."); printList(qs); sleepSeconds(10); } } static S getNewQuestions_lastSeen; static L getNewQuestions() { L msgs = slackReadTalkingBots(150, getNewQuestions_lastSeen); if (!msgs.isEmpty()) getNewQuestions_lastSeen = last(msgs).ts; int i = indexOfLastBotAnswer(msgs); if (i > 0) { print("Last bot answer at " + (i+1) + "/" + l(msgs) + ": " + structure(msgs.get(i))); msgs = subList(msgs, i+1); } ret msgs; } static int indexOfLastBotAnswer(L msgs) { for (int i = l(msgs)-1; i >= 0; i--) if (msgs.get(i).botName != null) ret i; ret -1; }