Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1001912 // Bot loop test for #talkingbots

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (906L/7K/22K).

!752

p {
  while true {
    L<SlackMsg> qs = getNewQuestions();
    print(l(qs) + " question(s).");
    printList(qs);
    sleepSeconds(10);
  }
}

static S getNewQuestions_lastSeen;

static L<SlackMsg> getNewQuestions() {
  L<SlackMsg> 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<SlackMsg> msgs) {
  for (int i = l(msgs)-1; i >= 0; i--)
    if (msgs.get(i).botName != null) ret i;
  ret -1;
}

Author comment

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: 611 / 655
Referenced in: [show references]