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

50
LINES

< > BotCompany Repo | #1001903 // Simpler chat bot algorithm (one question at a time), developing

JavaX source code - run with: x30.jar

!752

p {
  L<Msg> msgs = getLastMsgs(); // must be in order
  for (Msg msg : msgs)
    onMsg(msg);
  now();
  
  while true {
    msgs = getMoreMsgs();
    for (Msg msg : msgs)
      onMsg(msg);
    if (!msgs.isEmpty())
      now();
    sleepSeconds(10);
  }
}

static void onMsg(Msg msg) {
  if (isQuestion(msg))
    questions.add(msg);
  else if (isAnswer(msg)) {
    Msg q = getQuestion(msg);
    questions.remove(q);
    if (current == q)
      current = null;
  }
}

static void now() {
  if (current != null) ret; // still waiting for my own answer to appear
  if (!questions.isEmpty()) {
    current = questions.get(0);
    questions.remove(0);
    postAnswer(current);
  }
}

static Msg getQuestion(Msg a) {
  // TODO
}

static void postAnswer(Msg q) {
  // call the bot
  // if answer == null:
  //   if we're directly targeted in the question (@blabot),
  //   say "i don't know".
  //   if we're not targeted, delete the question from list.
  // if there is an answer, post the answer with time stamp of question.
}

Author comment

Began life as a copy of #1001893

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001903
Snippet name: Simpler chat bot algorithm (one question at a time), developing
Eternal ID of this version: #1001903/1
Text MD5: 38858f8436fd5bb2289a8abd9555b4ad
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-06 18:33:35
Source code size: 1076 bytes / 50 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 605 / 544
Referenced in: #3000189 - Answer for stefanreich(>> t bla)
#3000190 - Answer for stefanreich(>> t 20 questions)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)